Search in sources :

Example 1 with Database

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

the class CheckModelRelationshipVisitor method visit.

@Override
public void visit(ConnectsTo relation) {
    RootNode source = topology.getEdgeSource(relation);
    RootNode target = topology.getEdgeTarget(relation);
    if (!(source instanceof WebApplication && target instanceof Database)) {
        throw new UnsupportedTypeException("ConnectsTo relationship from source: " + source + " to target: " + target + " not supported.");
    }
}
Also used : RootNode(org.opentosca.toscana.model.node.RootNode) Database(org.opentosca.toscana.model.node.Database) UnsupportedTypeException(org.opentosca.toscana.model.visitor.UnsupportedTypeException) WebApplication(org.opentosca.toscana.model.node.WebApplication)

Example 2 with Database

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

the class IntrinsicFunctionResolverTest method getPropertySelfTest.

@Test
public void getPropertySelfTest() {
    EffectiveModel model = new EffectiveModelFactory().create(GET_PROPERTY_SELF, logMock());
    Database database = (Database) model.getNodeMap().get("my_db");
    assertEquals("my_user_name", database.getDatabaseName());
}
Also used : Database(org.opentosca.toscana.model.node.Database) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 3 with Database

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

the class IntrinsicFunctionResolverTest method getNestedPropertyTest.

@Test
public void getNestedPropertyTest() {
    EffectiveModel model = new EffectiveModelFactory().create(GET_PROPERTY_IN_INTERFACE, logMock());
    Database database = (Database) model.getNodeMap().get("my_db");
    Set<OperationVariable> inputs = database.getStandardLifecycle().getConfigure().get().getInputs();
    OperationVariable input = inputs.stream().findFirst().orElse(null);
    assertEquals("my_user_name", input.getValue().get());
}
Also used : OperationVariable(org.opentosca.toscana.model.operation.OperationVariable) Database(org.opentosca.toscana.model.node.Database) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 4 with Database

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

the class IntrinsicFunctionResolverTest method getPropertyTest.

@Test
public void getPropertyTest() {
    EffectiveModel model = new EffectiveModelFactory().create(GET_PROPERTY, logMock());
    Database database = (Database) model.getNodeMap().get("my_second_db");
    assertEquals("my_db_name", database.getDatabaseName());
}
Also used : Database(org.opentosca.toscana.model.node.Database) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 5 with Database

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

the class IntrinsicFunctionResolverTest method correctPropertyNameTest.

/**
 *     Tests whether names of linked properties are correct
 */
@Test
public void correctPropertyNameTest() {
    EffectiveModel model = new EffectiveModelFactory().create(GET_PROPERTY_IN_INPUT, logMock());
    Database myApp = (Database) model.getNodeMap().get("my_db");
    OperationVariable input = myApp.getStandardLifecycle().getConfigure().get().getInputs().iterator().next();
    assertEquals("correct-name", input.getKey());
    assertEquals("test-string", input.getValue().get());
}
Also used : OperationVariable(org.opentosca.toscana.model.operation.OperationVariable) Database(org.opentosca.toscana.model.node.Database) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Aggregations

Database (org.opentosca.toscana.model.node.Database)6 Test (org.junit.Test)5 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)5 EffectiveModel (org.opentosca.toscana.model.EffectiveModel)5 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)5 OperationVariable (org.opentosca.toscana.model.operation.OperationVariable)2 RootNode (org.opentosca.toscana.model.node.RootNode)1 WebApplication (org.opentosca.toscana.model.node.WebApplication)1 UnsupportedTypeException (org.opentosca.toscana.model.visitor.UnsupportedTypeException)1