From 3cef651651aa7048a66addefcc9a52d25507c824 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Fri, 2 Mar 2018 15:26:19 +0000 Subject: [PATCH] Adde test git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/resource-registry-database-creator@164673 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../context/ContextManagementTest.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/test/java/org/gcube/informationsystem/resourceregistry/context/ContextManagementTest.java diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/context/ContextManagementTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/context/ContextManagementTest.java new file mode 100644 index 0000000..6e04167 --- /dev/null +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/context/ContextManagementTest.java @@ -0,0 +1,49 @@ +package org.gcube.informationsystem.resourceregistry.context; + +import java.io.IOException; +import java.util.UUID; + +import org.gcube.informationsystem.impl.entity.ContextImpl; +import org.gcube.informationsystem.impl.utils.ISMapper; +import org.gcube.informationsystem.model.entity.Context; +import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ContextManagementTest { + + private static Logger logger = LoggerFactory.getLogger(ContextManagementTest.class); + + protected Context read(UUID uuid) throws ResourceRegistryException, IOException { + ContextManagement contextManagement = new ContextManagement(); + contextManagement.setUUID(uuid); + String contextString = contextManagement.read(); + logger.debug("Read {}", contextString); + return ISMapper.unmarshal(Context.class, contextString); + } + + protected Context create(Context context) throws ResourceRegistryException, IOException { + ContextManagement contextManagement = new ContextManagement(); + contextManagement.setJSON(ISMapper.marshal(context)); + String contextString = contextManagement.create(); + logger.debug("Created {}", contextString); + Context c = ISMapper.unmarshal(Context.class, contextString); + return c; + } + + // @Test + public void createPreContext() throws Exception { + Context gcube = new ContextImpl("gcube"); + gcube = create(gcube); + + Context preprod = new ContextImpl("preprod"); + preprod.setParent(gcube); + preprod = create(preprod); + + Context parthenosVRE = new ContextImpl("PARTHENOS_PRE"); + parthenosVRE.setParent(preprod); + parthenosVRE = create(parthenosVRE); + + } + +}