Search in sources :

Example 6 with EntityId

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());
}
Also used : EntityId(org.opentosca.toscana.model.EntityId) ScalarEntity(org.opentosca.toscana.core.parse.model.ScalarEntity) Entity(org.opentosca.toscana.core.parse.model.Entity) MappingEntity(org.opentosca.toscana.core.parse.model.MappingEntity) ServiceGraph(org.opentosca.toscana.core.parse.model.ServiceGraph) Operation(org.opentosca.toscana.model.operation.Operation) Artifact(org.opentosca.toscana.model.artifact.Artifact) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 7 with EntityId

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();
}
Also used : EntityId(org.opentosca.toscana.model.EntityId)

Example 8 with EntityId

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"));
}
Also used : EntityId(org.opentosca.toscana.model.EntityId) ConnectsTo(org.opentosca.toscana.model.relation.ConnectsTo) DatabaseEndpointCapability(org.opentosca.toscana.model.capability.DatabaseEndpointCapability) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 9 with EntityId

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());
}
Also used : EntityId(org.opentosca.toscana.model.EntityId) ScalarEntity(org.opentosca.toscana.core.parse.model.ScalarEntity) Entity(org.opentosca.toscana.core.parse.model.Entity) MappingEntity(org.opentosca.toscana.core.parse.model.MappingEntity) ServiceGraph(org.opentosca.toscana.core.parse.model.ServiceGraph) WebApplication(org.opentosca.toscana.model.node.WebApplication) Artifact(org.opentosca.toscana.model.artifact.Artifact) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 10 with EntityId

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();
}
Also used : EntityId(org.opentosca.toscana.model.EntityId)

Aggregations

EntityId (org.opentosca.toscana.model.EntityId)13 MappingEntity (org.opentosca.toscana.core.parse.model.MappingEntity)5 ScalarEntity (org.opentosca.toscana.core.parse.model.ScalarEntity)5 Entity (org.opentosca.toscana.core.parse.model.Entity)4 Test (org.junit.Test)3 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)3 Artifact (org.opentosca.toscana.model.artifact.Artifact)3 ServiceGraph (org.opentosca.toscana.core.parse.model.ServiceGraph)2 ToscaTemplateException (org.opentosca.toscana.core.parse.ToscaTemplateException)1 DatabaseEndpointCapability (org.opentosca.toscana.model.capability.DatabaseEndpointCapability)1 RootNode (org.opentosca.toscana.model.node.RootNode)1 WebApplication (org.opentosca.toscana.model.node.WebApplication)1 Operation (org.opentosca.toscana.model.operation.Operation)1 ConnectsTo (org.opentosca.toscana.model.relation.ConnectsTo)1 MappingNode (org.yaml.snakeyaml.nodes.MappingNode)1 Node (org.yaml.snakeyaml.nodes.Node)1 NodeTuple (org.yaml.snakeyaml.nodes.NodeTuple)1 ScalarNode (org.yaml.snakeyaml.nodes.ScalarNode)1 SequenceNode (org.yaml.snakeyaml.nodes.SequenceNode)1