use of org.opentosca.toscana.core.transformation.Transformation 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.Transformation 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.Transformation 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.Transformation in project TOSCAna by StuPro-TOSCAna.
the class TransformationControllerTest method testGetOutputsInvalidState.
@Test
public void testGetOutputsInvalidState() throws Exception {
List<Transformation> transformations = preInitNonCreationTests();
Transformation t = transformations.get(0);
when(t.getState()).thenReturn(TransformationState.TRANSFORMING);
mvc.perform(get(GET_OUTPUT_URL)).andDo(print()).andExpect(status().is(400)).andReturn();
}
use of org.opentosca.toscana.core.transformation.Transformation in project TOSCAna by StuPro-TOSCAna.
the class TransformationControllerTest method testGetOutputsEmptyOutputs.
@Test
public void testGetOutputsEmptyOutputs() throws Exception {
List<Transformation> transformations = preInitNonCreationTests();
Transformation t = transformations.get(0);
when(t.getState()).thenReturn(TransformationState.DONE);
when(t.getOutputs()).thenReturn(new ArrayList<>());
mvc.perform(get(GET_OUTPUT_URL)).andDo(print()).andExpect(status().is(200)).andExpect(jsonPath("$.outputs").isArray()).andExpect(jsonPath("$.links[0].href").value("http://localhost/api/csars/kubernetes-cluster/transformations/p-a/outputs")).andReturn();
}
Aggregations