Adding test
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@133705 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a746eb869b
commit
82f7255824
|
@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue