Search in sources :

Example 1 with Capability

use of org.opentosca.toscana.model.capability.Capability 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)

Aggregations

Test (org.junit.Test)1 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)1 EffectiveModel (org.opentosca.toscana.model.EffectiveModel)1 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)1 Capability (org.opentosca.toscana.model.capability.Capability)1 EndpointCapability (org.opentosca.toscana.model.capability.EndpointCapability)1 RootNode (org.opentosca.toscana.model.node.RootNode)1 WebApplication (org.opentosca.toscana.model.node.WebApplication)1 RootRelationship (org.opentosca.toscana.model.relation.RootRelationship)1