2016-09-14 18:09:03 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
2017-04-03 18:44:47 +02:00
|
|
|
package org.gcube.informationsystem.resourceregistry.client;
|
2016-09-14 18:09:03 +02:00
|
|
|
|
2017-01-12 16:39:53 +01:00
|
|
|
import java.util.List;
|
2017-03-30 12:34:38 +02:00
|
|
|
import java.util.UUID;
|
2017-01-12 16:39:53 +01:00
|
|
|
|
|
|
|
import org.gcube.informationsystem.model.entity.facet.ContactFacet;
|
2017-03-30 12:34:38 +02:00
|
|
|
import org.gcube.informationsystem.model.entity.resource.EService;
|
2017-01-12 16:39:53 +01:00
|
|
|
import org.gcube.informationsystem.model.entity.resource.HostingNode;
|
2017-02-23 17:08:04 +01:00
|
|
|
import org.gcube.informationsystem.model.entity.resource.Service;
|
2017-02-24 12:01:33 +01:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
2016-10-27 17:51:22 +02:00
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
2017-04-03 18:44:47 +02:00
|
|
|
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
|
|
|
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
|
2017-01-12 16:39:53 +01:00
|
|
|
import org.gcube.informationsystem.types.TypeBinder.TypeDefinition;
|
2016-09-14 18:09:03 +02:00
|
|
|
import org.junit.Test;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
/**
|
2016-10-12 14:35:20 +02:00
|
|
|
* @author Luca Frosini (ISTI - CNR)
|
2016-09-14 18:09:03 +02:00
|
|
|
*/
|
2017-01-12 16:39:53 +01:00
|
|
|
public class ResourceRegistryClientTest extends ScopedTest {
|
2016-09-14 18:09:03 +02:00
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory
|
|
|
|
.getLogger(ResourceRegistryClientTest.class);
|
|
|
|
|
2016-10-18 10:52:05 +02:00
|
|
|
protected ResourceRegistryClient resourceRegistryClient;
|
|
|
|
|
2016-11-04 16:52:41 +01:00
|
|
|
public ResourceRegistryClientTest(){
|
2016-10-18 10:52:05 +02:00
|
|
|
resourceRegistryClient = ResourceRegistryClientFactory.create();
|
|
|
|
}
|
|
|
|
|
2016-09-14 18:09:03 +02:00
|
|
|
@Test
|
2017-04-03 18:44:47 +02:00
|
|
|
public void testQuery() throws ResourceRegistryException{
|
2016-10-18 10:52:05 +02:00
|
|
|
String res = resourceRegistryClient.query("SELECT FROM V", 0, null);
|
2016-10-31 17:05:00 +01:00
|
|
|
logger.trace(res);
|
2016-09-14 18:09:03 +02:00
|
|
|
}
|
2016-10-18 10:52:05 +02:00
|
|
|
|
2016-10-27 17:51:22 +02:00
|
|
|
@Test
|
2017-02-24 12:01:33 +01:00
|
|
|
public void testGetFacetSchema() throws SchemaNotFoundException, ResourceRegistryException {
|
2017-01-12 16:39:53 +01:00
|
|
|
List<TypeDefinition> typeDefinitions = resourceRegistryClient.getSchema(ContactFacet.class, true);
|
|
|
|
logger.trace("{}", typeDefinitions);
|
2016-10-27 17:51:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
2017-02-24 12:01:33 +01:00
|
|
|
public void testGetResourceSchema() throws SchemaNotFoundException, ResourceRegistryException {
|
2017-01-12 16:39:53 +01:00
|
|
|
List<TypeDefinition> typeDefinitions = resourceRegistryClient.getSchema(HostingNode.class, true);
|
|
|
|
logger.trace("{}", typeDefinitions);
|
2016-10-27 17:51:22 +02:00
|
|
|
}
|
|
|
|
|
2017-02-23 17:08:04 +01:00
|
|
|
interface Aux extends Service {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-02-24 11:00:12 +01:00
|
|
|
@Test(expected=SchemaNotFoundException.class)
|
2017-02-24 12:01:33 +01:00
|
|
|
public void testException() throws SchemaNotFoundException, ResourceRegistryException {
|
2017-02-24 11:00:12 +01:00
|
|
|
resourceRegistryClient.getSchema(Aux.class, true);
|
2017-02-23 17:08:04 +01:00
|
|
|
}
|
|
|
|
|
2017-10-30 14:01:59 +01:00
|
|
|
@Test
|
2017-03-30 12:34:38 +02:00
|
|
|
public void testGetResource() throws ResourceRegistryException {
|
2017-10-30 14:01:59 +01:00
|
|
|
UUID uuid = UUID.fromString("bdaccb35-7f27-45a6-8ca9-11d467cb9233");
|
2017-03-30 12:34:38 +02:00
|
|
|
EService eService = resourceRegistryClient.getInstance(EService.class, uuid);
|
|
|
|
logger.trace("{}", eService);
|
|
|
|
}
|
2017-02-23 17:08:04 +01:00
|
|
|
|
2017-10-30 14:01:59 +01:00
|
|
|
@Test
|
|
|
|
public void testExists() throws ResourceRegistryException {
|
|
|
|
UUID uuid = UUID.fromString("bdaccb35-7f27-45a6-8ca9-11d467cb9233");
|
|
|
|
resourceRegistryClient.exists(EService.class, uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testGetInstances() throws ResourceRegistryException {
|
|
|
|
resourceRegistryClient.getInstances(EService.NAME, true);
|
|
|
|
}
|
2016-09-14 18:09:03 +02:00
|
|
|
}
|