From 82f7255824976d44b2895b8884d66dbdcd9a13a9 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 28 Oct 2016 10:26:45 +0000 Subject: [PATCH] Adding test git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@133705 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../publisher/RRClientTest.java | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/test/java/org/gcube/informationsystem/resourceregistry/publisher/RRClientTest.java diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/publisher/RRClientTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/publisher/RRClientTest.java new file mode 100644 index 0000000..f447867 --- /dev/null +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/publisher/RRClientTest.java @@ -0,0 +1,74 @@ +/** + * + */ +package org.gcube.informationsystem.resourceregistry.publisher; + +import java.util.UUID; + +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.informationsystem.impl.entity.facet.CPUFacetImpl; +import org.gcube.informationsystem.model.entity.Facet; +import org.gcube.informationsystem.model.entity.facet.CPUFacet; +import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; +import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.FacetNotFoundException; +import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClient; +import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClientFactory; +import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher; +import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisherFactory; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Luca Frosini (ISTI - CNR) + * + */ +public class RRClientTest { + + private static final Logger logger = LoggerFactory.getLogger(EntityManagementTest.class); + + protected ResourceRegistryPublisher resourceRegistryPublisher; + protected ResourceRegistryClient resourceRegistryClient; + + @Before + public void before(){ + ScopeProvider.instance.set("/gcube/devNext/NextNext"); + resourceRegistryPublisher = ResourceRegistryPublisherFactory.create(); + resourceRegistryClient = ResourceRegistryClientFactory.create(); + } + + @Test + public void testGetFacet() throws FacetNotFoundException, ResourceRegistryException{ + CPUFacet cpuFacet = new CPUFacetImpl(); + cpuFacet.setClockSpeed("1 GHz"); + cpuFacet.setModel("Opteron"); + cpuFacet.setVendor("AMD"); + + CPUFacet createdCpuFacet = resourceRegistryPublisher.createFacet(CPUFacet.class, cpuFacet); + + Assert.assertTrue(cpuFacet.getClockSpeed().compareTo(createdCpuFacet.getClockSpeed())==0); + Assert.assertTrue(cpuFacet.getModel().compareTo(createdCpuFacet.getModel())==0); + Assert.assertTrue(cpuFacet.getVendor().compareTo(createdCpuFacet.getVendor())==0); + + UUID uuid = createdCpuFacet.getHeader().getUUID(); + + Facet f = resourceRegistryClient.getFacet(uuid); + Assert.assertTrue(f instanceof CPUFacet); + + CPUFacet readCpuFacet = (CPUFacet) f; + Assert.assertTrue(readCpuFacet.getClockSpeed().compareTo(createdCpuFacet.getClockSpeed())==0); + Assert.assertTrue(readCpuFacet.getModel().compareTo(createdCpuFacet.getModel())==0); + Assert.assertTrue(readCpuFacet.getVendor().compareTo(createdCpuFacet.getVendor())==0); + + + readCpuFacet = resourceRegistryClient.getFacet(CPUFacet.class, uuid); + Assert.assertTrue(readCpuFacet.getClockSpeed().compareTo(createdCpuFacet.getClockSpeed())==0); + Assert.assertTrue(readCpuFacet.getModel().compareTo(createdCpuFacet.getModel())==0); + Assert.assertTrue(readCpuFacet.getVendor().compareTo(createdCpuFacet.getVendor())==0); + + } + + +}