From c7b4de1566c80eaf91302b44681b087a7b279fc1 Mon Sep 17 00:00:00 2001 From: pkupczyk <pkupczyk> Date: Sun, 21 Jan 2018 18:46:23 +0000 Subject: [PATCH] SSDM-4997 : Project Authorization fix tests SVN: 39120 --- .../generic/server/CommonServerTest.java | 24 ++++++++++++++++--- .../server/ServiceForDataStoreServerTest.java | 1 + .../server/GenericServerDatabaseTest.java | 1 + .../openbis/systemtest/CommonServerTest.java | 1 + 4 files changed, 24 insertions(+), 3 deletions(-) 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 716dc908a49..743befe3899 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 @@ -29,6 +29,7 @@ import java.util.Set; import org.apache.commons.lang.builder.EqualsBuilder; import org.hamcrest.core.IsEqual; +import org.hibernate.SessionFactory; import org.jmock.Expectations; import org.springframework.dao.DataIntegrityViolationException; import org.testng.annotations.BeforeMethod; @@ -160,6 +161,10 @@ public final class CommonServerTest extends AbstractServerTestCase private IDataStoreService dataStoreService; + private SessionFactory hibernateSessionFactory; + + private org.hibernate.Session hibernateSession; + private final CommonServer createServer() { CommonServer server = @@ -208,6 +213,8 @@ public final class CommonServerTest extends AbstractServerTestCase entityValidatorFactory = context.mock(IEntityValidatorFactory.class); entityValidatorHotDeployPlugin = context.mock(IEntityValidatorHotDeployPlugin.class); hotDeploymentController = context.mock(IHotDeploymentController.class); + hibernateSessionFactory = context.mock(SessionFactory.class); + hibernateSession = context.mock(org.hibernate.Session.class); } @Test @@ -243,7 +250,8 @@ public final class CommonServerTest extends AbstractServerTestCase assertEquals( "# Besides the full identifier of format '/SPACE_CODE/PROJECT_CODE/EXPERIMENT_CODE', two short formats 'EXPERIMENT_CODE' and 'PROJECT_CODE/EXPERIMENT_CODE' are accepted given that the default project (former short format) or default space (latter short format) are configured. If the proper default value is not configured when using a short format, experiment import will fail.\nidentifier\tNON-MANAGED-PROP\tMANAGED-PROP-NO-SUBCOLUMNS\t" - + "MANAGED-PROP-SUBCOLUMNS:A\tMANAGED-PROP-SUBCOLUMNS:B", template); + + "MANAGED-PROP-SUBCOLUMNS:A\tMANAGED-PROP-SUBCOLUMNS:B", + template); context.assertIsSatisfied(); } @@ -1194,7 +1202,7 @@ public final class CommonServerTest extends AbstractServerTestCase List<Script> scripts = createServer(entityValidatorFactory, dynamicPropertyCalculatorFactory, managedPropertyEvaluatorFactory).listScripts(SESSION_TOKEN, - ScriptType.ENTITY_VALIDATION, EntityKind.SAMPLE); + ScriptType.ENTITY_VALIDATION, EntityKind.SAMPLE); assertEquals("s2", scripts.get(0).getName()); assertEquals(ScriptType.ENTITY_VALIDATION, scripts.get(0).getScriptType()); @@ -1247,7 +1255,7 @@ public final class CommonServerTest extends AbstractServerTestCase createServer(entityValidatorFactory, dynamicPropertyCalculatorFactory, managedPropertyEvaluatorFactory).deleteScripts(SESSION_TOKEN, - Arrays.asList(id1, id2)); + Arrays.asList(id1, id2)); context.assertIsSatisfied(); } @@ -1895,6 +1903,7 @@ public final class CommonServerTest extends AbstractServerTestCase public void testSaveDisplaySettings() { final PersonPE person = new PersonPE(); + person.setId(123L); EntityVisit v0 = visit(EntityKind.MATERIAL, 0); EntityVisit v1 = visit(EntityKind.SAMPLE, 2); DisplaySettings currentDisplaySettings = displaySettingsWithVisits(v0, v1); @@ -1902,6 +1911,15 @@ public final class CommonServerTest extends AbstractServerTestCase context.checking(new Expectations() { { + one(daoFactory).getSessionFactory(); + will(returnValue(hibernateSessionFactory)); + + one(hibernateSessionFactory).getCurrentSession(); + will(returnValue(hibernateSession)); + + one(hibernateSession).get(PersonPE.class, person.getId()); + will(returnValue(person)); + allowing(sessionManager).getSession(SESSION_TOKEN); Session mySession = createSession(CommonTestUtils.USER_ID); mySession.setPerson(person); diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/ServiceForDataStoreServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/ServiceForDataStoreServerTest.java index ca756e158fb..757384decc6 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/ServiceForDataStoreServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/ServiceForDataStoreServerTest.java @@ -1386,6 +1386,7 @@ public class ServiceForDataStoreServerTest extends SystemTestCase SampleUpdatesDTO updates = new SampleUpdatesDTO(new TechId(sampleId), null, null, null, null, 0, SampleIdentifierFactory.parse(sampleIdentifier), null, null); updates.setProperties(Arrays.asList(createEntityProperty(propertyCode, propertyValue))); + updates.setUpdateExperimentLink(false); return updates; } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerDatabaseTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerDatabaseTest.java index ba605f30ba9..6e09172c5f8 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerDatabaseTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/plugin/generic/server/GenericServerDatabaseTest.java @@ -740,6 +740,7 @@ public class GenericServerDatabaseTest extends AbstractDAOTest new SampleUpdatesDTO(new TechId(sampleId), null, null, null, Collections.emptyList(), 0, SampleIdentifierFactory.parse(sampleIdentifier), null, null); updates.setProperties(Arrays.asList(createEntityProperty(propertyCode, propertyValue))); + updates.setUpdateExperimentLink(false); return updates; } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java index c23cfe23473..7b5e16a3bf7 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/CommonServerTest.java @@ -1735,6 +1735,7 @@ public class CommonServerTest extends SystemTestCase SampleUpdatesDTO updates = new SampleUpdatesDTO(new TechId(1055L), Arrays.asList(new IEntityProperty[] { property }), null, null, new ArrayList<NewAttachment>(), 0, null, null, null); // /TEST-SPACE/EV-TEST + updates.setUpdateExperimentLink(false); if (user.isInstanceUserOrTestSpaceUserOrEnabledTestProjectUser()) { -- GitLab