implementing Publisher
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@131478 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
54f731c69a
commit
329ad8f6eb
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package org.gcube.informationsystem.resourceregistry.publisher;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
@ -21,6 +22,7 @@ import org.gcube.informationsystem.model.entity.facet.NetworkingFacet;
|
|||
import org.gcube.informationsystem.model.entity.facet.SoftwareFacet;
|
||||
import org.gcube.informationsystem.model.entity.resource.EService;
|
||||
import org.gcube.informationsystem.model.entity.resource.HostingNode;
|
||||
import org.gcube.informationsystem.model.relation.ConsistsOf;
|
||||
import org.gcube.informationsystem.model.relation.IsIdentifiedBy;
|
||||
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
|
||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
||||
|
@ -101,18 +103,21 @@ public class ResourceRegistryPublisherTest {
|
|||
IsIdentifiedBy<EService, SoftwareFacet> isIdentifiedByESSF = new IsIdentifiedByImpl<>(eService, softwareFacet, null);
|
||||
eService.addFacet(isIdentifiedByESSF);
|
||||
|
||||
Entities.registerSubtypes(IsIdentifiedBy.class, SoftwareFacet.class, EService.class);
|
||||
Entities.registerSubtypes(IsIdentifiedBy.class, SoftwareFacet.class, EService.class, HostingNode.class, NetworkingFacet.class, CPUFacet.class);
|
||||
|
||||
logger.debug("Going to create : {}", eService);
|
||||
EService createdEService = resourceRegistryPublisher.createResource(EService.class, eService);
|
||||
logger.debug("Created : {}", createdEService);
|
||||
|
||||
SoftwareFacet createdSoftwareFacet = (SoftwareFacet) createdEService.getIdentificationFacets().get(0);
|
||||
List<? extends Facet> idenficationFacets = createdEService.getIdentificationFacets();
|
||||
Assert.assertTrue(idenficationFacets!=null);
|
||||
Assert.assertTrue(idenficationFacets.size()==1);
|
||||
Facet f = idenficationFacets.get(0);
|
||||
Assert.assertTrue(f!=null);
|
||||
Assert.assertTrue(SoftwareFacet.class.isAssignableFrom(f.getClass()));
|
||||
SoftwareFacet createdSoftwareFacet = (SoftwareFacet) f;
|
||||
logger.debug("Created : {}", softwareFacet);
|
||||
|
||||
|
||||
|
||||
|
||||
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
|
||||
networkingFacet.setIPAddress("146.48.87.183");
|
||||
networkingFacet.setHostName("pc-frosini.isti.cnr.it");
|
||||
|
@ -120,7 +125,6 @@ public class ResourceRegistryPublisherTest {
|
|||
networkingFacet.setMask("255.255.248.0");
|
||||
networkingFacet.setBroadcastAddress("146.48.87.255");
|
||||
|
||||
|
||||
logger.debug("Going to create : {}", networkingFacet);
|
||||
NetworkingFacet createdNetworkingFacet = resourceRegistryPublisher.createFacet(NetworkingFacet.class, networkingFacet);
|
||||
logger.debug("Created : {}", createdNetworkingFacet);
|
||||
|
@ -138,20 +142,24 @@ public class ResourceRegistryPublisherTest {
|
|||
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedByHNNF = new IsIdentifiedByImpl<>(hostingNode, createdNetworkingFacet, null);
|
||||
hostingNode.attachFacet(isIdentifiedByHNNF);
|
||||
|
||||
Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>(hostingNode, eService, null);
|
||||
Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>(hostingNode, createdEService, null);
|
||||
|
||||
hostingNode.attachResource(hosts);
|
||||
|
||||
|
||||
|
||||
Entities.registerSubtypes(HostingNode.class, CPUFacet.class);
|
||||
|
||||
logger.debug("Going to create : {}", hostingNode);
|
||||
HostingNode createdHostingNode = resourceRegistryPublisher.createResource(HostingNode.class, hostingNode);
|
||||
logger.debug("Created : {}", createdHostingNode);
|
||||
|
||||
List<ConsistsOf<? extends Resource, ? extends Facet>> consistsOfList = createdHostingNode.getConsistsOf();
|
||||
CPUFacet createdCPUFacet = null;
|
||||
for(ConsistsOf<? extends Resource, ? extends Facet> consistsOf : consistsOfList){
|
||||
if (CPUFacet.class.isAssignableFrom(consistsOf.getTarget().getClass())) {
|
||||
createdCPUFacet = (CPUFacet) consistsOf.getTarget();
|
||||
}
|
||||
|
||||
CPUFacet createdCPUFacet = (CPUFacet) createdHostingNode.getIdentificationFacets().get(0);
|
||||
}
|
||||
Assert.assertTrue(createdCPUFacet!=null);
|
||||
logger.debug("Created : {}", createdCPUFacet);
|
||||
|
||||
|
||||
|
@ -191,6 +199,9 @@ public class ResourceRegistryPublisherTest {
|
|||
IsIdentifiedBy<Resource, Facet> isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(eService, softwareFacet, null);
|
||||
eService.addFacet(isIdentifiedBy);
|
||||
|
||||
Entities.registerSubtypes(IsIdentifiedBy.class, SoftwareFacet.class, EService.class);
|
||||
|
||||
|
||||
logger.debug("Going to create : {}", eService);
|
||||
EService createdEService = resourceRegistryPublisher.createResource(EService.class, eService);
|
||||
logger.debug("Created : {}", createdEService);
|
||||
|
@ -208,6 +219,10 @@ public class ResourceRegistryPublisherTest {
|
|||
cpuFacet.setModel("Opteron");
|
||||
cpuFacet.setVendor("AMD");
|
||||
|
||||
|
||||
Entities.registerSubtypes(HostingNode.class, CPUFacet.class);
|
||||
|
||||
|
||||
logger.debug("Going to create: {}", cpuFacet);
|
||||
CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(CPUFacet.class, cpuFacet);
|
||||
logger.debug("Created: {}", createdCpuFacet);
|
||||
|
@ -219,7 +234,6 @@ public class ResourceRegistryPublisherTest {
|
|||
IsIdentifiedBy<HostingNode, CPUFacet> createdIsIdentifiedByCPUFacet = resourceRegistryPublisher.createConsistsOf(IsIdentifiedBy.class, isIdentifiedByCPUFacet);
|
||||
logger.debug("Created : {}", createdIsIdentifiedByCPUFacet);
|
||||
|
||||
|
||||
Hosts<HostingNode, EService> hosts = new HostsImpl<>(createdHostingNode, createdEService, null);
|
||||
logger.debug("Going to create : {}", hosts);
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
Loading…
Reference in New Issue