diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/ComplexTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/ComplexTest.java index 5f14e41..7f7a7ae 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/ComplexTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/multicontext/ComplexTest.java @@ -1,5 +1,7 @@ package org.gcube.informationsystem.resourceregistry.instances.multicontext; +import java.net.URI; +import java.util.Calendar; import java.util.Set; import java.util.UUID; @@ -17,9 +19,15 @@ import org.gcube.informationsystem.resourceregistry.instances.model.entities.Fac import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement; import org.gcube.informationsystem.resourceregistry.instances.model.relations.IsRelatedToManagement; import org.gcube.informationsystem.utils.ElementMapper; +import org.gcube.resourcemanagement.model.impl.entities.facets.EventFacetImpl; +import org.gcube.resourcemanagement.model.impl.entities.facets.StateFacetImpl; +import org.gcube.resourcemanagement.model.impl.properties.ValueSchemaImpl; import org.gcube.resourcemanagement.model.impl.relations.isrelatedto.ActivatesImpl; +import org.gcube.resourcemanagement.model.reference.entities.facets.EventFacet; +import org.gcube.resourcemanagement.model.reference.entities.facets.StateFacet; import org.gcube.resourcemanagement.model.reference.entities.resources.EService; import org.gcube.resourcemanagement.model.reference.entities.resources.HostingNode; +import org.gcube.resourcemanagement.model.reference.properties.ValueSchema; import org.gcube.resourcemanagement.model.reference.relations.isrelatedto.Activates; import org.junit.Assert; import org.junit.Test; @@ -37,25 +45,46 @@ public class ComplexTest extends MultiContextTest { ContextCache contextCache = ContextCache.getInstance(); contextCache.setContextCacheRenewal(contextCacheRenewal); + HostingNode hostingNode = ElementMapper.unmarshal(HostingNode.class, SmartgearResourcesTest.HOSTING_NODE); + + EventFacet hnEventFacet = new EventFacetImpl(); + hnEventFacet.setDate(Calendar.getInstance().getTime()); + ValueSchema hnEvent = new ValueSchemaImpl(); + hnEvent.setSchema(new URI("Schema")); + hnEvent.setValue("Created"); + hnEventFacet.setEvent(hnEvent); + hostingNode.addFacet(hnEventFacet); ResourceManagement hostingNodeManagement = new ResourceManagement(); hostingNodeManagement.setElementType(HostingNode.NAME); - hostingNodeManagement.setJson(SmartgearResourcesTest.HOSTING_NODE); + hostingNodeManagement.setJson(ElementMapper.marshal(hostingNode)); String hnJson = hostingNodeManagement.create(); logger.debug("Created : {}", hnJson); - HostingNode hostingNode = ElementMapper.unmarshal(HostingNode.class, hnJson); + hostingNode = ElementMapper.unmarshal(HostingNode.class, hnJson); logger.debug("Unmarshalled {} {}", HostingNode.NAME, hostingNode); /* Creating EService */ + EService eService = ElementMapper.unmarshal(EService.class, SmartgearResourcesTest.ESERVICE); + StateFacet stateFacet = new StateFacetImpl(); + stateFacet.setValue("ready"); + eService.addFacet(stateFacet); + + EventFacet eventFacet = new EventFacetImpl(); + eventFacet.setDate(Calendar.getInstance().getTime()); + ValueSchema event = new ValueSchemaImpl(); + event.setValue("Created"); + eventFacet.setEvent(event); + eService.addFacet(eventFacet); + ResourceManagement eServiceManagement = new ResourceManagement(); eServiceManagement.setElementType(EService.NAME); - eServiceManagement.setJson(SmartgearResourcesTest.ESERVICE); + eServiceManagement.setJson(ElementMapper.marshal(eService)); String eservicejson = eServiceManagement.create(); logger.debug("Created : {}", eservicejson); - EService eService = ElementMapper.unmarshal(EService.class, eservicejson); + eService = ElementMapper.unmarshal(EService.class, eservicejson); logger.debug("Unmarshalled {} {}", EService.NAME, eService);