Refs #11903: Use new REST interface in Resource Registry Publisher

Task-Url: https://support.d4science.org/issues/11903

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@169036 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2018-06-12 08:02:31 +00:00
parent 6e984b7acb
commit f57e55f9a4
1 changed files with 214 additions and 220 deletions

View File

@ -77,8 +77,8 @@ public class ERManagementTest extends ScopedTest {
softwareFacet.setGroup("InformationSystem");
softwareFacet.setName("resource-registry");
softwareFacet.setVersion("1.1.0");
IsIdentifiedBy<EService, Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService, Facet>(eService,
softwareFacet, null);
IsIdentifiedBy<EService,Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService,Facet>(eService, softwareFacet,
null);
eService.addFacet(isIdentifiedBy);
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
@ -115,8 +115,8 @@ public class ERManagementTest extends ScopedTest {
softwareFacet.setGroup("InformationSystem");
softwareFacet.setName("resource-registry");
softwareFacet.setVersion("1.1.0");
IsIdentifiedBy<EService, Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService, Facet>(eService,
softwareFacet, null);
IsIdentifiedBy<EService,Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService,Facet>(eService, softwareFacet,
null);
eService.addFacet(isIdentifiedBy);
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
@ -159,8 +159,8 @@ public class ERManagementTest extends ScopedTest {
softwareFacet.setGroup("InformationSystem");
softwareFacet.setName("resource-registry");
softwareFacet.setVersion("1.1.0");
IsIdentifiedBy<EService, Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService, Facet>(eService,
softwareFacet, null);
IsIdentifiedBy<EService,Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService,Facet>(eService, softwareFacet,
null);
eService.addFacet(isIdentifiedBy);
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
@ -201,8 +201,8 @@ public class ERManagementTest extends ScopedTest {
softwareFacet.setGroup("InformationSystem");
softwareFacet.setName("resource-registry");
softwareFacet.setVersion("1.1.0");
IsIdentifiedBy<EService, Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService, Facet>(eService,
softwareFacet, null);
IsIdentifiedBy<EService,Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService,Facet>(eService, softwareFacet,
null);
eService.addFacet(isIdentifiedBy);
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
@ -299,8 +299,8 @@ public class ERManagementTest extends ScopedTest {
softwareFacet.setName("resource-registry");
softwareFacet.setVersion("1.1.0");
IsIdentifiedBy<Resource, Facet> isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(eService,
softwareFacet, null);
IsIdentifiedBy<Resource,Facet> isIdentifiedBy = new IsIdentifiedByImpl<Resource,Facet>(eService, softwareFacet,
null);
eService.addFacet(isIdentifiedBy);
eService = resourceRegistryPublisher.createResource(eService);
@ -491,108 +491,102 @@ public class ERManagementTest extends ScopedTest {
UUID hostingNodeUUID = hostingNode.getHeader().getUUID();
/* EService */
List<Resource> resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, true,
eServiceUUID, Direction.both);
List<Resource> resourceList = resourceRegistryClient.getRelatedResourcesFromReferenceResource(Resource.class,
IsRelatedTo.class, EService.class, eServiceUUID, Direction.both, true);
Assert.assertTrue(resourceList.size() == 1);
Resource sourceResource = resourceList.get(0);
Resource targetResource = sourceResource.getIsRelatedTo().get(0).getTarget();
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(hostingNodeUUID) == 0);
Assert.assertTrue(targetResource.getHeader().getUUID().compareTo(eServiceUUID) == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, true, eServiceUUID,
Direction.in);
resourceList = resourceRegistryClient.getRelatedResourcesFromReferenceResource(Resource.class,
IsRelatedTo.class, EService.class, eServiceUUID, Direction.out, true);
Assert.assertTrue(resourceList.size() == 1);
sourceResource = resourceList.get(0);
targetResource = sourceResource.getIsRelatedTo().get(0).getTarget();
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(hostingNodeUUID) == 0);
Assert.assertTrue(targetResource.getHeader().getUUID().compareTo(eServiceUUID) == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, true, eServiceUUID,
Direction.out);
resourceList = resourceRegistryClient.getRelatedResourcesFromReferenceResource(Resource.class,
IsRelatedTo.class, EService.class, eServiceUUID, Direction.in, true);
Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, false, eServiceUUID,
Direction.both);
resourceList = resourceRegistryClient.getRelatedResourcesFromReferenceResource(Resource.class,
IsRelatedTo.class, EService.class, eServiceUUID, Direction.both, false);
Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, false, eServiceUUID,
Direction.in);
resourceList = resourceRegistryClient.getRelatedResourcesFromReferenceResource(Resource.class,
IsRelatedTo.class, EService.class, eServiceUUID, Direction.out, false);
Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, false, eServiceUUID,
Direction.out);
resourceList = resourceRegistryClient.getRelatedResourcesFromReferenceResource(Resource.class,
IsRelatedTo.class, EService.class, eServiceUUID, Direction.in, false);
Assert.assertTrue(resourceList.size() == 0);
/* END EService */
/* Hosting Node */
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, true, hostingNodeUUID,
Direction.both);
resourceList = resourceRegistryClient.getRelatedResourcesFromReferenceResource(Resource.class,
IsRelatedTo.class, HostingNode.class, hostingNodeUUID, Direction.both, true);
Assert.assertTrue(resourceList.size() == 1);
sourceResource = resourceList.get(0);
targetResource = sourceResource.getIsRelatedTo().get(0).getTarget();
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(hostingNodeUUID) == 0);
Assert.assertTrue(targetResource.getHeader().getUUID().compareTo(eServiceUUID) == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, true, hostingNodeUUID,
Direction.in);
resourceList = resourceRegistryClient.getRelatedResourcesFromReferenceResource(Resource.class,
IsRelatedTo.class, HostingNode.class, hostingNodeUUID, Direction.out, true);
Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, true, hostingNodeUUID,
Direction.out);
resourceList = resourceRegistryClient.getRelatedResourcesFromReferenceResource(Resource.class,
IsRelatedTo.class, HostingNode.class, hostingNodeUUID, Direction.in, true);
Assert.assertTrue(resourceList.size() == 1);
sourceResource = resourceList.get(0);
targetResource = sourceResource.getIsRelatedTo().get(0).getTarget();
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(hostingNodeUUID) == 0);
Assert.assertTrue(targetResource.getHeader().getUUID().compareTo(eServiceUUID) == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, false, hostingNodeUUID,
Direction.both);
resourceList = resourceRegistryClient.getRelatedResourcesFromReferenceResource(Resource.class,
IsRelatedTo.class, HostingNode.class, hostingNodeUUID, Direction.both, false);
Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, false, hostingNodeUUID,
Direction.in);
resourceList = resourceRegistryClient.getRelatedResourcesFromReferenceResource(Resource.class,
IsRelatedTo.class, HostingNode.class, hostingNodeUUID, Direction.out, false);
Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(IsRelatedTo.class, false, hostingNodeUUID,
Direction.out);
resourceList = resourceRegistryClient.getRelatedResourcesFromReferenceResource(Resource.class,
IsRelatedTo.class, HostingNode.class, hostingNodeUUID, Direction.in, false);
Assert.assertTrue(resourceList.size() == 0);
/* END HostingNode */
Facet identificationFacet = eService.getIdentificationFacets().get(0);
UUID identificationFacetUUID = identificationFacet.getHeader().getUUID();
/* SoftwareFacet of Eservice */
resourceList = resourceRegistryClient.getInstancesFromEntity(ConsistsOf.class, true, identificationFacetUUID,
Direction.both);
/* Eservice with Software Facet as Identification Facet */
resourceList = resourceRegistryClient.getResourcesFromReferenceFacet(Resource.class, ConsistsOf.class, SoftwareFacet.class, identificationFacetUUID, true);
Assert.assertTrue(resourceList.size() == 1);
sourceResource = resourceList.get(0);
Facet targetIdentificationFacet = sourceResource.getIdentificationFacets().get(0);
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(eServiceUUID) == 0);
Assert.assertTrue(targetIdentificationFacet.getHeader().getUUID().compareTo(identificationFacetUUID) == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(ConsistsOf.class, true, identificationFacetUUID,
Direction.in);
resourceList = resourceRegistryClient.getResourcesFromReferenceFacet(Resource.class, ConsistsOf.class, SoftwareFacet.class, identificationFacetUUID, false);
Assert.assertTrue(resourceList.size() == 0);
/* END Eservice with Software Facet as Identification Facet */
/* END SoftwareFacet of Eservice */
List<Facet> facets = resourceRegistryClient.getRelated(Facet.class, ConsistsOf.class, EService.class, eServiceUUID, Direction.in, true);
Assert.assertTrue(resourceList.size() == 1);
sourceResource = resourceList.get(0);
targetIdentificationFacet = sourceResource.getIdentificationFacets().get(0);
Assert.assertTrue(sourceResource.getHeader().getUUID().compareTo(eServiceUUID) == 0);
Assert.assertTrue(targetIdentificationFacet.getHeader().getUUID().compareTo(identificationFacetUUID) == 0);
Facet facet = facets.get(0);
Assert.assertTrue(facet.getHeader().getUUID().compareTo(identificationFacetUUID) == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(ConsistsOf.class, true, identificationFacetUUID,
Direction.out);
facets = resourceRegistryClient.getRelated(Facet.class, ConsistsOf.class, EService.class, eServiceUUID, Direction.in, false);
Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(ConsistsOf.class, false, identificationFacetUUID,
Direction.both);
Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(ConsistsOf.class, false, identificationFacetUUID,
Direction.in);
Assert.assertTrue(resourceList.size() == 0);
resourceList = resourceRegistryClient.getInstancesFromEntity(ConsistsOf.class, false, identificationFacetUUID,
Direction.out);
Assert.assertTrue(resourceList.size() == 0);
/* END SoftwareFacet of Eservice */
/* Removing created Entity and Relation to have a clean DB */
@ -633,8 +627,8 @@ public class ERManagementTest extends ScopedTest {
softwareFacet.setName("resource-registry");
softwareFacet.setVersion("1.1.0");
IsIdentifiedBy<Resource, Facet> isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(eService,
softwareFacet, null);
IsIdentifiedBy<Resource,Facet> isIdentifiedBy = new IsIdentifiedByImpl<Resource,Facet>(eService, softwareFacet,
null);
eService.addFacet(isIdentifiedBy);
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();