Search in sources :

Example 6 with PluginFileAccess

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

the class ServiceTest method setUp.

@Before
public void setUp() throws IOException {
    EffectiveModel lamp = new EffectiveModelFactory().create(TestCsars.VALID_LAMP_NO_INPUT_TEMPLATE, logMock());
    this.context = setUpMockTransformationContext(lamp);
    envUser = System.getenv(CF_ENVIRONMENT_USER);
    envPw = System.getenv(CF_ENVIRONMENT_PW);
    envHost = System.getenv(CF_ENVIRONMENT_HOST);
    envOrga = System.getenv(CF_ENVIRONMENT_ORGA);
    envSpace = System.getenv(CF_ENVIRONMENT_SPACE);
    app = new Application(appName, 1, context);
    app.setProvider(provider);
    connection = createConnection();
    app.setConnection(connection);
    File sourceDir = new File(tmpdir, "sourceDir");
    targetDir = new File(tmpdir, "targetDir");
    sourceDir.mkdir();
    targetDir.mkdir();
    fileAccess = new PluginFileAccess(sourceDir, targetDir, logMock());
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application) File(java.io.File) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) Before(org.junit.Before)

Example 7 with PluginFileAccess

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

the class BashScriptTest method setUp.

@Before
public void setUp() {
    bashScript = null;
    fileName = UUID.randomUUID().toString();
    access = new PluginFileAccess(tmpdir, tmpdir, logMock());
    try {
        bashScript = new BashScript(access, fileName);
    } catch (IOException e) {
        e.printStackTrace();
    }
    targetScriptFolder = new File(tmpdir, SCRIPTS_DIR_PATH);
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) IOException(java.io.IOException) File(java.io.File) Before(org.junit.Before)

Example 8 with PluginFileAccess

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

the class CloudFormationFileCreatorTest method setUp.

@Before
public void setUp() throws Exception {
    File sourceDir = new File(tmpdir, "sourceDir");
    targetDir = new File(tmpdir, "targetDir");
    sourceDir.mkdir();
    targetDir.mkdir();
    FILEPATH_SOURCE_TEST_FILE = new File(sourceDir, FILENAME_TEST_FILE);
    FILEPATH_TARGET_TEST_FILE = new File(targetDir, FILEPATH_TARGET + FILENAME_TEST_FILE);
    writeTestFile();
    FILEPATH_TARGET_TEST_FILE_LOCAL = RELATIVE_DIRECTORY_PREFIX + FILENAME_TEST_FILE;
    when(log.getLogger(any(Class.class))).thenReturn(mock(Logger.class));
    PluginFileAccess fileAccess = new PluginFileAccess(sourceDir, targetDir, log);
    cfnModule = new CloudFormationModule(fileAccess, "us-west-2", new BasicAWSCredentials("", ""));
    TransformationContext context = mock(TransformationContext.class);
    when(context.getLogger((Class<?>) any(Class.class))).thenReturn(LoggerFactory.getLogger("File Creator Test Logger"));
    fileCreator = new CloudFormationFileCreator(context, cfnModule);
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) Logger(org.slf4j.Logger) File(java.io.File) TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) Before(org.junit.Before)

Example 9 with PluginFileAccess

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

the class CloudFormationPluginTest method setUp.

@Before
public void setUp() throws Exception {
    lamp = new EffectiveModelFactory().create(TestCsars.VALID_LAMP_NO_INPUT_TEMPLATE, logMock());
    fileAccess = new PluginFileAccess(new File("src/test/resources/csars/yaml/valid/lamp-input/"), tmpdir, logMock());
    cfnModule = new CloudFormationModule(fileAccess, "us-west-2", new BasicAWSCredentials("", ""));
    TransformationContext context = mock(TransformationContext.class);
    when(context.getModel()).thenReturn(lamp);
    when(context.getLogger((Class<?>) any(Class.class))).thenReturn(LoggerFactory.getLogger("Dummy Logger"));
    TransformModelNodeVisitor cfnNodeVisitorL = new TransformModelNodeVisitor(context, cfnModule);
    cfnNodeVisitor = spy(cfnNodeVisitorL);
    CapabilityMapper capabilityMapper = mock(CapabilityMapper.class);
    when(capabilityMapper.mapOsCapabilityToImageId(any(OsCapability.class))).thenReturn("ami-testami");
    when(cfnNodeVisitor.createCapabilityMapper()).thenReturn(capabilityMapper);
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) OsCapability(org.opentosca.toscana.model.capability.OsCapability) TransformModelNodeVisitor(org.opentosca.toscana.plugins.cloudformation.visitor.TransformModelNodeVisitor) File(java.io.File) TransformationContext(org.opentosca.toscana.core.transformation.TransformationContext) CapabilityMapper(org.opentosca.toscana.plugins.cloudformation.mapper.CapabilityMapper) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) BasicAWSCredentials(com.amazonaws.auth.BasicAWSCredentials) Before(org.junit.Before)

Example 10 with PluginFileAccess

use of org.opentosca.toscana.core.plugin.PluginFileAccess 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)

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