use of org.opentosca.toscana.core.transformation.TransformationImpl in project TOSCAna by StuPro-TOSCAna.
the class TransformationControllerTest method mockTransformationService.
private void mockTransformationService() {
transformationService = mock(TransformationService.class);
when(transformationService.createTransformation(any(Csar.class), any(Platform.class))).then(iom -> {
Csar csar = (Csar) iom.getArguments()[0];
Platform platform = (Platform) iom.getArguments()[1];
Transformation t = new TransformationImpl(csar, platform, logMock(), modelMock());
csar.getTransformations().put(platform.id, t);
return t;
});
}
use of org.opentosca.toscana.core.transformation.TransformationImpl in project TOSCAna by StuPro-TOSCAna.
the class CsarFilesystemDaoTest method returnedCsarHasPopulatedTransformations.
@Test
public void returnedCsarHasPopulatedTransformations() {
// test whether CsarDao calls TransformationDao internally to populate list of transformations
String identifier = createFakeCsarDirectories(1)[0];
Csar csar = new CsarImpl(new File(""), identifier, logMock());
csarDao = new CsarFilesystemDao(preferences, transformationDao);
List<Transformation> transformations = TestPlugins.PLATFORMS.stream().map(platform -> new TransformationImpl(csar, platform, logMock(), modelMock())).collect(Collectors.toList());
when(transformationDao.find(any())).thenReturn(transformations);
csarDao.init();
Optional<Csar> result = csarDao.find(identifier);
assertTrue(result.isPresent());
assertEquals(TestPlugins.PLATFORMS.size(), result.get().getTransformations().size());
}
use of org.opentosca.toscana.core.transformation.TransformationImpl in project TOSCAna by StuPro-TOSCAna.
the class TransformationControllerTest method preInitNonCreationTests.
// </editor-fold>
// <editor-fold desc="Util Methods">
public List<Transformation> preInitNonCreationTests() throws PlatformNotFoundException {
// add a transformation
Optional<Csar> csar = csarService.getCsar(VALID_CSAR_NAME);
assertTrue(csar.isPresent());
String[] pnames = { VALID_PLATFORM_NAME, SECOND_VALID_PLATFORM_NAME };
List<Transformation> transformations = new ArrayList<>();
for (String pname : pnames) {
LogEntry entry = new LogEntry(0, "Test Context", "Test Message", Level.DEBUG);
Log mockLog = logMock();
when(mockLog.getLogEntries(0)).thenReturn(Collections.singletonList(entry));
Transformation transformation = new TransformationImpl(csar.get(), platformService.findPlatformById(pname).get(), mockLog, modelMock());
transformation = spy(transformation);
transformations.add(transformation);
csar.get().getTransformations().put(pname, transformation);
}
return transformations;
}
use of org.opentosca.toscana.core.transformation.TransformationImpl 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);
}
Aggregations