From 94a63e61f48ede9d3a59a989e87a8cd5d178a06a Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Thu, 5 Oct 2017 09:44:18 +0000 Subject: [PATCH] Added test for resource update git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@154890 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../resourceregistry/er/ERManagementTest.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) 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); + } + + }