|
|
|
@ -3,11 +3,16 @@ package org.gcube.informationsystem.model.discovery;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.ServiceLoader;
|
|
|
|
|
|
|
|
|
|
import org.gcube.informationsystem.model.reference.ISManageable;
|
|
|
|
|
import org.gcube.informationsystem.model.reference.entities.Entity;
|
|
|
|
|
import org.gcube.informationsystem.model.reference.properties.Property;
|
|
|
|
|
import org.gcube.informationsystem.model.reference.relations.Relation;
|
|
|
|
|
import org.gcube.informationsystem.base.reference.ISManageable;
|
|
|
|
|
import org.gcube.informationsystem.base.reference.entities.BaseEntity;
|
|
|
|
|
import org.gcube.informationsystem.base.reference.properties.BaseProperty;
|
|
|
|
|
import org.gcube.informationsystem.base.reference.relations.BaseRelation;
|
|
|
|
|
import org.gcube.informationsystem.types.TypeBinder;
|
|
|
|
|
import org.gcube.informationsystem.types.reference.TypeDefinition;
|
|
|
|
|
import org.gcube.informationsystem.types.reference.entities.EntityTypeDefinition;
|
|
|
|
|
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
|
|
|
|
import org.gcube.informationsystem.types.reference.properties.PropertyTypeDefiniton;
|
|
|
|
|
import org.gcube.informationsystem.types.reference.relations.RelationTypeDefinition;
|
|
|
|
|
import org.gcube.informationsystem.utils.discovery.ISMDiscovery;
|
|
|
|
|
import org.gcube.informationsystem.utils.discovery.RegistrationProvider;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
@ -15,12 +20,13 @@ import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
public class ISMDiscoveryTest {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(ISMDiscovery.class);
|
|
|
|
|
|
|
|
|
|
private void addDiscoveredModel(ISMDiscovery<? extends ISManageable> ismDiscovery) {
|
|
|
|
|
ServiceLoader<? extends RegistrationProvider> regsitrationProviders = ServiceLoader.load(RegistrationProvider.class);
|
|
|
|
|
for (RegistrationProvider registrationProvider : regsitrationProviders) {
|
|
|
|
|
ServiceLoader<? extends RegistrationProvider> regsitrationProviders = ServiceLoader
|
|
|
|
|
.load(RegistrationProvider.class);
|
|
|
|
|
for(RegistrationProvider registrationProvider : regsitrationProviders) {
|
|
|
|
|
List<Package> packages = registrationProvider.getPackagesToRegister();
|
|
|
|
|
for(Package p : packages) {
|
|
|
|
|
ismDiscovery.addPackage(p);
|
|
|
|
@ -29,36 +35,51 @@ public class ISMDiscoveryTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testPropertyDiscovery() throws Exception{
|
|
|
|
|
ISMDiscovery<Property> propertyDiscovery = new ISMDiscovery<>(Property.class);
|
|
|
|
|
public void testPropertyDiscovery() throws Exception {
|
|
|
|
|
ISMDiscovery<BaseProperty> propertyDiscovery = new ISMDiscovery<BaseProperty>(BaseProperty.class);
|
|
|
|
|
addDiscoveredModel(propertyDiscovery);
|
|
|
|
|
propertyDiscovery.discover();
|
|
|
|
|
|
|
|
|
|
for(Class<Property> propertyClass : propertyDiscovery.getDiscovered()) {
|
|
|
|
|
logger.info("Going to create : {}", propertyClass);
|
|
|
|
|
for(Class<BaseProperty> propertyClass : propertyDiscovery.getDiscovered()) {
|
|
|
|
|
logger.info("{}", TypeBinder.serializeType(propertyClass));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEntityDiscovery() throws Exception{
|
|
|
|
|
ISMDiscovery<Entity> entityDiscovery = new ISMDiscovery<>(Entity.class);
|
|
|
|
|
public void testEntityTypeDefinitionSerialization() throws Exception {
|
|
|
|
|
logger.info("{}", TypeBinder.serializeType(EntityTypeDefinition.class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testDefinitionSerialization() throws Exception {
|
|
|
|
|
logger.info("{}", TypeBinder.serializeType(TypeDefinition.class));
|
|
|
|
|
logger.info("{}", TypeBinder.serializeType(EntityTypeDefinition.class));
|
|
|
|
|
logger.info("{}", TypeBinder.serializeType(RelationTypeDefinition.class));
|
|
|
|
|
logger.info("{}", TypeBinder.serializeType(PropertyTypeDefiniton.class));
|
|
|
|
|
logger.info("{}", TypeBinder.serializeType(PropertyDefinition.class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testEntityDiscovery() throws Exception {
|
|
|
|
|
ISMDiscovery<BaseEntity> entityDiscovery = new ISMDiscovery<>(BaseEntity.class);
|
|
|
|
|
addDiscoveredModel(entityDiscovery);
|
|
|
|
|
entityDiscovery.discover();
|
|
|
|
|
|
|
|
|
|
for(Class<Entity> entity : entityDiscovery.getDiscovered()) {
|
|
|
|
|
logger.info("Going to create : {}", entity);
|
|
|
|
|
for(Class<BaseEntity> entity : entityDiscovery.getDiscovered()) {
|
|
|
|
|
logger.info("{}", TypeBinder.serializeType(entity));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void testRelationDiscovery() throws Exception{
|
|
|
|
|
public void testRelationDiscovery() throws Exception {
|
|
|
|
|
@SuppressWarnings("rawtypes")
|
|
|
|
|
ISMDiscovery<Relation> relationDiscovery = new ISMDiscovery<>(Relation.class);
|
|
|
|
|
ISMDiscovery<BaseRelation> relationDiscovery = new ISMDiscovery<>(BaseRelation.class);
|
|
|
|
|
addDiscoveredModel(relationDiscovery);
|
|
|
|
|
relationDiscovery.discover();
|
|
|
|
|
|
|
|
|
|
for(@SuppressWarnings("rawtypes") Class<BaseRelation> relation : relationDiscovery.getDiscovered()) {
|
|
|
|
|
logger.info("{}", TypeBinder.serializeType(relation));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|