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
This commit is contained in:
parent
cd7a352223
commit
94a63e61f4
|
@ -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<EService, Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService, Facet>(
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue