Added test for resource-registry client which need publisher methods to be implements.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@133707 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
82f7255824
commit
82a11f399a
|
@ -106,6 +106,9 @@ public class EntityManagementTest {
|
||||||
Assert.assertTrue(SoftwareFacet.class.isAssignableFrom(f.getClass()));
|
Assert.assertTrue(SoftwareFacet.class.isAssignableFrom(f.getClass()));
|
||||||
SoftwareFacet createdSoftwareFacet = (SoftwareFacet) f;
|
SoftwareFacet createdSoftwareFacet = (SoftwareFacet) f;
|
||||||
logger.debug("Created : {}", softwareFacet);
|
logger.debug("Created : {}", softwareFacet);
|
||||||
|
Assert.assertTrue(createdSoftwareFacet.getGroup().compareTo(softwareFacet.getGroup())==0);
|
||||||
|
Assert.assertTrue(createdSoftwareFacet.getName().compareTo(softwareFacet.getName())==0);
|
||||||
|
Assert.assertTrue(createdSoftwareFacet.getVersion().compareTo(softwareFacet.getVersion())==0);
|
||||||
|
|
||||||
|
|
||||||
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
|
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
|
||||||
|
|
|
@ -3,14 +3,23 @@
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
import org.gcube.informationsystem.impl.entity.facet.CPUFacetImpl;
|
import org.gcube.informationsystem.impl.entity.facet.CPUFacetImpl;
|
||||||
|
import org.gcube.informationsystem.impl.entity.facet.SoftwareFacetImpl;
|
||||||
|
import org.gcube.informationsystem.impl.entity.resource.EServiceImpl;
|
||||||
|
import org.gcube.informationsystem.impl.relation.IsIdentifiedByImpl;
|
||||||
import org.gcube.informationsystem.model.entity.Facet;
|
import org.gcube.informationsystem.model.entity.Facet;
|
||||||
|
import org.gcube.informationsystem.model.entity.Resource;
|
||||||
import org.gcube.informationsystem.model.entity.facet.CPUFacet;
|
import org.gcube.informationsystem.model.entity.facet.CPUFacet;
|
||||||
|
import org.gcube.informationsystem.model.entity.facet.SoftwareFacet;
|
||||||
|
import org.gcube.informationsystem.model.entity.resource.EService;
|
||||||
|
import org.gcube.informationsystem.model.relation.IsIdentifiedBy;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.FacetNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.FacetNotFoundException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.ResourceNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClient;
|
import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClient;
|
||||||
import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClientFactory;
|
import org.gcube.informationsystem.resourceregistry.client.proxy.ResourceRegistryClientFactory;
|
||||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
||||||
|
@ -70,5 +79,50 @@ public class RRClientTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetResource() throws ResourceNotFoundException, ResourceRegistryException{
|
||||||
|
EService eService = new EServiceImpl();
|
||||||
|
|
||||||
|
SoftwareFacet softwareFacet = new SoftwareFacetImpl();
|
||||||
|
softwareFacet.setGroup("InformationSystem");
|
||||||
|
softwareFacet.setName("resource-registry");
|
||||||
|
softwareFacet.setVersion("1.1.0");
|
||||||
|
|
||||||
|
IsIdentifiedBy<EService, SoftwareFacet> isIdentifiedByESSF = new IsIdentifiedByImpl<>(eService, softwareFacet, null);
|
||||||
|
eService.addFacet(isIdentifiedByESSF);
|
||||||
|
|
||||||
|
EService createdEService = resourceRegistryPublisher.createResource(EService.class, eService);
|
||||||
|
|
||||||
|
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(f instanceof SoftwareFacet);
|
||||||
|
SoftwareFacet createdSoftwareFacet = (SoftwareFacet) f;
|
||||||
|
Assert.assertTrue(createdSoftwareFacet.getGroup().compareTo(softwareFacet.getGroup())==0);
|
||||||
|
Assert.assertTrue(createdSoftwareFacet.getName().compareTo(softwareFacet.getName())==0);
|
||||||
|
Assert.assertTrue(createdSoftwareFacet.getVersion().compareTo(softwareFacet.getVersion())==0);
|
||||||
|
|
||||||
|
|
||||||
|
Resource resource = resourceRegistryClient.getResource(createdEService.getHeader().getUUID());
|
||||||
|
Assert.assertTrue(resource.getHeader().getUUID().compareTo(createdEService.getHeader().getUUID())==0);
|
||||||
|
Assert.assertTrue(resource instanceof EService);
|
||||||
|
|
||||||
|
EService readEService = resourceRegistryClient.getResource(EService.class, createdEService.getHeader().getUUID());
|
||||||
|
Assert.assertTrue(readEService.getHeader().getUUID().compareTo(createdEService.getHeader().getUUID())==0);
|
||||||
|
List<? extends Facet> idFacets = readEService.getIdentificationFacets();
|
||||||
|
Assert.assertTrue(idFacets!=null);
|
||||||
|
Assert.assertTrue(idFacets.size()==1);
|
||||||
|
f = idFacets.get(0);
|
||||||
|
Assert.assertTrue(f!=null);
|
||||||
|
Assert.assertTrue(f instanceof SoftwareFacet);
|
||||||
|
SoftwareFacet readSoftwareFacet = (SoftwareFacet) f;
|
||||||
|
Assert.assertTrue(readSoftwareFacet.getGroup().compareTo(softwareFacet.getGroup())==0);
|
||||||
|
Assert.assertTrue(readSoftwareFacet.getName().compareTo(softwareFacet.getName())==0);
|
||||||
|
Assert.assertTrue(readSoftwareFacet.getVersion().compareTo(softwareFacet.getVersion())==0);
|
||||||
|
Assert.assertTrue(readSoftwareFacet.getHeader().getUUID().compareTo(createdSoftwareFacet.getHeader().getUUID())==0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue