Fixing regular expression types creation problems

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@130948 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-08-02 15:36:32 +00:00
parent 841d7ee6df
commit 14d7937060
5 changed files with 77 additions and 26 deletions

View File

@ -5,10 +5,11 @@ package org.gcube.informationsystem.resourceregistry.dbinitialization;
import org.gcube.informationsystem.model.embedded.Embedded;
import org.gcube.informationsystem.model.entity.Entity;
import org.gcube.informationsystem.model.entity.facet.CPUFacet;
import org.gcube.informationsystem.model.entity.resource.Configuration;
import org.gcube.informationsystem.model.entity.facet.AccessPointInterfaceFacet;
import org.gcube.informationsystem.model.entity.resource.Actor;
import org.gcube.informationsystem.model.relation.Relation;
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
import org.gcube.informationsystem.model.relation.consistsof.HasContact;
import org.gcube.informationsystem.model.relation.isrelatedto.BelongsTo;
import org.junit.Test;
/**
@ -22,9 +23,10 @@ public class ContextCreation {
SchemaInitializator.addPackage(Embedded.class.getPackage());
SchemaInitializator.addPackage(Entity.class.getPackage());
SchemaInitializator.addPackage(Relation.class.getPackage());
SchemaInitializator.addPackage(CPUFacet.class.getPackage());
SchemaInitializator.addPackage(Hosts.class.getPackage());
SchemaInitializator.addPackage(Configuration.class.getPackage());
SchemaInitializator.addPackage(AccessPointInterfaceFacet.class.getPackage());
SchemaInitializator.addPackage(Actor.class.getPackage());
SchemaInitializator.addPackage(HasContact.class.getPackage());
SchemaInitializator.addPackage(BelongsTo.class.getPackage());
SchemaInitializator.createTypes();
}

View File

@ -1,5 +0,0 @@
package org.gcube.informationsystem.resourceregistry.entitymanager;
public class EntityRegistrationTest {
}

View File

@ -154,7 +154,7 @@ public class ContextManagementImplTest {
}
//@Test
@Test
public void devContextTest() throws ContextNotFoundException, ContextException {
String gcube = contextManagementImpl.create(null, "gcube");
logger.trace("/gcube : {}", gcube);

View File

@ -8,11 +8,13 @@ import java.io.StringWriter;
import org.codehaus.jettison.json.JSONObject;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.informationsystem.impl.entity.facet.CPUFacetImpl;
import org.gcube.informationsystem.impl.entity.facet.ContactFacetImpl;
import org.gcube.informationsystem.impl.utils.Entities;
import org.gcube.informationsystem.impl.utils.Utility;
import org.gcube.informationsystem.model.embedded.Header;
import org.gcube.informationsystem.model.entity.Entity;
import org.gcube.informationsystem.model.entity.facet.CPUFacet;
import org.gcube.informationsystem.model.entity.facet.ContactFacet;
import org.gcube.informationsystem.model.entity.resource.HostingNode;
import org.gcube.informationsystem.model.relation.ConsistsOf;
import org.gcube.informationsystem.model.relation.Relation;
@ -164,20 +166,24 @@ public class EntityManagementImplTest {
}
/*
* @Test public void testCreateFacet() throws Exception{
* ScopeProvider.instance.set("/gcube/devsec");
*
* CPUFacetImpl cpuFacetImpl = new CPUFacetImpl();
* cpuFacetImpl.setClockSpeed("1 GHz");
* cpuFacetImpl.setModelName("Opteron"); cpuFacetImpl.setVendor("AMD");
* StringWriter stringWriter = new StringWriter();
* Entities.marshal(cpuFacetImpl, stringWriter);
*
* String json =
* entityManagementImpl.createFacet(CPUFacet.class.getSimpleName(),
* stringWriter.toString()); logger.debug("Created : {}", json); }
*/
@Test
public void testCreateFacet() throws Exception {
ScopeProvider.instance.set("/gcube/devsec");
ContactFacet contactFacet = new ContactFacetImpl();
contactFacet.setName("Luca");
contactFacet.setSurname("Frosini");
contactFacet.setEMail("info@lcuafrosini.com");
StringWriter stringWriter = new StringWriter();
Entities.marshal(contactFacet, stringWriter);
logger.debug("Going to create : {}", stringWriter.toString());
String json = entityManagementImpl.createFacet(
ContactFacet.class.getSimpleName(), stringWriter.toString());
logger.debug("Created : {}", json);
}
/*
* @Test public void testReadFacet() throws Exception{

View File

@ -0,0 +1,48 @@
/**
*
*/
package org.gcube.informationsystem.resourceregistry.resources.impl;
import org.gcube.informationsystem.model.entity.facet.ContactFacet;
import org.gcube.informationsystem.model.entity.facet.LocationFacet;
import org.gcube.informationsystem.model.entity.facet.MemoryFacet;
import org.gcube.informationsystem.types.TypeBinder;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
public class SchemaManagementImplTest {
private static Logger logger = LoggerFactory.getLogger(SchemaManagementImplTest.class);
@Test
public void registerContactFacetEntity() throws Exception{
Class<?> clz = ContactFacet.class;
String json = TypeBinder.serializeType(clz);
logger.trace(json);
new SchemaManagementImpl().registerFacetSchema(json);
}
@Test
public void registerLocationFacetEntity() throws Exception{
Class<?> clz = LocationFacet.class;
String json = TypeBinder.serializeType(clz);
logger.trace(json);
new SchemaManagementImpl().registerFacetSchema(json);
}
@Test
public void registerMemoryFacetEntity() throws Exception{
Class<?> clz = MemoryFacet.class;
String json = TypeBinder.serializeType(clz);
logger.trace(json);
//new SchemaManagementImpl().registerFacetSchema(json);
}
}