Search in sources :

Example 1 with PlatformService

use of org.opentosca.toscana.core.transformation.platform.PlatformService in project TOSCAna by StuPro-TOSCAna.

the class TransformationControllerTest method mockPlatformService.

private void mockPlatformService() {
    platformService = mock(PlatformService.class);
    Set<Platform> platforms = new HashSet<>();
    for (int i = 0; i < 5; i++) {
        HashSet<PlatformInput> inputs = new HashSet<>();
        for (PropertyType type : PropertyType.values()) {
            inputs.add(new PlatformInput(type.getTypeName() + "_input", type));
        }
        char[] chars = "abcdefghijklmnopqrstuvwxyz".toCharArray();
        if (i == 0) {
            inputs.add(new PlatformInput(PROPERTY_TEST_DEFAULT_VALUE_KEY, PropertyType.TEXT, "", false, INPUT_TEST_DEFAULT_VALUE));
        }
        platforms.add(new Platform("p-" + chars[i], "platform-" + (i + 1), inputs));
    }
    when(platformService.getSupportedPlatforms()).thenReturn(platforms);
    when(platformService.isSupported(any(Platform.class))).thenReturn(false);
    when(platformService.findPlatformById(anyString())).thenReturn(Optional.empty());
    for (Platform platform : platforms) {
        when(platformService.findPlatformById(platform.id)).thenReturn(Optional.of(platform));
        when(platformService.isSupported(platform)).thenReturn(true);
    }
}
Also used : PlatformService(org.opentosca.toscana.core.transformation.platform.PlatformService) Platform(org.opentosca.toscana.core.transformation.platform.Platform) PropertyType(org.opentosca.toscana.core.transformation.properties.PropertyType) MockMvcResultHandlers.print(org.springframework.test.web.servlet.result.MockMvcResultHandlers.print) HashSet(java.util.HashSet) PlatformInput(org.opentosca.toscana.core.transformation.properties.PlatformInput)

Aggregations

HashSet (java.util.HashSet)1 Platform (org.opentosca.toscana.core.transformation.platform.Platform)1 PlatformService (org.opentosca.toscana.core.transformation.platform.PlatformService)1 PlatformInput (org.opentosca.toscana.core.transformation.properties.PlatformInput)1 PropertyType (org.opentosca.toscana.core.transformation.properties.PropertyType)1 MockMvcResultHandlers.print (org.springframework.test.web.servlet.result.MockMvcResultHandlers.print)1