Fixing tests
This commit is contained in:
parent
df3d81d2bd
commit
f80eec0301
|
@ -589,8 +589,6 @@ public class ERManagementTest extends ContextTest {
|
||||||
deleteResource(eService);
|
deleteResource(eService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// public static final String TEST_RESOURCE = "test-resource.json";
|
// public static final String TEST_RESOURCE = "test-resource.json";
|
||||||
//
|
//
|
||||||
|
@ -612,8 +610,4 @@ public class ERManagementTest extends ContextTest {
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,15 @@ public class QueryTest extends ContextTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAll() throws Exception {
|
public void testGetAll() throws Exception {
|
||||||
|
|
||||||
|
// Clean the environment first to avoid error if a previous tests fails without cleaning the env
|
||||||
|
ResourceManagement rm = (ResourceManagement) ElementManagementUtility.getERManagement(Resource.NAME);
|
||||||
|
String all = rm.all(true);
|
||||||
|
List<Resource> allResources = ElementMapper.unmarshalList(Resource.class, all);
|
||||||
|
for(Resource r : allResources) {
|
||||||
|
ERManagementTest.deleteResource(r);
|
||||||
|
}
|
||||||
|
|
||||||
Map<String, List<Resource>> resources = new HashMap<>();
|
Map<String, List<Resource>> resources = new HashMap<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -4,9 +4,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.Schema
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.ERManagementTest;
|
import org.gcube.informationsystem.resourceregistry.instances.ERManagementTest;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.relations.ConsistsOfManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.relations.ConsistsOfManagement;
|
||||||
import org.gcube.informationsystem.utils.ElementMapper;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet;
|
import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet;
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.resources.EService;
|
import org.gcube.resourcemanagement.model.reference.entities.resources.EService;
|
||||||
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
|
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
|
||||||
|
@ -16,15 +14,10 @@ public class AddToContextTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateEServiceAndRemoveFromContextRequiredFacet() throws Exception {
|
public void testCreateEServiceAndRemoveFromContextRequiredFacet() throws Exception {
|
||||||
EService eService = ERManagementTest.instantiateValidEService();
|
EService eService = ERManagementTest.createEService();
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setElementType(EService.NAME);
|
|
||||||
resourceManagement.setJson(ElementMapper.marshal(eService));
|
|
||||||
String createEServiceString = resourceManagement.create();
|
|
||||||
EService createEService = ElementMapper.unmarshal(EService.class, createEServiceString);
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
IsIdentifiedBy<EService, SoftwareFacet> isIdentifiedBy = (IsIdentifiedBy<EService, SoftwareFacet>) createEService.getConsistsOf(IsIdentifiedBy.class).get(0);
|
IsIdentifiedBy<EService, SoftwareFacet> isIdentifiedBy = (IsIdentifiedBy<EService, SoftwareFacet>) eService.getConsistsOf(IsIdentifiedBy.class).get(0);
|
||||||
ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement();
|
ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement();
|
||||||
consistsOfManagement.setElementType(IsIdentifiedBy.NAME);
|
consistsOfManagement.setElementType(IsIdentifiedBy.NAME);
|
||||||
consistsOfManagement.setUUID(isIdentifiedBy.getHeader().getUUID());
|
consistsOfManagement.setUUID(isIdentifiedBy.getHeader().getUUID());
|
||||||
|
@ -35,7 +28,7 @@ public class AddToContextTest {
|
||||||
}catch (SchemaViolationException e) {
|
}catch (SchemaViolationException e) {
|
||||||
// As expected
|
// As expected
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
resourceManagement.delete();
|
ERManagementTest.deleteResource(eService);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,11 +43,11 @@ public class AddToContextTest {
|
||||||
}catch (SchemaViolationException e) {
|
}catch (SchemaViolationException e) {
|
||||||
// As expected
|
// As expected
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
resourceManagement.delete();
|
ERManagementTest.deleteResource(eService);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
resourceManagement.delete();
|
ERManagementTest.deleteResource(eService);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue