Search in sources :

Example 6 with EffectiveModel

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

the class KubernetesPluginTest method modelCheckTest.

@Test(expected = ValidationFailureException.class)
public void modelCheckTest() throws Exception {
    EffectiveModel singleComputeModel = new EffectiveModelFactory().create(TestCsars.VALID_SINGLE_COMPUTE_WINDOWS_TEMPLATE, logMock());
    TransformationContext context = setUpMockTransformationContext(singleComputeModel);
    KubernetesLifecycle lifecycle = plugin.getInstance(context);
    plugin.transform(lifecycle);
}
Also used : KubernetesLifecycle(org.opentosca.toscana.plugins.kubernetes.lifecycle.KubernetesLifecycle) TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext) TestUtil.setUpMockTransformationContext(org.opentosca.toscana.plugins.util.TestUtil.setUpMockTransformationContext) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) MapperTest(org.opentosca.toscana.plugins.kubernetes.docker.mapper.MapperTest) Test(org.junit.Test)

Example 7 with EffectiveModel

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

the class TransformationFilesystemDao method createTransformation.

private Transformation createTransformation(Csar csar, Platform platform) {
    try {
        Log log = getLog(csar, platform);
        EffectiveModel model = effectiveModelFactory.create(csar.getTemplate(), log);
        return new TransformationImpl(csar, platform, getLog(csar, platform), model);
    } catch (InvalidCsarException e) {
        throw new IllegalStateException("Failed to create csar. Should not have happened - csar upload should have" + "already failed", e);
    }
}
Also used : Log(org.opentosca.toscana.core.transformation.logging.Log) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) InvalidCsarException(org.opentosca.toscana.core.parse.InvalidCsarException)

Example 8 with EffectiveModel

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

the class BaseTest method modelMock.

/**
 *     @return a mocked EffectiveModel instance which returns empty sets / maps /graphs upon every call
 */
protected EffectiveModel modelMock() {
    EffectiveModel model = mock(EffectiveModel.class);
    when(model.getInputs()).thenReturn(new HashMap<>());
    when(model.getNodeMap()).thenReturn(new HashMap<>());
    when(model.getNodes()).thenReturn(new HashSet<>());
    when(model.getTopology()).thenReturn(new DefaultDirectedGraph<>(RootRelationship.class));
    return model;
}
Also used : EffectiveModel(org.opentosca.toscana.model.EffectiveModel) RootRelationship(org.opentosca.toscana.model.relation.RootRelationship)

Example 9 with EffectiveModel

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

the class LinkResolverTest method resolveRequirementLink.

@Test
public void resolveRequirementLink() {
    EffectiveModel model = new EffectiveModelFactory().create(REQUIREMENT, logMock());
    WebServer node = (WebServer) model.getNodeMap().get("test-node1");
    HostRequirement requirement = node.getHost();
    assertNotNull(requirement);
    Set<Compute> fulfillers = requirement.getFulfillers();
    assertEquals(1, fulfillers.size());
    Compute fulfiller = fulfillers.iterator().next();
    assertEquals("test-node2", fulfiller.getEntityName());
}
Also used : WebServer(org.opentosca.toscana.model.node.WebServer) HostRequirement(org.opentosca.toscana.model.requirement.HostRequirement) Compute(org.opentosca.toscana.model.node.Compute) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 10 with EffectiveModel

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

the class LinkResolverTest method resolveRepositoryLink.

@Test
public void resolveRepositoryLink() {
    EffectiveModel model = new EffectiveModelFactory().create(REPOSITORY, logMock());
    WebServer node = (WebServer) model.getNodeMap().get("test-node");
    Set<Artifact> artifacts = node.getArtifacts();
    Artifact artifact = artifacts.iterator().next();
    assertNotNull(artifact);
    Optional<Repository> repo = artifact.getRepository();
    assertTrue(repo.isPresent());
    assertEquals("http://test.repo.com/", repo.get().getUrl());
}
Also used : Repository(org.opentosca.toscana.model.artifact.Repository) WebServer(org.opentosca.toscana.model.node.WebServer) 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