use of org.opentosca.toscana.model.EntityId in project TOSCAna by StuPro-TOSCAna.
the class GraphNormalizerTest method operationNormalization.
@Test
public void operationNormalization() {
ServiceGraph graph = new ServiceGraph(OPERATION, logMock());
EntityId lifecycleId = ToscaStructure.NODE_TEMPLATES.descend("test-node").descend(RootNode.INTERFACES.name).descend(RootNode.STANDARD_LIFECYCLE.name);
EntityId createId = lifecycleId.descend(StandardLifecycle.CREATE.name);
Entity createEntity = graph.getEntity(createId).get();
Operation create = new TypeWrapper().wrapEntity((MappingEntity) createEntity, Operation.class);
assertTrue(create.getArtifact().isPresent());
Artifact createArtifact = create.getArtifact().get();
assertEquals("test-artifact", createArtifact.getFilePath());
EntityId startId = lifecycleId.descend(StandardLifecycle.START.name);
Entity startEntity = graph.getEntity(startId).get();
Operation start = new TypeWrapper().wrapEntity((MappingEntity) startEntity, Operation.class);
assertTrue(start.getArtifact().isPresent());
Artifact startArtifact = start.getArtifact().get();
assertEquals("test-artifact2", startArtifact.getFilePath());
}
use of org.opentosca.toscana.model.EntityId in project TOSCAna by StuPro-TOSCAna.
the class ServiceGraphTest method get.
private String get(String... context) {
ServiceGraph graph = getGraph();
Entity entity = graph.getEntityOrThrow(new EntityId(Lists.newArrayList(context)));
return ((ScalarEntity) entity).getValue();
}
use of org.opentosca.toscana.model.EntityId in project TOSCAna by StuPro-TOSCAna.
the class ServiceGraphTest method requirementTest.
@Test
public void requirementTest() {
currentFile = REQUIREMENT;
Optional<Entity> fulfiller = getGraph().getEntity(Lists.newArrayList("topology_template", "node_templates", "test-node", "requirements", "test-requirement1", "node"));
assertTrue(fulfiller.isPresent());
Optional<Entity> fulfiller2 = getGraph().getEntity(Lists.newArrayList("topology_template", "node_templates", "test-node", "requirements", "test-requirement2", "node"));
assertTrue(fulfiller2.isPresent());
MappingEntity capabilityEntity = (MappingEntity) getGraph().getEntity(new EntityId(Lists.newArrayList("topology_template", "node_templates", "test-node", "requirements", "test-requirement2", "capability"))).get();
DatabaseEndpointCapability capability = TypeWrapper.wrapTypedElement(capabilityEntity);
assertNotNull(capability);
MappingEntity relationshipEntity = (MappingEntity) getGraph().getEntity(new EntityId(Lists.newArrayList("topology_template", "node_templates", "test-node", "requirements", "test-requirement2", "relationship"))).get();
ConnectsTo relationship = TypeWrapper.wrapTypedElement(relationshipEntity);
assertNotNull(relationship);
assertEquals(Lists.newArrayList("1", "2"), getList("topology_template", "node_templates", "test-node", "requirements", "test-requirement2", "occurrences"));
}
use of org.opentosca.toscana.model.EntityId in project TOSCAna by StuPro-TOSCAna.
the class GraphNormalizerTest method artifactNormalization.
@Test
public void artifactNormalization() {
ServiceGraph graph = new ServiceGraph(ARTIFACT, logMock());
EntityId nodeId = ToscaStructure.NODE_TEMPLATES.descend("test-node");
Entity nodeEntity = graph.getEntityOrThrow(nodeId);
WebApplication webApplication = new TypeWrapper().wrapEntity((MappingEntity) nodeEntity, WebApplication.class);
Artifact artifact = webApplication.getArtifacts().iterator().next();
assertEquals("test-artifact", artifact.getEntityName());
assertEquals("test-artifact-file", artifact.getFilePath());
}
use of org.opentosca.toscana.model.EntityId in project TOSCAna by StuPro-TOSCAna.
the class ServiceGraphTest method getList.
private List<String> getList(String... context) {
ServiceGraph graph = getGraph();
Entity entity = graph.getEntityOrThrow(new EntityId(Lists.newArrayList(context)));
return ((SequenceEntity) entity).getValues();
}
Aggregations