Search in sources :

Example 1 with EffectiveModelFactory

use of org.opentosca.toscana.model.EffectiveModelFactory in project TOSCAna by StuPro-TOSCAna.

the class TemplateConverterTest method expressConverter.

@Test
public void expressConverter() {
    EffectiveModel model = new EffectiveModelFactory().create(TestCsars.VALID_EXPRESS_TEMPLATE, logMock());
    assertNotNull(model);
}
Also used : EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) BaseUnitTest(org.opentosca.toscana.core.BaseUnitTest) Test(org.junit.Test)

Example 2 with EffectiveModelFactory

use of org.opentosca.toscana.model.EffectiveModelFactory in project TOSCAna by StuPro-TOSCAna.

the class CloudFormationLifecycleTest method setUp.

@Before
public void setUp() throws Exception {
    PluginFileAccess accessL = new PluginFileAccess(new File(tmpdir, "sourceDir"), new File(tmpdir, "targetDir"), logMock());
    EffectiveModel effectiveModel = new EffectiveModelFactory().create(TestCsars.VALID_LAMP_NO_INPUT_TEMPLATE, logMock());
    PluginFileAccess access = spy(accessL);
    doNothing().when(access).copy(anyString(), anyString());
    doReturn("DummyFileContent").when(access).read(anyString());
    when(context.getPluginFileAccess()).thenReturn(access);
    when(context.getLogger((Class<?>) any(Class.class))).thenReturn(LoggerFactory.getLogger("Dummy Logger"));
    when(context.getModel()).thenReturn(effectiveModel);
    String accessKey = System.getenv("AWS_ACCESS_KEY");
    String secretKey = System.getenv("AWS_SECRET_KEY");
    Assume.assumeNotNull(accessKey);
    Assume.assumeNotNull(secretKey);
    when(context.getInputs()).thenReturn(mock(PropertyInstance.class));
    when(context.getInputs().getOrThrow(AWS_ACCESS_KEY_ID_KEY)).thenReturn(accessKey);
    when(context.getInputs().getOrThrow(AWS_SECRET_KEY_KEY)).thenReturn(secretKey);
    when(context.getInputs().getOrThrow(AWS_REGION_KEY)).thenReturn(AWS_REGION_DEFAULT);
    cloudFormationLifecycle = new CloudFormationLifecycle(context);
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) PropertyInstance(org.opentosca.toscana.core.transformation.properties.PropertyInstance) File(java.io.File) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) Before(org.junit.Before)

Example 3 with EffectiveModelFactory

use of org.opentosca.toscana.model.EffectiveModelFactory in project TOSCAna by StuPro-TOSCAna.

the class CloudFoundryPluginTest method setUp.

@Before
public void setUp() throws Exception {
    EffectiveModel lamp = new EffectiveModelFactory().create(TestCsars.VALID_LAMP_NO_INPUT_TEMPLATE, logMock());
    context = setUpMockTransformationContext(lamp);
    String userName = System.getenv("TEST_CF_USER");
    String pw = System.getenv("TEST_CF_PW");
    String host = System.getenv("TEST_CF_HOST");
    String space = System.getenv("TEST_CF_SPACE");
    String orga = System.getenv("TEST_CF_ORGA");
    Assume.assumeNotNull(userName, pw, host, space, orga);
    when(context.getInputs()).thenReturn(mock(PropertyInstance.class));
    when(context.getInputs().getOrThrow(CF_PROPERTY_KEY_USERNAME)).thenReturn(userName);
    when(context.getInputs().getOrThrow(CF_PROPERTY_KEY_PASSWORD)).thenReturn(pw);
    when(context.getInputs().getOrThrow(CF_PROPERTY_KEY_API)).thenReturn(host);
    when(context.getInputs().getOrThrow(CF_PROPERTY_KEY_SPACE)).thenReturn(space);
    when(context.getInputs().getOrThrow(CF_PROPERTY_KEY_ORGANIZATION)).thenReturn(orga);
    cfCycle = new CloudFoundryLifecycle(context);
    cfCycle.checkModel();
    cfCycle.prepare();
    cfCycle.fillApplications();
    File sourceDir = new File(resourcesPath, "csars/yaml/valid/lamp-noinput");
    targetDir = new File(tmpdir, "targetDir");
    sourceDir.mkdir();
    targetDir.mkdir();
    PluginFileAccess fileAccess = new PluginFileAccess(sourceDir, targetDir, logMock());
    // Set<RootNode> nodes = lamp.getNodes();
    when(context.getPluginFileAccess()).thenReturn(fileAccess);
    paths.add("app1/my_app/index.php");
    paths.add("app1/my_app/create_myphpapp.sh");
    paths.add("app1/my_db/createtable.sql");
    List<Application> applications = cfCycle.getFilledApplications();
    FileCreator fileCreator = new FileCreator(fileAccess, applications, context);
    fileCreator.createFiles();
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) FileCreator(org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator) PropertyInstance(org.opentosca.toscana.core.transformation.properties.PropertyInstance) File(java.io.File) Application(org.opentosca.toscana.plugins.cloudfoundry.application.Application) EffectiveModel(org.opentosca.toscana.model.EffectiveModel) EffectiveModelFactory(org.opentosca.toscana.model.EffectiveModelFactory) Before(org.junit.Before)

Example 4 with EffectiveModelFactory

use of org.opentosca.toscana.model.EffectiveModelFactory in project TOSCAna by StuPro-TOSCAna.

the class DeploymentTest 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);
    File sourceDir = new File(tmpdir, "sourceDir");
    targetDir = new File(tmpdir, "targetDir");
    sourceDir.mkdir();
    targetDir.mkdir();
    fileAccess = new PluginFileAccess(sourceDir, targetDir, log);
    deployScript = new BashScript(fileAccess, "deploy_" + appName);
}
Also used : PluginFileAccess(org.opentosca.toscana.core.plugin.PluginFileAccess) BashScript(org.opentosca.toscana.plugins.scripts.BashScript) 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 5 with EffectiveModelFactory

use of org.opentosca.toscana.model.EffectiveModelFactory 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)

Aggregations

EffectiveModelFactory (org.opentosca.toscana.model.EffectiveModelFactory)37 EffectiveModel (org.opentosca.toscana.model.EffectiveModel)31 Test (org.junit.Test)25 BaseUnitTest (org.opentosca.toscana.core.BaseUnitTest)22 File (java.io.File)10 Before (org.junit.Before)10 PluginFileAccess (org.opentosca.toscana.core.plugin.PluginFileAccess)6 Database (org.opentosca.toscana.model.node.Database)5 Application (org.opentosca.toscana.plugins.cloudfoundry.application.Application)5 WebApplication (org.opentosca.toscana.model.node.WebApplication)4 BaseSpringTest (org.opentosca.toscana.core.BaseSpringTest)3 Csar (org.opentosca.toscana.core.csar.Csar)3 Log (org.opentosca.toscana.core.transformation.logging.Log)3 Artifact (org.opentosca.toscana.model.artifact.Artifact)3 RootNode (org.opentosca.toscana.model.node.RootNode)3 WebServer (org.opentosca.toscana.model.node.WebServer)3 FileCreator (org.opentosca.toscana.plugins.cloudfoundry.filecreator.FileCreator)3 ArrayList (java.util.ArrayList)2 CsarImpl (org.opentosca.toscana.core.csar.CsarImpl)2 TransformationContext (org.opentosca.toscana.core.transformation.TransformationContext)2