From 14d79370608d43ebdab3b48a10c36589f466e3ff Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Tue, 2 Aug 2016 15:36:32 +0000 Subject: [PATCH] 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 --- .../dbinitialization/ContextCreation.java | 14 +++--- .../entitymanager/EntityRegistrationTest.java | 5 -- .../impl/ContextManagementImplTest.java | 2 +- .../impl/EntityManagementImplTest.java | 34 +++++++------ .../impl/SchemaManagementImplTest.java | 48 +++++++++++++++++++ 5 files changed, 77 insertions(+), 26 deletions(-) delete mode 100644 src/test/java/org/gcube/informationsystem/resourceregistry/entitymanager/EntityRegistrationTest.java create mode 100644 src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/SchemaManagementImplTest.java diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/dbinitialization/ContextCreation.java b/src/test/java/org/gcube/informationsystem/resourceregistry/dbinitialization/ContextCreation.java index 0e51123..63641c7 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/dbinitialization/ContextCreation.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/dbinitialization/ContextCreation.java @@ -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(); } diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/entitymanager/EntityRegistrationTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/entitymanager/EntityRegistrationTest.java deleted file mode 100644 index d577e7c..0000000 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/entitymanager/EntityRegistrationTest.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.gcube.informationsystem.resourceregistry.entitymanager; - -public class EntityRegistrationTest { - -} diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/ContextManagementImplTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/ContextManagementImplTest.java index 1ae57f0..2c7cd7a 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/ContextManagementImplTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/ContextManagementImplTest.java @@ -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); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/EntityManagementImplTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/EntityManagementImplTest.java index 9266733..120786f 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/EntityManagementImplTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/EntityManagementImplTest.java @@ -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{ diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/SchemaManagementImplTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/SchemaManagementImplTest.java new file mode 100644 index 0000000..140ebbd --- /dev/null +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/resources/impl/SchemaManagementImplTest.java @@ -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); + } + +}