2017-12-18 15:37:22 +01:00
|
|
|
package org.gcube.informationsystem.resourceregistry.schema;
|
|
|
|
|
2017-12-19 11:27:29 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2019-02-06 10:01:35 +01:00
|
|
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
2018-06-12 19:26:11 +02:00
|
|
|
import org.gcube.informationsystem.types.TypeBinder;
|
2019-02-06 10:14:05 +01:00
|
|
|
import org.gcube.informationsystem.types.annotations.Abstract;
|
2019-10-25 17:44:44 +02:00
|
|
|
import org.gcube.informationsystem.types.reference.TypeDefinition;
|
2018-06-12 19:26:11 +02:00
|
|
|
import org.junit.Assert;
|
2017-12-19 11:27:29 +01:00
|
|
|
import org.junit.Test;
|
2017-12-18 15:37:22 +01:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2019-02-13 12:24:38 +01:00
|
|
|
public class ResourceRegistrySchemaClientTest extends ContextTest {
|
2017-12-18 15:37:22 +01:00
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(ResourceRegistrySchemaClientTest.class);
|
|
|
|
|
2018-06-12 19:26:11 +02:00
|
|
|
@Abstract
|
|
|
|
interface AuxFacet extends Facet {
|
|
|
|
public static final String NAME = "aux"; //AuxFacet.class.getSimpleName();
|
2019-01-17 17:00:09 +01:00
|
|
|
public static final String DESCRIPTION = "This is AuxFacet used for Test";
|
2018-06-12 19:26:11 +02:00
|
|
|
public static final String VERSION = "1.0.0";
|
2017-12-19 11:27:29 +01:00
|
|
|
}
|
|
|
|
|
2019-01-18 15:29:43 +01:00
|
|
|
// @Test
|
2017-12-19 11:27:29 +01:00
|
|
|
public void testCreate() throws Exception {
|
|
|
|
ResourceRegistrySchemaClient resourceRegistrySchemaClient = ResourceRegistrySchemaClientFactory.create();
|
2019-11-05 18:47:10 +01:00
|
|
|
TypeDefinition td = resourceRegistrySchemaClient.create(AuxFacet.class);
|
2017-12-19 11:27:29 +01:00
|
|
|
logger.debug("{}", td);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testRead() throws Exception {
|
|
|
|
ResourceRegistrySchemaClient resourceRegistrySchemaClient = ResourceRegistrySchemaClientFactory.create();
|
2019-10-30 12:43:56 +01:00
|
|
|
List<TypeDefinition> types = resourceRegistrySchemaClient.read(Facet.class, true);
|
2018-06-12 19:26:11 +02:00
|
|
|
Assert.assertTrue(types.size()>1);
|
2019-10-30 12:43:56 +01:00
|
|
|
for(TypeDefinition td : types) {
|
2017-12-19 11:27:29 +01:00
|
|
|
logger.debug("{}", td);
|
|
|
|
}
|
2018-06-12 19:26:11 +02:00
|
|
|
|
|
|
|
types = resourceRegistrySchemaClient.read(Facet.class, false);
|
|
|
|
Assert.assertTrue(types.size()==1);
|
2019-11-05 18:47:10 +01:00
|
|
|
TypeDefinition gotFacetDefinition = types.get(0);
|
|
|
|
TypeDefinition facetDefinition = TypeBinder.createTypeDefinition(Facet.class);
|
2018-06-12 19:26:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
Assert.assertTrue(gotFacetDefinition.getName().compareTo(facetDefinition.getName())==0);
|
2019-01-18 17:34:11 +01:00
|
|
|
// Uncomment when OrientDB team solve bug https://github.com/orientechnologies/orientdb/issues/8730
|
|
|
|
//Assert.assertTrue(gotFacetDefinition.getDescription().compareTo(facetDefinition.getDescription())==0);
|
2017-12-19 11:27:29 +01:00
|
|
|
}
|
|
|
|
|
2017-12-18 15:37:22 +01:00
|
|
|
|
|
|
|
}
|