Fixing tests

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@141578 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-01-13 17:20:14 +00:00
parent e29df940e5
commit 6480c31d46
1 changed files with 244 additions and 203 deletions

View File

@ -43,7 +43,7 @@ import org.gcube.informationsystem.model.relation.IsIdentifiedBy;
import org.gcube.informationsystem.model.relation.IsRelatedTo; import org.gcube.informationsystem.model.relation.IsRelatedTo;
import org.gcube.informationsystem.model.relation.Relation; import org.gcube.informationsystem.model.relation.Relation;
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts; import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.client.proxy.Direction; import org.gcube.informationsystem.resourceregistry.client.proxy.Direction;
import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClient; import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClient;
import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClientFactory; import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClientFactory;
@ -62,15 +62,15 @@ public class ERManagementTest extends ScopedTest {
private static Logger logger = LoggerFactory private static Logger logger = LoggerFactory
.getLogger(ERManagementTest.class); .getLogger(ERManagementTest.class);
protected ResourceRegistryPublisher resourceRegistryPublisher; protected ResourceRegistryPublisher resourceRegistryPublisher;
protected ResourceRegistryClient resourceRegistryClient; protected ResourceRegistryClient resourceRegistryClient;
public ERManagementTest(){ public ERManagementTest() {
resourceRegistryPublisher = ResourceRegistryPublisherFactory.create(); resourceRegistryPublisher = ResourceRegistryPublisherFactory.create();
resourceRegistryClient = ResourceRegistryClientFactory.create(); resourceRegistryClient = ResourceRegistryClientFactory.create();
} }
@Test @Test
public void testCreateEService() throws Exception { public void testCreateEService() throws Exception {
EService eService = new EServiceImpl(); EService eService = new EServiceImpl();
@ -104,9 +104,9 @@ public class ERManagementTest extends ScopedTest {
"https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11")); "https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11"));
eService.addFacet(licenseFacet); eService.addFacet(licenseFacet);
eService = resourceRegistryPublisher.createResource(EService.class, eService); eService = resourceRegistryPublisher.createResource(EService.class,
eService);
boolean deleted = resourceRegistryPublisher.deleteResource(eService); boolean deleted = resourceRegistryPublisher.deleteResource(eService);
Assert.assertTrue(deleted); Assert.assertTrue(deleted);
} }
@ -118,7 +118,8 @@ public class ERManagementTest extends ScopedTest {
cpuFacet.setModel("Opteron"); cpuFacet.setModel("Opteron");
cpuFacet.setVendor("AMD"); cpuFacet.setVendor("AMD");
CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(CPUFacet.class, cpuFacet); CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(
CPUFacet.class, cpuFacet);
Assert.assertTrue(cpuFacet.getClockSpeed().compareTo( Assert.assertTrue(cpuFacet.getClockSpeed().compareTo(
createdCpuFacet.getClockSpeed()) == 0); createdCpuFacet.getClockSpeed()) == 0);
@ -129,8 +130,8 @@ public class ERManagementTest extends ScopedTest {
UUID uuid = createdCpuFacet.getHeader().getUUID(); UUID uuid = createdCpuFacet.getHeader().getUUID();
CPUFacet readCpuFacet = resourceRegistryClient.getInstance(
CPUFacet readCpuFacet = resourceRegistryClient.getInstance(CPUFacet.class, uuid); CPUFacet.class, uuid);
Assert.assertTrue(cpuFacet.getClockSpeed().compareTo( Assert.assertTrue(cpuFacet.getClockSpeed().compareTo(
readCpuFacet.getClockSpeed()) == 0); readCpuFacet.getClockSpeed()) == 0);
Assert.assertTrue(cpuFacet.getModel() Assert.assertTrue(cpuFacet.getModel()
@ -139,7 +140,6 @@ public class ERManagementTest extends ScopedTest {
readCpuFacet.getVendor()) == 0); readCpuFacet.getVendor()) == 0);
Assert.assertTrue(uuid.compareTo(readCpuFacet.getHeader().getUUID()) == 0); Assert.assertTrue(uuid.compareTo(readCpuFacet.getHeader().getUUID()) == 0);
String newVendor = "Intel"; String newVendor = "Intel";
String newClockSpeed = "2 GHz"; String newClockSpeed = "2 GHz";
readCpuFacet.setVendor(newVendor); readCpuFacet.setVendor(newVendor);
@ -150,8 +150,8 @@ public class ERManagementTest extends ScopedTest {
readCpuFacet.setAdditionalProperty(additionPropertyKey, readCpuFacet.setAdditionalProperty(additionPropertyKey,
additionPropertyValue); additionPropertyValue);
CPUFacet updatedCpuFacet = resourceRegistryPublisher.updateFacet(
CPUFacet updatedCpuFacet = resourceRegistryPublisher.updateFacet(CPUFacet.class, readCpuFacet); CPUFacet.class, readCpuFacet);
Assert.assertTrue(readCpuFacet.getClockSpeed().compareTo( Assert.assertTrue(readCpuFacet.getClockSpeed().compareTo(
updatedCpuFacet.getClockSpeed()) == 0); updatedCpuFacet.getClockSpeed()) == 0);
Assert.assertTrue(readCpuFacet.getModel().compareTo( Assert.assertTrue(readCpuFacet.getModel().compareTo(
@ -164,8 +164,8 @@ public class ERManagementTest extends ScopedTest {
.getAdditionalProperty(additionPropertyKey)) == 0); .getAdditionalProperty(additionPropertyKey)) == 0);
Assert.assertTrue(uuid.compareTo(updatedCpuFacet.getHeader().getUUID()) == 0); Assert.assertTrue(uuid.compareTo(updatedCpuFacet.getHeader().getUUID()) == 0);
CPUFacet readUpdatedCpuFacet = resourceRegistryClient.getInstance(
CPUFacet readUpdatedCpuFacet = resourceRegistryClient.getInstance(CPUFacet.class, uuid); CPUFacet.class, uuid);
Assert.assertTrue(updatedCpuFacet.getClockSpeed().compareTo( Assert.assertTrue(updatedCpuFacet.getClockSpeed().compareTo(
readUpdatedCpuFacet.getClockSpeed()) == 0); readUpdatedCpuFacet.getClockSpeed()) == 0);
Assert.assertTrue(updatedCpuFacet.getModel().compareTo( Assert.assertTrue(updatedCpuFacet.getModel().compareTo(
@ -178,14 +178,15 @@ public class ERManagementTest extends ScopedTest {
.getAdditionalProperty(additionPropertyKey)) == 0); .getAdditionalProperty(additionPropertyKey)) == 0);
Assert.assertTrue(uuid.compareTo(updatedCpuFacet.getHeader().getUUID()) == 0); Assert.assertTrue(uuid.compareTo(updatedCpuFacet.getHeader().getUUID()) == 0);
boolean deleted = resourceRegistryPublisher.deleteFacet(readUpdatedCpuFacet); boolean deleted = resourceRegistryPublisher
.deleteFacet(readUpdatedCpuFacet);
Assert.assertTrue(deleted); Assert.assertTrue(deleted);
} }
public Map<String, Resource> createHostingNodeAndEService()
public Map<String, Resource> createHostingNodeAndEService() throws Exception { throws Exception {
Map<String, Resource> map = new HashMap<>(); Map<String, Resource> map = new HashMap<>();
EService eService = new EServiceImpl(); EService eService = new EServiceImpl();
SoftwareFacet softwareFacet = new SoftwareFacetImpl(); SoftwareFacet softwareFacet = new SoftwareFacetImpl();
@ -196,11 +197,11 @@ public class ERManagementTest extends ScopedTest {
IsIdentifiedBy<Resource, Facet> isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>( IsIdentifiedBy<Resource, Facet> isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(
eService, softwareFacet, null); eService, softwareFacet, null);
eService.addFacet(isIdentifiedBy); eService.addFacet(isIdentifiedBy);
eService = resourceRegistryPublisher.createResource(EService.class, eService); eService = resourceRegistryPublisher.createResource(EService.class,
eService);
map.put(EService.NAME, eService); map.put(EService.NAME, eService);
NetworkingFacet networkingFacet = new NetworkingFacetImpl(); NetworkingFacet networkingFacet = new NetworkingFacetImpl();
networkingFacet.setIPAddress("146.48.87.183"); networkingFacet.setIPAddress("146.48.87.183");
networkingFacet.setHostName("pc-frosini.isti.cnr.it"); networkingFacet.setHostName("pc-frosini.isti.cnr.it");
@ -208,7 +209,8 @@ public class ERManagementTest extends ScopedTest {
networkingFacet.setMask("255.255.248.0"); networkingFacet.setMask("255.255.248.0");
networkingFacet.setBroadcastAddress("146.48.87.255"); networkingFacet.setBroadcastAddress("146.48.87.255");
networkingFacet = resourceRegistryPublisher.createFacet(NetworkingFacet.class, networkingFacet); networkingFacet = resourceRegistryPublisher.createFacet(
NetworkingFacet.class, networkingFacet);
logger.debug("Unmarshalled {} {}", NetworkingFacet.NAME, logger.debug("Unmarshalled {} {}", NetworkingFacet.NAME,
networkingFacet); networkingFacet);
@ -224,83 +226,93 @@ public class ERManagementTest extends ScopedTest {
networkingFacet, null); networkingFacet, null);
hostingNode.attachFacet(isIdentifiedBy); hostingNode.attachFacet(isIdentifiedBy);
PropagationConstraint propagationConstraint = new PropagationConstraintImpl(); PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade); propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>( Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>(
hostingNode, eService, propagationConstraint); hostingNode, eService, propagationConstraint);
hostingNode.attachResource(hosts); hostingNode.attachResource(hosts);
hostingNode = resourceRegistryPublisher.createResource(HostingNode.class, hostingNode); hostingNode = resourceRegistryPublisher.createResource(
HostingNode.class, hostingNode);
logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode); logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode);
map.put(HostingNode.NAME, hostingNode); map.put(HostingNode.NAME, hostingNode);
return map; return map;
} }
@Test @Test
public void testCreateHostingNodeAndEService() throws Exception { public void testCreateHostingNodeAndEService() throws Exception {
Map<String, Resource> map = createHostingNodeAndEService(); Map<String, Resource> map = createHostingNodeAndEService();
boolean deleted = resourceRegistryPublisher.deleteResource(map.get(EService.NAME)); boolean deleted = resourceRegistryPublisher.deleteResource(map
.get(EService.NAME));
Assert.assertTrue(deleted); Assert.assertTrue(deleted);
deleted = resourceRegistryPublisher.deleteResource(map.get(HostingNode.NAME)); deleted = resourceRegistryPublisher.deleteResource(map
.get(HostingNode.NAME));
Assert.assertTrue(deleted); Assert.assertTrue(deleted);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testCreateHostingNodeAndEServiceWithSharedFacet() throws Exception { public void testCreateHostingNodeAndEServiceWithSharedFacet()
throws Exception {
Map<String, Resource> map = createHostingNodeAndEService(); Map<String, Resource> map = createHostingNodeAndEService();
EService eService = (EService) map.get(EService.NAME); EService eService = (EService) map.get(EService.NAME);
HostingNode hostingNode = (HostingNode) map.get(HostingNode.NAME); HostingNode hostingNode = (HostingNode) map.get(HostingNode.NAME);
Facet shared = hostingNode.getConsistsOf().get(0).getTarget(); Facet shared = hostingNode.getConsistsOf().get(0).getTarget();
UUID sharedFacetUUID = shared.getHeader().getUUID(); UUID sharedFacetUUID = shared.getHeader().getUUID();
ConsistsOf<EService, Facet> consistsOf = new ConsistsOfImpl<EService, Facet>(eService, shared, null); ConsistsOf<EService, Facet> consistsOf = new ConsistsOfImpl<EService, Facet>(
consistsOf = resourceRegistryPublisher.createConsistsOf(ConsistsOf.class, consistsOf); eService, shared, null);
consistsOf = resourceRegistryPublisher.createConsistsOf(
ConsistsOf.class, consistsOf);
boolean deleted = resourceRegistryPublisher.deleteResource(map.get(EService.NAME)); boolean deleted = resourceRegistryPublisher.deleteResource(map
.get(EService.NAME));
Assert.assertTrue(deleted); Assert.assertTrue(deleted);
deleted = resourceRegistryPublisher.deleteResource(map.get(HostingNode.NAME)); deleted = resourceRegistryPublisher.deleteResource(map
.get(HostingNode.NAME));
Assert.assertTrue(deleted); Assert.assertTrue(deleted);
try { try {
resourceRegistryClient.getInstance(Facet.class, sharedFacetUUID); resourceRegistryClient.getInstance(Facet.class, sharedFacetUUID);
throw new Exception(String.format("Shared Facet %s was not deleted", shared)); throw new Exception(String.format(
}catch(FacetNotFoundException e){ "Shared Facet %s was not deleted", shared));
} catch (ResourceRegistryException e) {
logger.debug("Shared Facet was not foud as expected"); logger.debug("Shared Facet was not foud as expected");
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testCreateResourceAndFacet() throws Exception { public void testCreateResourceAndFacet() throws Exception {
HostingNode hostingNode = new HostingNodeImpl(); HostingNode hostingNode = new HostingNodeImpl();
hostingNode = resourceRegistryPublisher.createResource(HostingNode.class, hostingNode); hostingNode = resourceRegistryPublisher.createResource(
HostingNode.class, hostingNode);
CPUFacet cpuFacet = new CPUFacetImpl(); CPUFacet cpuFacet = new CPUFacetImpl();
cpuFacet.setClockSpeed("1 GHz"); cpuFacet.setClockSpeed("1 GHz");
cpuFacet.setModel("Opteron"); cpuFacet.setModel("Opteron");
cpuFacet.setVendor("AMD"); cpuFacet.setVendor("AMD");
CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(CPUFacet.class, cpuFacet); CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(
CPUFacet.class, cpuFacet);
ConsistsOf<HostingNode, Facet> consistsOf = new ConsistsOfImpl<HostingNode, Facet>(hostingNode, createdCpuFacet, null);
consistsOf = resourceRegistryPublisher.createConsistsOf(ConsistsOf.class, consistsOf); ConsistsOf<HostingNode, Facet> consistsOf = new ConsistsOfImpl<HostingNode, Facet>(
hostingNode, createdCpuFacet, null);
consistsOf = resourceRegistryPublisher.createConsistsOf(
ConsistsOf.class, consistsOf);
UUID consistOfUUID = consistsOf.getHeader().getUUID(); UUID consistOfUUID = consistsOf.getHeader().getUUID();
boolean detached = resourceRegistryPublisher.deleteConsistsOf(consistsOf); boolean detached = resourceRegistryPublisher
.deleteConsistsOf(consistsOf);
if (detached) { if (detached) {
logger.trace("{} {} with uuid {} removed successfully", logger.trace("{} {} with uuid {} removed successfully",
@ -314,192 +326,221 @@ public class ERManagementTest extends ScopedTest {
boolean deleted = resourceRegistryPublisher.deleteResource(hostingNode); boolean deleted = resourceRegistryPublisher.deleteResource(hostingNode);
Assert.assertTrue(deleted); Assert.assertTrue(deleted);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void testGetAll() throws Exception{ public void testGetAll() throws Exception {
Map<String, List<Resource>> resources = new HashMap<>(); Map<String, List<Resource>> resources = new HashMap<>();
final int MAX = 5; final int MAX = 5;
int typeNumber = 0; int typeNumber = 0;
for(int i=0; i<MAX; i++){ for (int i = 0; i < MAX; i++) {
Map<String, Resource> map = createHostingNodeAndEService(); Map<String, Resource> map = createHostingNodeAndEService();
if(typeNumber==0){ if (typeNumber == 0) {
typeNumber = map.size(); typeNumber = map.size();
} }
for(String key : map.keySet()){ for (String key : map.keySet()) {
if(!resources.containsKey(key)){ if (!resources.containsKey(key)) {
resources.put(key, new ArrayList<Resource>()); resources.put(key, new ArrayList<Resource>());
} }
resources.get(key).add(map.get(key)); resources.get(key).add(map.get(key));
} }
} }
/* Getting all instances of created specific Resources*/
for(String key : resources.keySet()){
List<Resource> list = (List<Resource>) resourceRegistryClient.getInstances(resources.get(key).get(0).getClass(), false);
logger.debug("{} are {} : {} ", key, list.size(), list);
Assert.assertTrue(list.size()==MAX);
}
/* Getting all Resources polymorphic and non polymorphic */
List<Resource> list = (List<Resource>) resourceRegistryClient.getInstances(Resource.class, true);
logger.debug("{} are {} : {} ", Resource.NAME, list.size(), list);
Assert.assertTrue(list.size()==(MAX*typeNumber));
list = (List<Resource>) resourceRegistryClient.getInstances(Resource.class, false);
Assert.assertTrue(list.size()==0);
/* Getting all IsRelatedTo polymorphic and non polymorphic */
List<Resource> resourcesList = (List<Resource>) resourceRegistryClient.getInstances(IsRelatedTo.class, true);
logger.debug("{} are {} : {} ", IsRelatedTo.NAME, resourcesList.size(), resourcesList);
Assert.assertTrue(resourcesList.size()==MAX);
resourcesList = (List<Resource>) resourceRegistryClient.getInstances(IsRelatedTo.class, false); /* Getting all instances of created specific Resources */
Assert.assertTrue(resourcesList.size()==0); for (String key : resources.keySet()) {
List<Resource> list = (List<Resource>) resourceRegistryClient
.getInstances(key, false);
logger.debug("{} are {} : {} ", key, list.size(), list);
Assert.assertTrue(list.size() == MAX);
}
/* Getting all Resources polymorphic and non polymorphic */
List<Resource> list = (List<Resource>) resourceRegistryClient
.getInstances(Resource.NAME, true);
logger.debug("{} are {} : {} ", Resource.NAME, list.size(), list);
Assert.assertTrue(list.size() == (MAX * typeNumber));
list = (List<Resource>) resourceRegistryClient.getInstances(
Resource.NAME, false);
Assert.assertTrue(list.size() == 0);
/* Getting all IsRelatedTo polymorphic and non polymorphic */
List<Resource> resourcesList = (List<Resource>) resourceRegistryClient
.getInstances(IsRelatedTo.NAME, true);
logger.debug("{} are {} : {} ", IsRelatedTo.NAME, resourcesList.size(),
resourcesList);
Assert.assertTrue(resourcesList.size() == MAX);
resourcesList = (List<Resource>) resourceRegistryClient.getInstances(
IsRelatedTo.NAME, false);
Assert.assertTrue(resourcesList.size() == 0);
/* Getting all ConsistsOf polymorphic and non polymorphic */ /* Getting all ConsistsOf polymorphic and non polymorphic */
List<Resource> consistsOfPolimorphicList = (List<Resource>) resourceRegistryClient.getInstances(ConsistsOf.class, true); List<Resource> consistsOfPolimorphicList = (List<Resource>) resourceRegistryClient
logger.debug("{} are {} : {} ", IsRelatedTo.NAME, consistsOfPolimorphicList.size(), consistsOfPolimorphicList); .getInstances(ConsistsOf.NAME, true);
logger.debug("{} are {} : {} ", IsRelatedTo.NAME,
List<Resource> consistsOfNonPolimorphicList = (List<Resource>) resourceRegistryClient.getInstances(ConsistsOf.class, false); consistsOfPolimorphicList.size(), consistsOfPolimorphicList);
logger.debug("{} are {} : {} ", IsRelatedTo.NAME, consistsOfNonPolimorphicList.size(), consistsOfNonPolimorphicList);
List<Resource> consistsOfNonPolimorphicList = (List<Resource>) resourceRegistryClient
Assert.assertTrue(consistsOfPolimorphicList.size()>=consistsOfNonPolimorphicList.size()); .getInstances(ConsistsOf.NAME, false);
logger.debug("{} are {} : {} ", IsRelatedTo.NAME,
consistsOfNonPolimorphicList.size(),
consistsOfNonPolimorphicList);
Assert.assertTrue(consistsOfPolimorphicList.size() >= consistsOfNonPolimorphicList
.size());
/* Removing created Entity and Relation to have a clean DB */ /* Removing created Entity and Relation to have a clean DB */
List<Resource> resourceList = resources.get(HostingNode.NAME); List<Resource> resourceList = resources.get(HostingNode.NAME);
for(Resource r : resourceList){ for (Resource r : resourceList) {
boolean deleted = resourceRegistryPublisher.deleteResource(r); boolean deleted = resourceRegistryPublisher.deleteResource(r);
Assert.assertTrue(deleted); Assert.assertTrue(deleted);
} }
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testGetAllFrom() throws Exception{ public void testGetAllFrom() throws Exception {
Map<String, Resource> map = createHostingNodeAndEService(); Map<String, Resource> map = createHostingNodeAndEService();
EService eService = (EService) map.get(EService.NAME); EService eService = (EService) map.get(EService.NAME);
UUID eServiceUUID = eService.getHeader().getUUID(); UUID eServiceUUID = eService.getHeader().getUUID();
HostingNode hostingNode = (HostingNode) map.get(HostingNode.NAME); HostingNode hostingNode = (HostingNode) map.get(HostingNode.NAME);
UUID hostingNodeUUID = hostingNode.getHeader().getUUID(); UUID hostingNodeUUID = hostingNode.getHeader().getUUID();
/* EService */ /* EService */
List<Resource> resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, true, eServiceUUID, Direction.both); List<Resource> resourceList = resourceRegistryClient
Assert.assertTrue(resourceList.size()==1); .getInstancesFromEntity(IsRelatedTo.NAME, true, eServiceUUID,
Direction.both);
Assert.assertTrue(resourceList.size() == 1);
Resource sourceResource = resourceList.get(0); Resource sourceResource = resourceList.get(0);
Resource targetResource = sourceResource.getIsRelatedTo().get(0).getTarget(); Resource targetResource = sourceResource.getIsRelatedTo().get(0)
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(hostingNodeUUID)==0); .getTarget();
Assert.assertTrue(targetResource.getHeader().getUUID().compareTo(eServiceUUID)==0); Assert.assertTrue(sourceResource.getHeader().getUUID()
.compareTo(hostingNodeUUID) == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, true, eServiceUUID, Direction.in); Assert.assertTrue(targetResource.getHeader().getUUID()
Assert.assertTrue(resourceList.size()==1); .compareTo(eServiceUUID) == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(
IsRelatedTo.NAME, true, eServiceUUID, Direction.in);
Assert.assertTrue(resourceList.size() == 1);
sourceResource = resourceList.get(0); sourceResource = resourceList.get(0);
targetResource = sourceResource.getIsRelatedTo().get(0).getTarget(); targetResource = sourceResource.getIsRelatedTo().get(0).getTarget();
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(hostingNodeUUID)==0); Assert.assertTrue(sourceResource.getHeader().getUUID()
Assert.assertTrue(targetResource.getHeader().getUUID().compareTo(eServiceUUID)==0); .compareTo(hostingNodeUUID) == 0);
Assert.assertTrue(targetResource.getHeader().getUUID()
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, true, eServiceUUID, Direction.out); .compareTo(eServiceUUID) == 0);
Assert.assertTrue(resourceList.size()==0);
resourceList = resourceRegistryClient.getInstancesFromEntity(
IsRelatedTo.NAME, true, eServiceUUID, Direction.out);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, false, eServiceUUID, Direction.both); Assert.assertTrue(resourceList.size() == 0);
Assert.assertTrue(resourceList.size()==0);
resourceList = resourceRegistryClient.getInstancesFromEntity(
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, false, eServiceUUID, Direction.in); IsRelatedTo.NAME, false, eServiceUUID, Direction.both);
Assert.assertTrue(resourceList.size()==0); Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, false, eServiceUUID, Direction.out); resourceList = resourceRegistryClient.getInstancesFromEntity(
Assert.assertTrue(resourceList.size()==0); IsRelatedTo.NAME, false, eServiceUUID, Direction.in);
Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(
IsRelatedTo.NAME, false, eServiceUUID, Direction.out);
Assert.assertTrue(resourceList.size() == 0);
/* END EService */ /* END EService */
/* Hosting Node */ /* Hosting Node */
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, true, hostingNodeUUID, Direction.both); resourceList = resourceRegistryClient.getInstancesFromEntity(
Assert.assertTrue(resourceList.size()==1); IsRelatedTo.NAME, true, hostingNodeUUID, Direction.both);
Assert.assertTrue(resourceList.size() == 1);
sourceResource = resourceList.get(0); sourceResource = resourceList.get(0);
targetResource = sourceResource.getIsRelatedTo().get(0).getTarget(); targetResource = sourceResource.getIsRelatedTo().get(0).getTarget();
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(hostingNodeUUID)==0); Assert.assertTrue(sourceResource.getHeader().getUUID()
Assert.assertTrue(targetResource.getHeader().getUUID().compareTo(eServiceUUID)==0); .compareTo(hostingNodeUUID) == 0);
Assert.assertTrue(targetResource.getHeader().getUUID()
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, true, hostingNodeUUID, Direction.in); .compareTo(eServiceUUID) == 0);
Assert.assertTrue(resourceList.size()==0);
resourceList = resourceRegistryClient.getInstancesFromEntity(
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, true, hostingNodeUUID, Direction.out); IsRelatedTo.NAME, true, hostingNodeUUID, Direction.in);
Assert.assertTrue(resourceList.size()==1); Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(
IsRelatedTo.NAME, true, hostingNodeUUID, Direction.out);
Assert.assertTrue(resourceList.size() == 1);
sourceResource = resourceList.get(0); sourceResource = resourceList.get(0);
targetResource = sourceResource.getIsRelatedTo().get(0).getTarget(); targetResource = sourceResource.getIsRelatedTo().get(0).getTarget();
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(hostingNodeUUID)==0); Assert.assertTrue(sourceResource.getHeader().getUUID()
Assert.assertTrue(targetResource.getHeader().getUUID().compareTo(eServiceUUID)==0); .compareTo(hostingNodeUUID) == 0);
Assert.assertTrue(targetResource.getHeader().getUUID()
.compareTo(eServiceUUID) == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, false, hostingNodeUUID, Direction.both);
Assert.assertTrue(resourceList.size()==0); resourceList = resourceRegistryClient.getInstancesFromEntity(
IsRelatedTo.NAME, false, hostingNodeUUID, Direction.both);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, false, hostingNodeUUID, Direction.in); Assert.assertTrue(resourceList.size() == 0);
Assert.assertTrue(resourceList.size()==0);
resourceList = resourceRegistryClient.getInstancesFromEntity(
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, false, hostingNodeUUID, Direction.out); IsRelatedTo.NAME, false, hostingNodeUUID, Direction.in);
Assert.assertTrue(resourceList.size()==0); Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(
IsRelatedTo.NAME, false, hostingNodeUUID, Direction.out);
Assert.assertTrue(resourceList.size() == 0);
/* END HostingNode */ /* END HostingNode */
Facet identificationFacet = eService.getIdentificationFacets().get(0); Facet identificationFacet = eService.getIdentificationFacets().get(0);
UUID identificationFacetUUID = identificationFacet.getHeader().getUUID(); UUID identificationFacetUUID = identificationFacet.getHeader()
.getUUID();
/* SoftwareFacet of Eservice */ /* SoftwareFacet of Eservice */
resourceList = resourceRegistryClient.getInstancesFromEntity(ConsistsOf.class, true, identificationFacetUUID, Direction.both); resourceList = resourceRegistryClient.getInstancesFromEntity(
Assert.assertTrue(resourceList.size()==1); ConsistsOf.NAME, true, identificationFacetUUID, Direction.both);
Assert.assertTrue(resourceList.size() == 1);
sourceResource = resourceList.get(0); sourceResource = resourceList.get(0);
Facet targetIdentificationFacet = sourceResource.getIdentificationFacets().get(0); Facet targetIdentificationFacet = sourceResource
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(eServiceUUID)==0); .getIdentificationFacets().get(0);
Assert.assertTrue(targetIdentificationFacet.getHeader().getUUID().compareTo(identificationFacetUUID)==0); Assert.assertTrue(sourceResource.getHeader().getUUID()
.compareTo(eServiceUUID) == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(ConsistsOf.class, true, identificationFacetUUID, Direction.in); Assert.assertTrue(targetIdentificationFacet.getHeader().getUUID()
Assert.assertTrue(resourceList.size()==1); .compareTo(identificationFacetUUID) == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(
ConsistsOf.NAME, true, identificationFacetUUID, Direction.in);
Assert.assertTrue(resourceList.size() == 1);
sourceResource = resourceList.get(0); sourceResource = resourceList.get(0);
targetIdentificationFacet = sourceResource.getIdentificationFacets().get(0); targetIdentificationFacet = sourceResource.getIdentificationFacets()
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(eServiceUUID)==0); .get(0);
Assert.assertTrue(targetIdentificationFacet.getHeader().getUUID().compareTo(identificationFacetUUID)==0); Assert.assertTrue(sourceResource.getHeader().getUUID()
.compareTo(eServiceUUID) == 0);
Assert.assertTrue(targetIdentificationFacet.getHeader().getUUID()
resourceList = resourceRegistryClient.getInstancesFromEntity(ConsistsOf.class, true, identificationFacetUUID, Direction.out); .compareTo(identificationFacetUUID) == 0);
Assert.assertTrue(resourceList.size()==0);
resourceList = resourceRegistryClient.getInstancesFromEntity(
ConsistsOf.NAME, true, identificationFacetUUID, Direction.out);
Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(ConsistsOf.class, false, identificationFacetUUID, Direction.both);
Assert.assertTrue(resourceList.size()==0); resourceList = resourceRegistryClient
.getInstancesFromEntity(ConsistsOf.NAME, false,
resourceRegistryClient.getInstancesFromEntity(ConsistsOf.class, false, identificationFacetUUID, Direction.in); identificationFacetUUID, Direction.both);
Assert.assertTrue(resourceList.size()==0); Assert.assertTrue(resourceList.size() == 0);
resourceRegistryClient.getInstancesFromEntity(ConsistsOf.NAME, false,
resourceRegistryClient.getInstancesFromEntity(ConsistsOf.class, false, identificationFacetUUID, Direction.out); identificationFacetUUID, Direction.in);
Assert.assertTrue(resourceList.size()==0); Assert.assertTrue(resourceList.size() == 0);
resourceRegistryClient.getInstancesFromEntity(ConsistsOf.NAME, false,
identificationFacetUUID, Direction.out);
Assert.assertTrue(resourceList.size() == 0);
/* END SoftwareFacet of Eservice */ /* END SoftwareFacet of Eservice */
/* Removing created Entity and Relation to have a clean DB */ /* Removing created Entity and Relation to have a clean DB */
boolean deleted = resourceRegistryPublisher.deleteResource(hostingNode); boolean deleted = resourceRegistryPublisher.deleteResource(hostingNode);
Assert.assertTrue(deleted); Assert.assertTrue(deleted);
} }
} }