Improving tests
This commit is contained in:
parent
25f2850114
commit
ec9b6665ca
|
@ -96,8 +96,96 @@ import com.orientechnologies.orient.core.record.ODirection;
|
||||||
*/
|
*/
|
||||||
public class ERManagementTest extends ContextTest {
|
public class ERManagementTest extends ContextTest {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory
|
private static Logger logger = LoggerFactory.getLogger(ERManagementTest.class);
|
||||||
.getLogger(ERManagementTest.class);
|
|
||||||
|
public static EService instantiateValidEService() throws Exception {
|
||||||
|
EService eService = new EServiceImpl();
|
||||||
|
|
||||||
|
SoftwareFacet softwareFacet = new SoftwareFacetImpl();
|
||||||
|
softwareFacet.setGroup("InformationSystem");
|
||||||
|
softwareFacet.setName("resource-registry");
|
||||||
|
softwareFacet.setVersion("1.1.0");
|
||||||
|
|
||||||
|
IsIdentifiedBy<Resource, Facet> isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(eService,
|
||||||
|
softwareFacet, null);
|
||||||
|
eService.addFacet(isIdentifiedBy);
|
||||||
|
|
||||||
|
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
|
||||||
|
accessPointFacet.setEndpoint(new URI("https://localhost"));
|
||||||
|
accessPointFacet.setEntryName("port1");
|
||||||
|
eService.addFacet(accessPointFacet);
|
||||||
|
|
||||||
|
EventFacet eventFacet = new EventFacetImpl();
|
||||||
|
eventFacet.setDate(Calendar.getInstance().getTime());
|
||||||
|
ValueSchema event = new ValueSchemaImpl();
|
||||||
|
event.setSchema(new URI("Schema"));
|
||||||
|
event.setValue("Created");
|
||||||
|
eventFacet.setEvent(event);
|
||||||
|
eService.addFacet(eventFacet);
|
||||||
|
|
||||||
|
StateFacet stateFacet = new StateFacetImpl();
|
||||||
|
stateFacet.setValue("ready");
|
||||||
|
eService.addFacet(stateFacet);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return eService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HostingNode instantiateValidHostinNode() throws Exception {
|
||||||
|
HostingNode hostingNode = new HostingNodeImpl();
|
||||||
|
|
||||||
|
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
|
||||||
|
networkingFacet.setIPAddress("146.48.87.183");
|
||||||
|
networkingFacet.setHostName("pc-frosini.isti.cnr.it");
|
||||||
|
networkingFacet.setDomainName("isti.cnr.it");
|
||||||
|
networkingFacet.setMask("255.255.248.0");
|
||||||
|
networkingFacet.setBroadcastAddress("146.48.87.255");
|
||||||
|
|
||||||
|
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedBy = new IsIdentifiedByImpl<HostingNode, NetworkingFacet>(
|
||||||
|
hostingNode, networkingFacet);
|
||||||
|
hostingNode.addFacet(isIdentifiedBy);
|
||||||
|
|
||||||
|
CPUFacet cpuFacet = new CPUFacetImpl();
|
||||||
|
cpuFacet.setClockSpeed("1 GHz");
|
||||||
|
cpuFacet.setModel("Opteron");
|
||||||
|
cpuFacet.setVendor("AMD");
|
||||||
|
hostingNode.addFacet(cpuFacet);
|
||||||
|
|
||||||
|
MemoryFacet persistentMemoryFacet = new MemoryFacetImpl();
|
||||||
|
persistentMemoryFacet.setSize(1024);
|
||||||
|
persistentMemoryFacet.setUnit(MemoryUnit.GB);
|
||||||
|
persistentMemoryFacet.setUsed(512);
|
||||||
|
HasPersistentMemory<HostingNode, MemoryFacet> hasPersistentMemory = new HasPersistentMemoryImpl<HostingNode, MemoryFacet>(
|
||||||
|
hostingNode, persistentMemoryFacet);
|
||||||
|
hostingNode.addFacet(hasPersistentMemory);
|
||||||
|
|
||||||
|
MemoryFacet volatileMemoryFacet = new MemoryFacetImpl();
|
||||||
|
volatileMemoryFacet.setSize(8);
|
||||||
|
volatileMemoryFacet.setUnit(MemoryUnit.GB);
|
||||||
|
volatileMemoryFacet.setUsed(4);
|
||||||
|
HasVolatileMemory<HostingNode, MemoryFacet> hasVolatileMemory = new HasVolatileMemoryImpl<HostingNode, MemoryFacet>(
|
||||||
|
hostingNode, volatileMemoryFacet);
|
||||||
|
hostingNode.addFacet(hasVolatileMemory);
|
||||||
|
|
||||||
|
StateFacet hnStateFacet = new StateFacetImpl();
|
||||||
|
hnStateFacet.setValue("certified");
|
||||||
|
hostingNode.addFacet(hnStateFacet);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return hostingNode;
|
||||||
|
}
|
||||||
|
|
||||||
@Test(expected = SchemaViolationException.class)
|
@Test(expected = SchemaViolationException.class)
|
||||||
public void testCreateFacet() throws Exception {
|
public void testCreateFacet() throws Exception {
|
||||||
|
@ -117,12 +205,11 @@ public class ERManagementTest extends ContextTest {
|
||||||
facetManagement.create();
|
facetManagement.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateFacetWithEncrypted() throws Exception {
|
public void testCreateFacetWithEncrypted() throws Exception {
|
||||||
/*
|
/*
|
||||||
* A facet cannot be created per se. Going to create a Configuration which
|
* A facet cannot be created per se. Going to create a Configuration which does
|
||||||
* does not impose any particular constraint except the IdentifierFact
|
* not impose any particular constraint except the IdentifierFact
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Configuration configuration = new ConfigurationImpl();
|
Configuration configuration = new ConfigurationImpl();
|
||||||
|
@ -132,10 +219,10 @@ public class ERManagementTest extends ContextTest {
|
||||||
identifierFacet.setValue("MyID");
|
identifierFacet.setValue("MyID");
|
||||||
identifierFacet.setPersistent(false);
|
identifierFacet.setPersistent(false);
|
||||||
|
|
||||||
IsIdentifiedBy<Configuration, IdentifierFacet> isIdentifiedBy = new IsIdentifiedByImpl<Configuration, IdentifierFacet>(configuration, identifierFacet);
|
IsIdentifiedBy<Configuration, IdentifierFacet> isIdentifiedBy = new IsIdentifiedByImpl<Configuration, IdentifierFacet>(
|
||||||
|
configuration, identifierFacet);
|
||||||
configuration.addFacet(isIdentifiedBy);
|
configuration.addFacet(isIdentifiedBy);
|
||||||
|
|
||||||
|
|
||||||
CPUFacet cpuFacet = new CPUFacetImpl();
|
CPUFacet cpuFacet = new CPUFacetImpl();
|
||||||
cpuFacet.setClockSpeed("1 GHz");
|
cpuFacet.setClockSpeed("1 GHz");
|
||||||
cpuFacet.setModel("Opteron");
|
cpuFacet.setModel("Opteron");
|
||||||
|
@ -156,23 +243,18 @@ public class ERManagementTest extends ContextTest {
|
||||||
/* A facet cannot be created per se */
|
/* A facet cannot be created per se */
|
||||||
String configurationJsonString = resourceManagement.create();
|
String configurationJsonString = resourceManagement.create();
|
||||||
|
|
||||||
|
Configuration createdConfiguration = ElementMapper.unmarshal(Configuration.class, configurationJsonString);
|
||||||
Configuration createdConfiguration = ElementMapper.unmarshal(Configuration.class,
|
logger.debug("Created:\nRaw Json : {}\nUnmarshalled : {}", configurationJsonString, createdConfiguration);
|
||||||
configurationJsonString);
|
|
||||||
logger.debug("Created:\nRaw Json : {}\nUnmarshalled : {}",
|
|
||||||
configurationJsonString, createdConfiguration);
|
|
||||||
|
|
||||||
CPUFacet readCpuFacet = configuration.getFacets(CPUFacet.class).get(0);
|
CPUFacet readCpuFacet = configuration.getFacets(CPUFacet.class).get(0);
|
||||||
String gotEncryptedValue = ((Encrypted) readCpuFacet.getAdditionalProperty("test")).getEncryptedValue();
|
String gotEncryptedValue = ((Encrypted) readCpuFacet.getAdditionalProperty("test")).getEncryptedValue();
|
||||||
Assert.assertTrue(gotEncryptedValue.compareTo(encryptedValue)==0);
|
Assert.assertTrue(gotEncryptedValue.compareTo(encryptedValue) == 0);
|
||||||
String gotPlainValue = EncryptedImpl.decrypt(gotEncryptedValue);
|
String gotPlainValue = EncryptedImpl.decrypt(gotEncryptedValue);
|
||||||
Assert.assertTrue(gotPlainValue.compareTo(plainValue)==0);
|
Assert.assertTrue(gotPlainValue.compareTo(plainValue) == 0);
|
||||||
|
|
||||||
resourceManagement.delete();
|
resourceManagement.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreatePropertyTypeNotInSchema() throws Exception {
|
public void testCreatePropertyTypeNotInSchema() throws Exception {
|
||||||
|
|
||||||
|
@ -208,10 +290,10 @@ public class ERManagementTest extends ContextTest {
|
||||||
Assert.assertTrue(apf.getAdditionalProperty("Enc") instanceof Encrypted);
|
Assert.assertTrue(apf.getAdditionalProperty("Enc") instanceof Encrypted);
|
||||||
Encrypted enc = (Encrypted) apf.getAdditionalProperty("Enc");
|
Encrypted enc = (Encrypted) apf.getAdditionalProperty("Enc");
|
||||||
String encValue = enc.getEncryptedValue();
|
String encValue = enc.getEncryptedValue();
|
||||||
Assert.assertTrue(encValue.compareTo(encryptedValue)==0);
|
Assert.assertTrue(encValue.compareTo(encryptedValue) == 0);
|
||||||
String decryptedValue = EncryptedImpl.decrypt(encValue);
|
String decryptedValue = EncryptedImpl.decrypt(encValue);
|
||||||
Assert.assertTrue(decryptedValue.compareTo("Encrypted")==0);
|
Assert.assertTrue(decryptedValue.compareTo("Encrypted") == 0);
|
||||||
Assert.assertTrue(((String)apf.getAdditionalProperty("Test")).compareTo("MyTest")==0);
|
Assert.assertTrue(((String) apf.getAdditionalProperty("Test")).compareTo("MyTest") == 0);
|
||||||
|
|
||||||
UUID uuid = apf.getHeader().getUUID();
|
UUID uuid = apf.getHeader().getUUID();
|
||||||
|
|
||||||
|
@ -230,8 +312,8 @@ public class ERManagementTest extends ContextTest {
|
||||||
softwareFacet.setGroup("information-system");
|
softwareFacet.setGroup("information-system");
|
||||||
softwareFacet.setName("is-exporter-se-plugin");
|
softwareFacet.setName("is-exporter-se-plugin");
|
||||||
softwareFacet.setVersion("1.0.0");
|
softwareFacet.setVersion("1.0.0");
|
||||||
IsIdentifiedBy<RunningPlugin, Facet> isIdentifiedBy = new IsIdentifiedByImpl<>(
|
IsIdentifiedBy<RunningPlugin, Facet> isIdentifiedBy = new IsIdentifiedByImpl<>(runningPlugin, softwareFacet,
|
||||||
runningPlugin, softwareFacet, null);
|
null);
|
||||||
runningPlugin.addFacet(isIdentifiedBy);
|
runningPlugin.addFacet(isIdentifiedBy);
|
||||||
|
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
|
@ -251,44 +333,9 @@ public class ERManagementTest extends ContextTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateEService() throws Exception {
|
public void testCreateEService() throws Exception {
|
||||||
EService eService = new EServiceImpl();
|
EService eService = ERManagementTest.instantiateValidEService();
|
||||||
|
|
||||||
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("https://localhost"));
|
|
||||||
accessPointFacet.setEntryName("port1");
|
|
||||||
eService.addFacet(accessPointFacet);
|
|
||||||
|
|
||||||
EventFacet eventFacet = new EventFacetImpl();
|
|
||||||
eventFacet.setDate(Calendar.getInstance().getTime());
|
|
||||||
ValueSchema event = new ValueSchemaImpl();
|
|
||||||
event.setValue("Created");
|
|
||||||
event.setSchema(new URI(""));
|
|
||||||
eventFacet.setEvent(event);
|
|
||||||
eService.addFacet(eventFacet);
|
|
||||||
|
|
||||||
StateFacet stateFacet = new StateFacetImpl();
|
|
||||||
stateFacet.setValue("ready");
|
|
||||||
eService.addFacet(stateFacet);
|
|
||||||
|
|
||||||
|
|
||||||
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 resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setElementType(EService.NAME);
|
resourceManagement.setElementType(EService.NAME);
|
||||||
|
@ -306,28 +353,27 @@ public class ERManagementTest extends ContextTest {
|
||||||
Assert.assertTrue(deleted);
|
Assert.assertTrue(deleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void testReadResource() throws Exception {
|
public void testReadResource() throws Exception {
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(UUID.fromString("26da57ee-33bd-4c4b-8aef-9206b61c329e"));
|
resourceManagement.setUUID(UUID.fromString("26da57ee-33bd-4c4b-8aef-9206b61c329e"));
|
||||||
|
|
||||||
String read= resourceManagement.read().toString();
|
String read = resourceManagement.read().toString();
|
||||||
logger.debug(read);
|
logger.debug(read);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void testDeleteResource() throws Exception {
|
public void testDeleteResource() throws Exception {
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(UUID
|
resourceManagement.setUUID(UUID.fromString("64635295-7ced-4931-a55f-40fc8199b280"));
|
||||||
.fromString("64635295-7ced-4931-a55f-40fc8199b280"));
|
|
||||||
|
|
||||||
boolean deleted = resourceManagement.delete();
|
boolean deleted = resourceManagement.delete();
|
||||||
Assert.assertTrue(deleted);
|
Assert.assertTrue(deleted);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=ResourceRegistryException.class)
|
@Test(expected = ResourceRegistryException.class)
|
||||||
public void testCreateAbstractEntity() throws Exception {
|
public void testCreateAbstractEntity() throws Exception {
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setElementType(Actor.NAME);
|
resourceManagement.setElementType(Actor.NAME);
|
||||||
|
@ -337,7 +383,7 @@ public class ERManagementTest extends ContextTest {
|
||||||
resourceManagement.create();
|
resourceManagement.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=ResourceRegistryException.class)
|
@Test(expected = ResourceRegistryException.class)
|
||||||
public void testCreateAnEntityDifferentFromDeclared() throws Exception {
|
public void testCreateAnEntityDifferentFromDeclared() throws Exception {
|
||||||
SimpleFacet simpleFacet = new SimpleFacetImpl();
|
SimpleFacet simpleFacet = new SimpleFacetImpl();
|
||||||
|
|
||||||
|
@ -366,17 +412,12 @@ public class ERManagementTest extends ContextTest {
|
||||||
facetManagement.setJson(json);
|
facetManagement.setJson(json);
|
||||||
|
|
||||||
String cpuFacetJson = facetManagement.create();
|
String cpuFacetJson = facetManagement.create();
|
||||||
CPUFacet createdCpuFacet = ElementMapper.unmarshal(CPUFacet.class,
|
CPUFacet createdCpuFacet = ElementMapper.unmarshal(CPUFacet.class, cpuFacetJson);
|
||||||
cpuFacetJson);
|
logger.debug("Created:\nRaw Json : {}\nUnmarshalled : {}", cpuFacetJson, createdCpuFacet);
|
||||||
logger.debug("Created:\nRaw Json : {}\nUnmarshalled : {}",
|
|
||||||
cpuFacetJson, createdCpuFacet);
|
|
||||||
|
|
||||||
Assert.assertTrue(cpuFacet.getClockSpeed().compareTo(
|
Assert.assertTrue(cpuFacet.getClockSpeed().compareTo(createdCpuFacet.getClockSpeed()) == 0);
|
||||||
createdCpuFacet.getClockSpeed()) == 0);
|
Assert.assertTrue(cpuFacet.getModel().compareTo(createdCpuFacet.getModel()) == 0);
|
||||||
Assert.assertTrue(cpuFacet.getModel().compareTo(
|
Assert.assertTrue(cpuFacet.getVendor().compareTo(createdCpuFacet.getVendor()) == 0);
|
||||||
createdCpuFacet.getModel()) == 0);
|
|
||||||
Assert.assertTrue(cpuFacet.getVendor().compareTo(
|
|
||||||
createdCpuFacet.getVendor()) == 0);
|
|
||||||
|
|
||||||
UUID uuid = createdCpuFacet.getHeader().getUUID();
|
UUID uuid = createdCpuFacet.getHeader().getUUID();
|
||||||
|
|
||||||
|
@ -385,14 +426,10 @@ public class ERManagementTest extends ContextTest {
|
||||||
|
|
||||||
String readJson = facetManagement.read().toString();
|
String readJson = facetManagement.read().toString();
|
||||||
CPUFacet readCpuFacet = ElementMapper.unmarshal(CPUFacet.class, readJson);
|
CPUFacet readCpuFacet = ElementMapper.unmarshal(CPUFacet.class, readJson);
|
||||||
logger.debug("Read:\nRaw Json : {}\nUnmarshalled : {}", readJson,
|
logger.debug("Read:\nRaw Json : {}\nUnmarshalled : {}", readJson, readCpuFacet);
|
||||||
readCpuFacet);
|
Assert.assertTrue(cpuFacet.getClockSpeed().compareTo(readCpuFacet.getClockSpeed()) == 0);
|
||||||
Assert.assertTrue(cpuFacet.getClockSpeed().compareTo(
|
Assert.assertTrue(cpuFacet.getModel().compareTo(readCpuFacet.getModel()) == 0);
|
||||||
readCpuFacet.getClockSpeed()) == 0);
|
Assert.assertTrue(cpuFacet.getVendor().compareTo(readCpuFacet.getVendor()) == 0);
|
||||||
Assert.assertTrue(cpuFacet.getModel()
|
|
||||||
.compareTo(readCpuFacet.getModel()) == 0);
|
|
||||||
Assert.assertTrue(cpuFacet.getVendor().compareTo(
|
|
||||||
readCpuFacet.getVendor()) == 0);
|
|
||||||
Assert.assertTrue(uuid.compareTo(readCpuFacet.getHeader().getUUID()) == 0);
|
Assert.assertTrue(uuid.compareTo(readCpuFacet.getHeader().getUUID()) == 0);
|
||||||
|
|
||||||
ContextTest.setContextByName(DEFAULT_TEST_SCOPE_ANOTHER_USER);
|
ContextTest.setContextByName(DEFAULT_TEST_SCOPE_ANOTHER_USER);
|
||||||
|
@ -404,51 +441,35 @@ public class ERManagementTest extends ContextTest {
|
||||||
|
|
||||||
String additionPropertyKey = "My";
|
String additionPropertyKey = "My";
|
||||||
String additionPropertyValue = "Test";
|
String additionPropertyValue = "Test";
|
||||||
readCpuFacet.setAdditionalProperty(additionPropertyKey,
|
readCpuFacet.setAdditionalProperty(additionPropertyKey, additionPropertyValue);
|
||||||
additionPropertyValue);
|
|
||||||
|
|
||||||
facetManagement = new FacetManagement();
|
facetManagement = new FacetManagement();
|
||||||
facetManagement.setUUID(uuid);
|
facetManagement.setUUID(uuid);
|
||||||
facetManagement.setJson(ElementMapper.marshal(readCpuFacet));
|
facetManagement.setJson(ElementMapper.marshal(readCpuFacet));
|
||||||
|
|
||||||
String updatedJson = facetManagement.update();
|
String updatedJson = facetManagement.update();
|
||||||
CPUFacet updatedCpuFacet = ElementMapper.unmarshal(CPUFacet.class,
|
CPUFacet updatedCpuFacet = ElementMapper.unmarshal(CPUFacet.class, updatedJson);
|
||||||
updatedJson);
|
logger.debug("Updated:\nRaw Json : {}\nUnmarshalled : {}", updatedJson, updatedCpuFacet);
|
||||||
logger.debug("Updated:\nRaw Json : {}\nUnmarshalled : {}", updatedJson,
|
Assert.assertTrue(updatedCpuFacet.getClockSpeed().compareTo(newClockSpeed) == 0);
|
||||||
updatedCpuFacet);
|
Assert.assertTrue(readCpuFacet.getModel().compareTo(updatedCpuFacet.getModel()) == 0);
|
||||||
Assert.assertTrue(updatedCpuFacet.getClockSpeed().compareTo(
|
Assert.assertTrue(updatedCpuFacet.getVendor().compareTo(newVendor) == 0);
|
||||||
newClockSpeed) == 0);
|
Assert.assertTrue(((String) updatedCpuFacet.getAdditionalProperty(additionPropertyKey))
|
||||||
Assert.assertTrue(readCpuFacet.getModel().compareTo(
|
.compareTo((String) readCpuFacet.getAdditionalProperty(additionPropertyKey)) == 0);
|
||||||
updatedCpuFacet.getModel()) == 0);
|
|
||||||
Assert.assertTrue(updatedCpuFacet.getVendor().compareTo(
|
|
||||||
newVendor) == 0);
|
|
||||||
Assert.assertTrue(((String) updatedCpuFacet
|
|
||||||
.getAdditionalProperty(additionPropertyKey))
|
|
||||||
.compareTo((String) readCpuFacet
|
|
||||||
.getAdditionalProperty(additionPropertyKey)) == 0);
|
|
||||||
Assert.assertTrue(uuid.compareTo(updatedCpuFacet.getHeader().getUUID()) == 0);
|
Assert.assertTrue(uuid.compareTo(updatedCpuFacet.getHeader().getUUID()) == 0);
|
||||||
String user = AuthorizationProvider.instance.get().getClient().getId();
|
String user = AuthorizationProvider.instance.get().getClient().getId();
|
||||||
Assert.assertTrue(updatedCpuFacet.getHeader().getModifiedBy().compareTo(user)==0);
|
Assert.assertTrue(updatedCpuFacet.getHeader().getModifiedBy().compareTo(user) == 0);
|
||||||
|
|
||||||
|
|
||||||
facetManagement = new FacetManagement();
|
facetManagement = new FacetManagement();
|
||||||
facetManagement.setUUID(uuid);
|
facetManagement.setUUID(uuid);
|
||||||
|
|
||||||
String readUpdatedJson = facetManagement.read().toString();
|
String readUpdatedJson = facetManagement.read().toString();
|
||||||
CPUFacet readUpdatedCpuFacet = ElementMapper.unmarshal(CPUFacet.class,
|
CPUFacet readUpdatedCpuFacet = ElementMapper.unmarshal(CPUFacet.class, readUpdatedJson);
|
||||||
readUpdatedJson);
|
logger.debug("Read Updated:\nRaw Json : {}\nUnmarshalled : {}", readUpdatedJson, readUpdatedCpuFacet);
|
||||||
logger.debug("Read Updated:\nRaw Json : {}\nUnmarshalled : {}",
|
Assert.assertTrue(updatedCpuFacet.getClockSpeed().compareTo(readUpdatedCpuFacet.getClockSpeed()) == 0);
|
||||||
readUpdatedJson, readUpdatedCpuFacet);
|
Assert.assertTrue(updatedCpuFacet.getModel().compareTo(readUpdatedCpuFacet.getModel()) == 0);
|
||||||
Assert.assertTrue(updatedCpuFacet.getClockSpeed().compareTo(
|
Assert.assertTrue(updatedCpuFacet.getVendor().compareTo(readUpdatedCpuFacet.getVendor()) == 0);
|
||||||
readUpdatedCpuFacet.getClockSpeed()) == 0);
|
Assert.assertTrue(((String) updatedCpuFacet.getAdditionalProperty(additionPropertyKey))
|
||||||
Assert.assertTrue(updatedCpuFacet.getModel().compareTo(
|
.compareTo((String) readUpdatedCpuFacet.getAdditionalProperty(additionPropertyKey)) == 0);
|
||||||
readUpdatedCpuFacet.getModel()) == 0);
|
|
||||||
Assert.assertTrue(updatedCpuFacet.getVendor().compareTo(
|
|
||||||
readUpdatedCpuFacet.getVendor()) == 0);
|
|
||||||
Assert.assertTrue(((String) updatedCpuFacet
|
|
||||||
.getAdditionalProperty(additionPropertyKey))
|
|
||||||
.compareTo((String) readUpdatedCpuFacet
|
|
||||||
.getAdditionalProperty(additionPropertyKey)) == 0);
|
|
||||||
Assert.assertTrue(uuid.compareTo(updatedCpuFacet.getHeader().getUUID()) == 0);
|
Assert.assertTrue(uuid.compareTo(updatedCpuFacet.getHeader().getUUID()) == 0);
|
||||||
|
|
||||||
facetManagement = new FacetManagement();
|
facetManagement = new FacetManagement();
|
||||||
|
@ -458,45 +479,10 @@ public class ERManagementTest extends ContextTest {
|
||||||
Assert.assertTrue(deleted);
|
Assert.assertTrue(deleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Map<String, Resource> createHostingNodeAndEService() throws Exception {
|
public Map<String, Resource> createHostingNodeAndEService() throws Exception {
|
||||||
Map<String, Resource> map = new HashMap<>();
|
Map<String, Resource> map = new HashMap<>();
|
||||||
|
|
||||||
EService eService = new EServiceImpl();
|
EService eService = ERManagementTest.instantiateValidEService();
|
||||||
|
|
||||||
SoftwareFacet softwareFacet = new SoftwareFacetImpl();
|
|
||||||
softwareFacet.setGroup("InformationSystem");
|
|
||||||
softwareFacet.setName("resource-registry");
|
|
||||||
softwareFacet.setVersion("1.1.0");
|
|
||||||
|
|
||||||
IsIdentifiedBy<Resource, Facet> isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(
|
|
||||||
eService, softwareFacet, null);
|
|
||||||
eService.addFacet(isIdentifiedBy);
|
|
||||||
|
|
||||||
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
|
|
||||||
accessPointFacet.setEndpoint(new URI("https://localhost"));
|
|
||||||
accessPointFacet.setEntryName("port1");
|
|
||||||
eService.addFacet(accessPointFacet);
|
|
||||||
|
|
||||||
EventFacet eventFacet = new EventFacetImpl();
|
|
||||||
eventFacet.setDate(Calendar.getInstance().getTime());
|
|
||||||
ValueSchema event = new ValueSchemaImpl();
|
|
||||||
event.setSchema(new URI("Schema"));
|
|
||||||
event.setValue("Created");
|
|
||||||
eventFacet.setEvent(event);
|
|
||||||
eService.addFacet(eventFacet);
|
|
||||||
|
|
||||||
StateFacet stateFacet = new StateFacetImpl();
|
|
||||||
stateFacet.setValue("ready");
|
|
||||||
eService.addFacet(stateFacet);
|
|
||||||
|
|
||||||
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 resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setElementType(EService.NAME);
|
resourceManagement.setElementType(EService.NAME);
|
||||||
|
@ -508,58 +494,12 @@ public class ERManagementTest extends ContextTest {
|
||||||
logger.debug("Unmarshalled {} {}", EService.NAME, eService);
|
logger.debug("Unmarshalled {} {}", EService.NAME, eService);
|
||||||
map.put(EService.NAME, eService);
|
map.put(EService.NAME, eService);
|
||||||
|
|
||||||
|
HostingNode hostingNode = ERManagementTest.instantiateValidHostinNode();
|
||||||
|
|
||||||
|
|
||||||
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
|
|
||||||
networkingFacet.setIPAddress("146.48.87.183");
|
|
||||||
networkingFacet.setHostName("pc-frosini.isti.cnr.it");
|
|
||||||
networkingFacet.setDomainName("isti.cnr.it");
|
|
||||||
networkingFacet.setMask("255.255.248.0");
|
|
||||||
networkingFacet.setBroadcastAddress("146.48.87.255");
|
|
||||||
|
|
||||||
HostingNode hostingNode = new HostingNodeImpl();
|
|
||||||
isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(hostingNode,
|
|
||||||
networkingFacet, null);
|
|
||||||
hostingNode.addFacet(isIdentifiedBy);
|
|
||||||
|
|
||||||
CPUFacet cpuFacet = new CPUFacetImpl();
|
|
||||||
cpuFacet.setClockSpeed("1 GHz");
|
|
||||||
cpuFacet.setModel("Opteron");
|
|
||||||
cpuFacet.setVendor("AMD");
|
|
||||||
hostingNode.addFacet(cpuFacet);
|
|
||||||
|
|
||||||
MemoryFacet persistentMemoryFacet = new MemoryFacetImpl();
|
|
||||||
persistentMemoryFacet.setSize(1024);
|
|
||||||
persistentMemoryFacet.setUnit(MemoryUnit.GB);
|
|
||||||
persistentMemoryFacet.setUsed(512);
|
|
||||||
HasPersistentMemory<HostingNode, MemoryFacet> hasPersistentMemory = new HasPersistentMemoryImpl<HostingNode, MemoryFacet>(hostingNode, persistentMemoryFacet);
|
|
||||||
hostingNode.addFacet(hasPersistentMemory);
|
|
||||||
|
|
||||||
MemoryFacet volatileMemoryFacet = new MemoryFacetImpl();
|
|
||||||
volatileMemoryFacet.setSize(8);
|
|
||||||
volatileMemoryFacet.setUnit(MemoryUnit.GB);
|
|
||||||
volatileMemoryFacet.setUsed(4);
|
|
||||||
HasVolatileMemory<HostingNode, MemoryFacet> hasVolatileMemory = new HasVolatileMemoryImpl<HostingNode, MemoryFacet>(hostingNode, volatileMemoryFacet);
|
|
||||||
hostingNode.addFacet(hasVolatileMemory);
|
|
||||||
|
|
||||||
StateFacet hnStateFacet = new StateFacetImpl();
|
|
||||||
hnStateFacet.setValue("certified");
|
|
||||||
hostingNode.addFacet(hnStateFacet);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
|
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
|
||||||
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
|
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
|
||||||
|
Activates<HostingNode, EService> activates = new ActivatesImpl<HostingNode, EService>(hostingNode, eService,
|
||||||
Activates<HostingNode, EService> activates = new ActivatesImpl<HostingNode, EService>(
|
propagationConstraint);
|
||||||
hostingNode, eService, propagationConstraint);
|
|
||||||
hostingNode.attachResource(activates);
|
hostingNode.attachResource(activates);
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
|
@ -590,7 +530,6 @@ public class ERManagementTest extends ContextTest {
|
||||||
Assert.assertTrue(deleted);
|
Assert.assertTrue(deleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateConsistsOfBeetweenResources() throws Exception {
|
public void testCreateConsistsOfBeetweenResources() throws Exception {
|
||||||
Map<String, Resource> map = createHostingNodeAndEService();
|
Map<String, Resource> map = createHostingNodeAndEService();
|
||||||
|
@ -604,7 +543,8 @@ public class ERManagementTest extends ContextTest {
|
||||||
SimpleFacet fakeEServiceAsSimpleFacet = new SimpleFacetImpl();
|
SimpleFacet fakeEServiceAsSimpleFacet = new SimpleFacetImpl();
|
||||||
fakeEServiceAsSimpleFacet.setHeader(new HeaderImpl(eServiceUUID));
|
fakeEServiceAsSimpleFacet.setHeader(new HeaderImpl(eServiceUUID));
|
||||||
|
|
||||||
ConsistsOf<Resource, Facet> consistsOf = new ConsistsOfImpl<Resource, Facet>(hostingNode, fakeEServiceAsSimpleFacet, null);
|
ConsistsOf<Resource, Facet> consistsOf = new ConsistsOfImpl<Resource, Facet>(hostingNode,
|
||||||
|
fakeEServiceAsSimpleFacet, null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement();
|
ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement();
|
||||||
|
@ -616,7 +556,6 @@ public class ERManagementTest extends ContextTest {
|
||||||
consistsOfManagement.create();
|
consistsOfManagement.create();
|
||||||
logger.debug("The creation terminated correctly. This should not happen");
|
logger.debug("The creation terminated correctly. This should not happen");
|
||||||
|
|
||||||
|
|
||||||
} catch (ResourceRegistryException e) {
|
} catch (ResourceRegistryException e) {
|
||||||
logger.error("Sounds good. A {} cannot be created between two resources", ConsistsOf.NAME, e);
|
logger.error("Sounds good. A {} cannot be created between two resources", ConsistsOf.NAME, e);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -642,7 +581,6 @@ public class ERManagementTest extends ContextTest {
|
||||||
|
|
||||||
Facet shared = hostingNode.getConsistsOf().get(0).getTarget();
|
Facet shared = hostingNode.getConsistsOf().get(0).getTarget();
|
||||||
|
|
||||||
|
|
||||||
ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement();
|
ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement();
|
||||||
consistsOfManagement.setElementType(ConsistsOf.NAME);
|
consistsOfManagement.setElementType(ConsistsOf.NAME);
|
||||||
consistsOfManagement.setJson("{}");
|
consistsOfManagement.setJson("{}");
|
||||||
|
@ -670,151 +608,135 @@ public class ERManagementTest extends ContextTest {
|
||||||
String read = facetManagement.read().toString();
|
String read = facetManagement.read().toString();
|
||||||
logger.debug("Read facet is : {}", read);
|
logger.debug("Read facet is : {}", read);
|
||||||
throw new Exception(String.format("Shared Facet %s was not deleted", shared));
|
throw new Exception(String.format("Shared Facet %s was not deleted", shared));
|
||||||
}catch(FacetNotFoundException e){
|
} catch (FacetNotFoundException e) {
|
||||||
logger.debug("Shared Facet was not foud as expected");
|
logger.debug("Shared Facet was not foud as expected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@Test
|
* @Test public void testCreateResourceAndFacet() throws Exception {
|
||||||
public void testCreateResourceAndFacet() throws Exception {
|
* ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
* resourceManagement.setElementType(HostingNode.NAME);
|
||||||
resourceManagement.setElementType(HostingNode.NAME);
|
* resourceManagement.setJson("{}");
|
||||||
resourceManagement.setJson("{}");
|
*
|
||||||
|
* String json = resourceManagement.create(); HostingNode hostingNode =
|
||||||
String json = resourceManagement.create();
|
* ElementMapper.unmarshal(HostingNode.class, json); UUID resourceUUID =
|
||||||
HostingNode hostingNode = ElementMapper.unmarshal(HostingNode.class, json);
|
* hostingNode.getHeader().getUUID();
|
||||||
UUID resourceUUID = hostingNode.getHeader().getUUID();
|
*
|
||||||
|
* CPUFacet cpuFacet = new CPUFacetImpl(); cpuFacet.setClockSpeed("1 GHz");
|
||||||
CPUFacet cpuFacet = new CPUFacetImpl();
|
* cpuFacet.setModel("Opteron"); cpuFacet.setVendor("AMD");
|
||||||
cpuFacet.setClockSpeed("1 GHz");
|
*
|
||||||
cpuFacet.setModel("Opteron");
|
* FacetManagement facetManagement = new FacetManagement();
|
||||||
cpuFacet.setVendor("AMD");
|
* facetManagement.setJson(ElementMapper.marshal(cpuFacet));
|
||||||
|
* facetManagement.setElementType(CPUFacet.NAME); json =
|
||||||
FacetManagement facetManagement = new FacetManagement();
|
* facetManagement.create(); CPUFacet createdCPUFacet =
|
||||||
facetManagement.setJson(ElementMapper.marshal(cpuFacet));
|
* ElementMapper.unmarshal(CPUFacet.class, json);
|
||||||
facetManagement.setElementType(CPUFacet.NAME);
|
*
|
||||||
json = facetManagement.create();
|
* ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement();
|
||||||
CPUFacet createdCPUFacet = ElementMapper.unmarshal(CPUFacet.class, json);
|
* consistsOfManagement.setElementType(ConsistsOf.NAME); ConsistsOf<HostingNode,
|
||||||
|
* CPUFacet> consistsOf = new ConsistsOfImpl<>(hostingNode, createdCPUFacet,
|
||||||
ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement();
|
* null); consistsOfManagement.setJson(ElementMapper.marshal(consistsOf)); json
|
||||||
consistsOfManagement.setElementType(ConsistsOf.NAME);
|
* = consistsOfManagement.create();
|
||||||
ConsistsOf<HostingNode, CPUFacet> consistsOf = new ConsistsOfImpl<>(hostingNode, createdCPUFacet, null);
|
*
|
||||||
consistsOfManagement.setJson(ElementMapper.marshal(consistsOf));
|
* logger.debug("Facet attached : {}", json);
|
||||||
json = consistsOfManagement.create();
|
*
|
||||||
|
* UUID consistOfUUID = Utility.getUUIDFromJSONString(json);
|
||||||
logger.debug("Facet attached : {}", json);
|
*
|
||||||
|
* consistsOfManagement = new ConsistsOfManagement();
|
||||||
UUID consistOfUUID = Utility.getUUIDFromJSONString(json);
|
* consistsOfManagement.setUUID(consistOfUUID);
|
||||||
|
*
|
||||||
consistsOfManagement = new ConsistsOfManagement();
|
* boolean detached = consistsOfManagement.delete();
|
||||||
consistsOfManagement.setUUID(consistOfUUID);
|
*
|
||||||
|
* if (detached) { logger.trace("{} {} with uuid {} removed successfully",
|
||||||
boolean detached = consistsOfManagement.delete();
|
* ConsistsOf.NAME, Relation.NAME, consistOfUUID); } else { String error =
|
||||||
|
* String.format("Unable to remove %s %s with uuid %s", ConsistsOf.NAME,
|
||||||
if (detached) {
|
* Relation.NAME, consistOfUUID); logger.error(error); throw new
|
||||||
logger.trace("{} {} with uuid {} removed successfully",
|
* Exception(error); }
|
||||||
ConsistsOf.NAME, Relation.NAME, consistOfUUID);
|
*
|
||||||
} else {
|
* resourceManagement = new ResourceManagement();
|
||||||
String error = String.format("Unable to remove %s %s with uuid %s",
|
* resourceManagement.setUUID(resourceUUID); boolean deleted =
|
||||||
ConsistsOf.NAME, Relation.NAME, consistOfUUID);
|
* resourceManagement.delete(); Assert.assertTrue(deleted); }
|
||||||
logger.error(error);
|
|
||||||
throw new Exception(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setUUID(resourceUUID);
|
|
||||||
boolean deleted = resourceManagement.delete();
|
|
||||||
Assert.assertTrue(deleted);
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAll() throws Exception{
|
public void testGetAll() throws Exception {
|
||||||
Map<String, List<Resource>> resources = new HashMap<>();
|
Map<String, List<Resource>> resources = new HashMap<>();
|
||||||
|
|
||||||
final int MAX = 5;
|
final int MAX = 5;
|
||||||
int typeNumber = 0;
|
int typeNumber = 0;
|
||||||
|
|
||||||
for(int i=0; i<MAX; i++){
|
for (int i = 0; i < MAX; i++) {
|
||||||
Map<String, Resource> map = createHostingNodeAndEService();
|
Map<String, Resource> map = createHostingNodeAndEService();
|
||||||
if(typeNumber==0){
|
if (typeNumber == 0) {
|
||||||
typeNumber = map.size();
|
typeNumber = map.size();
|
||||||
}
|
}
|
||||||
for(String key : map.keySet()){
|
for (String key : map.keySet()) {
|
||||||
if(!resources.containsKey(key)){
|
if (!resources.containsKey(key)) {
|
||||||
resources.put(key, new ArrayList<Resource>());
|
resources.put(key, new ArrayList<Resource>());
|
||||||
}
|
}
|
||||||
resources.get(key).add(map.get(key));
|
resources.get(key).add(map.get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Getting all instances of created specific Resources*/
|
/* Getting all instances of created specific Resources */
|
||||||
for(String key : resources.keySet()){
|
for (String key : resources.keySet()) {
|
||||||
ResourceManagement resourceManagement = (ResourceManagement) ElementManagementUtility.getERManagement(key);
|
ResourceManagement resourceManagement = (ResourceManagement) ElementManagementUtility.getERManagement(key);
|
||||||
String json = resourceManagement.all(false);
|
String json = resourceManagement.all(false);
|
||||||
|
|
||||||
List<Resource> list = ElementMapper.unmarshalList(Resource.class, json);
|
List<Resource> list = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
logger.debug("{} are {} : {} ", key, list.size(), list);
|
logger.debug("{} are {} : {} ", key, list.size(), list);
|
||||||
Assert.assertTrue(list.size()==MAX);
|
Assert.assertTrue(list.size() == MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Getting all Resources polymorphic and non polymorphic */
|
/* Getting all Resources polymorphic and non polymorphic */
|
||||||
|
|
||||||
ResourceManagement resourceManagement = (ResourceManagement) ElementManagementUtility.getERManagement(Resource.NAME);
|
ResourceManagement resourceManagement = (ResourceManagement) ElementManagementUtility
|
||||||
|
.getERManagement(Resource.NAME);
|
||||||
|
|
||||||
String json = resourceManagement.all(true);
|
String json = resourceManagement.all(true);
|
||||||
List<Resource> list = ElementMapper.unmarshalList(Resource.class, json);
|
List<Resource> list = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
logger.debug("{} are {} : {} ", Resource.NAME, list.size(), list);
|
logger.debug("{} are {} : {} ", Resource.NAME, list.size(), list);
|
||||||
Assert.assertTrue(list.size()==(MAX*typeNumber));
|
Assert.assertTrue(list.size() == (MAX * typeNumber));
|
||||||
|
|
||||||
|
|
||||||
json = resourceManagement.all(false);
|
json = resourceManagement.all(false);
|
||||||
list = ElementMapper.unmarshalList(Resource.class, json);
|
list = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(list.size()==0);
|
Assert.assertTrue(list.size() == 0);
|
||||||
|
|
||||||
|
|
||||||
/* Getting all IsRelatedTo polymorphic and non polymorphic */
|
/* Getting all IsRelatedTo polymorphic and non polymorphic */
|
||||||
|
|
||||||
IsRelatedToManagement isRelatedToManagement = (IsRelatedToManagement) ElementManagementUtility.getERManagement(IsRelatedTo.NAME);
|
IsRelatedToManagement isRelatedToManagement = (IsRelatedToManagement) ElementManagementUtility
|
||||||
|
.getERManagement(IsRelatedTo.NAME);
|
||||||
|
|
||||||
json = isRelatedToManagement.all(true);
|
json = isRelatedToManagement.all(true);
|
||||||
|
|
||||||
List<Resource> resourcesList = ElementMapper.unmarshalList(Resource.class, json);
|
List<Resource> resourcesList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
logger.debug("{} are {} : {} ", IsRelatedTo.NAME, resourcesList.size(), resourcesList);
|
logger.debug("{} are {} : {} ", IsRelatedTo.NAME, resourcesList.size(), resourcesList);
|
||||||
Assert.assertTrue(resourcesList.size()==MAX);
|
Assert.assertTrue(resourcesList.size() == MAX);
|
||||||
|
|
||||||
|
|
||||||
json = isRelatedToManagement.all(false);
|
json = isRelatedToManagement.all(false);
|
||||||
resourcesList = ElementMapper.unmarshalList(Resource.class, json);
|
resourcesList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourcesList.size()==0);
|
Assert.assertTrue(resourcesList.size() == 0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Getting all ConsistsOf polymorphic and non polymorphic */
|
/* Getting all ConsistsOf polymorphic and non polymorphic */
|
||||||
|
|
||||||
ConsistsOfManagement consistsOfManagement = (ConsistsOfManagement) ElementManagementUtility.getERManagement(ConsistsOf.NAME);
|
ConsistsOfManagement consistsOfManagement = (ConsistsOfManagement) ElementManagementUtility
|
||||||
|
.getERManagement(ConsistsOf.NAME);
|
||||||
|
|
||||||
json = consistsOfManagement.all(true);
|
json = consistsOfManagement.all(true);
|
||||||
List<Resource> consistsOfPolimorphicList = ElementMapper.unmarshalList(Resource.class, json);
|
List<Resource> consistsOfPolimorphicList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
logger.debug("{} are {} : {} ", IsRelatedTo.NAME, consistsOfPolimorphicList.size(), consistsOfPolimorphicList);
|
logger.debug("{} are {} : {} ", IsRelatedTo.NAME, consistsOfPolimorphicList.size(), consistsOfPolimorphicList);
|
||||||
|
|
||||||
|
|
||||||
json = consistsOfManagement.all(false);
|
json = consistsOfManagement.all(false);
|
||||||
List<Resource> consistsOfNonPolimorphicList = ElementMapper.unmarshalList(Resource.class, json);
|
List<Resource> consistsOfNonPolimorphicList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
logger.debug("{} are {} : {} ", IsRelatedTo.NAME, consistsOfNonPolimorphicList.size(), consistsOfNonPolimorphicList);
|
logger.debug("{} are {} : {} ", IsRelatedTo.NAME, consistsOfNonPolimorphicList.size(),
|
||||||
|
consistsOfNonPolimorphicList);
|
||||||
Assert.assertTrue(consistsOfPolimorphicList.size()>=consistsOfNonPolimorphicList.size());
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Assert.assertTrue(consistsOfPolimorphicList.size() >= consistsOfNonPolimorphicList.size());
|
||||||
|
|
||||||
/* Removing created Entity and Relation to have a clean DB */
|
/* Removing created Entity and Relation to have a clean DB */
|
||||||
|
|
||||||
List<Resource> resourceList = resources.get(HostingNode.NAME);
|
List<Resource> resourceList = resources.get(HostingNode.NAME);
|
||||||
for(Resource r : resourceList){
|
for (Resource r : resourceList) {
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(r.getHeader().getUUID());
|
resourceManagement.setUUID(r.getHeader().getUUID());
|
||||||
boolean deleted = resourceManagement.delete();
|
boolean deleted = resourceManagement.delete();
|
||||||
|
@ -823,7 +745,7 @@ public class ERManagementTest extends ContextTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetAllFrom() throws Exception{
|
public void testGetAllFrom() throws Exception {
|
||||||
|
|
||||||
Map<String, Resource> map = createHostingNodeAndEService();
|
Map<String, Resource> map = createHostingNodeAndEService();
|
||||||
|
|
||||||
|
@ -833,117 +755,126 @@ public class ERManagementTest extends ContextTest {
|
||||||
HostingNode hostingNode = (HostingNode) map.get(HostingNode.NAME);
|
HostingNode hostingNode = (HostingNode) map.get(HostingNode.NAME);
|
||||||
UUID hostingNodeUUID = hostingNode.getHeader().getUUID();
|
UUID hostingNodeUUID = hostingNode.getHeader().getUUID();
|
||||||
|
|
||||||
|
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setElementType(Service.NAME);
|
resourceManagement.setElementType(Service.NAME);
|
||||||
|
|
||||||
boolean includeRelation = false;
|
boolean includeRelation = false;
|
||||||
|
|
||||||
/* Getting Hosting Node */
|
/* Getting Hosting Node */
|
||||||
String json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, true, null, includeRelation);
|
String json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, true,
|
||||||
|
null, includeRelation);
|
||||||
List<Resource> resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
List<Resource> resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==1);
|
Assert.assertTrue(resourceList.size() == 1);
|
||||||
Resource resource = resourceList.get(0);
|
Resource resource = resourceList.get(0);
|
||||||
Assert.assertTrue(resource.getHeader().getUUID().compareTo(hostingNodeUUID)==0);
|
Assert.assertTrue(resource.getHeader().getUUID().compareTo(hostingNodeUUID) == 0);
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, true, null, includeRelation);
|
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, true, null,
|
||||||
|
includeRelation);
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==1);
|
Assert.assertTrue(resourceList.size() == 1);
|
||||||
resource = resourceList.get(0);
|
resource = resourceList.get(0);
|
||||||
Assert.assertTrue(resource.getHeader().getUUID().compareTo(hostingNodeUUID)==0);
|
Assert.assertTrue(resource.getHeader().getUUID().compareTo(hostingNodeUUID) == 0);
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, true, null, includeRelation);
|
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, true, null,
|
||||||
|
includeRelation);
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size() == 0);
|
||||||
|
|
||||||
|
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, false, null,
|
||||||
|
includeRelation);
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.BOTH, false, null, includeRelation);
|
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size() == 0);
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, false, null, includeRelation);
|
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.OUT, false, null,
|
||||||
|
includeRelation);
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size() == 0);
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, false, null, includeRelation);
|
json = resourceManagement.query(IsRelatedTo.NAME, EService.NAME, eServiceUUID, ODirection.IN, false, null,
|
||||||
|
includeRelation);
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size() == 0);
|
||||||
/* END Getting Hosting Node */
|
/* END Getting Hosting Node */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Getting EService */
|
/* Getting EService */
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.BOTH, true, null, includeRelation);
|
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.BOTH, true,
|
||||||
|
null, includeRelation);
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==1);
|
Assert.assertTrue(resourceList.size() == 1);
|
||||||
Assert.assertTrue(resourceList.get(0).getHeader().getUUID().compareTo(eServiceUUID)==0);
|
Assert.assertTrue(resourceList.get(0).getHeader().getUUID().compareTo(eServiceUUID) == 0);
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, true, null, includeRelation);
|
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, true, null,
|
||||||
|
includeRelation);
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size() == 0);
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, true, null, includeRelation);
|
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, true, null,
|
||||||
|
includeRelation);
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==1);
|
Assert.assertTrue(resourceList.size() == 1);
|
||||||
Assert.assertTrue(resourceList.get(0).getHeader().getUUID().compareTo(eServiceUUID)==0);
|
Assert.assertTrue(resourceList.get(0).getHeader().getUUID().compareTo(eServiceUUID) == 0);
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.BOTH, false, null, includeRelation);
|
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.BOTH, false,
|
||||||
|
null, includeRelation);
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size() == 0);
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, false, null, includeRelation);
|
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.OUT, false,
|
||||||
|
null, includeRelation);
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size() == 0);
|
||||||
|
|
||||||
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, false, null, includeRelation);
|
json = resourceManagement.query(IsRelatedTo.NAME, HostingNode.NAME, hostingNodeUUID, ODirection.IN, false, null,
|
||||||
|
includeRelation);
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size() == 0);
|
||||||
/* END Getting HostingNode */
|
/* END Getting HostingNode */
|
||||||
|
|
||||||
|
|
||||||
Facet identificationFacet = eService.getIdentificationFacets().get(0);
|
Facet identificationFacet = eService.getIdentificationFacets().get(0);
|
||||||
UUID identificationFacetUUID = identificationFacet.getHeader().getUUID();
|
UUID identificationFacetUUID = identificationFacet.getHeader().getUUID();
|
||||||
|
|
||||||
/* EService --ConsistsOf--> SoftwareFacet*/
|
/* EService --ConsistsOf--> SoftwareFacet */
|
||||||
try {
|
try {
|
||||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.BOTH, true, null, includeRelation);
|
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID,
|
||||||
}catch(InvalidQueryException e) {
|
ODirection.BOTH, true, null, includeRelation);
|
||||||
|
} catch (InvalidQueryException e) {
|
||||||
// Ok expected
|
// Ok expected
|
||||||
}
|
}
|
||||||
|
|
||||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.OUT, true, null, includeRelation);
|
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.OUT,
|
||||||
|
true, null, includeRelation);
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==1);
|
Assert.assertTrue(resourceList.size() == 1);
|
||||||
resource = resourceList.get(0);
|
resource = resourceList.get(0);
|
||||||
Facet targetIdentificationFacet = ((GCubeResource) resource).getIdentificationFacets().get(0);
|
Facet targetIdentificationFacet = ((GCubeResource) resource).getIdentificationFacets().get(0);
|
||||||
Assert.assertTrue(resource.getHeader().getUUID().compareTo(eServiceUUID)==0);
|
Assert.assertTrue(resource.getHeader().getUUID().compareTo(eServiceUUID) == 0);
|
||||||
Assert.assertTrue(targetIdentificationFacet.getHeader().getUUID().compareTo(identificationFacetUUID)==0);
|
Assert.assertTrue(targetIdentificationFacet.getHeader().getUUID().compareTo(identificationFacetUUID) == 0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.IN, true, null, includeRelation);
|
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.IN,
|
||||||
}catch(InvalidQueryException e) {
|
true, null, includeRelation);
|
||||||
|
} catch (InvalidQueryException e) {
|
||||||
// Ok expected
|
// Ok expected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.BOTH, false, null, includeRelation);
|
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID,
|
||||||
}catch(InvalidQueryException e) {
|
ODirection.BOTH, false, null, includeRelation);
|
||||||
|
} catch (InvalidQueryException e) {
|
||||||
// Ok expected
|
// Ok expected
|
||||||
}
|
}
|
||||||
|
|
||||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.OUT, false, null, includeRelation);
|
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.OUT,
|
||||||
|
false, null, includeRelation);
|
||||||
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
resourceList = ElementMapper.unmarshalList(Resource.class, json);
|
||||||
Assert.assertTrue(resourceList.size()==0);
|
Assert.assertTrue(resourceList.size() == 0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.IN, false, null, includeRelation);
|
json = resourceManagement.query(ConsistsOf.NAME, SoftwareFacet.NAME, identificationFacetUUID, ODirection.IN,
|
||||||
}catch(InvalidQueryException e) {
|
false, null, includeRelation);
|
||||||
|
} catch (InvalidQueryException e) {
|
||||||
// Ok expected
|
// Ok expected
|
||||||
}
|
}
|
||||||
|
|
||||||
/* END EService --ConsistsOf--> SoftwareFacet*/
|
/* END EService --ConsistsOf--> SoftwareFacet */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Removing created Entity and Relation to have a clean DB */
|
/* Removing created Entity and Relation to have a clean DB */
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
|
@ -955,8 +886,9 @@ public class ERManagementTest extends ContextTest {
|
||||||
|
|
||||||
public static final String TEST_RESOURCE = "test-resource.json";
|
public static final String TEST_RESOURCE = "test-resource.json";
|
||||||
|
|
||||||
//@Test
|
// @Test
|
||||||
public void testUpdateResourceFromFile() throws JsonParseException, JsonMappingException, IOException, ResourceRegistryException{
|
public void testUpdateResourceFromFile()
|
||||||
|
throws JsonParseException, JsonMappingException, IOException, ResourceRegistryException {
|
||||||
File file = new File("src/test/resources/" + TEST_RESOURCE);
|
File file = new File("src/test/resources/" + TEST_RESOURCE);
|
||||||
|
|
||||||
logger.debug("{}", file.getAbsolutePath());
|
logger.debug("{}", file.getAbsolutePath());
|
||||||
|
@ -973,7 +905,8 @@ public class ERManagementTest extends ContextTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
public void readSingleResource() throws ResourceRegistryException, JsonParseException, JsonMappingException, IOException{
|
public void readSingleResource()
|
||||||
|
throws ResourceRegistryException, JsonParseException, JsonMappingException, IOException {
|
||||||
UUID uuid = UUID.fromString("");
|
UUID uuid = UUID.fromString("");
|
||||||
|
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
|
@ -983,7 +916,6 @@ public class ERManagementTest extends ContextTest {
|
||||||
|
|
||||||
Configuration configuration = ElementMapper.unmarshal(Configuration.class, res);
|
Configuration configuration = ElementMapper.unmarshal(Configuration.class, res);
|
||||||
|
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(configuration.getHeader().getUUID());
|
resourceManagement.setUUID(configuration.getHeader().getUUID());
|
||||||
resourceManagement.setJson(ElementMapper.marshal(configuration));
|
resourceManagement.setJson(ElementMapper.marshal(configuration));
|
||||||
|
@ -992,44 +924,9 @@ public class ERManagementTest extends ContextTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateUpdateDeleteEService() throws Exception {
|
public void testCreateUpdateDeleteEService() throws Exception {
|
||||||
EService eService = new EServiceImpl();
|
EService eService = ERManagementTest.instantiateValidEService();
|
||||||
|
|
||||||
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("https://localhost"));
|
|
||||||
accessPointFacet.setEntryName("port1");
|
|
||||||
eService.addFacet(accessPointFacet);
|
|
||||||
|
|
||||||
EventFacet eventFacet = new EventFacetImpl();
|
|
||||||
eventFacet.setDate(Calendar.getInstance().getTime());
|
|
||||||
ValueSchema event = new ValueSchemaImpl();
|
|
||||||
event.setSchema(new URI("Schema"));
|
|
||||||
event.setValue("Created");
|
|
||||||
eventFacet.setEvent(event);
|
|
||||||
eService.addFacet(eventFacet);
|
|
||||||
|
|
||||||
StateFacet stateFacet = new StateFacetImpl();
|
|
||||||
stateFacet.setValue("ready");
|
|
||||||
eService.addFacet(stateFacet);
|
|
||||||
|
|
||||||
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 resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setElementType(EService.NAME);
|
resourceManagement.setElementType(EService.NAME);
|
||||||
|
@ -1050,8 +947,7 @@ public class ERManagementTest extends ContextTest {
|
||||||
logger.trace("Updated {}", json);
|
logger.trace("Updated {}", json);
|
||||||
eService = ElementMapper.unmarshal(EService.class, json);
|
eService = ElementMapper.unmarshal(EService.class, json);
|
||||||
|
|
||||||
Assert.assertTrue(eService.getFacets(SoftwareFacet.class).get(0).getVersion().compareTo(newVersion)==0);
|
Assert.assertTrue(eService.getFacets(SoftwareFacet.class).get(0).getVersion().compareTo(newVersion) == 0);
|
||||||
|
|
||||||
|
|
||||||
resourceManagement = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setUUID(eService.getHeader().getUUID());
|
resourceManagement.setUUID(eService.getHeader().getUUID());
|
||||||
|
@ -1060,5 +956,4 @@ public class ERManagementTest extends ContextTest {
|
||||||
Assert.assertTrue(deleted);
|
Assert.assertTrue(deleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,40 +3,20 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
|
|
||||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint;
|
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.instances.ERManagementTest;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.ERManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.model.ERManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||||
import org.gcube.informationsystem.utils.ElementMapper;
|
import org.gcube.informationsystem.utils.ElementMapper;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.AccessPointFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.EventFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.LicenseFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.StateFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.resources.EServiceImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.properties.ValueSchemaImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.relations.consistsof.IsIdentifiedByImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.AccessPointFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.EventFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.LicenseFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet;
|
|
||||||
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.EService;
|
||||||
import org.gcube.resourcemanagement.model.reference.properties.ValueSchema;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
|
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -53,45 +33,8 @@ public class AnotherEnhancedTest extends MultiContextTest {
|
||||||
@Test
|
@Test
|
||||||
public void testNoFollows() throws Exception {
|
public void testNoFollows() throws Exception {
|
||||||
ContextTest.setContextByName(DEFAULT_TEST_SCOPE);
|
ContextTest.setContextByName(DEFAULT_TEST_SCOPE);
|
||||||
EService eService = new EServiceImpl();
|
|
||||||
|
|
||||||
SoftwareFacet softwareFacet = new SoftwareFacetImpl();
|
|
||||||
softwareFacet.setGroup("InformationSystem");
|
|
||||||
softwareFacet.setName("resource-registry");
|
|
||||||
softwareFacet.setVersion("1.1.0");
|
|
||||||
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
|
|
||||||
propagationConstraint.setAddConstraint(AddConstraint.propagate);
|
|
||||||
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
|
|
||||||
|
|
||||||
IsIdentifiedBy<EService, Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService, Facet>(
|
|
||||||
eService, softwareFacet, propagationConstraint);
|
|
||||||
eService.addFacet(isIdentifiedBy);
|
|
||||||
|
|
||||||
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
|
|
||||||
accessPointFacet.setEndpoint(new URI("https://localhost"));
|
|
||||||
accessPointFacet.setEntryName("port1");
|
|
||||||
eService.addFacet(accessPointFacet);
|
|
||||||
|
|
||||||
EventFacet eventFacet = new EventFacetImpl();
|
|
||||||
eventFacet.setDate(Calendar.getInstance().getTime());
|
|
||||||
ValueSchema event = new ValueSchemaImpl();
|
|
||||||
event.setValue("Created");
|
|
||||||
event.setSchema(new URI(""));
|
|
||||||
eventFacet.setEvent(event);
|
|
||||||
eService.addFacet(eventFacet);
|
|
||||||
|
|
||||||
StateFacet stateFacet = new StateFacetImpl();
|
|
||||||
stateFacet.setValue("ready");
|
|
||||||
eService.addFacet(stateFacet);
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
EService eService = ERManagementTest.instantiateValidEService();
|
||||||
|
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setElementType(EService.NAME);
|
resourceManagement.setElementType(EService.NAME);
|
||||||
|
|
|
@ -3,9 +3,6 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -14,7 +11,6 @@ import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
import org.gcube.common.authorization.client.exceptions.ObjectNotFound;
|
||||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||||
import org.gcube.informationsystem.context.reference.entities.Context;
|
import org.gcube.informationsystem.context.reference.entities.Context;
|
||||||
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
|
|
||||||
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
|
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
|
||||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
||||||
|
@ -30,6 +26,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resour
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.RelationAvailableInAnotherContextException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.RelationAvailableInAnotherContextException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.instances.ERManagementTest;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.SmartgearResourcesTest;
|
import org.gcube.informationsystem.resourceregistry.instances.SmartgearResourcesTest;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
|
@ -37,35 +34,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.entities.ResourceManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.relations.IsRelatedToManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.relations.IsRelatedToManagement;
|
||||||
import org.gcube.informationsystem.utils.ElementMapper;
|
import org.gcube.informationsystem.utils.ElementMapper;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.AccessPointFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.CPUFacetImpl;
|
import org.gcube.resourcemanagement.model.impl.entities.facets.CPUFacetImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.EventFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.LicenseFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.MemoryFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.NetworkingFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl;
|
import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.StateFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.resources.EServiceImpl;
|
import org.gcube.resourcemanagement.model.impl.entities.resources.EServiceImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.resources.HostingNodeImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.properties.ValueSchemaImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.relations.consistsof.HasPersistentMemoryImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.relations.consistsof.HasVolatileMemoryImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.relations.consistsof.IsIdentifiedByImpl;
|
import org.gcube.resourcemanagement.model.impl.relations.consistsof.IsIdentifiedByImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.relations.isrelatedto.ActivatesImpl;
|
import org.gcube.resourcemanagement.model.impl.relations.isrelatedto.ActivatesImpl;
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.AccessPointFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.CPUFacet;
|
import org.gcube.resourcemanagement.model.reference.entities.facets.CPUFacet;
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.EventFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.LicenseFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.MemoryFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.MemoryFacet.MemoryUnit;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.NetworkingFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet;
|
import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet;
|
||||||
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.EService;
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.resources.HostingNode;
|
import org.gcube.resourcemanagement.model.reference.entities.resources.HostingNode;
|
||||||
import org.gcube.resourcemanagement.model.reference.properties.ValueSchema;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.relations.consistsof.HasPersistentMemory;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.relations.consistsof.HasVolatileMemory;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
|
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
|
||||||
import org.gcube.resourcemanagement.model.reference.relations.isrelatedto.Activates;
|
import org.gcube.resourcemanagement.model.reference.relations.isrelatedto.Activates;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -214,38 +191,7 @@ public class BasicTest extends MultiContextTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateEServiceHostingNode() throws Exception {
|
public void testCreateEServiceHostingNode() throws Exception {
|
||||||
EService eService = new EServiceImpl();
|
EService eService = ERManagementTest.instantiateValidEService();
|
||||||
|
|
||||||
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("https://localhost"));
|
|
||||||
accessPointFacet.setEntryName("port1");
|
|
||||||
eService.addFacet(accessPointFacet);
|
|
||||||
|
|
||||||
EventFacet eventFacet = new EventFacetImpl();
|
|
||||||
eventFacet.setDate(Calendar.getInstance().getTime());
|
|
||||||
ValueSchema event = new ValueSchemaImpl();
|
|
||||||
event.setValue("Created");
|
|
||||||
eventFacet.setEvent(event);
|
|
||||||
eService.addFacet(eventFacet);
|
|
||||||
|
|
||||||
StateFacet stateFacet = new StateFacetImpl();
|
|
||||||
stateFacet.setValue("ready");
|
|
||||||
eService.addFacet(stateFacet);
|
|
||||||
|
|
||||||
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 resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setElementType(EService.NAME);
|
resourceManagement.setElementType(EService.NAME);
|
||||||
|
@ -263,65 +209,7 @@ public class BasicTest extends MultiContextTest {
|
||||||
eServiceInstances.put(consistsOf.getTarget().getHeader().getUUID(), consistsOf.getTarget());
|
eServiceInstances.put(consistsOf.getTarget().getHeader().getUUID(), consistsOf.getTarget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HostingNode hostingNode = ERManagementTest.instantiateValidHostinNode();
|
||||||
|
|
||||||
HostingNode hostingNode = new HostingNodeImpl();
|
|
||||||
|
|
||||||
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
|
|
||||||
networkingFacet.setIPAddress("146.48.87.183");
|
|
||||||
networkingFacet.setHostName("pc-frosini.isti.cnr.it");
|
|
||||||
networkingFacet.setDomainName("isti.cnr.it");
|
|
||||||
networkingFacet.setMask("255.255.248.0");
|
|
||||||
networkingFacet.setBroadcastAddress("146.48.87.255");
|
|
||||||
|
|
||||||
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedByHNNF = new IsIdentifiedByImpl<HostingNode, NetworkingFacet>(
|
|
||||||
hostingNode, networkingFacet, null);
|
|
||||||
hostingNode.addFacet(isIdentifiedByHNNF);
|
|
||||||
|
|
||||||
CPUFacet cpuFacet = new CPUFacetImpl();
|
|
||||||
cpuFacet.setClockSpeed("1 GHz");
|
|
||||||
cpuFacet.setModel("Opteron");
|
|
||||||
cpuFacet.setVendor("AMD");
|
|
||||||
hostingNode.addFacet(cpuFacet);
|
|
||||||
|
|
||||||
MemoryFacet ram = new MemoryFacetImpl();
|
|
||||||
ram.setSize(8);
|
|
||||||
ram.setUnit(MemoryUnit.GB);
|
|
||||||
ram.setUsed(2);
|
|
||||||
|
|
||||||
HasVolatileMemory<HostingNode, MemoryFacet> hasVolatileMemory = new HasVolatileMemoryImpl<HostingNode, MemoryFacet>(
|
|
||||||
hostingNode, ram, null);
|
|
||||||
hostingNode.addFacet(hasVolatileMemory);
|
|
||||||
|
|
||||||
MemoryFacet disk = new MemoryFacetImpl();
|
|
||||||
disk.setSize(256);
|
|
||||||
disk.setUnit(MemoryUnit.GB);
|
|
||||||
disk.setUsed(120);
|
|
||||||
|
|
||||||
HasPersistentMemory<HostingNode, MemoryFacet> hasPersistentMemory = new HasPersistentMemoryImpl<HostingNode, MemoryFacet>(
|
|
||||||
hostingNode, disk, null);
|
|
||||||
hostingNode.addFacet(hasPersistentMemory);
|
|
||||||
|
|
||||||
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
|
|
||||||
propagationConstraint.setAddConstraint(AddConstraint.unpropagate);
|
|
||||||
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
|
|
||||||
Activates<HostingNode, EService> activates = new ActivatesImpl<HostingNode, EService>(
|
|
||||||
hostingNode, eService, propagationConstraint);
|
|
||||||
UUID activatedUUID = UUID.randomUUID();
|
|
||||||
activates.setHeader(new HeaderImpl(activatedUUID));
|
|
||||||
hostingNode.attachResource(activates);
|
|
||||||
|
|
||||||
StateFacet hnStateFacet = new StateFacetImpl();
|
|
||||||
hnStateFacet.setValue("certified");
|
|
||||||
hostingNode.addFacet(hnStateFacet);
|
|
||||||
|
|
||||||
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 = new ResourceManagement();
|
resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setElementType(HostingNode.NAME);
|
resourceManagement.setElementType(HostingNode.NAME);
|
||||||
|
|
|
@ -3,40 +3,20 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
|
|
||||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint;
|
|
||||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.instances.ERManagementTest;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.ERManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.model.ERManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||||
import org.gcube.informationsystem.utils.ElementMapper;
|
import org.gcube.informationsystem.utils.ElementMapper;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.AccessPointFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.EventFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.LicenseFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.StateFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.resources.EServiceImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.properties.ValueSchemaImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.relations.consistsof.IsIdentifiedByImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.AccessPointFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.EventFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.LicenseFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet;
|
|
||||||
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.EService;
|
||||||
import org.gcube.resourcemanagement.model.reference.properties.ValueSchema;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
|
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -53,45 +33,7 @@ public class EnhancedTest extends MultiContextTest {
|
||||||
@Test
|
@Test
|
||||||
public void testNoFollows() throws Exception {
|
public void testNoFollows() throws Exception {
|
||||||
ContextTest.setContextByName(DEFAULT_TEST_SCOPE);
|
ContextTest.setContextByName(DEFAULT_TEST_SCOPE);
|
||||||
EService eService = new EServiceImpl();
|
EService eService = ERManagementTest.instantiateValidEService();
|
||||||
|
|
||||||
SoftwareFacet softwareFacet = new SoftwareFacetImpl();
|
|
||||||
softwareFacet.setGroup("InformationSystem");
|
|
||||||
softwareFacet.setName("resource-registry");
|
|
||||||
softwareFacet.setVersion("1.1.0");
|
|
||||||
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
|
|
||||||
propagationConstraint.setAddConstraint(AddConstraint.propagate);
|
|
||||||
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
|
|
||||||
|
|
||||||
IsIdentifiedBy<EService, Facet> isIdentifiedBy = new IsIdentifiedByImpl<EService, Facet>(
|
|
||||||
eService, softwareFacet, propagationConstraint);
|
|
||||||
eService.addFacet(isIdentifiedBy);
|
|
||||||
|
|
||||||
AccessPointFacet accessPointFacet = new AccessPointFacetImpl();
|
|
||||||
accessPointFacet.setEndpoint(new URI("https://localhost"));
|
|
||||||
accessPointFacet.setEntryName("port1");
|
|
||||||
eService.addFacet(accessPointFacet);
|
|
||||||
|
|
||||||
EventFacet eventFacet = new EventFacetImpl();
|
|
||||||
eventFacet.setDate(Calendar.getInstance().getTime());
|
|
||||||
ValueSchema event = new ValueSchemaImpl();
|
|
||||||
event.setValue("Created");
|
|
||||||
event.setSchema(new URI(""));
|
|
||||||
eventFacet.setEvent(event);
|
|
||||||
eService.addFacet(eventFacet);
|
|
||||||
|
|
||||||
StateFacet stateFacet = new StateFacetImpl();
|
|
||||||
stateFacet.setValue("ready");
|
|
||||||
eService.addFacet(stateFacet);
|
|
||||||
|
|
||||||
|
|
||||||
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 resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setElementType(EService.NAME);
|
resourceManagement.setElementType(EService.NAME);
|
||||||
|
|
|
@ -1,33 +1,16 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAlreadyPresentException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAlreadyPresentException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceAlreadyPresentException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceAlreadyPresentException;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.instances.ERManagementTest;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||||
import org.gcube.informationsystem.utils.ElementMapper;
|
import org.gcube.informationsystem.utils.ElementMapper;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.AccessPointFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.EventFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.LicenseFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.StateFacetImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.resources.EServiceImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.properties.ValueSchemaImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.relations.consistsof.IsIdentifiedByImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.AccessPointFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.EventFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.LicenseFacet;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet;
|
import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet;
|
||||||
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.EService;
|
||||||
import org.gcube.resourcemanagement.model.reference.properties.ValueSchema;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -42,38 +25,7 @@ public class RuleTest extends ContextTest {
|
||||||
.getLogger(RuleTest.class);
|
.getLogger(RuleTest.class);
|
||||||
|
|
||||||
public EService createEservice() throws Exception {
|
public EService createEservice() throws Exception {
|
||||||
EService eService = new EServiceImpl();
|
EService eService = ERManagementTest.instantiateValidEService();
|
||||||
|
|
||||||
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("https://localhost"));
|
|
||||||
accessPointFacet.setEntryName("port1");
|
|
||||||
eService.addFacet(accessPointFacet);
|
|
||||||
|
|
||||||
EventFacet eventFacet = new EventFacetImpl();
|
|
||||||
eventFacet.setDate(Calendar.getInstance().getTime());
|
|
||||||
ValueSchema event = new ValueSchemaImpl();
|
|
||||||
event.setValue("Created");
|
|
||||||
eventFacet.setEvent(event);
|
|
||||||
eService.addFacet(eventFacet);
|
|
||||||
|
|
||||||
StateFacet stateFacet = new StateFacetImpl();
|
|
||||||
stateFacet.setValue("ready");
|
|
||||||
eService.addFacet(stateFacet);
|
|
||||||
|
|
||||||
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 resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setElementType(EService.NAME);
|
resourceManagement.setElementType(EService.NAME);
|
||||||
|
@ -157,8 +109,6 @@ public class RuleTest extends ContextTest {
|
||||||
// TODO continue with checks
|
// TODO continue with checks
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
eServiceManagement = new ResourceManagement();
|
eServiceManagement = new ResourceManagement();
|
||||||
eServiceManagement.setElementType(EService.NAME);
|
eServiceManagement.setElementType(EService.NAME);
|
||||||
eServiceManagement.setJson(eServiceString);
|
eServiceManagement.setJson(eServiceString);
|
||||||
|
|
Loading…
Reference in New Issue