Refs #10318: Refactor Resource Regsitry Client API

Task-Url: https://support.d4science.org/issues/10318

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-client@158403 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-11-13 11:46:08 +00:00
parent 8ec2d249b1
commit 4e59b78f6b
3 changed files with 222 additions and 102 deletions

View File

@ -24,33 +24,45 @@ import org.gcube.informationsystem.types.TypeBinder.TypeDefinition;
*/ */
public interface ResourceRegistryClient { public interface ResourceRegistryClient {
public String query(final String query, final int limit, final String fetchPlan) public <ERType extends ER> boolean exists(Class<ERType> clazz, UUID uuid)
throws InvalidQueryException, ResourceRegistryException; throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException;
public <ERType extends ER> void exists(Class<ERType> clazz, UUID uuid) public boolean exists(String type, UUID uuid)
throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException; throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException;
public <ERType extends ER> ERType getInstance(Class<ERType> clazz, UUID uuid) public <ERType extends ER> ERType getInstance(Class<ERType> clazz, UUID uuid)
throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException; throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException;
public List<? extends Entity> getInstances(String type, Boolean polymorphic) throws ResourceRegistryException; public String getInstance(String type, UUID uuid)
throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException;
public List<Resource> getInstancesFromEntity(String relationType, Boolean polymorphic, UUID reference, public <ERType extends ER, R extends Resource> List<R> getInstances(Class<ERType> clazz, Boolean polymorphic)
Direction direction) throws ResourceRegistryException; throws ResourceRegistryException;
public <R extends Resource> List<R> getFilteredResources(Class<R> resourceClass, public String getInstances(String type, Boolean polymorphic) throws ResourceRegistryException;
@SuppressWarnings("rawtypes") Class<? extends ConsistsOf> consistsOfClass,
Class<? extends Facet> facetClass, public <ERType extends ER, E extends Entity, R extends Resource> List<R> getInstancesFromEntity(Class<ERType> clazz,
Boolean polymorphic, E reference, Direction direction) throws ResourceRegistryException;
public <ERType extends ER, R extends Resource> List<R> getInstancesFromEntity(Class<ERType> clazz,
Boolean polymorphic, UUID reference, Direction direction) throws ResourceRegistryException;
public String getInstancesFromEntity(String type, Boolean polymorphic, UUID reference, Direction direction)
throws ResourceRegistryException;
public <R extends Resource, F extends Facet, C extends ConsistsOf<?, ?>> List<R> getFilteredResources(
Class<R> resourceClass, Class<C> consistsOfClass, Class<F> facetClass, boolean polymorphic,
Map<String, Object> map) throws ResourceRegistryException;
public String getFilteredResources(String resourceType, String consistsOfType, String facetType,
boolean polymorphic, Map<String, Object> map) throws ResourceRegistryException; boolean polymorphic, Map<String, Object> map) throws ResourceRegistryException;
public List<Resource> getFilteredResources(String resourceType, String consistsOfType, String facetType, public String query(final String query, final int limit, final String fetchPlan)
boolean polymorphic, Map<String, Object> map) throws ResourceRegistryException; throws InvalidQueryException, ResourceRegistryException;
public <ISM extends ISManageable> List<TypeDefinition> getSchema(Class<ISM> clazz, Boolean polymorphic) public <ISM extends ISManageable> List<TypeDefinition> getSchema(Class<ISM> clazz, Boolean polymorphic)
throws SchemaNotFoundException, ResourceRegistryException; throws SchemaNotFoundException, ResourceRegistryException;
public Context getContext(UUID uuid) public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException;
throws ContextNotFoundException, ResourceRegistryException;
} }

View File

