Skip to content
Snippets Groups Projects
Commit 7c6e5042 authored by anttil's avatar anttil
Browse files

BIS-528 / SP-881: Fix tests

SVN: 29774
parent 22eff44a
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ import java.util.EnumSet; ...@@ -23,6 +23,7 @@ import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import org.testng.annotations.Test; import org.testng.annotations.Test;
...@@ -44,11 +45,9 @@ import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableModel; ...@@ -44,11 +45,9 @@ import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.QueryTableModel;
import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.ReportDescription; import ch.systemsx.cisd.openbis.plugin.query.shared.api.v1.dto.ReportDescription;
/** /**
* This class groups tests for aggregation, injestion services as well as other reporting services. * This class groups tests for aggregation, injestion services as well as other reporting services. It abstracts however the way it calls the
* It abstracts however the way it calls the services, so that the subclasses testing the reports * services, so that the subclasses testing the reports via particular api can be created. This class is extended by {@link QueryFacadeTest} and
* via particular api can be created. This class is extended by {@link QueryFacadeTest} and * {@link QueryApiJsonDssServiceRpcGenericTest}, one testing the {@link IQueryApiFacade} and the other {@link IDssServiceRpcGeneric}.
* {@link QueryApiJsonDssServiceRpcGenericTest}, one testing the {@link IQueryApiFacade} and the
* other {@link IDssServiceRpcGeneric}.
* *
* @author Jakub Straszewski * @author Jakub Straszewski
* @author Chandrasekhar Ramakrishnan * @author Chandrasekhar Ramakrishnan
...@@ -73,8 +72,7 @@ public abstract class AbstractQueryFacadeTest extends SystemTestCase ...@@ -73,8 +72,7 @@ public abstract class AbstractQueryFacadeTest extends SystemTestCase
public abstract String getSessionToken(); public abstract String getSessionToken();
/** /**
* Unique short identifier to create data with different ids in different implementation of this * Unique short identifier to create data with different ids in different implementation of this test class
* test class
*/ */
public abstract String getTestId(); public abstract String getTestId();
...@@ -185,7 +183,9 @@ public abstract class AbstractQueryFacadeTest extends SystemTestCase ...@@ -185,7 +183,9 @@ public abstract class AbstractQueryFacadeTest extends SystemTestCase
public void testDbModifyingAggregationServiceReport() throws Exception public void testDbModifyingAggregationServiceReport() throws Exception
{ {
HashMap<String, Object> parameters = new HashMap<String, Object>(); HashMap<String, Object> parameters = new HashMap<String, Object>();
String spaceCode = UUID.randomUUID().toString();
parameters.put("name", "world"); parameters.put("name", "world");
parameters.put("space", spaceCode);
QueryTableModel table = QueryTableModel table =
createReportFromAggregationService("example-db-modifying-aggregation-service", createReportFromAggregationService("example-db-modifying-aggregation-service",
...@@ -204,7 +204,7 @@ public abstract class AbstractQueryFacadeTest extends SystemTestCase ...@@ -204,7 +204,7 @@ public abstract class AbstractQueryFacadeTest extends SystemTestCase
boolean foundSpace = false; boolean foundSpace = false;
for (SpaceWithProjectsAndRoleAssignments space : spaces) for (SpaceWithProjectsAndRoleAssignments space : spaces)
{ {
if ("NEWDUMMYSPACE".equalsIgnoreCase(space.getCode())) if (spaceCode.equalsIgnoreCase(space.getCode()))
{ {
foundSpace = true; foundSpace = true;
} }
...@@ -217,14 +217,15 @@ public abstract class AbstractQueryFacadeTest extends SystemTestCase ...@@ -217,14 +217,15 @@ public abstract class AbstractQueryFacadeTest extends SystemTestCase
public void testJythonDbModifyingAggregationServiceReport() throws Exception public void testJythonDbModifyingAggregationServiceReport() throws Exception
{ {
HashMap<String, Object> parameters = new HashMap<String, Object>(); HashMap<String, Object> parameters = new HashMap<String, Object>();
parameters.put("code", "JYTHON-TEST"); String code = UUID.randomUUID().toString();
parameters.put("code", code);
QueryTableModel table = QueryTableModel table =
createReportFromAggregationService( createReportFromAggregationService(
"example-jython-db-modifying-aggregation-service", parameters); "example-jython-db-modifying-aggregation-service", parameters);
assertEquals("[CODE, IDENTIFIER]", getHeaders(table).toString()); assertEquals("[CODE, IDENTIFIER]", getHeaders(table).toString());
assertEquals("[JYTHON-TEST, /CISD/JYTHON-TEST]", Arrays.asList(table.getRows().get(0)) assertEquals("[" + code + ", /CISD/" + code + "]", Arrays.asList(table.getRows().get(0))
.toString()); .toString());
assertEquals(1, table.getRows().size()); assertEquals(1, table.getRows().size());
...@@ -236,13 +237,13 @@ public abstract class AbstractQueryFacadeTest extends SystemTestCase ...@@ -236,13 +237,13 @@ public abstract class AbstractQueryFacadeTest extends SystemTestCase
boolean foundSample = false; boolean foundSample = false;
for (Sample sample : samples) for (Sample sample : samples)
{ {
if ("JYTHON-TEST".equalsIgnoreCase(sample.getCode())) if (code.equalsIgnoreCase(sample.getCode()))
{ {
foundSample = true; foundSample = true;
} }
} }
assertTrue("Did not find a sample called [JYTHON-TEST]", foundSample); assertTrue("Did not find a sample called " + code, foundSample);
} }
/** /**
...@@ -262,8 +263,7 @@ public abstract class AbstractQueryFacadeTest extends SystemTestCase ...@@ -262,8 +263,7 @@ public abstract class AbstractQueryFacadeTest extends SystemTestCase
} }
/** /**
* The testcase, where the observer tries to acces the dataset that he cannot see, but through * The testcase, where the observer tries to acces the dataset that he cannot see, but through the non-authorized content provider.
* the non-authorized content provider.
*/ */
@Test @Test
public void testJythonAggregationServiceWithoutContentProviderAuthentication() throws Exception public void testJythonAggregationServiceWithoutContentProviderAuthentication() throws Exception
......
...@@ -50,7 +50,7 @@ public class ExampleDbModifyingAggregationService extends ...@@ -50,7 +50,7 @@ public class ExampleDbModifyingAggregationService extends
public TableModel process(IDataSetRegistrationTransactionV2 transaction, public TableModel process(IDataSetRegistrationTransactionV2 transaction,
Map<String, Object> parameters, DataSetProcessingContext context) Map<String, Object> parameters, DataSetProcessingContext context)
{ {
transaction.createNewSpace("NewDummySpace", null); transaction.createNewSpace(parameters.get("space").toString(), null);
SimpleTableModelBuilder builder = new SimpleTableModelBuilder(true); SimpleTableModelBuilder builder = new SimpleTableModelBuilder(true);
builder.addHeader("String"); builder.addHeader("String");
......
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