use of org.opentosca.toscana.core.transformation.TransformationContext in project TOSCAna by StuPro-TOSCAna.
the class BaseTransformTest method initContext.
/**
* initializes the transformation context
*/
protected TransformationContext initContext() throws Exception {
Csar csar = new CsarImpl(tmpdir, "csarId", logMock());
Transformation t = new TransformationImpl(csar, plugin.getPlatform(), logMock(), model);
Transformation transformation = spy(t);
when(transformation.getInputs()).thenReturn(inputs);
return new TransformationContext(transformation, workingDir);
}
use of org.opentosca.toscana.core.transformation.TransformationContext in project TOSCAna by StuPro-TOSCAna.
the class ExportingImageBuilderIT method testBuildShaImage.
@Test
public void testBuildShaImage() throws Exception {
assumeTrue(DockerTestUtils.isDockerAvailable());
// Create Dockerfile and the corresponding Binary file
shaDigest = buildSHADockerfile();
init();
TransformationContext ctx = mock(TransformationContext.class);
when(ctx.getPluginFileAccess()).thenReturn(access);
when(ctx.getLogger((Class<?>) any(Class.class))).thenReturn(LoggerFactory.getLogger("Mock Logger"));
imageBuilder = instantiateImageBuilder(ctx);
logger.info("Building Image");
imageBuilder.buildImage();
logger.info("Storing Image");
imageBuilder.storeImage();
validate(imageBuilder.getTag());
}
use of org.opentosca.toscana.core.transformation.TransformationContext in project TOSCAna by StuPro-TOSCAna.
the class ToscanaPlugin method transform.
/**
* This method will transform given model (contained in the TransformationContext instance) and will store the result
* in a directory provided by the context.
* <p>
* Performs the execution in phases in the order that has been defined during the construction of the object
*/
public void transform(LifecycleT lifecycle) throws Exception {
TransformationContext context = lifecycle.getContext();
Logger logger = context.getLogger(getClass());
long time = System.currentTimeMillis();
List<ExecutionPhase> phases = lifecycle.getLifecyclePhases();
int taskCount = countExecutionPhases(context, phases);
logger.info("This transformation has {} phases", taskCount);
for (int i = 0; i < phases.size(); i++) {
ExecutionPhase phase = phases.get(i);
if (phase.shouldExecute(context)) {
logger.info("Executing phase '{}' ({} of {})", phase.getName(), (i + 1), taskCount);
phase.execute(lifecycle);
} else {
phase.skip();
logger.info("Skipping phase '{}' ({} of {})", phase.getName(), (i + 1), taskCount);
}
}
time = System.currentTimeMillis() - time;
logger.info("Transformation finished after {} ms", time);
}
Aggregations