use of org.opentosca.toscana.core.transformation.TransformationContext 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();
}
}
}
use of org.opentosca.toscana.core.transformation.TransformationContext in project TOSCAna by StuPro-TOSCAna.
the class AbstractLifeCycleTest method setUp.
@Before
public void setUp() throws IOException {
TransformationContext context = mock(TransformationContext.class);
PluginFileAccess access = new PluginFileAccess(new File(""), tmpdir, logMock());
when(context.getPluginFileAccess()).thenReturn(access);
when(context.getLogger((Class<?>) any(Class.class))).thenReturn(LoggerFactory.getLogger("Dummy Logger"));
new TestLifecycle(context);
}
use of org.opentosca.toscana.core.transformation.TransformationContext 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);
}
use of org.opentosca.toscana.core.transformation.TransformationContext in project TOSCAna by StuPro-TOSCAna.
the class ExecutionDummyPlugin method transform.
@Override
public void transform(AbstractLifecycle lifecycle) throws Exception {
TransformationContext context = lifecycle.getContext();
Logger logger = context.getLogger(getClass());
int i = 0;
context.getPluginFileAccess().access("some-output-file").append("some transformation result").close();
logger.info("Waiting 500ms until completion");
while (!Thread.currentThread().isInterrupted() && i < 5) {
Thread.sleep(100);
i++;
}
if (failDuringExec) {
logger.info("Throwing test exception");
throw new InterruptedException("Test Exception");
}
}
use of org.opentosca.toscana.core.transformation.TransformationContext in project TOSCAna by StuPro-TOSCAna.
the class FileCreationExcecutionDummy method transform.
@Override
public void transform(AbstractLifecycle lifecycle) throws Exception {
TransformationContext transformation = lifecycle.getContext();
Random rnd = new Random(123456);
for (int i = 0; i < 5; i++) {
String outerPath = "outer-" + i;
for (int j = 0; j < 5; j++) {
String innerPath = "inner-" + i;
String path = outerPath + "/" + innerPath + ".bin";
writeFilepath(transformation, rnd, path);
}
}
for (int l = 0; l < 20; l++) {
writeFilepath(transformation, rnd, "file-" + l + ".bin");
}
super.transform(lifecycle);
}
Aggregations