Search in sources :

Example 1 with TransformationImpl

use of org.opentosca.toscana.core.transformation.TransformationImpl 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 TransformationImpl

use of org.opentosca.toscana.core.transformation.TransformationImpl 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 TransformationImpl

use of org.opentosca.toscana.core.transformation.TransformationImpl 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)

Example 4 with TransformationImpl

use of org.opentosca.toscana.core.transformation.TransformationImpl in project TOSCAna by StuPro-TOSCAna.

the class TransformerHealthIndicatorTest method initTestEnvironment.

private void initTestEnvironment() {
    // Create Dummy Csar
    // DummyCsar csar = new DummyCsar("test");
    Csar csar = new CsarImpl(new File(""), MOCK_CSAR_NAME, logMock());
    csar = spy(csar);
    Map<String, Transformation> transformations = new HashMap<>();
    Set<Platform> platformSet = new HashSet<>();
    for (Object[] d : MOCK_DATA) {
        // Initialize transformation Mock
        Transformation transformation = new TransformationImpl(csar, (Platform) d[0], logMock(), modelMock());
        transformation.setState((TransformationState) d[1]);
        transformations.put(((Platform) d[0]).id, transformation);
        // Add platform to supported platform list
        platformSet.add((Platform) d[0]);
    }
    // Add Transformations to csar
    when(csar.getTransformations()).thenReturn(transformations);
    // Platforms
    when(pluginService.getSupportedPlatforms()).thenReturn(platformSet);
    // Repository
    when(repository.findAll()).thenReturn(Collections.singletonList(csar));
}
Also used : Csar(org.opentosca.toscana.core.csar.Csar) TransformationImpl(org.opentosca.toscana.core.transformation.TransformationImpl) Transformation(org.opentosca.toscana.core.transformation.Transformation) Platform(org.opentosca.toscana.core.transformation.platform.Platform) HashMap(java.util.HashMap) CsarImpl(org.opentosca.toscana.core.csar.CsarImpl) File(java.io.File) HashSet(java.util.HashSet)

Example 5 with TransformationImpl

use of org.opentosca.toscana.core.transformation.TransformationImpl in project TOSCAna by StuPro-TOSCAna.

the class CsarControllerTest method testDeleteCsarBusy.

@Test
public void testDeleteCsarBusy() throws Exception {
    // Add mock transformation to csar
    Csar csar = service.getCsar(VALID_CSAR_NAME).get();
    Transformation transformation = new TransformationImpl(csar, PLATFORM1, logMock(), modelMock());
    transformation.setState(TransformationState.TRANSFORMING);
    csar.getTransformations().put(PLATFORM1.id, transformation);
    // Perform request
    mvc.perform(delete(DELETE_VALID_CSAR_URL)).andDo(print()).andExpect(status().is(400));
}
Also used : Csar(org.opentosca.toscana.core.csar.Csar) TransformationImpl(org.opentosca.toscana.core.transformation.TransformationImpl) Transformation(org.opentosca.toscana.core.transformation.Transformation) Test(org.junit.Test) BaseSpringTest(org.opentosca.toscana.core.BaseSpringTest)

Aggregations

TransformationImpl (org.opentosca.toscana.core.transformation.TransformationImpl)9 Transformation (org.opentosca.toscana.core.transformation.Transformation)8 Csar (org.opentosca.toscana.core.csar.Csar)7 CsarImpl (org.opentosca.toscana.core.csar.CsarImpl)5 File (java.io.File)4 Before (org.junit.Before)3 Test (org.junit.Test)3 TransformationContext (org.opentosca.toscana.core.transformation.TransformationContext)3 Platform (org.opentosca.toscana.core.transformation.platform.Platform)3 HashSet (java.util.HashSet)2 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)2 EffectiveModel (org.opentosca.toscana.model.EffectiveModel)2 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Assert.assertEquals (org.junit.Assert.assertEquals)1