Aligned client with new REST interface

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@141529 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-01-12 15:37:46 +00:00
parent f30ace606b
commit 828d893388
4 changed files with 15 additions and 10 deletions

View File

@ -12,6 +12,7 @@ import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
import javax.xml.ws.EndpointReference; import javax.xml.ws.EndpointReference;
@ -115,7 +116,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
protected final String body; protected final String body;
protected String getParametersDataString( protected String getParametersDataString(
List<Map.Entry<String, String>> parameters) List<Entry<String, String>> parameters)
throws UnsupportedEncodingException { throws UnsupportedEncodingException {
if (parameters == null) { if (parameters == null) {
return null; return null;
@ -123,7 +124,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
boolean first = true; boolean first = true;
for (Map.Entry<String, String> entry : parameters) { for (Entry<String, String> entry : parameters) {
if (first) { if (first) {
first = false; first = false;
} else { } else {

View File

@ -153,7 +153,7 @@ public class MultiContextTest extends ScopedTest {
UUID eServiceUUID = createEService.getHeader().getUUID(); UUID eServiceUUID = createEService.getHeader().getUUID();
try { try {
resourceRegistryClient.getResource(eServiceUUID); resourceRegistryClient.getInstance(EService.class, eServiceUUID);
}catch(ResourceRegistryException e){ }catch(ResourceRegistryException e){
logger.debug("Resource with {} Not Found as Expected", uuid.toString()); logger.debug("Resource with {} Not Found as Expected", uuid.toString());
} }

View File

@ -62,7 +62,7 @@ public class RRClientTest extends ScopedTest {
UUID uuid = createdCpuFacet.getHeader().getUUID(); UUID uuid = createdCpuFacet.getHeader().getUUID();
Facet f = resourceRegistryClient.getFacet(uuid); Facet f = resourceRegistryClient.getInstance(Facet.class, uuid);
Assert.assertTrue(f instanceof CPUFacet); Assert.assertTrue(f instanceof CPUFacet);
CPUFacet readCpuFacet = (CPUFacet) f; CPUFacet readCpuFacet = (CPUFacet) f;
@ -71,11 +71,14 @@ public class RRClientTest extends ScopedTest {
Assert.assertTrue(readCpuFacet.getVendor().compareTo(createdCpuFacet.getVendor())==0); Assert.assertTrue(readCpuFacet.getVendor().compareTo(createdCpuFacet.getVendor())==0);
readCpuFacet = resourceRegistryClient.getFacet(CPUFacet.class, uuid); readCpuFacet = resourceRegistryClient.getInstance(CPUFacet.class, uuid);
Assert.assertTrue(readCpuFacet.getClockSpeed().compareTo(createdCpuFacet.getClockSpeed())==0); Assert.assertTrue(readCpuFacet.getClockSpeed().compareTo(createdCpuFacet.getClockSpeed())==0);
Assert.assertTrue(readCpuFacet.getModel().compareTo(createdCpuFacet.getModel())==0); Assert.assertTrue(readCpuFacet.getModel().compareTo(createdCpuFacet.getModel())==0);
Assert.assertTrue(readCpuFacet.getVendor().compareTo(createdCpuFacet.getVendor())==0); Assert.assertTrue(readCpuFacet.getVendor().compareTo(createdCpuFacet.getVendor())==0);
boolean deleted = resourceRegistryPublisher.deleteFacet(createdCpuFacet);
Assert.assertTrue(deleted);
} }
@Test @Test
@ -104,11 +107,11 @@ public class RRClientTest extends ScopedTest {
Assert.assertTrue(createdSoftwareFacet.getVersion().compareTo(softwareFacet.getVersion())==0); Assert.assertTrue(createdSoftwareFacet.getVersion().compareTo(softwareFacet.getVersion())==0);
Resource resource = resourceRegistryClient.getResource(createdEService.getHeader().getUUID()); Resource resource = resourceRegistryClient.getInstance(Resource.class, createdEService.getHeader().getUUID());
Assert.assertTrue(resource.getHeader().getUUID().compareTo(createdEService.getHeader().getUUID())==0); Assert.assertTrue(resource.getHeader().getUUID().compareTo(createdEService.getHeader().getUUID())==0);
Assert.assertTrue(resource instanceof EService); Assert.assertTrue(resource instanceof EService);
EService readEService = resourceRegistryClient.getResource(EService.class, createdEService.getHeader().getUUID()); EService readEService = resourceRegistryClient.getInstance(EService.class, createdEService.getHeader().getUUID());
Assert.assertTrue(readEService.getHeader().getUUID().compareTo(createdEService.getHeader().getUUID())==0); Assert.assertTrue(readEService.getHeader().getUUID().compareTo(createdEService.getHeader().getUUID())==0);
List<? extends Facet> idFacets = readEService.getIdentificationFacets(); List<? extends Facet> idFacets = readEService.getIdentificationFacets();
Assert.assertTrue(idFacets!=null); Assert.assertTrue(idFacets!=null);
@ -122,6 +125,10 @@ public class RRClientTest extends ScopedTest {
Assert.assertTrue(readSoftwareFacet.getVersion().compareTo(softwareFacet.getVersion())==0); Assert.assertTrue(readSoftwareFacet.getVersion().compareTo(softwareFacet.getVersion())==0);
Assert.assertTrue(readSoftwareFacet.getHeader().getUUID().compareTo(createdSoftwareFacet.getHeader().getUUID())==0); Assert.assertTrue(readSoftwareFacet.getHeader().getUUID().compareTo(createdSoftwareFacet.getHeader().getUUID())==0);
boolean deleted = resourceRegistryPublisher.deleteResource(createdEService);
Assert.assertTrue(deleted);
} }
} }

View File

@ -22,7 +22,6 @@ import java.util.UUID;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.informationsystem.impl.embedded.HeaderImpl; import org.gcube.informationsystem.impl.embedded.HeaderImpl;
import org.gcube.informationsystem.impl.entity.facet.CPUFacetImpl; import org.gcube.informationsystem.impl.entity.facet.CPUFacetImpl;
import org.gcube.informationsystem.impl.entity.facet.ContainerStateFacetImpl; import org.gcube.informationsystem.impl.entity.facet.ContainerStateFacetImpl;
@ -105,8 +104,6 @@ public class SmartgearResourcesTest extends ScopedTest {
@Test @Test
public void testHostingNodeOperations() throws ResourceRegistryException, IOException{ public void testHostingNodeOperations() throws ResourceRegistryException, IOException{
ScopeProvider.instance.set("/gcube/devNext");
UUID uuid = UUID.randomUUID(); UUID uuid = UUID.randomUUID();
HostingNode hostingNode = new HostingNodeImpl(); HostingNode hostingNode = new HostingNodeImpl();