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);
}
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;
}
}
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);
}
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);
}
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;
}
Aggregations