Search in sources :

Example 11 with PluginFileAccess

use of org.opentosca.toscana.core.plugin.PluginFileAccess in project TOSCAna by StuPro-TOSCAna.

the class BaseDockerfileTest method setUp.

@Before
public void setUp() {
    inputDir = new File(tmpdir, INPUT_DIR_NAME);
    workDir = new File(tmpdir, WORKING_DIR_NAME);
    dockerWorkdir = new File(workDir, WORKING_DIR_SUBFOLDER_NAME);
    logger.info("Initialing Environment");
    inputDir.mkdirs();
    workDir.mkdirs();
    access = new PluginFileAccess(inputDir, workDir, logMock());
    builder = new DockerfileBuilder("library/ubuntu:latest", WORKING_DIR_SUBFOLDER_NAME, access);
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) DockerfileBuilder(org.opentosca.toscana.plugins.kubernetes.docker.dockerfile.builder.DockerfileBuilder) File(java.io.File) Before(org.junit.Before)

Example 12 with PluginFileAccess

use of org.opentosca.toscana.core.plugin.PluginFileAccess in project TOSCAna by StuPro-TOSCAna.

the class TestUtil method setUpMockTransformationContext.

public static TransformationContext setUpMockTransformationContext(EffectiveModel model) throws IOException {
    TransformationContext context = mock(TransformationContext.class);
    PluginFileAccess pluginFileAccess = mock(PluginFileAccess.class);
    when(context.getPluginFileAccess()).thenReturn(pluginFileAccess);
    when(context.getModel()).thenReturn(model);
    when(context.getLogger((Class<?>) any(Class.class))).thenReturn(LoggerFactory.getLogger("Dummy Logger"));
    PluginFileAccess.BufferedLineWriter mock = mock(PluginFileAccess.BufferedLineWriter.class);
    when(pluginFileAccess.access(any(String.class))).thenReturn(mock);
    when(mock.append(any(String.class))).thenReturn(mock);
    return context;
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext)

Example 13 with PluginFileAccess

use of org.opentosca.toscana.core.plugin.PluginFileAccess in project TOSCAna by StuPro-TOSCAna.

the class CloudFoundryLifecycle method transform.

@Override
public void transform() {
    logger.info("Begin transformation to Cloud Foundry.");
    PluginFileAccess fileAccess = context.getPluginFileAccess();
    fillApplications();
    try {
        FileCreator fileCreator = new FileCreator(fileAccess, filledApplications, context);
        fileCreator.createFiles();
    } catch (FileNotFoundException f) {
        throw new TransformationFailureException("A file which is declared in the template could not be found", f);
    } catch (IOException | JSONException e) {
        e.printStackTrace();
    }
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) FileCreator(org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator) TransformationFailureException(org.opentosca.toscana.plugins.util.TransformationFailureException) FileNotFoundException(java.io.FileNotFoundException) JSONException(org.json.JSONException) IOException(java.io.IOException)

Aggregations

PluginFileAccess (org.opentosca.toscana.core.plugin.PluginFileAccess)13 File (java.io.File)10 Before (org.junit.Before)10 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)6 EffectiveModel (org.opentosca.toscana.model.EffectiveModel)5 TransformationContext (org.opentosca.toscana.core.transformation.TransformationContext)4 Application (org.opentosca.toscana.plugins.cloudfoundry.application.Application)4 FileCreator (org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator)3 BasicAWSCredentials (com.amazonaws.auth.BasicAWSCredentials)2 IOException (java.io.IOException)2 PropertyInstance (org.opentosca.toscana.core.transformation.properties.PropertyInstance)2 BufferedWriter (java.io.BufferedWriter)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 JSONException (org.json.JSONException)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 OsCapability (org.opentosca.toscana.model.capability.OsCapability)1 WebApplication (org.opentosca.toscana.model.node.WebApplication)1 CapabilityMapper (org.opentosca.toscana.plugins.cloudformation.mapper.CapabilityMapper)1