Search in sources :

Example 21 with EffectiveModel

use of org.opentosca.toscana.model.EffectiveModel in project TOSCAna by StuPro-TOSCAna.

the class LinkResolverTest method resolveImplementationLink.

@Test
public void resolveImplementationLink() {
    EffectiveModel model = new EffectiveModelFactory().create(ARTIFACT, logMock());
    WebServer node = (WebServer) model.getNodeMap().get("test-node");
    Optional<Operation> create = node.getStandardLifecycle().getCreate();
    assertTrue(create.isPresent());
    Optional<Artifact> artifact = create.get().getArtifact();
    assertTrue(artifact.isPresent());
    assertEquals("test-file", artifact.get().getFilePath());
}
Also used : WebServer(org.opentosca.toscana.model.node.WebServer) Operation(org.opentosca.toscana.model.operation.Operation) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) Artifact(org.opentosca.toscana.model.artifact.Artifact) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 22 with EffectiveModel

use of org.opentosca.toscana.model.EffectiveModel in project TOSCAna by StuPro-TOSCAna.

the class DataTypeTest method portTest.

@Test
public void portTest() {
    EffectiveModel model = new EffectiveModelFactory().create(TestTemplates.Datatypes.PORT, logMock());
    WebApplication app = (WebApplication) model.getNodes().iterator().next();
    EndpointCapability endpoint = app.getAppEndpoint();
    assertEquals(new Port(3000), endpoint.getPort().get());
    Port expected = new Port(4000);
    endpoint.setPort(expected);
    assertEquals(expected, endpoint.getPort().get());
}
Also used : Port(org.opentosca.toscana.model.datatype.Port) WebApplication(org.opentosca.toscana.model.node.WebApplication) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) EndpointCapability(org.opentosca.toscana.model.capability.EndpointCapability) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 23 with EffectiveModel

use of org.opentosca.toscana.model.EffectiveModel in project TOSCAna by StuPro-TOSCAna.

the class DynamicRequirementTest method dynamicRequirementTest.

@Test
public void dynamicRequirementTest() {
    EffectiveModel model = new EffectiveModelFactory().create(TestTemplates.Requirements.DYNAMIC_REQUIREMENT, logMock());
    WebApplication app = (WebApplication) model.getNodes().iterator().next();
    Requirement<? extends Capability, ? extends RootNode, ? extends RootRelationship> dynamicRequirement = app.getRequirements().stream().filter(r -> "dynamic-requirement".equals(r.getEntityName())).findFirst().orElseThrow(() -> new IllegalStateException("dynamic requirement should exist"));
    RootRelationship relationship = dynamicRequirement.getRelationship().get();
    assertEquals(ConnectsTo.class, relationship.getClass());
    Capability capability = dynamicRequirement.get(dynamicRequirement.CAPABILITY);
    assertEquals(EndpointCapability.class, capability.getClass());
    RootNode fulfiller = dynamicRequirement.getFulfillers().iterator().next();
    assertEquals(app, fulfiller);
}
Also used : RootNode(org.opentosca.toscana.model.node.RootNode) EndpointCapability(org.opentosca.toscana.model.capability.EndpointCapability) Capability(org.opentosca.toscana.model.capability.Capability) WebApplication(org.opentosca.toscana.model.node.WebApplication) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) RootRelationship(org.opentosca.toscana.model.relation.RootRelationship) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 24 with EffectiveModel

use of org.opentosca.toscana.model.EffectiveModel in project TOSCAna by StuPro-TOSCAna.

the class EffectiveModelTest method outputTest.

@Test
public void outputTest() {
    EffectiveModel model = new EffectiveModelFactory().create(TestCsars.Testing.OUTPUTS_TEMPLATE, logMock());
    Map<String, OutputProperty> outputs = model.getOutputs();
    assertNotNull(outputs);
    assertEquals(1, outputs.size());
    OutputProperty linkedOutput = outputs.get("test_output_linked");
    assertNotNull(linkedOutput);
    assertTrue(linkedOutput.getDescription().isPresent());
    assertEquals("test-description2", linkedOutput.getDescription().get());
    assertTrue(linkedOutput.getValue().isPresent());
    assertEquals("8084", linkedOutput.getValue().get());
}
Also used : OutputProperty(org.opentosca.toscana.core.transformation.properties.OutputProperty) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 25 with EffectiveModel

use of org.opentosca.toscana.model.EffectiveModel in project TOSCAna by StuPro-TOSCAna.

the class NodeConvertTest method java.

@Test
public void java() {
    EffectiveModel model = new EffectiveModelFactory().create(JAVA, logMock());
    JavaApplication app = (JavaApplication) model.getNodeMap().get("app");
    assertEquals("test-vm_options", app.getVmOptions().get());
    assertEquals("test-arguments", app.getArguments().get());
    Artifact artifact = app.getJar();
    assertEquals("test-artifact-path", artifact.getFilePath());
    JavaRuntime jre = (JavaRuntime) model.getNodeMap().get("jre");
    assertEquals("1.8", jre.getComponentVersion().get());
}
Also used : JavaRuntime(org.opentosca.toscana.model.node.custom.JavaRuntime) JavaApplication(org.opentosca.toscana.model.node.custom.JavaApplication) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) Artifact(org.opentosca.toscana.model.artifact.Artifact) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Aggregations

EffectiveModel (org.opentosca.toscana.model.EffectiveModel)33 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)31 Test (org.junit.Test)22 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)22 File (java.io.File)9 Before (org.junit.Before)9 PluginFileAccess (org.opentosca.toscana.core.plugin.PluginFileAccess)5 Database (org.opentosca.toscana.model.node.Database)5 Application (org.opentosca.toscana.plugins.cloudfoundry.application.Application)5 Log (org.opentosca.toscana.core.transformation.logging.Log)4 WebApplication (org.opentosca.toscana.model.node.WebApplication)4 Artifact (org.opentosca.toscana.model.artifact.Artifact)3 WebServer (org.opentosca.toscana.model.node.WebServer)3 FileCreator (org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator)3 ArrayList (java.util.ArrayList)2 CsarImpl (org.opentosca.toscana.core.csar.CsarImpl)2 PropertyInstance (org.opentosca.toscana.core.transformation.properties.PropertyInstance)2 EndpointCapability (org.opentosca.toscana.model.capability.EndpointCapability)2 Compute (org.opentosca.toscana.model.node.Compute)2 RootNode (org.opentosca.toscana.model.node.RootNode)2