Fixing test

This commit is contained in:
Luca Frosini 2021-02-23 11:44:09 +01:00
parent c443ae8c4e
commit 985d37a077
1 changed files with 33 additions and 4 deletions

View File

@ -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);