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;
|
package org.gcube.informationsystem.resourceregistry.publisher;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
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.facet.SoftwareFacet;
|
||||||
import org.gcube.informationsystem.model.entity.resource.EService;
|
import org.gcube.informationsystem.model.entity.resource.EService;
|
||||||
import org.gcube.informationsystem.model.entity.resource.HostingNode;
|
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.IsIdentifiedBy;
|
||||||
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
|
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
|
||||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
||||||
|
@ -101,18 +103,21 @@ public class ResourceRegistryPublisherTest {
|
||||||
IsIdentifiedBy<EService, SoftwareFacet> isIdentifiedByESSF = new IsIdentifiedByImpl<>(eService, softwareFacet, null);
|
IsIdentifiedBy<EService, SoftwareFacet> isIdentifiedByESSF = new IsIdentifiedByImpl<>(eService, softwareFacet, null);
|
||||||
eService.addFacet(isIdentifiedByESSF);
|
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);
|
logger.debug("Going to create : {}", eService);
|
||||||
EService createdEService = resourceRegistryPublisher.createResource(EService.class, eService);
|
EService createdEService = resourceRegistryPublisher.createResource(EService.class, eService);
|
||||||
logger.debug("Created : {}", createdEService);
|
logger.debug("Created : {}", createdEService);
|
||||||
|
List<? extends Facet> idenficationFacets = createdEService.getIdentificationFacets();
|
||||||
SoftwareFacet createdSoftwareFacet = (SoftwareFacet) createdEService.getIdentificationFacets().get(0);
|
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);
|
logger.debug("Created : {}", softwareFacet);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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");
|
||||||
|
@ -120,7 +125,6 @@ public class ResourceRegistryPublisherTest {
|
||||||
networkingFacet.setMask("255.255.248.0");
|
networkingFacet.setMask("255.255.248.0");
|
||||||
networkingFacet.setBroadcastAddress("146.48.87.255");
|
networkingFacet.setBroadcastAddress("146.48.87.255");
|
||||||
|
|
||||||
|
|
||||||
logger.debug("Going to create : {}", networkingFacet);
|
logger.debug("Going to create : {}", networkingFacet);
|
||||||
NetworkingFacet createdNetworkingFacet = resourceRegistryPublisher.createFacet(NetworkingFacet.class, networkingFacet);
|
NetworkingFacet createdNetworkingFacet = resourceRegistryPublisher.createFacet(NetworkingFacet.class, networkingFacet);
|
||||||
logger.debug("Created : {}", createdNetworkingFacet);
|
logger.debug("Created : {}", createdNetworkingFacet);
|
||||||
|
@ -138,20 +142,24 @@ public class ResourceRegistryPublisherTest {
|
||||||
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedByHNNF = new IsIdentifiedByImpl<>(hostingNode, createdNetworkingFacet, null);
|
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedByHNNF = new IsIdentifiedByImpl<>(hostingNode, createdNetworkingFacet, null);
|
||||||
hostingNode.attachFacet(isIdentifiedByHNNF);
|
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);
|
hostingNode.attachResource(hosts);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Entities.registerSubtypes(HostingNode.class, CPUFacet.class);
|
|
||||||
|
|
||||||
logger.debug("Going to create : {}", hostingNode);
|
logger.debug("Going to create : {}", hostingNode);
|
||||||
HostingNode createdHostingNode = resourceRegistryPublisher.createResource(HostingNode.class, hostingNode);
|
HostingNode createdHostingNode = resourceRegistryPublisher.createResource(HostingNode.class, hostingNode);
|
||||||
logger.debug("Created : {}", createdHostingNode);
|
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);
|
logger.debug("Created : {}", createdCPUFacet);
|
||||||
|
|
||||||
|
|
||||||
|
@ -191,6 +199,9 @@ public class ResourceRegistryPublisherTest {
|
||||||
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.addFacet(isIdentifiedBy);
|
||||||
|
|
||||||
|
Entities.registerSubtypes(IsIdentifiedBy.class, SoftwareFacet.class, EService.class);
|
||||||
|
|
||||||
|
|
||||||
logger.debug("Going to create : {}", eService);
|
logger.debug("Going to create : {}", eService);
|
||||||
EService createdEService = resourceRegistryPublisher.createResource(EService.class, eService);
|
EService createdEService = resourceRegistryPublisher.createResource(EService.class, eService);
|
||||||
logger.debug("Created : {}", createdEService);
|
logger.debug("Created : {}", createdEService);
|
||||||
|
@ -208,6 +219,10 @@ public class ResourceRegistryPublisherTest {
|
||||||
cpuFacet.setModel("Opteron");
|
cpuFacet.setModel("Opteron");
|
||||||
cpuFacet.setVendor("AMD");
|
cpuFacet.setVendor("AMD");
|
||||||
|
|
||||||
|
|
||||||
|
Entities.registerSubtypes(HostingNode.class, CPUFacet.class);
|
||||||
|
|
||||||
|
|
||||||
logger.debug("Going to create: {}", cpuFacet);
|
logger.debug("Going to create: {}", cpuFacet);
|
||||||
CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(CPUFacet.class, cpuFacet);
|
CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(CPUFacet.class, cpuFacet);
|
||||||
logger.debug("Created: {}", createdCpuFacet);
|
logger.debug("Created: {}", createdCpuFacet);
|
||||||
|
@ -219,7 +234,6 @@ public class ResourceRegistryPublisherTest {
|
||||||
IsIdentifiedBy<HostingNode, CPUFacet> createdIsIdentifiedByCPUFacet = resourceRegistryPublisher.createConsistsOf(IsIdentifiedBy.class, isIdentifiedByCPUFacet);
|
IsIdentifiedBy<HostingNode, CPUFacet> createdIsIdentifiedByCPUFacet = resourceRegistryPublisher.createConsistsOf(IsIdentifiedBy.class, isIdentifiedByCPUFacet);
|
||||||
logger.debug("Created : {}", createdIsIdentifiedByCPUFacet);
|
logger.debug("Created : {}", createdIsIdentifiedByCPUFacet);
|
||||||
|
|
||||||
|
|
||||||
Hosts<HostingNode, EService> hosts = new HostsImpl<>(createdHostingNode, createdEService, null);
|
Hosts<HostingNode, EService> hosts = new HostsImpl<>(createdHostingNode, createdEService, null);
|
||||||
logger.debug("Going to create : {}", hosts);
|
logger.debug("Going to create : {}", hosts);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|
Loading…
Reference in New Issue