All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebean.BeanCapture Maven / Gradle / Ivy

There is a newer version: 13.7.0
Show newest version
package io.ebean;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * Base functionality for capturing beans that are sent to the save(), delete() methods
 * of an EbeanServer.
 * 

* Capture the beans in order to use with test asserts. */ public class BeanCapture { protected boolean captureBeans = true; /** * The captured beans sent to the save() methods. */ public List save = new ArrayList(); /** * The captured beans sent to the insert() methods. */ public List insert = new ArrayList(); /** * The captured beans sent to the update() methods. */ public List update = new ArrayList(); /** * The captured beans sent to the delete() methods. *

* Note that these can include MethodCall objects for the cases when * delete by id is called. */ public List delete = new ArrayList(); /** * Captured beans sent to deletePermanent() methods. */ public List deletePermanent = new ArrayList(); protected void addSaved(Object bean) { if (captureBeans) { save.add(bean); } } protected void addSavedAll(Collection beans) { if (captureBeans) { save.addAll(beans); } } protected void addInsertedAll(Collection beans) { if (captureBeans) { insert.addAll(beans); } } protected void addInserted(Object bean) { if (captureBeans) { insert.add(bean); } } protected void addUpdatedAll(Collection beans) { if (captureBeans) { update.addAll(beans); } } protected void addUpdated(Object bean) { if (captureBeans) { update.add(bean); } } protected void addDeletedAll(Collection beans) { if (captureBeans) { delete.addAll(beans); } } protected void addDeleted(Object bean) { if (captureBeans) { delete.add(bean); } } protected void addDeletePermanent(Object bean) { if (captureBeans) { deletePermanent.add(bean); } } public void addDeletedAllPermanent(Collection beans) { if (captureBeans) { deletePermanent.addAll(beans); } } }