Search in sources :

Example 1 with TransformationDao

use of org.opentosca.toscana.core.transformation.TransformationDao 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());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Mock(org.mockito.Mock) Transformation(org.opentosca.toscana.core.transformation.Transformation) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) FileInputStream(java.io.FileInputStream) Mockito.when(org.mockito.Mockito.when) Collectors(java.util.stream.Collectors) TestPlugins(org.opentosca.toscana.core.testdata.TestPlugins) File(java.io.File) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) TransformationImpl(org.opentosca.toscana.core.transformation.TransformationImpl) List(java.util.List) Preferences(org.opentosca.toscana.core.util.Preferences) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) TransformationDao(org.opentosca.toscana.core.transformation.TransformationDao) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) TestCsars(org.opentosca.toscana.core.testdata.TestCsars) Before(org.junit.Before) TransformationImpl(org.opentosca.toscana.core.transformation.TransformationImpl) Transformation(org.opentosca.toscana.core.transformation.Transformation) File(java.io.File) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Aggregations

File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 List (java.util.List)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertNotEquals (org.junit.Assert.assertNotEquals)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 Mock (org.mockito.Mock)1 Mockito.when (org.mockito.Mockito.when)1 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)1 TestCsars (org.opentosca.toscana.core.testdata.TestCsars)1 TestPlugins (org.opentosca.toscana.core.testdata.TestPlugins)1 Transformation (org.opentosca.toscana.core.transformation.Transformation)1 TransformationDao (org.opentosca.toscana.core.transformation.TransformationDao)1