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;
|
|
|
|
|
2018-10-02 09:25:12 +02:00
|
|
|
import org.gcube.informationsystem.model.reference.annotations.Abstract;
|
|
|
|
import org.gcube.informationsystem.model.reference.entity.Facet;
|
2018-06-12 19:26:11 +02:00
|
|
|
import org.gcube.informationsystem.types.TypeBinder;
|
2017-12-19 11:27:29 +01:00
|
|
|
import org.gcube.informationsystem.types.TypeBinder.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;
|
|
|
|
|
|
|
|
public class ResourceRegistrySchemaClientTest extends ScopedTest {
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testCreate() throws Exception {
|
|
|
|
ResourceRegistrySchemaClient resourceRegistrySchemaClient = ResourceRegistrySchemaClientFactory.create();
|
2018-06-12 19:26:11 +02: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();
|
|
|
|
List<TypeDefinition> types = resourceRegistrySchemaClient.read(Facet.class, true);
|
2018-06-12 19:26:11 +02:00
|
|
|
Assert.assertTrue(types.size()>1);
|
2017-12-19 11:27:29 +01:00
|
|
|
for(TypeDefinition td : types) {
|
|
|
|
logger.debug("{}", td);
|
|
|
|
}
|
2018-06-12 19:26:11 +02:00
|
|
|
|
|
|
|
types = resourceRegistrySchemaClient.read(Facet.class, false);
|
|
|
|
Assert.assertTrue(types.size()==1);
|
|
|
|
TypeDefinition gotFacetDefinition = types.get(0);
|
|
|
|
TypeDefinition facetDefinition = TypeBinder.createTypeDefinition(Facet.class);
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertTrue(gotFacetDefinition.getName().compareTo(facetDefinition.getName())==0);
|
|
|
|
Assert.assertTrue(gotFacetDefinition.getDescription().compareTo(facetDefinition.getDescription())==0);
|
2017-12-19 11:27:29 +01:00
|
|
|
}
|
|
|
|
|
2017-12-18 15:37:22 +01:00
|
|
|
|
|
|
|
}
|