Improved test

This commit is contained in:
Luca Frosini 2023-04-28 17:16:46 +02:00
parent 678296e7cb
commit 247eeb2340
2 changed files with 19 additions and 7 deletions

View File

@ -19,6 +19,7 @@ import org.gcube.resourcemanagement.model.impl.relations.isrelatedto.ActivatesIm
import org.gcube.resourcemanagement.model.reference.entities.resources.EService;
import org.gcube.resourcemanagement.model.reference.entities.resources.HostingNode;
import org.gcube.resourcemanagement.model.reference.relations.isrelatedto.Activates;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -39,22 +40,31 @@ public class PolymorphismTest {
public static final String NYESERVICE2 = "{\"" + Element.TYPE_PROPERTY + "\":\"MyEService\",\""+ Element.SUPERTYPES_PROPERTY + "\":[\"EService\",\"Service\",\"Resource\"],\"" + IdentifiableElement.ID_PROPERTY + "\":\"3ace4bd0-e5cd-49a3-97a8-a0a9468ce6d4\",\"metadata\":{\"" + Element.TYPE_PROPERTY + "\":\"Metadata\",\"creator\":null, \"creationTime\":null, \"lastUpdateTime\":null},\"consistsOf\":[{\"" + Element.TYPE_PROPERTY + "\":\"IsIdentifiedBy\",\"metadata\":null,\"target\":{\""+ Element.SUPERTYPES_PROPERTY + "\":[\"SoftwareFacet\", \"Facet\", \"Entity\"],\"" + Element.TYPE_PROPERTY + "\":\"MySoftwareFacet\",\""+ Element.SUPERTYPES_PROPERTY + "\":[\"SoftwareFacet\", \"Facet\", \"Entity\"],\"metadata\":null,\"name\":\"WhnManager\",\"group\":\"VREManagement\",\"version\":\"2.0.0-SNAPSHOT\",\"description\":\"Web Hosting Node Service\",\"qualifier\":null,\"optional\":false}},{\"" + Element.TYPE_PROPERTY + "\":\"ConsistsOf\",\"metadata\":null,\"target\":{\"" + Element.TYPE_PROPERTY + "\":\"AccessPointFacet\",\"metadata\":null,\"entryName\":\"whnmanager\",\"endpoint\":\"https://pc-frosini.isti.cnr.it:8080/whn-manager/gcube/vremanagement/ws/whnmanager\",\"protocol\":null,\"description\":null,\"authorization\": {\"" + Element.TYPE_PROPERTY + "\":\"ValueSchema\",\"value\":\"gcube-token\",\"schema\":null},\"properties\":null}},{\"" + Element.TYPE_PROPERTY + "\":\"ConsistsOf\",\"metadata\":null,\"target\":{\"" + Element.TYPE_PROPERTY + "\":\"AccessPointFacet\",\"metadata\":null,\"entryName\":\"WhnManager-remote-management\",\"endpoint\":\"https://pc-frosini.isti.cnr.it:8080/whn-manager/gcube/resource\",\"protocol\":null,\"description\":null,\"authorization\":{\"" + Element.TYPE_PROPERTY + "\":\"ValueSchema\",\"value\":\"gcube-token\",\"schema\":null},\"properties\":null}}],\"isRelatedTo\":[]}";
public static final String MYANOTHERESERVICE2 = "{\"" + Element.TYPE_PROPERTY + "\":\"MyEService\",\""+ Element.SUPERTYPES_PROPERTY + "\":[\"EService\",\"Service\",\"Resource\"],\"" + IdentifiableElement.ID_PROPERTY + "\":\"3ace4bd0-e5cd-49a3-97a8-a0a9468ce6d4\",\"metadata\":{\"" + Element.TYPE_PROPERTY + "\":\"Metadata\",\"creator\":null, \"creationTime\":null, \"lastUpdateTime\":null},\"consistsOf\":[{\"" + Element.TYPE_PROPERTY + "\":\"IsIdentifiedBy\",\"metadata\":null,\"target\":{\"" + Element.TYPE_PROPERTY + "\":\"MySoftwareFacet\",\""+ Element.SUPERTYPES_PROPERTY + "\":[\"SoftwareFacet\", \"Facet\", \"Entity\"],\"metadata\":null,\"name\":\"WhnManager\",\"group\":\"VREManagement\",\"version\":\"2.0.0-SNAPSHOT\",\"description\":\"Web Hosting Node Service\",\"qualifier\":null,\"optional\":false}},{\"" + Element.TYPE_PROPERTY + "\":\"ConsistsOf\",\"metadata\":null,\"target\":{\"" + Element.TYPE_PROPERTY + "\":\"AccessPointFacet\",\"metadata\":null,\"entryName\":\"whnmanager\",\"endpoint\":\"https://pc-frosini.isti.cnr.it:8080/whn-manager/gcube/vremanagement/ws/whnmanager\",\"protocol\":null,\"description\":null,\"authorization\": {\"" + Element.TYPE_PROPERTY + "\":\"ValueSchema\",\"value\":\"gcube-token\",\"schema\":null},\"properties\":null}},{\"" + Element.TYPE_PROPERTY + "\":\"ConsistsOf\",\"metadata\":null,\"target\":{\"" + Element.TYPE_PROPERTY + "\":\"AccessPointFacet\",\"metadata\":null,\"entryName\":\"WhnManager-remote-management\",\"endpoint\":\"https://pc-frosini.isti.cnr.it:8080/whn-manager/gcube/resource\",\"protocol\":null,\"description\":null,\"authorization\":{\"" + Element.TYPE_PROPERTY + "\":\"ValueSchema\",\"value\":\"gcube-token\",\"schema\":null},\"properties\":null}}],\"isRelatedTo\":[]}";
public static final String MY_CONSISTS_OF = "{\""+ Element.SUPERTYPES_PROPERTY + "\":[\"IsIdentifiedBy\", \"ConsistsOf\", \"Relation\"],\"" + Element.TYPE_PROPERTY + "\":\"MyIsIdentifiedBy\",\"target\":{\""+ Element.SUPERTYPES_PROPERTY + "\":[\"SoftwareFacet\", \"Facet\", \"Entity\"],\"" + Element.TYPE_PROPERTY + "\":\"MySoftwareFacet\",\"metadata\":null,\"name\":\"WhnManager\",\"group\":\"VREManagement\",\"version\":\"2.0.0-SNAPSHOT\",\"description\":\"Web Hosting Node Service\",\"qualifier\":null,\"optional\":false}}";
public static final String MY_TEST_FACET = "{\""+ Element.SUPERTYPES_PROPERTY + "\":[\"SoftwareFacet\", \"Facet\", \"Entity\"],\"" + Element.TYPE_PROPERTY + "\":\"MySoftwareFacet\",\"name\":\"WhnManager\",\"group\":\"VREManagement\",\"version\":\"2.0.0-SNAPSHOT\",\"description\":\"Web Hosting Node Service\",\"qualifier\":null,\"optional\":false}";
public static final String MY_SOFTWARE_FACET_TYPE = "MySoftwareFacetTest";
public static final String MY_TEST_FACET = "{\"" + Element.TYPE_PROPERTY + "\":\"" + MY_SOFTWARE_FACET_TYPE + "\",\"" + Element.SUPERTYPES_PROPERTY + "\":[\"SoftwareFacet\", \"Facet\" ],\"name\":\"WhnManager\",\"group\":\"VREManagement\",\"version\":\"2.0.0-SNAPSHOT\",\"description\":\"Web Hosting Node Service\",\"qualifier\":null,\"optional\":false}";
public static final String MY_IS_IDENTIFIED_BY_TYPE = "MyIsIdentifiedByTest";
public static final String MY_CONSISTS_OF = "{\"" + Element.TYPE_PROPERTY + "\":\"" + MY_IS_IDENTIFIED_BY_TYPE + "\",\"" + Element.SUPERTYPES_PROPERTY + "\":[\"IsIdentifiedBy\", \"ConsistsOf\" ],\"target\":" + MY_TEST_FACET + "}";
@Test
public void testER() throws Exception {
logger.debug(MY_TEST_FACET);
Facet f = ElementMapper.unmarshal(Facet.class, MY_TEST_FACET);
logger.debug("{} {}", f.getClass().getSimpleName(), f);
logger.debug("{} {}", f.getTypeName(), f);
Assert.assertTrue(f.getExpectedtype()!=null);
Assert.assertTrue(f.getExpectedtype().compareTo(MY_SOFTWARE_FACET_TYPE)==0);
logger.debug(MY_CONSISTS_OF);
ConsistsOf<?,?> c = ElementMapper.unmarshal(ConsistsOf.class, MY_CONSISTS_OF);
logger.debug("{} {}", c.getClass().getSimpleName(), c);
logger.debug("{} {}", c.getTypeName(), c);
Assert.assertTrue(c.getExpectedtype()!=null);
Assert.assertTrue(c.getExpectedtype().compareTo(MY_IS_IDENTIFIED_BY_TYPE)==0);
String[] eServices = new String[]{NYESERVICE, MYESERVICE, MYOTHERESERVICE, MYANOTHERESERVICE, NYESERVICE2, MYANOTHERESERVICE2};
//String[] eServices = new String[]{NYESERVICE2, MYANOTHERESERVICE2};
//String[] eServices = new String[]{ESERVICE};
// String[] eServices = new String[]{NYESERVICE2, MYANOTHERESERVICE2};
// String[] eServices = new String[]{ESERVICE};
// String[] eServices = new String[]{};
for(String eService : eServices){
logger.debug("Going to unmarshal {}", eService);
Resource resource = ElementMapper.unmarshal(Resource.class, eService);

View File

@ -10,7 +10,9 @@
<logger name="org.gcube" level="TRACE" />
<logger name="org.gcube.informationsystem.discovery" level="WARN" />
<logger name="org.gcube.informationsystem.types" level="WARN" />
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>