use of io.github.edmm.core.parser.EntityGraph in project winery by eclipse.
the class EdmmConverterTest method transformTopologyWithOperations.
@Test
void transformTopologyWithOperations() {
// region *** build the TopologyTemplate ***
TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
topology.addNodeTemplate(nodeTemplates.get("test_node_4"));
// endregion
TServiceTemplate serviceTemplate = new TServiceTemplate.Builder("testST", topology.build()).build();
EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations, relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping, false);
EntityGraph transform = edmmConverter.transform(serviceTemplate);
assertNotNull(transform);
Optional<Entity> operations = transform.getEntity(Arrays.asList("0", "components", "test_node_4", "operations"));
assertTrue(operations.isPresent());
Optional<Entity> start = transform.getEntity(Arrays.asList("0", "components", "test_node_4", "operations", "start"));
assertTrue(start.isPresent());
assertTrue(start.get() instanceof ScalarEntity);
assertEquals("/artifacttemplates/https%3A%2F%2Fex.org%2Ftosca%2Fto%2Fedmm/startTestNode4/files/script.sh", ((ScalarEntity) start.get()).getValue());
Optional<Entity> stop = transform.getEntity(Arrays.asList("0", "components", "test_node_4", "operations", "stop"));
assertTrue(stop.isPresent());
assertTrue(stop.get() instanceof ScalarEntity);
assertEquals("/artifacttemplates/https%3A%2F%2Fex.org%2Ftosca%2Fto%2Fedmm/startTestNode4/files/script.sh", ((ScalarEntity) stop.get()).getValue());
}
use of io.github.edmm.core.parser.EntityGraph in project winery by eclipse.
the class EdmmConverterTest method transformTopology.
@Test
void transformTopology() {
// region *** build the TopologyTemplate ***
TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
topology.addNodeTemplate(nodeTemplates.get("test_node_1"));
topology.addNodeTemplate(nodeTemplates.get("test_node_2"));
topology.addNodeTemplate(nodeTemplates.get("test_node_3"));
topology.addNodeTemplate(nodeTemplates.get("test_node_4"));
topology.addRelationshipTemplate(relationshipTemplates.get("1_hosted_on_3"));
topology.addRelationshipTemplate(relationshipTemplates.get("2_hosted_on_3"));
topology.addRelationshipTemplate(relationshipTemplates.get("4_hosted_on_1"));
topology.addRelationshipTemplate(relationshipTemplates.get("1_connects_to_2"));
TServiceTemplate serviceTemplate = new TServiceTemplate();
serviceTemplate.setTopologyTemplate(topology.build());
// endregion
EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations, relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping, false);
EntityGraph transform = edmmConverter.transform(serviceTemplate);
StringWriter stringWriter = new StringWriter();
transform.generateYamlOutput(stringWriter);
assertEquals("---\n" + "components:\n" + " test_node_1:\n" + " type: software_component\n" + " relations:\n" + " - connects_to: test_node_2\n" + " - hosted_on: test_node_3\n" + " properties:\n" + " name: test_node_1\n" + " artifacts:\n" + " - war: /artifacttemplates/https%3A%2F%2Fex.org%2Ftosca%2Fto%2Fedmm/testNode1-DA/files/da.war\n" + " test_node_3:\n" + " type: https_ex.orgtoscatoedmm__test_node_type_3\n" + " properties:\n" + " public_key: '-----BEGIN PUBLIC KEY----- ... -----END PUBLIC KEY-----'\n" + " ssh_port: '22'\n" + " os_family: ubuntu\n" + " name: test_node_3\n" + " test_node_2:\n" + " relations:\n" + " - hosted_on: test_node_3\n" + " type: https_ex.orgtoscatoedmm__test_node_type_2\n" + " properties:\n" + " name: test_node_2\n" + " test_node_4:\n" + " operations:\n" + " stop: /artifacttemplates/https%3A%2F%2Fex.org%2Ftosca%2Fto%2Fedmm/startTestNode4/files/script.sh\n" + " start: /artifacttemplates/https%3A%2F%2Fex.org%2Ftosca%2Fto%2Fedmm/startTestNode4/files/script.sh\n" + " type: https_ex.orgtoscatoedmm__test_node_type_4\n" + " relations:\n" + " - hosted_on: test_node_1\n" + " properties:\n" + " name: test_node_4\n" + "relation_types:\n" + " depends_on:\n" + " extends: null\n" + " hosted_on:\n" + " extends: depends_on\n" + " connects_to:\n" + " extends: depends_on\n" + "multi_id: '12345'\n" + "component_types:\n" + " https_ex.orgtoscatoedmm__test_node_type_2:\n" + " extends: software_component\n" + " compute:\n" + " extends: base\n" + " https_ex.orgtoscatoedmm__test_node_type_3:\n" + " extends: compute\n" + " properties:\n" + " public_key:\n" + " type: string\n" + " ssh_port:\n" + " type: number\n" + " os_family:\n" + " type: string\n" + " web_application:\n" + " extends: base\n" + " https_ex.orgtoscatoedmm__test_node_type_4:\n" + " extends: web_application\n" + " software_component:\n" + " extends: base\n" + "version: edm_1_0\n", stringWriter.toString());
}
use of io.github.edmm.core.parser.EntityGraph in project winery by eclipse.
the class EdmmConverterTest method transformDerivedFrom.
@Test
void transformDerivedFrom() {
// region *** build the TopologyTemplate ***
TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
topology.addNodeTemplate(nodeTemplates.get("test_node_2"));
// endregion
TServiceTemplate serviceTemplate = new TServiceTemplate();
serviceTemplate.setTopologyTemplate(topology.build());
EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations, relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping);
EntityGraph transform = edmmConverter.transform(serviceTemplate);
assertNotNull(transform);
assertTrue(transform.vertexSet().stream().anyMatch(entity -> entity instanceof ScalarEntity && entity.getName().equals("extends") && ((ScalarEntity) entity).getValue().equals("software_component")));
}
use of io.github.edmm.core.parser.EntityGraph in project winery by eclipse.
the class EdmmConverterTest method transformTopologyWithRelationsAndRelationTypes.
@Test
void transformTopologyWithRelationsAndRelationTypes() {
// region *** build the TopologyTemplate ***
TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
topology.addNodeTemplate(nodeTemplates.get("test_node_1"));
topology.addNodeTemplate(nodeTemplates.get("test_node_2"));
topology.addNodeTemplate(nodeTemplates.get("test_node_3"));
topology.addRelationshipTemplate(relationshipTemplates.get("1_hosted_on_3"));
topology.addRelationshipTemplate(relationshipTemplates.get("2_hosted_on_3"));
topology.addRelationshipTemplate(relationshipTemplates.get("1_connects_to_2"));
// endregion
TServiceTemplate serviceTemplate = new TServiceTemplate();
serviceTemplate.setTopologyTemplate(topology.build());
EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations, relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping);
EntityGraph transform = edmmConverter.transform(serviceTemplate);
assertNotNull(transform);
assertTrue(transform.vertexSet().stream().anyMatch(entity -> entity instanceof ScalarEntity && entity.getName().equals("hosted_on") && ((ScalarEntity) entity).getValue().equals("test_node_3") && entity.getParent().isPresent() && entity.getParent().get().getName().equals("relations")));
assertTrue(transform.vertexSet().stream().anyMatch(entity -> entity instanceof ScalarEntity && entity.getName().equals("connects_to") && ((ScalarEntity) entity).getValue().equals("test_node_2") && entity.getParent().isPresent() && entity.getParent().get().getName().equals("relations")));
}
use of io.github.edmm.core.parser.EntityGraph in project winery by eclipse.
the class EdmmConverterTest method transformOneNodeTemplate.
@Test
void transformOneNodeTemplate() {
// region *** build the TopologyTemplate ***
TTopologyTemplate.Builder topology = new TTopologyTemplate.Builder();
topology.addNodeTemplate(nodeTemplates.get("test_node_1"));
// endregion
TServiceTemplate serviceTemplate = new TServiceTemplate();
serviceTemplate.setTopologyTemplate(topology.build());
EdmmConverter edmmConverter = new EdmmConverter(nodeTypes, relationshipTypes, nodeTypeImplementations, relationshipTypeImplementations, artifactTemplates, edmmTypeExtendsMapping, edmm1to1Mapping);
EntityGraph transform = edmmConverter.transform(serviceTemplate);
assertNotNull(transform);
assertEquals(13, transform.vertexSet().size());
}
Aggregations