@ -1,6 +1,3 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.client; package org.gcube.informationsystem.resourceregistry.client;
import java.io.StringWriter; import java.io.StringWriter;
@ -58,9 +55,15 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
} }
@Override @Override
public <ERType extends ER> void exists(Class<ERType> clazz, UUID uuid) public <ERType extends ER> boolean exists(Class<ERType> clazz, UUID uuid)
throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException { throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException {
String type = Utility.getType(clazz); String type = Utility.getType(clazz);
return exists(type, uuid);
}
@Override
public boolean exists(String type, UUID uuid)
throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException {
try { try {
logger.info("Going to check if {} with UUID {} exists", type, uuid); logger.info("Going to check if {} with UUID {} exists", type, uuid);
StringWriter stringWriter = new StringWriter(); StringWriter stringWriter = new StringWriter();
@ -74,9 +77,10 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
stringWriter.append(uuid.toString()); stringWriter.append(uuid.toString());
HTTPCall httpCall = getHTTPCall(); HTTPCall httpCall = getHTTPCall();
httpCall.call(clazz, stringWriter.toString(), HTTPMETHOD.HEAD); httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.HEAD);
logger.debug("{} with UUID {} exists", type, uuid); logger.debug("{} with UUID {} exists", type, uuid);
return true;
} catch (ResourceRegistryException e) { } catch (ResourceRegistryException e) {
// logger.trace("Error while checking if {} with UUID {} exists.", type, uuid, // logger.trace("Error while checking if {} with UUID {} exists.", type, uuid,
// e); // e);
@ -92,6 +96,16 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
public <ERType extends ER> ERType getInstance(Class<ERType> clazz, UUID uuid) public <ERType extends ER> ERType getInstance(Class<ERType> clazz, UUID uuid)
throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException { throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException {
String type = Utility.getType(clazz); String type = Utility.getType(clazz);
String ret = getInstance(type, uuid);
try {
return ISMapper.unmarshal(clazz, ret);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public String getInstance(String type, UUID uuid)
throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException {
try { try {
logger.info("Going to get {} with UUID {}", type, uuid); logger.info("Going to get {} with UUID {}", type, uuid);
StringWriter stringWriter = new StringWriter(); StringWriter stringWriter = new StringWriter();
@ -105,10 +119,10 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
stringWriter.append(uuid.toString()); stringWriter.append(uuid.toString());
HTTPCall httpCall = getHTTPCall(); HTTPCall httpCall = getHTTPCall();
ERType erType = httpCall.call(clazz, stringWriter.toString(), HTTPMETHOD.GET); String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET);
logger.debug("Got {} with UUID {} is {}", type, uuid, erType); logger.debug("Got {} with UUID {} is {}", type, uuid, ret);
return erType; return ret;
} catch (ResourceRegistryException e) { } catch (ResourceRegistryException e) {
// logger.trace("Error while getting {} with UUID {}", type, uuid, e); // logger.trace("Error while getting {} with UUID {}", type, uuid, e);
throw e; throw e;
@ -118,8 +132,21 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
} }
} }
@SuppressWarnings("unchecked")
@Override @Override
public List<? extends Entity> getInstances(String type, Boolean polymorphic) throws ResourceRegistryException { public <ERType extends ER, R extends Resource> List<R> getInstances(Class<ERType> clazz, Boolean polymorphic)
throws ResourceRegistryException {
String type = Utility.getType(clazz);
String ret = getInstances(type, polymorphic);
try {
return (List<R>) ISMapper.unmarshalList(Resource.class, ret);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public String getInstances(String type, Boolean polymorphic) throws ResourceRegistryException {
try { try {
logger.info("Going to get all instances of {} ", type); logger.info("Going to get all instances of {} ", type);
StringWriter stringWriter = new StringWriter(); StringWriter stringWriter = new StringWriter();
@ -137,7 +164,7 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters); String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
logger.debug("Got instances of {} are {}", type, ret); logger.debug("Got instances of {} are {}", type, ret);
return ISMapper.unmarshalList(Entity.class, ret); return ret;
} catch (ResourceRegistryException e) { } catch (ResourceRegistryException e) {
// logger.trace("Error while getting {} instances", type, e); // logger.trace("Error while getting {} instances", type, e);
throw e; throw e;
@ -148,17 +175,36 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
} }
@Override @Override
public List<Resource> getInstancesFromEntity(String relationType, Boolean polymorphic, UUID reference, public <ERType extends ER, E extends Entity, R extends Resource> List<R> getInstancesFromEntity(Class<ERType> clazz,
Direction direction) throws ResourceRegistryException { Boolean polymorphic, E reference, Direction direction) throws ResourceRegistryException {
return getInstancesFromEntity(clazz, polymorphic, reference.getHeader().getUUID(), direction);
}
@SuppressWarnings("unchecked")
@Override
public <ERType extends ER, R extends Resource> List<R> getInstancesFromEntity(Class<ERType> clazz,
Boolean polymorphic, UUID reference, Direction direction) throws ResourceRegistryException {
String type = Utility.getType(clazz);
String ret = getInstancesFromEntity(type, polymorphic, reference, direction);
try { try {
logger.info("Going to get all instances of {} from/to {}", relationType, reference.toString()); return (List<R>) ISMapper.unmarshalList(Resource.class, ret);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public String getInstancesFromEntity(String type, Boolean polymorphic, UUID reference, Direction direction)
throws ResourceRegistryException {
try {
logger.info("Going to get all instances of {} from/to {}", type, reference.toString());
StringWriter stringWriter = new StringWriter(); StringWriter stringWriter = new StringWriter();
stringWriter.append(PATH_SEPARATOR); stringWriter.append(PATH_SEPARATOR);
stringWriter.append(AccessPath.ACCESS_PATH_PART); stringWriter.append(AccessPath.ACCESS_PATH_PART);
stringWriter.append(PATH_SEPARATOR); stringWriter.append(PATH_SEPARATOR);
stringWriter.append(AccessPath.INSTANCES_PATH_PART); stringWriter.append(AccessPath.INSTANCES_PATH_PART);
stringWriter.append(PATH_SEPARATOR); stringWriter.append(PATH_SEPARATOR);
stringWriter.append(relationType); stringWriter.append(type);
Map<String, String> parameters = new HashMap<>(); Map<String, String> parameters = new HashMap<>();
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString()); parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
@ -168,8 +214,8 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
HTTPCall httpCall = getHTTPCall(); HTTPCall httpCall = getHTTPCall();
String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters); String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
logger.debug("Got instances of {} from/to {} are {}", relationType, reference.toString(), ret); logger.debug("Got instances of {} from/to {} are {}", type, reference.toString(), ret);
return ISMapper.unmarshalList(Resource.class, ret); return ret;
} catch (ResourceRegistryException e) { } catch (ResourceRegistryException e) {
// logger.trace("Error while getting instances of {} from/to {}", relationType, // logger.trace("Error while getting instances of {} from/to {}", relationType,
// e); // e);
@ -181,37 +227,54 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
} }
} }
@SuppressWarnings("unchecked")
@Override @Override
public <ISM extends ISManageable> List<TypeDefinition> getSchema(Class<ISM> clazz, Boolean polymorphic) public <R extends Resource, F extends Facet, C extends ConsistsOf<?, ?>> List<R> getFilteredResources(
throws SchemaNotFoundException, ResourceRegistryException { Class<R> resourceClass, Class<C> consistsOfClass, Class<F> facetClass, boolean polymorphic,
String type = Utility.getType(clazz); Map<String, Object> map) throws ResourceRegistryException {
String resourceType = Utility.getType(resourceClass);
String consistsOfType = Utility.getType(consistsOfClass);
String facetType = Utility.getType(facetClass);
String ret = getFilteredResources(resourceType, consistsOfType, facetType, polymorphic, map);
try { try {
logger.info("Going to get {} schema", type); return (List<R>) ISMapper.unmarshalList(Resource.class, ret);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public String getFilteredResources(String resourceType, String consistsOfType, String facetType,
boolean polymorphic, Map<String, Object> map) throws ResourceRegistryException {
try {
logger.info("Going to get Filtered Resources ({}) linked by a ConsistsOf Relation ({}) to a Facet ({})"
+ " having {}", resourceType, consistsOfType, facetType, map);
StringWriter stringWriter = new StringWriter(); StringWriter stringWriter = new StringWriter();
stringWriter.append(PATH_SEPARATOR); stringWriter.append(PATH_SEPARATOR);
stringWriter.append(AccessPath.ACCESS_PATH_PART); stringWriter.append(AccessPath.ACCESS_PATH_PART);
stringWriter.append(PATH_SEPARATOR); stringWriter.append(PATH_SEPARATOR);
stringWriter.append(AccessPath.SCHEMA_PATH_PART); stringWriter.append(AccessPath.RESOURCE_INSTANCES_PATH_PART);
stringWriter.append(PATH_SEPARATOR);
stringWriter.append(resourceType);
stringWriter.append(PATH_SEPARATOR);
stringWriter.append(consistsOfType);
stringWriter.append(PATH_SEPARATOR);
stringWriter.append(facetType);
stringWriter.append(PATH_SEPARATOR); stringWriter.append(PATH_SEPARATOR);
stringWriter.append(type);
Map<String, String> parameters = new HashMap<>(); Map<String, Object> parameters = new HashMap<>(map);
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString()); parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic);
HTTPCall httpCall = getHTTPCall(); HTTPCall httpCall = getHTTPCall();
String json = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters); String json = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
logger.debug("Got schema for {} is {}", type, json); logger.info("Filtered Resources ({}) linked by a ConsistsOf Relation ({}) to a Facet ({})"
return TypeBinder.deserializeTypeDefinitions(json); + " having {} are : {}", resourceType, consistsOfType, facetType, map, json);
return json;
} catch (ResourceRegistryException e) { } catch (ResourceRegistryException e) {
// logger.trace("Error while getting {} schema for {}", polymorphic ?
// AccessPath.POLYMORPHIC_PARAM + " " : "",
// type, e);
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
// logger.trace("Error while getting {}schema for {}", polymorphic ?
// AccessPath.POLYMORPHIC_PARAM + " " : "",
// type, e);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
} }
@ -251,56 +314,8 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
} }
} }
@SuppressWarnings("unchecked")
@Override @Override
public <R extends Resource> List<R> getFilteredResources(Class<R> resourceClass, public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException {
@SuppressWarnings("rawtypes") Class<? extends ConsistsOf> consistsOfClass, Class<? extends Facet> facetClass,
boolean polymorphic, Map<String, Object> map) throws ResourceRegistryException {
String resourceType = Utility.getType(resourceClass);
String consistsOfType = Utility.getType(consistsOfClass);
String facetType = Utility.getType(facetClass);
return (List<R>) getFilteredResources(resourceType, consistsOfType, facetType, polymorphic, map);
}
@Override
public List<Resource> getFilteredResources(String resourceType, String consistsOfType, String facetType,
boolean polymorphic, Map<String, Object> map) throws ResourceRegistryException {
try {
logger.info("Going to get Filtered Resources ({}) linked by a ConsistsOf Relation ({}) to a Facet ({})"
+ " having {}", resourceType, consistsOfType, facetType, map);
StringWriter stringWriter = new StringWriter();
stringWriter.append(PATH_SEPARATOR);
stringWriter.append(AccessPath.ACCESS_PATH_PART);
stringWriter.append(PATH_SEPARATOR);
stringWriter.append(AccessPath.RESOURCE_INSTANCES_PATH_PART);
stringWriter.append(PATH_SEPARATOR);
stringWriter.append(resourceType);
stringWriter.append(PATH_SEPARATOR);
stringWriter.append(consistsOfType);
stringWriter.append(PATH_SEPARATOR);
stringWriter.append(facetType);
stringWriter.append(PATH_SEPARATOR);
Map<String, Object> parameters = new HashMap<>(map);
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic);
HTTPCall httpCall = getHTTPCall();
String json = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
logger.info("Filtered Resources ({}) linked by a ConsistsOf Relation ({}) to a Facet ({})"
+ " having {} are : {}", resourceType, consistsOfType, facetType, map, json);
return ISMapper.unmarshalList(Resource.class, json);
} catch (ResourceRegistryException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public Context getContext(UUID uuid)
throws ContextNotFoundException, ResourceRegistryException {
try { try {
logger.info("Going to get {} with UUID {}", Context.NAME, uuid.toString()); logger.info("Going to get {} with UUID {}", Context.NAME, uuid.toString());
StringWriter stringWriter = new StringWriter(); StringWriter stringWriter = new StringWriter();
@ -329,4 +344,39 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
} }
} }
@Override
public <ISM extends ISManageable> List<TypeDefinition> getSchema(Class<ISM> clazz, Boolean polymorphic)
throws SchemaNotFoundException, ResourceRegistryException {
String type = Utility.getType(clazz);
try {
logger.info("Going to get {} schema", type);
StringWriter stringWriter = new StringWriter();
stringWriter.append(PATH_SEPARATOR);
stringWriter.append(AccessPath.ACCESS_PATH_PART);
stringWriter.append(PATH_SEPARATOR);
stringWriter.append(AccessPath.SCHEMA_PATH_PART);
stringWriter.append(PATH_SEPARATOR);
stringWriter.append(type);
Map<String, String> parameters = new HashMap<>();
parameters.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
HTTPCall httpCall = getHTTPCall();
String json = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET, parameters);
logger.debug("Got schema for {} is {}", type, json);
return TypeBinder.deserializeTypeDefinitions(json);
} catch (ResourceRegistryException e) {
// logger.trace("Error while getting {} schema for {}", polymorphic ?
// AccessPath.POLYMORPHIC_PARAM + " " : "",
// type, e);
throw e;
} catch (Exception e) {
// logger.trace("Error while getting {}schema for {}", polymorphic ?
// AccessPath.POLYMORPHIC_PARAM + " " : "",
// type, e);
throw new RuntimeException(e);
}
}
} }

View File

@ -8,7 +8,10 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.gcube.informationsystem.impl.embedded.HeaderImpl;
import org.gcube.informationsystem.impl.entity.resource.HostingNodeImpl;
import org.gcube.informationsystem.impl.utils.ISMapper; import org.gcube.informationsystem.impl.utils.ISMapper;
import org.gcube.informationsystem.model.embedded.Header;
import org.gcube.informationsystem.model.entity.facet.ContactFacet; import org.gcube.informationsystem.model.entity.facet.ContactFacet;
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;
@ -67,25 +70,79 @@ public class ResourceRegistryClientTest extends ScopedTest {
} }
@Test @Test
public void testGetResource() throws ResourceRegistryException { public void testExists() throws ResourceRegistryException {
UUID uuid = UUID.fromString("bdaccb35-7f27-45a6-8ca9-11d467cb9233");
resourceRegistryClient.exists(EService.NAME, uuid);
}
@Test
public void testExistsByClass() throws ResourceRegistryException {
UUID uuid = UUID.fromString("bdaccb35-7f27-45a6-8ca9-11d467cb9233");
resourceRegistryClient.exists(EService.class, uuid);
}
@Test
public void testGetInstance() throws ResourceRegistryException {
UUID uuid = UUID.fromString("bdaccb35-7f27-45a6-8ca9-11d467cb9233");
String eService = resourceRegistryClient.getInstance(EService.NAME, uuid);
logger.trace("{}", eService);
}
@Test
public void testGetInstanceByClass() throws ResourceRegistryException {
UUID uuid = UUID.fromString("bdaccb35-7f27-45a6-8ca9-11d467cb9233"); UUID uuid = UUID.fromString("bdaccb35-7f27-45a6-8ca9-11d467cb9233");
EService eService = resourceRegistryClient.getInstance(EService.class, uuid); EService eService = resourceRegistryClient.getInstance(EService.class, uuid);
logger.trace("{}", eService); logger.trace("{}", eService);
} }
@Test @Test
public void testExists() throws ResourceRegistryException { public void testGetInstances() throws ResourceRegistryException {
UUID uuid = UUID.fromString("bdaccb35-7f27-45a6-8ca9-11d467cb9233"); String eServices = resourceRegistryClient.getInstances(EService.NAME, true);
resourceRegistryClient.exists(EService.class, uuid); logger.trace("{}", eServices);
} }
@Test @Test
public void testGetInstances() throws ResourceRegistryException { public void testGetInstancesByClass() throws ResourceRegistryException {
resourceRegistryClient.getInstances(EService.NAME, true); List<EService> eServices = resourceRegistryClient.getInstances(EService.class, true);
logger.trace("{}", eServices);
} }
@Test
public void testGetInstancesFromEntity() throws ResourceRegistryException {
UUID uuid = UUID.fromString("b0d15e45-62af-4221-b785-7d014f10e631");
String eServices = resourceRegistryClient.getInstancesFromEntity(EService.NAME, true, uuid, Direction.out);
logger.trace("{}", eServices);
}
@Test
public void testGetInstancesFromEntityByClass() throws ResourceRegistryException {
UUID uuid = UUID.fromString("b0d15e45-62af-4221-b785-7d014f10e631");
List<EService> eServices = resourceRegistryClient.getInstancesFromEntity(EService.class, true, uuid, Direction.out);
logger.trace("{}", eServices);
}
@Test
public void testGetInstancesFromEntityByClasses() throws ResourceRegistryException {
UUID uuid = UUID.fromString("b0d15e45-62af-4221-b785-7d014f10e631");
HostingNode hostingNode = new HostingNodeImpl();
Header header = new HeaderImpl(uuid);
hostingNode.setHeader(header);
List<EService> eServices = resourceRegistryClient.getInstancesFromEntity(EService.class, true, hostingNode, Direction.out);
logger.trace("{}", eServices);
}
@Test @Test
public void testGetFilteredResources() throws ResourceRegistryException, JsonProcessingException { public void testGetFilteredResources() throws ResourceRegistryException, JsonProcessingException {
Map<String, Object> map = new HashMap<>();
map.put("group", "VREManagement");
map.put("name", "SmartExecutor");
String json = resourceRegistryClient.getFilteredResources(EService.NAME, IsIdentifiedBy.NAME, SoftwareFacet.NAME, true, map);
logger.trace(json);
}
@Test
public void testGetFilteredResourcesByClasses() throws ResourceRegistryException, JsonProcessingException {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("group", "VREManagement"); map.put("group", "VREManagement");
map.put("name", "SmartExecutor"); map.put("name", "SmartExecutor");
@ -94,4 +151,5 @@ public class ResourceRegistryClientTest extends ScopedTest {
logger.trace("{}", ISMapper.marshal(eService)); logger.trace("{}", ISMapper.marshal(eService));
} }
} }
} }