diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java index 888dc19f7acaf027718a576b1623398876034881..c2512f81707d5f7586fea8550072c41a73f12562 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java @@ -24,6 +24,7 @@ import java.util.List; import org.apache.commons.lang.StringUtils; +import ch.rinn.restrictions.Private; import ch.systemsx.cisd.authentication.ISessionManager; import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException; @@ -59,10 +60,10 @@ import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils; */ public class ETLService extends AbstractServer<IETLService> implements IETLService { - private static final String PROCESSING_PATH = "$processing-path-for-"; - private static final String PROCESSING_PATH_TEMPLATE = PROCESSING_PATH + "%s"; - private static final String PROCESSING_PARAMETERS_TEMPLATE = "$processing-parameters-for-%s"; - private static final String PROCESSING_DESCRIPTION_TEMPLATE = "$processing-description-for-%s"; + @Private static final String PROCESSING_PATH = "$processing-path-for-"; + @Private static final String PROCESSING_PATH_TEMPLATE = PROCESSING_PATH + "%s"; + @Private static final String PROCESSING_PARAMETERS_TEMPLATE = "$processing-parameters-for-%s"; + @Private static final String PROCESSING_DESCRIPTION_TEMPLATE = "$processing-description-for-%s"; private static final String ENCODING = "utf-8"; private ISessionManager<Session> sessionManager; @@ -115,6 +116,7 @@ public class ETLService extends AbstractServer<IETLService> implements IETLServi public String createDataSetCode(String sessionToken) throws UserFailureException { + sessionManager.getSession(sessionToken); // throws exception if invalid sessionToken return daoFactory.getExternalDataDAO().createDataSetCode(); } @@ -315,7 +317,7 @@ public class ETLService extends AbstractServer<IETLService> implements IETLServi if (experiment.getInvalidation() != null) { throw new UserFailureException("Data set can not be registered because experiment '" - + experiment.getCode() + "' is invalid."); + + experiment.getIdentifier() + "' is invalid."); } List<ProcedurePE> procedures = experiment.getProcedures(); ProcedurePE procedure = tryToFindProcedureByType(procedures, procedureTypeCode); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/CommonServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/CommonServerTest.java index deb01f1a7a6185cfc4f2590576f9d18cdd86e9b9..44f924a02d3dce00deaec8c4f4e81e243134c370 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/CommonServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/CommonServerTest.java @@ -123,7 +123,7 @@ public final class CommonServerTest extends AbstractServerTestCase { final String user = "user"; final String password = "password"; - final Session session = createExampleSession(); + final Session session = createSession(); final PersonPE systemPerson = createSystemUser(); final PersonPE person = CommonTestUtils.createPersonFromPrincipal(PRINCIPAL); final RoleAssignmentPE roleAssignment = new RoleAssignmentPE(); @@ -164,7 +164,6 @@ public final class CommonServerTest extends AbstractServerTestCase { final String user = "user"; final String password = "password"; - final Session session = createExampleSession(); final PersonPE systemPerson = createSystemUser(); final PersonPE person = CommonTestUtils.createPersonFromPrincipal(PRINCIPAL); context.checking(new Expectations() @@ -174,7 +173,7 @@ public final class CommonServerTest extends AbstractServerTestCase will(returnValue(SESSION_TOKEN)); one(sessionManager).getSession(SESSION_TOKEN); - will(returnValue(session)); + will(returnValue(SESSION)); one(personDAO).listPersons(); will(returnValue(Arrays.asList(systemPerson, person))); @@ -198,7 +197,6 @@ public final class CommonServerTest extends AbstractServerTestCase { final String user = "user"; final String password = "password"; - final Session session = createExampleSession(); final PersonPE systemPerson = createSystemUser(); final PersonPE person = CommonTestUtils.createPersonFromPrincipal(PRINCIPAL); context.checking(new Expectations() @@ -208,7 +206,7 @@ public final class CommonServerTest extends AbstractServerTestCase will(returnValue(SESSION_TOKEN)); one(sessionManager).getSession(SESSION_TOKEN); - will(returnValue(session)); + will(returnValue(SESSION)); one(personDAO).listPersons(); will(returnValue(Arrays.asList(systemPerson, person))); @@ -217,11 +215,11 @@ public final class CommonServerTest extends AbstractServerTestCase will(returnValue(person)); } }); - assertEquals(null, session.tryGetPerson()); + assertEquals(null, SESSION.tryGetPerson()); final Session s = createServer().tryToAuthenticate(user, password); - assertSame(session, s); + assertSame(SESSION, s); assertEquals(person, s.tryGetPerson()); context.assertIsSatisfied(); @@ -234,13 +232,15 @@ public final class CommonServerTest extends AbstractServerTestCase final DatabaseInstanceIdentifier identifier = DatabaseInstanceIdentifier.createHome(); final GroupPE g1 = CommonTestUtils.createGroup("g1", homeDatabaseInstance); final GroupPE g2 = CommonTestUtils.createGroup("g2", homeDatabaseInstance); - final Session session = prepareGetSession(); + final Session session = createSession(); session.setPerson(person); person.setHomeGroup(g1); g1.setId(42L); context.checking(new Expectations() { { + one(sessionManager).getSession(SESSION_TOKEN); + will(returnValue(session)); one(groupDAO).listGroups(homeDatabaseInstance); will(returnValue(Arrays.asList(g1, g2))); } @@ -260,14 +260,14 @@ public final class CommonServerTest extends AbstractServerTestCase @Test public void testRegisterGroup() { - final Session session = prepareGetSession(); + prepareGetSession(); final String groupCode = "group"; final String description = "description"; final String leader = "leader"; context.checking(new Expectations() { { - one(commonBusinessObjectFactory).createGroupBO(session); + one(commonBusinessObjectFactory).createGroupBO(SESSION); will(returnValue(groupBO)); one(groupBO).define(groupCode, description, leader); @@ -410,13 +410,13 @@ public final class CommonServerTest extends AbstractServerTestCase @Test public final void testListExternalData() { - final Session session = prepareGetSession(); final SampleIdentifier sampleIdentifier = CommonTestUtils.createSampleIdentifier(); final ExternalDataPE externalDataPE = new ExternalDataPE(); + prepareGetSession(); context.checking(new Expectations() { { - one(commonBusinessObjectFactory).createExternalDataTable(session); + one(commonBusinessObjectFactory).createExternalDataTable(SESSION); will(returnValue(externalDataTable)); one(externalDataTable).loadBySampleIdentifier(sampleIdentifier); @@ -438,13 +438,13 @@ public final class CommonServerTest extends AbstractServerTestCase @Test public void testListExternalDataOfAnExperiment() { - final Session session = prepareGetSession(); final ExperimentIdentifier identifier = CommonTestUtils.createExperimentIdentifier(); final ExternalDataPE externalDataPE = new ExternalDataPE(); + prepareGetSession(); context.checking(new Expectations() { { - one(commonBusinessObjectFactory).createExternalDataTable(session); + one(commonBusinessObjectFactory).createExternalDataTable(SESSION); will(returnValue(externalDataTable)); one(externalDataTable).loadByExperimentIdentifier(identifier); @@ -464,13 +464,13 @@ public final class CommonServerTest extends AbstractServerTestCase @Test public void testListExperiments() { - final Session session = prepareGetSession(); final ProjectIdentifier projectIdentifier = CommonTestUtils.createProjectIdentifier(); final ExperimentTypePE experimentType = CommonTestUtils.createExperimentType(); + prepareGetSession(); context.checking(new Expectations() { { - one(commonBusinessObjectFactory).createExperimentTable(session); + one(commonBusinessObjectFactory).createExperimentTable(SESSION); will(returnValue(experimentTable)); one(experimentTable).load(experimentType.getCode(), projectIdentifier); @@ -482,14 +482,14 @@ public final class CommonServerTest extends AbstractServerTestCase } }); createServer() - .listExperiments(session.getSessionToken(), experimentType, projectIdentifier); + .listExperiments(SESSION_TOKEN, experimentType, projectIdentifier); context.assertIsSatisfied(); } @Test public void testListExperimentTypes() { - final Session session = prepareGetSession(); + prepareGetSession(); final List<EntityTypePE> types = new ArrayList<EntityTypePE>(); types.add(CommonTestUtils.createExperimentType()); context.checking(new Expectations() @@ -502,14 +502,14 @@ public final class CommonServerTest extends AbstractServerTestCase will(returnValue(types)); } }); - assertEquals(types, createServer().listExperimentTypes(session.getSessionToken())); + assertEquals(types, createServer().listExperimentTypes(SESSION_TOKEN)); context.assertIsSatisfied(); } @Test public void testListProjects() { - final Session session = prepareGetSession(); + prepareGetSession(); context.checking(new Expectations() { { @@ -520,18 +520,18 @@ public final class CommonServerTest extends AbstractServerTestCase will(returnValue(new ArrayList<ProjectPE>())); } }); - createServer().listProjects(session.getSessionToken()); + createServer().listProjects(SESSION_TOKEN); context.assertIsSatisfied(); } @Test public void testListPropertyTypes() { - final Session session = prepareGetSession(); + prepareGetSession(); context.checking(new Expectations() { { - one(commonBusinessObjectFactory).createPropertyTypeTable(session); + one(commonBusinessObjectFactory).createPropertyTypeTable(SESSION); will(returnValue(propertyTypeTable)); one(propertyTypeTable).load(); @@ -541,14 +541,14 @@ public final class CommonServerTest extends AbstractServerTestCase will(returnValue(new ArrayList<PropertyTypePE>())); } }); - createServer().listPropertyTypes(session.getSessionToken()); + createServer().listPropertyTypes(SESSION_TOKEN); context.assertIsSatisfied(); } @Test public final void testListDataTypes() { - final Session session = prepareGetSession(); + prepareGetSession(); context.checking(new Expectations() { { @@ -559,7 +559,7 @@ public final class CommonServerTest extends AbstractServerTestCase will(returnValue(Collections.emptyList())); } }); - final List<DataTypePE> dataTypes = createServer().listDataTypes(session.getSessionToken()); + final List<DataTypePE> dataTypes = createServer().listDataTypes(SESSION_TOKEN); assertEquals(0, dataTypes.size()); context.assertIsSatisfied(); } @@ -567,7 +567,7 @@ public final class CommonServerTest extends AbstractServerTestCase @Test public final void testListVocabularies() { - final Session session = prepareGetSession(); + prepareGetSession(); final boolean excludeInternal = true; context.checking(new Expectations() { @@ -580,7 +580,7 @@ public final class CommonServerTest extends AbstractServerTestCase } }); final List<VocabularyPE> vocabularies = - createServer().listVocabularies(session.getSessionToken(), true, excludeInternal); + createServer().listVocabularies(SESSION_TOKEN, true, excludeInternal); assertEquals(0, vocabularies.size()); context.assertIsSatisfied(); } @@ -588,11 +588,11 @@ public final class CommonServerTest extends AbstractServerTestCase @Test public final void testRegisterPropertyType() { - final Session session = prepareGetSession(); + prepareGetSession(); context.checking(new Expectations() { { - one(commonBusinessObjectFactory).createPropertyTypeBO(session); + one(commonBusinessObjectFactory).createPropertyTypeBO(SESSION); will(returnValue(propertyTypeBO)); one(propertyTypeBO).define(with(aNonNull(PropertyType.class))); @@ -606,11 +606,11 @@ public final class CommonServerTest extends AbstractServerTestCase @Test public final void testRegisterVocabulary() { - final Session session = prepareGetSession(); + prepareGetSession(); context.checking(new Expectations() { { - one(commonBusinessObjectFactory).createVocabularyBO(session); + one(commonBusinessObjectFactory).createVocabularyBO(SESSION); will(returnValue(vocabularyBO)); one(vocabularyBO).define(with(aNonNull(Vocabulary.class))); @@ -624,7 +624,7 @@ public final class CommonServerTest extends AbstractServerTestCase @Test public final void testAssignPropertyType() { - final Session session = prepareGetSession(); + prepareGetSession(); final EntityKind entityKind = EntityKind.EXPERIMENT; final String propertyTypeCode = "USER.DISTANCE"; final String entityTypeCode = "ARCHERY"; @@ -633,7 +633,7 @@ public final class CommonServerTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(commonBusinessObjectFactory).createEntityTypePropertyTypeBO(session, + one(commonBusinessObjectFactory).createEntityTypePropertyTypeBO(SESSION, entityKind); will(returnValue(entityTypePropertyTypeBO)); @@ -651,12 +651,12 @@ public final class CommonServerTest extends AbstractServerTestCase @Test public void testListMaterials() { - final Session session = prepareGetSession(); + prepareGetSession(); final MaterialTypePE materialType = CommonTestUtils.createMaterialType(); context.checking(new Expectations() { { - one(commonBusinessObjectFactory).createMaterialTable(session); + one(commonBusinessObjectFactory).createMaterialTable(SESSION); will(returnValue(materialTable)); one(materialTable).load(materialType.getCode()); @@ -668,14 +668,14 @@ public final class CommonServerTest extends AbstractServerTestCase will(returnValue(new ArrayList<MaterialTypePE>())); } }); - createServer().listMaterials(session.getSessionToken(), materialType); + createServer().listMaterials(SESSION_TOKEN, materialType); context.assertIsSatisfied(); } @Test public void testListMaterialTypes() { - final Session session = prepareGetSession(); + prepareGetSession(); final List<EntityTypePE> types = new ArrayList<EntityTypePE>(); types.add(CommonTestUtils.createMaterialType()); context.checking(new Expectations() @@ -688,7 +688,7 @@ public final class CommonServerTest extends AbstractServerTestCase will(returnValue(types)); } }); - assertEquals(types, createServer().listMaterialTypes(session.getSessionToken())); + assertEquals(types, createServer().listMaterialTypes(SESSION_TOKEN)); context.assertIsSatisfied(); } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerTestCase.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerTestCase.java index 538cff051170ba27d11731a213287de002bf7da7..23a24cb713367f01104f0fa88b6a2ce3f3423668 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerTestCase.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/AbstractServerTestCase.java @@ -16,6 +16,7 @@ package ch.systemsx.cisd.openbis.generic.shared; +import org.apache.log4j.Level; import org.jmock.Expectations; import org.jmock.Mockery; import org.testng.AssertJUnit; @@ -25,6 +26,7 @@ import org.testng.annotations.BeforeMethod; import ch.systemsx.cisd.authentication.IAuthenticationService; import ch.systemsx.cisd.authentication.ISessionManager; import ch.systemsx.cisd.authentication.Principal; +import ch.systemsx.cisd.common.logging.BufferedAppender; import ch.systemsx.cisd.common.logging.LogInitializer; import ch.systemsx.cisd.openbis.generic.server.business.bo.IEntityTypePropertyTypeBO; import ch.systemsx.cisd.openbis.generic.server.business.bo.IExperimentBO; @@ -40,6 +42,7 @@ import ch.systemsx.cisd.openbis.generic.server.business.bo.IVocabularyBO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDatabaseInstanceDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IEntityTypeDAO; +import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExperimentAttachmentDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IExternalDataDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IGroupDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IPersonDAO; @@ -66,8 +69,13 @@ public abstract class AbstractServerTestCase extends AssertJUnit { protected static final Principal PRINCIPAL = new Principal(CommonTestUtils.USER_ID, "john", "doe", "j@d"); - + protected static final String SESSION_TOKEN = "session-token"; + + protected static final Session SESSION = + new Session(CommonTestUtils.USER_ID, SESSION_TOKEN, PRINCIPAL, "remote-host", 1); + + protected BufferedAppender logRecorder; protected Mockery context; @@ -123,11 +131,14 @@ public abstract class AbstractServerTestCase extends AssertJUnit protected IEntityTypePropertyTypeBO entityTypePropertyTypeBO; + protected IExperimentAttachmentDAO experimentAttachmentDAO; + @BeforeMethod @SuppressWarnings("unchecked") public void setUp() { LogInitializer.init(); + logRecorder = new BufferedAppender("%m%n", Level.DEBUG); context = new Mockery(); authenticationService = context.mock(IAuthenticationService.class); sessionManager = context.mock(ISessionManager.class); @@ -140,6 +151,7 @@ public abstract class AbstractServerTestCase extends AssertJUnit roleAssignmentDAO = context.mock(IRoleAssignmentDAO.class); externalDataDAO = context.mock(IExternalDataDAO.class); entityTypeDAO = context.mock(IEntityTypeDAO.class); + experimentAttachmentDAO = context.mock(IExperimentAttachmentDAO.class); projectDAO = context.mock(IProjectDAO.class); sampleTypeDAO = context.mock(ISampleTypeDAO.class); propertyTypeDAO = context.mock(IPropertyTypeDAO.class); @@ -175,6 +187,10 @@ public abstract class AbstractServerTestCase extends AssertJUnit will(returnValue(roleAssignmentDAO)); allowing(daoFactory).getSampleTypeDAO(); will(returnValue(sampleTypeDAO)); + allowing(daoFactory).getExternalDataDAO(); + will(returnValue(externalDataDAO)); + allowing(daoFactory).getExperimentAttachmentDAO(); + will(returnValue(experimentAttachmentDAO)); } }); } @@ -182,27 +198,26 @@ public abstract class AbstractServerTestCase extends AssertJUnit @AfterMethod public void tearDown() { + logRecorder.reset(); // To following line of code should also be called at the end of each test method. // Otherwise one do not known which test failed. context.assertIsSatisfied(); } - - protected Session createExampleSession() + + protected Session createSession() { - return new Session(CommonTestUtils.USER_ID, SESSION_TOKEN, PRINCIPAL, "remote-host", 1); + return new Session(CommonTestUtils.USER_ID, SESSION_TOKEN, PRINCIPAL, "remote-host", 2); } - protected Session prepareGetSession() + protected void prepareGetSession() { - final Session session = createExampleSession(); context.checking(new Expectations() { { one(sessionManager).getSession(SESSION_TOKEN); - will(returnValue(session)); + will(returnValue(SESSION)); } }); - return session; } static final protected ExperimentPE createExperiment(final String experimentTypeCode, @@ -213,10 +228,14 @@ public abstract class AbstractServerTestCase extends AssertJUnit final ProjectPE projectPE = new ProjectPE(); final GroupPE groupPE = new GroupPE(); groupPE.setCode(groupCode); + DatabaseInstancePE databaseInstancePE = new DatabaseInstancePE(); + databaseInstancePE.setCode("DB"); + groupPE.setDatabaseInstance(databaseInstancePE); projectPE.setGroup(groupPE); + projectPE.setCode("P"); experimentPE.setProject(projectPE); final ExperimentTypePE experimentTypePE = new ExperimentTypePE(); - experimentPE.setCode(experimentTypeCode); + experimentTypePE.setCode(experimentTypeCode); experimentPE.setExperimentType(experimentTypePE); return experimentPE; } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java index 68cc49d05cd3d7ddf8514ac0bf22cb8fea4861ee..602ec8184683e8ae9381e7b85d8f23163b9621b3 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerTest.java @@ -37,7 +37,6 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.ProcedurePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleGenerationDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleTypePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.Session; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifierFactory; @@ -85,7 +84,7 @@ public final class GenericServerTest extends AbstractServerTestCase @Test public final void testGetSampleInfo() { - final Session session = prepareGetSession(); + prepareGetSession(); final SampleIdentifier sampleIdentifier = CommonTestUtils.createSampleIdentifier(); final SamplePE samplePE = CommonTestUtils.createSample(); final SampleGenerationDTO sampleGenerationDTO = new SampleGenerationDTO(); @@ -93,7 +92,7 @@ public final class GenericServerTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(genericBusinessObjectFactory).createSampleBO(session); + one(genericBusinessObjectFactory).createSampleBO(SESSION); will(returnValue(sampleBO)); one(sampleBO).loadBySampleIdentifier(sampleIdentifier); @@ -101,7 +100,7 @@ public final class GenericServerTest extends AbstractServerTestCase one(sampleBO).getSample(); will(returnValue(samplePE)); - one(sampleTypeSlaveServerPlugin).getSampleInfo(session, samplePE); + one(sampleTypeSlaveServerPlugin).getSampleInfo(SESSION, samplePE); will(returnValue(sampleGenerationDTO)); } }); @@ -116,12 +115,12 @@ public final class GenericServerTest extends AbstractServerTestCase @Test public final void testRegisterSample() { - final Session session = prepareGetSession(); + prepareGetSession(); final NewSample newSample = new NewSample(); context.checking(new Expectations() { { - one(genericBusinessObjectFactory).createSampleBO(session); + one(genericBusinessObjectFactory).createSampleBO(SESSION); will(returnValue(sampleBO)); one(sampleBO).define(newSample); @@ -136,14 +135,14 @@ public final class GenericServerTest extends AbstractServerTestCase @Test public void testGetExperimentInfo() throws Exception { - final Session session = prepareGetSession(); + prepareGetSession(); final ExperimentIdentifier experimentIdentifier = CommonTestUtils.createExperimentIdentifier(); final ExperimentPE experimentPE = CommonTestUtils.createExperiment(experimentIdentifier); context.checking(new Expectations() { { - one(genericBusinessObjectFactory).createExperimentBO(session); + one(genericBusinessObjectFactory).createExperimentBO(SESSION); will(returnValue(experimentBO)); one(experimentBO).loadByExperimentIdentifier(experimentIdentifier); @@ -162,14 +161,14 @@ public final class GenericServerTest extends AbstractServerTestCase @Test public void testGetExperimentFileAttachment() throws Exception { - final Session session = prepareGetSession(); + prepareGetSession(); final ExperimentIdentifier experimentIdentifier = CommonTestUtils.createExperimentIdentifier(); final AttachmentPE attachmentPE = CommonTestUtils.createAttachment(); context.checking(new Expectations() { { - one(genericBusinessObjectFactory).createExperimentBO(session); + one(genericBusinessObjectFactory).createExperimentBO(SESSION); will(returnValue(experimentBO)); one(experimentBO).loadByExperimentIdentifier(experimentIdentifier); @@ -181,7 +180,7 @@ public final class GenericServerTest extends AbstractServerTestCase } }); assertEquals(attachmentPE, createServer().getExperimentFileAttachment( - session.getSessionToken(), experimentIdentifier, attachmentPE.getFileName(), + SESSION_TOKEN, experimentIdentifier, attachmentPE.getFileName(), attachmentPE.getVersion())); context.assertIsSatisfied(); } @@ -230,7 +229,7 @@ public final class GenericServerTest extends AbstractServerTestCase @Test public final void testRegisterSamples() { - final Session session = prepareGetSession(); + prepareGetSession(); final SampleTypePE sampleTypePE = CommonTestUtils.createSampleType(); final SampleType sampleType = new SampleType(); sampleType.setCode(sampleTypePE.getCode()); @@ -243,22 +242,22 @@ public final class GenericServerTest extends AbstractServerTestCase one(sampleTypeDAO).tryFindSampleTypeByCode(sampleTypePE.getCode()); will(returnValue(sampleTypePE)); - one(sampleTypeSlaveServerPlugin).registerSamples(session, newSamples); + one(sampleTypeSlaveServerPlugin).registerSamples(SESSION, newSamples); } }); - createServer().registerSamples(session.getSessionToken(), sampleType, newSamples); + createServer().registerSamples(SESSION_TOKEN, sampleType, newSamples); context.assertIsSatisfied(); } @Test public final void testRegisterExperimentWithoutSamples() { - final Session session = prepareGetSession(); + prepareGetSession(); final NewExperiment newExperiment = new NewExperiment(); context.checking(new Expectations() { { - one(genericBusinessObjectFactory).createExperimentBO(session); + one(genericBusinessObjectFactory).createExperimentBO(SESSION); will(returnValue(experimentBO)); one(experimentBO).define(newExperiment); @@ -273,7 +272,7 @@ public final class GenericServerTest extends AbstractServerTestCase @Test public final void testRegisterExperimentWithSamples() { - final Session session = prepareGetSession(); + prepareGetSession(); final String experimentTypeCode = "EXP-TYPE1"; final String experimentCode = "EXP1"; final String groupCode = "CISD"; @@ -295,7 +294,7 @@ public final class GenericServerTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(genericBusinessObjectFactory).createExperimentBO(session); + one(genericBusinessObjectFactory).createExperimentBO(SESSION); will(returnValue(experimentBO)); one(experimentBO).define(newExperiment); @@ -303,20 +302,20 @@ public final class GenericServerTest extends AbstractServerTestCase one(experimentBO).getExperiment(); will(returnValue(experimentPE)); - one(genericBusinessObjectFactory).createProcedureBO(session); + one(genericBusinessObjectFactory).createProcedureBO(SESSION); will(returnValue(procedureBO)); one(procedureBO).define(experimentPE, procedureTypeCode); one(procedureBO).save(); one(procedureBO).getProcedure(); will(returnValue(procedurePE)); - one(genericBusinessObjectFactory).createSampleBO(session); + one(genericBusinessObjectFactory).createSampleBO(SESSION); will(returnValue(sampleBO)); one(sampleBO).loadBySampleIdentifier(sampleIdentifier1); one(sampleBO).enrichWithValidProcedure(); one(sampleBO).addProcedure(procedurePE); - one(genericBusinessObjectFactory).createSampleBO(session); + one(genericBusinessObjectFactory).createSampleBO(SESSION); will(returnValue(sampleBO)); one(sampleBO).loadBySampleIdentifier(sampleIdentifier2WithGroup); one(sampleBO).enrichWithValidProcedure(); @@ -331,7 +330,7 @@ public final class GenericServerTest extends AbstractServerTestCase @Test public final void testRegisterExperimentWithSampleFromWronGroup() { - final Session session = prepareGetSession(); + prepareGetSession(); final String experimentTypeCode = "EXP-TYPE1"; final String experimentCode = "EXP1"; final String groupCode = "CISD"; @@ -348,7 +347,7 @@ public final class GenericServerTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(genericBusinessObjectFactory).createExperimentBO(session); + one(genericBusinessObjectFactory).createExperimentBO(SESSION); will(returnValue(experimentBO)); one(experimentBO).define(newExperiment); @@ -356,7 +355,7 @@ public final class GenericServerTest extends AbstractServerTestCase one(experimentBO).getExperiment(); will(returnValue(experimentPE)); - one(genericBusinessObjectFactory).createProcedureBO(session); + one(genericBusinessObjectFactory).createProcedureBO(SESSION); will(returnValue(procedureBO)); one(procedureBO).define(experimentPE, procedureTypeCode); one(procedureBO).save(); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerTest.java index 1ab6b394855f7589fdda4dd2e103664121c64a83..c57d2ecc6a801efe0dcc6606207c4dfd0d682589 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/screening/server/ScreeningServerTest.java @@ -25,7 +25,6 @@ import ch.systemsx.cisd.openbis.generic.shared.AbstractServerTestCase; import ch.systemsx.cisd.openbis.generic.shared.CommonTestUtils; import ch.systemsx.cisd.openbis.generic.shared.dto.SampleGenerationDTO; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; -import ch.systemsx.cisd.openbis.generic.shared.dto.Session; import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier; import ch.systemsx.cisd.openbis.plugin.ISampleTypeSlaveServerPlugin; import ch.systemsx.cisd.openbis.plugin.screening.shared.IScreeningServer; @@ -64,7 +63,7 @@ public final class ScreeningServerTest extends AbstractServerTestCase @Test public final void testGetSampleInfo() { - final Session session = prepareGetSession(); + prepareGetSession(); final SampleIdentifier sampleIdentifier = CommonTestUtils.createSampleIdentifier(); final SamplePE samplePE = CommonTestUtils.createSample(); final SampleGenerationDTO sampleGenerationDTO = new SampleGenerationDTO(); @@ -72,7 +71,7 @@ public final class ScreeningServerTest extends AbstractServerTestCase context.checking(new Expectations() { { - one(screeningBusinessObjectFactory).createSampleBO(session); + one(screeningBusinessObjectFactory).createSampleBO(SESSION); will(returnValue(sampleBO)); one(sampleBO).loadBySampleIdentifier(sampleIdentifier); @@ -80,7 +79,7 @@ public final class ScreeningServerTest extends AbstractServerTestCase one(sampleBO).getSample(); will(returnValue(samplePE)); - one(sampleTypeSlaveServerPlugin).getSampleInfo(session, samplePE); + one(sampleTypeSlaveServerPlugin).getSampleInfo(SESSION, samplePE); will(returnValue(sampleGenerationDTO)); } });