Search in sources :

Example 6 with TransformationContext

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

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

the class ExecutionTask method transform.

private void transform() {
    try {
        AbstractLifecycle lifecycle = plugin.getInstance(new TransformationContext(transformation, transformationRootDir));
        transformation.setLifecyclePhases(lifecycle.getLifecyclePhases());
        plugin.transform(lifecycle);
        transformation.setState(TransformationState.DONE);
    } catch (Exception e) {
        logger.info("Transformation of {}/{} failed", csarId, platformId);
        logger.error("Something went wrong while transforming", e);
        failed = true;
    }
}
Also used : TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext) IOException(java.io.IOException)

Example 8 with TransformationContext

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

the class CloudFormationFileCreatorTest method setUp.

@Before
public void setUp() throws Exception {
    File sourceDir = new File(tmpdir, "sourceDir");
    targetDir = new File(tmpdir, "targetDir");
    sourceDir.mkdir();
    targetDir.mkdir();
    FILEPATH_SOURCE_TEST_FILE = new File(sourceDir, FILENAME_TEST_FILE);
    FILEPATH_TARGET_TEST_FILE = new File(targetDir, FILEPATH_TARGET + FILENAME_TEST_FILE);
    writeTestFile();
    FILEPATH_TARGET_TEST_FILE_LOCAL = RELATIVE_DIRECTORY_PREFIX + FILENAME_TEST_FILE;
    when(log.getLogger(any(Class.class))).thenReturn(mock(Logger.class));
    PluginFileAccess fileAccess = new PluginFileAccess(sourceDir, targetDir, log);
    cfnModule = new CloudFormationModule(fileAccess, "us-west-2", new BasicAWSCredentials("", ""));
    TransformationContext context = mock(TransformationContext.class);
    when(context.getLogger((Class<?>) any(Class.class))).thenReturn(LoggerFactory.getLogger("File Creator Test Logger"));
    fileCreator = new CloudFormationFileCreator(context, cfnModule);
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) Logger(org.slf4j.Logger) File(java.io.File) TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) Before(org.junit.Before)

Example 9 with TransformationContext

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

the class CloudFormationPluginTest method setUp.

@Before
public void setUp() throws Exception {
    lamp = new EffectiveModelFactory().create(TestCsars.VALID_LAMP_NO_INPUT_TEMPLATE, logMock());
    fileAccess = new PluginFileAccess(new File("src/test/resources/csars/yaml/valid/lamp-input/"), tmpdir, logMock());
    cfnModule = new CloudFormationModule(fileAccess, "us-west-2", new BasicAWSCredentials("", ""));
    TransformationContext context = mock(TransformationContext.class);
    when(context.getModel()).thenReturn(lamp);
    when(context.getLogger((Class<?>) any(Class.class))).thenReturn(LoggerFactory.getLogger("Dummy Logger"));
    TransformModelNodeVisitor cfnNodeVisitorL = new TransformModelNodeVisitor(context, cfnModule);
    cfnNodeVisitor = spy(cfnNodeVisitorL);
    CapabilityMapper capabilityMapper = mock(CapabilityMapper.class);
    when(capabilityMapper.mapOsCapabilityToImageId(any(OsCapability.class))).thenReturn("ami-testami");
    when(cfnNodeVisitor.createCapabilityMapper()).thenReturn(capabilityMapper);
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) OsCapability(org.opentosca.toscana.model.capability.OsCapability) TransformModelNodeVisitor(org.opentosca.toscana.plugins.cloudformation.visitor.TransformModelNodeVisitor) File(java.io.File) TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext) CapabilityMapper(org.opentosca.toscana.plugins.cloudformation.mapper.CapabilityMapper) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) Before(org.junit.Before)

Example 10 with TransformationContext

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

the class TestUtil method setUpMockTransformationContext.

public static TransformationContext setUpMockTransformationContext(EffectiveModel model) throws IOException {
    TransformationContext context = mock(TransformationContext.class);
    PluginFileAccess pluginFileAccess = mock(PluginFileAccess.class);
    when(context.getPluginFileAccess()).thenReturn(pluginFileAccess);
    when(context.getModel()).thenReturn(model);
    when(context.getLogger((Class<?>) any(Class.class))).thenReturn(LoggerFactory.getLogger("Dummy Logger"));
    PluginFileAccess.BufferedLineWriter mock = mock(PluginFileAccess.BufferedLineWriter.class);
    when(pluginFileAccess.access(any(String.class))).thenReturn(mock);
    when(mock.append(any(String.class))).thenReturn(mock);
    return context;
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext)

Aggregations

TransformationContext (org.opentosca.toscana.core.transformation.TransformationContext)13 File (java.io.File)4 Before (org.junit.Before)4 PluginFileAccess (org.opentosca.toscana.core.plugin.PluginFileAccess)4 Test (org.junit.Test)3 Csar (org.opentosca.toscana.core.csar.Csar)3 CsarImpl (org.opentosca.toscana.core.csar.CsarImpl)3 Transformation (org.opentosca.toscana.core.transformation.Transformation)3 TransformationImpl (org.opentosca.toscana.core.transformation.TransformationImpl)3 EffectiveModel (org.opentosca.toscana.model.EffectiveModel)3 Logger (org.slf4j.Logger)3 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)2 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)2 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)2 IOException (java.io.IOException)1 Random (java.util.Random)1 IntegrationTest (org.opentosca.toscana.IntegrationTest)1 NoSuchPropertyException (org.opentosca.toscana.core.transformation.properties.NoSuchPropertyException)1 PropertyInstance (org.opentosca.toscana.core.transformation.properties.PropertyInstance)1 OsCapability (org.opentosca.toscana.model.capability.OsCapability)1