Search in sources :

Example 6 with ServiceGraph

use of org.opentosca.toscana.core.parse.model.ServiceGraph in project TOSCAna by StuPro-TOSCAna.

the class GraphNormalizerTest method repositoryNormalization.

@Test
public void repositoryNormalization() {
    ServiceGraph graph = new ServiceGraph(REPOSITORY, logMock());
    Collection<Entity> repositories = graph.getEntity(ToscaStructure.REPOSITORIES).get().getChildren();
    Entity repository = repositories.iterator().next();
    Optional<Entity> url = repository.getChild("url");
    assertTrue(url.isPresent());
    Assert.assertEquals("http://test.repo.com/", ((ScalarEntity) url.get()).getValue());
}
Also used : 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) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 7 with ServiceGraph

use of org.opentosca.toscana.core.parse.model.ServiceGraph 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 8 with ServiceGraph

use of org.opentosca.toscana.core.parse.model.ServiceGraph in project TOSCAna by StuPro-TOSCAna.

the class TypeResolverTest method supportForAllWineryNodeTypes.

@Test
public void supportForAllWineryNodeTypes() {
    Set<String> wineryNodeTypes = getWineryNodeTypes();
    for (String nodeType : wineryNodeTypes) {
        logger.info("Testing conversion of type '{}'", nodeType);
        ServiceGraph graph = new ServiceGraph(logMock());
        MappingEntity nodeEntity = new MappingEntity(ToscaStructure.NODE_TEMPLATES.descend("my-node"), graph);
        graph.addEntity(nodeEntity);
        ScalarEntity typeEntity = new ScalarEntity(nodeType, nodeEntity.getId().descend("type"), graph);
        graph.addEntity(typeEntity);
        BaseToscaElement node = TypeWrapper.wrapTypedElement(nodeEntity);
        assertNotNull(node);
        logger.info("Node Type '{}': known", nodeType);
        System.out.println();
    }
// successful if no exception thrown
}
Also used : BaseToscaElement(org.opentosca.toscana.model.BaseToscaElement) ServiceGraph(org.opentosca.toscana.core.parse.model.ServiceGraph) ScalarEntity(org.opentosca.toscana.core.parse.model.ScalarEntity) MappingEntity(org.opentosca.toscana.core.parse.model.MappingEntity) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 9 with ServiceGraph

use of org.opentosca.toscana.core.parse.model.ServiceGraph in project TOSCAna by StuPro-TOSCAna.

the class MapperTest method getEntity.

public static MappingEntity getEntity() {
    ServiceGraph graph = new ServiceGraph(BaseTest.logMock());
    MappingEntity entity = new MappingEntity(entityId, graph);
    graph.addEntity(entity);
    return entity;
}
Also used : ServiceGraph(org.opentosca.toscana.core.parse.model.ServiceGraph) MappingEntity(org.opentosca.toscana.core.parse.model.MappingEntity)

Example 10 with ServiceGraph

use of org.opentosca.toscana.core.parse.model.ServiceGraph in project TOSCAna by StuPro-TOSCAna.

the class MapperTagLoaderIT method setUp.

@BeforeClass
public static void setUp() {
    ServiceGraph graph = new ServiceGraph(logMock());
    nodeEntity = new MappingEntity(entityId, graph);
    graph.addEntity(nodeEntity);
}
Also used : ServiceGraph(org.opentosca.toscana.core.parse.model.ServiceGraph) MappingEntity(org.opentosca.toscana.core.parse.model.MappingEntity) BeforeClass(org.junit.BeforeClass)

Aggregations

ServiceGraph (org.opentosca.toscana.core.parse.model.ServiceGraph)11 MappingEntity (org.opentosca.toscana.core.parse.model.MappingEntity)9 ScalarEntity (org.opentosca.toscana.core.parse.model.ScalarEntity)7 Entity (org.opentosca.toscana.core.parse.model.Entity)5 Test (org.junit.Test)4 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)4 EntityId (org.opentosca.toscana.model.EntityId)2 Artifact (org.opentosca.toscana.model.artifact.Artifact)2 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 ToscaTemplateException (org.opentosca.toscana.core.parse.ToscaTemplateException)1 BaseToscaElement (org.opentosca.toscana.model.BaseToscaElement)1 WebApplication (org.opentosca.toscana.model.node.WebApplication)1 Operation (org.opentosca.toscana.model.operation.Operation)1