Skip to content
Snippets Groups Projects
Commit 3677d6be authored by buczekp's avatar buczekp
Browse files

[LMS-1585] extended DAO tests to test creation of deletion events

SVN: 16663
parent 1bdaa460
No related branches found
No related tags found
No related merge requests found
......@@ -300,30 +300,6 @@ public final class SampleBOTest extends AbstractBOTest
context.assertIsSatisfied();
}
// FIXME 2009-06-22, Piotr Buczek
// @Test
// public void testDelete()
// {
// final TechId sampleId = SAMPLE_TECH_ID;
// final SamplePE sample = createSample(DEFAULT_SAMPLE_CODE);
// sample.setId(sampleId.getId());
// final String reason = "reason";
//
// prepareTryToLoadOfSampleWithId(sample);
// context.checking(new Expectations()
// {
// {
// PersonPE person = EXAMPLE_SESSION.tryGetPerson();
// EventPE event = SampleBO.createDeletionEvent(sample, person, reason);
// one(eventDAO).persist(event);
// one(sampleDAO).delete(sample);
// }
// });
// final SampleBO sampleBO = createSampleBO();
// sampleBO.deleteByTechId(sampleId, reason);
// context.assertIsSatisfied();
// }
@Test
public final void testDetachFromExperiment()
{
......
......@@ -37,15 +37,20 @@ import org.testng.annotations.Test;
import ch.rinn.restrictions.Friend;
import ch.systemsx.cisd.openbis.generic.server.business.bo.util.SampleOwner;
import ch.systemsx.cisd.openbis.generic.server.dataaccess.IEventDAO;
import ch.systemsx.cisd.openbis.generic.server.dataaccess.ISampleDAO;
import ch.systemsx.cisd.openbis.generic.shared.basic.TechId;
import ch.systemsx.cisd.openbis.generic.shared.dto.DatabaseInstancePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.EntityTypePropertyTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.EventPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.EventType;
import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.GroupPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePropertyPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.SampleTypePE;
import ch.systemsx.cisd.openbis.generic.shared.dto.EventPE.EntityType;
import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind;
import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils;
......@@ -334,10 +339,27 @@ public final class SampleDAOTest extends AbstractDAOTest
private void deleteSample(SamplePE sample)
{
final ISampleDAO sampleDAO = daoFactory.getSampleDAO();
// before deletion there shouldn't be any entry about deletion of the sample in event table
assertNull(tryGetDeletionEvent(sample));
List<TechId> sampleIds = new ArrayList<TechId>();
sampleIds.add(TechId.create(sample));
sampleDAO.delete(sampleIds, getSystemPerson(), "reason");
final PersonPE registrator = getSystemPerson();
final String reason = "reason" + sample.getPermId();
daoFactory.getSampleDAO().delete(sampleIds, registrator, reason);
// after deletion there should be an entry about deletion of the sample in event table
final EventPE event = tryGetDeletionEvent(sample);
assertNotNull(event);
assertEquals(reason, event.getReason());
assertEquals(registrator, event.getRegistrator());
}
private EventPE tryGetDeletionEvent(SamplePE sample)
{
final IEventDAO eventDAO = daoFactory.getEventDAO();
return eventDAO.tryFind(sample.getPermId(), EntityType.SAMPLE, EventType.DELETION);
}
@Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment