diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/er/ERManagementTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/er/ERManagementTest.java index 909ae29..7687d01 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/er/ERManagementTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/er/ERManagementTest.java @@ -748,4 +748,70 @@ public class ERManagementTest extends ScopedTest { } + + + + @Test + public void testCreateUpdateDeleteEService() throws Exception { + EService eService = new EServiceImpl(); + + SoftwareFacet softwareFacet = new SoftwareFacetImpl(); + softwareFacet.setGroup("InformationSystem"); + softwareFacet.setName("resource-registry"); + softwareFacet.setVersion("1.1.0"); + IsIdentifiedBy isIdentifiedBy = new IsIdentifiedByImpl( + eService, softwareFacet, null); + eService.addFacet(isIdentifiedBy); + + AccessPointFacet accessPointFacet = new AccessPointFacetImpl(); + accessPointFacet.setEndpoint(new URI("http://localhost")); + accessPointFacet.setEntryName("port1"); + eService.addFacet(accessPointFacet); + + EventFacet eventFacet = new EventFacetImpl(); + eventFacet.setDate(Calendar.getInstance().getTime()); + eventFacet.setValue("Created"); + eService.addFacet(eventFacet); + + ServiceStateFacet serviceStateFacet = new ServiceStateFacetImpl(); + serviceStateFacet.setValue("ready"); + eService.addFacet(serviceStateFacet); + + LicenseFacet licenseFacet = new LicenseFacetImpl(); + licenseFacet.setName("EUPL"); + licenseFacet + .setTextURL(new URL( + "https://joinup.ec.europa.eu/community/eupl/og_page/european-union-public-licence-eupl-v11")); + eService.addFacet(licenseFacet); + + + ResourceManagement resourceManagement = new ResourceManagement(); + resourceManagement.setElementType(EService.NAME); + resourceManagement.setJSON(ISMapper.marshal(eService)); + String json = resourceManagement.create(); + + logger.trace("Created {}", json); + + eService = ISMapper.unmarshal(EService.class, json); + eService.getFacets(SoftwareFacet.class).get(0).setVersion("1.2.0"); + + resourceManagement = new ResourceManagement(); + resourceManagement.setUUID(eService.getHeader().getUUID()); + resourceManagement.setJSON(ISMapper.marshal(eService)); + + json = resourceManagement.update(); + logger.trace("Updated {}", json); + eService = ISMapper.unmarshal(EService.class, json); + + Assert.assertTrue(eService.getFacets(SoftwareFacet.class).get(0).getVersion().compareTo("1.2.0")==0); + + + resourceManagement = new ResourceManagement(); + resourceManagement.setUUID(eService.getHeader().getUUID()); + + boolean deleted = resourceManagement.delete(); + Assert.assertTrue(deleted); + } + + }