Search in sources :

Example 1 with CsarImpl

use of org.opentosca.toscana.core.csar.CsarImpl in project TOSCAna by StuPro-TOSCAna.

the class DeploymentPropertyTest method check.

@Test
public void check() {
    try {
        File input = new File(this.tmpdir, "in");
        File output = new File(this.tmpdir, "out");
        PropertyInstance instance = new PropertyInstance(new HashSet<>(platform.properties), mock(Transformation.class));
        if (this.input != null) {
            instance.set(Platform.DEPLOY_AFTER_TRANSFORMATION_KEY, this.input);
        }
        Csar csar = new CsarImpl(input, "csarId", logMock());
        Transformation t = new TransformationImpl(csar, platform, logMock(), mock(EffectiveModel.class));
        Transformation transformation = spy(t);
        when(transformation.getInputs()).thenReturn(instance);
        TransformationContext context = new TransformationContext(transformation, output);
        Assert.assertEquals(expected, context.performDeployment());
    } catch (Exception e) {
        e.printStackTrace(System.out);
        if (expectedException == null || !expectedException.isInstance(e)) {
            fail();
        }
    }
}
Also used : Csar(org.opentosca.toscana.core.csar.Csar) TransformationImpl(org.opentosca.toscana.core.transformation.TransformationImpl) Transformation(org.opentosca.toscana.core.transformation.Transformation) CsarImpl(org.opentosca.toscana.core.csar.CsarImpl) PropertyInstance(org.opentosca.toscana.core.transformation.properties.PropertyInstance) File(java.io.File) TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) NoSuchPropertyException(org.opentosca.toscana.core.transformation.properties.NoSuchPropertyException) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 2 with CsarImpl

use of org.opentosca.toscana.core.csar.CsarImpl in project TOSCAna by StuPro-TOSCAna.

the class LifecycleAwarePluginTest method setUp.

@Before
public void setUp() throws Exception {
    Csar csar = new CsarImpl(tmpdir, "csarId", logMock());
    Transformation t = new TransformationImpl(csar, TestPlugins.PLATFORM1, logMock(), mock(EffectiveModel.class));
    context = spy(new TransformationContext(t, tmpdir));
    doReturn(false).when(context).performDeployment();
    lifecycle = spy(new TestTransformationLifecycle(context));
    checkModel = true;
    plugin = new LifecycleTestPlugin(TestPlugins.PLATFORM1);
}
Also used : Csar(org.opentosca.toscana.core.csar.Csar) TransformationImpl(org.opentosca.toscana.core.transformation.TransformationImpl) Transformation(org.opentosca.toscana.core.transformation.Transformation) CsarImpl(org.opentosca.toscana.core.csar.CsarImpl) TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) Before(org.junit.Before)

Example 3 with CsarImpl

use of org.opentosca.toscana.core.csar.CsarImpl in project TOSCAna by StuPro-TOSCAna.

the class TransformationPropertyHandlingTest method setUp.

@Before
public void setUp() throws Exception {
    Csar csar = new CsarImpl(new File(""), MOCK_CSAR_NAME, log);
    HashSet<PlatformInput> props = new HashSet<>();
    for (int i = 0; i < 10; i++) {
        props.add(new PlatformInput("prop-" + i, PropertyType.UNSIGNED_INTEGER, "No real Description", // Only mark the first 5 properties as required
        i < 5));
    }
    Platform p = new Platform("test", "Test Platform", props);
    transformation = new TransformationImpl(csar, p, log, modelMock());
    properties = transformation.getInputs();
}
Also used : Csar(org.opentosca.toscana.core.csar.Csar) Platform(org.opentosca.toscana.core.transformation.platform.Platform) CsarImpl(org.opentosca.toscana.core.csar.CsarImpl) File(java.io.File) PlatformInput(org.opentosca.toscana.core.transformation.properties.PlatformInput) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 4 with CsarImpl

use of org.opentosca.toscana.core.csar.CsarImpl in project TOSCAna by StuPro-TOSCAna.

the class TransformationPropertyHandlingTest method checkEmptyProperties.

@Test
public void checkEmptyProperties() throws Exception {
    Csar csar = new CsarImpl(new File(""), MOCK_CSAR_NAME, log);
    this.transformation = new TransformationImpl(csar, new Platform("test", "test", new HashSet<>()), logMock(), modelMock());
    assertEquals(TransformationState.READY, transformation.getState());
    assertTrue(transformation.getInputs().isValid());
}
Also used : Csar(org.opentosca.toscana.core.csar.Csar) Platform(org.opentosca.toscana.core.transformation.platform.Platform) CsarImpl(org.opentosca.toscana.core.csar.CsarImpl) File(java.io.File) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 5 with CsarImpl

use of org.opentosca.toscana.core.csar.CsarImpl in project TOSCAna by StuPro-TOSCAna.

the class PropertyInstanceTest method init.

@Before
public void init() {
    HashSet<PlatformInput> properties = new HashSet<>();
    for (int i = 0; i < 10; i++) {
        properties.add(new PlatformInput("p-" + i, PropertyType.INTEGER, "", i < 5));
    }
    Platform testPlatform = new Platform("test", "test", properties);
    transformation = new TransformationImpl(new CsarImpl(new File(""), "test", logMock()), testPlatform, logMock(), modelMock());
    this.instance = new PropertyInstance(new HashSet<>(properties), transformation);
}
Also used : TransformationImpl(org.opentosca.toscana.core.transformation.TransformationImpl) Platform(org.opentosca.toscana.core.transformation.platform.Platform) CsarImpl(org.opentosca.toscana.core.csar.CsarImpl) File(java.io.File) HashSet(java.util.HashSet) Before(org.junit.Before)

Aggregations

CsarImpl (org.opentosca.toscana.core.csar.CsarImpl)11 File (java.io.File)8 Csar (org.opentosca.toscana.core.csar.Csar)8 Before (org.junit.Before)6 TransformationImpl (org.opentosca.toscana.core.transformation.TransformationImpl)5 Transformation (org.opentosca.toscana.core.transformation.Transformation)4 Platform (org.opentosca.toscana.core.transformation.platform.Platform)4 EffectiveModel (org.opentosca.toscana.model.EffectiveModel)4 HashSet (java.util.HashSet)3 TransformationContext (org.opentosca.toscana.core.transformation.TransformationContext)3 Log (org.opentosca.toscana.core.transformation.logging.Log)3 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)2 CsarService (org.opentosca.toscana.core.csar.CsarService)2 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1