Search in sources :

Example 6 with FileCreator

use of org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator in project TOSCAna by StuPro-TOSCAna.

the class FileCreatorTest method setUp.

@Before
public void setUp() throws IOException {
    EffectiveModel lamp = new EffectiveModelFactory().create(TestCsars.VALID_LAMP_NO_INPUT_TEMPLATE, logMock());
    this.context = setUpMockTransformationContext(lamp);
    appName = "testApp";
    testApp = new Application("testApp", 1, context);
    testApp.setName(appName);
    File sourceDir = new File(tmpdir, "sourceDir");
    targetDir = new File(tmpdir, "targetDir");
    sourceDir.mkdir();
    targetDir.mkdir();
    fileAccess = new PluginFileAccess(sourceDir, targetDir, logMock());
    List<Application> applications = new ArrayList<>();
    applications.add(testApp);
    fileCreator = new FileCreator(fileAccess, applications, context);
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) FileCreator(org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator) ArrayList(java.util.ArrayList) Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application) WebApplication(org.opentosca.toscana.model.node.WebApplication) File(java.io.File) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) Before(org.junit.Before)

Example 7 with FileCreator

use of org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator in project TOSCAna by StuPro-TOSCAna.

the class ServiceTest method getAllServices.

@Test
public void getAllServices() throws Exception {
    assumeNotNull(envUser, envHost, envOrga, envPw, envSpace);
    app.addService("my_db1", ServiceTypes.MYSQL);
    List<Application> applications = new ArrayList<>();
    applications.add(app);
    fileCreator = new FileCreator(fileAccess, applications, context);
    fileCreator.createFiles();
    File all_services = new File(targetDir, SERVICE_FILE_PATH);
    String all_services_expected_content = "Following services you could choose:";
    String all_services_content = FileUtils.readFileToString(all_services, Charset.defaultCharset());
    assertTrue(all_services.exists());
    assertThat(all_services_content, CoreMatchers.containsString(all_services_expected_content));
}
Also used : FileCreator(org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator) ArrayList(java.util.ArrayList) Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application) File(java.io.File) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 8 with FileCreator

use of org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator 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

FileCreator (org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator)8 File (java.io.File)7 Application (org.opentosca.toscana.plugins.cloudfoundry.application.Application)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)5 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)5 WebApplication (org.opentosca.toscana.model.node.WebApplication)4 PluginFileAccess (org.opentosca.toscana.core.plugin.PluginFileAccess)3 EffectiveModel (org.opentosca.toscana.model.EffectiveModel)3 EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)3 Before (org.junit.Before)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 JSONException (org.json.JSONException)1 PropertyInstance (org.opentosca.toscana.core.transformation.properties.PropertyInstance)1 MysqlDatabase (org.opentosca.toscana.model.node.MysqlDatabase)1 RootNode (org.opentosca.toscana.model.node.RootNode)1 Provider (org.opentosca.toscana.plugins.cloudfoundry.application.Provider)1 TransformationFailureException (org.opentosca.toscana.plugins.util.TransformationFailureException)1