use of org.opentosca.toscana.model.EffectiveModelFactory in project TOSCAna by StuPro-TOSCAna.
the class TemplateConverterTest method taskTranslatorConverter.
@Test
public void taskTranslatorConverter() {
EffectiveModel model = new EffectiveModelFactory().create(TestCsars.VALID_TASKTRANSLATOR_TEMPLATE, logMock());
assertNotNull(model);
}
use of org.opentosca.toscana.model.EffectiveModelFactory in project TOSCAna by StuPro-TOSCAna.
the class TransformationDaoUnitTest method setUp.
@Before
public void setUp() throws IOException, InvalidCsarException {
when(platformService.findPlatformById(PLATFORM1.id)).thenReturn(Optional.ofNullable(PLATFORM1));
when(preferences.getDataDir()).thenReturn(tmpdir);
Log log = logMock();
csar = spy(new CsarImpl(new File(""), "csarIdentifier", log));
doReturn(new File("")).when(csar).getTemplate();
File csarTransformationDir = new File(tmpdir, "transformationDir");
csarTransformationDir.mkdir();
when(csarDao.getTransformationsDir(csar)).thenReturn(csarTransformationDir);
platformDir = new File(csarTransformationDir, PLATFORM1.id);
platformDir.mkdir();
File someTransformationFile = new File(platformDir, "some-file");
someTransformationFile.createNewFile();
EffectiveModelFactory modelFactory = mock(EffectiveModelFactory.class);
EffectiveModel model = modelMock();
when(modelFactory.create(any(File.class), any(Log.class))).thenReturn(model);
dao = new TransformationFilesystemDao(platformService, modelFactory);
dao.setCsarDao(csarDao);
}
use of org.opentosca.toscana.model.EffectiveModelFactory in project TOSCAna by StuPro-TOSCAna.
the class TransformationFilesystemDaoTest method setUp.
@Before
public void setUp() throws InvalidCsarException {
csar = spy(new CsarImpl(new File(""), "csar1", logMock()));
doReturn(new File("")).when(csar).getTemplate();
EffectiveModelFactory modelFactory = mock(EffectiveModelFactory.class);
EffectiveModel model = modelMock();
when(modelFactory.create(any(File.class), any(Log.class))).thenReturn(model);
transformationDao = new TransformationFilesystemDao(platformService, modelFactory);
transformationDao.setCsarDao(csarDao);
transformation = new TransformationImpl(csar, PLATFORM1, logMock(), modelMock());
transformationRootDir = transformationDao.getRootDir(transformation);
}
use of org.opentosca.toscana.model.EffectiveModelFactory 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);
}
use of org.opentosca.toscana.model.EffectiveModelFactory in project TOSCAna by StuPro-TOSCAna.
the class FileCreatorTest method checkMultipleApplicationServices.
@Test
public void checkMultipleApplicationServices() throws IOException, JSONException {
String serviceName = "mydb";
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);
connection = createConnection();
Application app = new Application("app", 1, context);
Application secondApp = new Application("appSec", 2, context);
app.setProvider(new Provider(Provider.CloudFoundryProviderType.PIVOTAL));
app.setConnection(connection);
secondApp.setProvider(new Provider(Provider.CloudFoundryProviderType.PIVOTAL));
secondApp.setConnection(connection);
app.addService(service1, ServiceTypes.MYSQL);
secondApp.addService(serviceName, ServiceTypes.MYSQL);
EffectiveModel lamp = new EffectiveModelFactory().create(TestCsars.VALID_LAMP_NO_INPUT_TEMPLATE, logMock());
RootNode webApplicationNode = null;
RootNode mysqlDatabaseNode = null;
for (RootNode node : lamp.getNodes()) {
if (node instanceof WebApplication) {
webApplicationNode = node;
}
if (node instanceof MysqlDatabase) {
mysqlDatabaseNode = node;
}
}
app.addConfigMysql(service1, "my_db/configSql.sql");
app.addExecuteFile("my_app/configure_myphpapp.sh", webApplicationNode);
secondApp.addConfigMysql(serviceName, "database/config.sql");
secondApp.addExecuteFile("database/dbinit.sh", mysqlDatabaseNode);
List<Application> applications = new ArrayList<>();
applications.add(app);
applications.add(secondApp);
FileCreator fileCreator = new FileCreator(fileAccess, applications, context);
fileCreator.createFiles();
File targetFile = new File(targetDir, outputPath + FILEPRAEFIX_DEPLOY + deploy_name + FILESUFFIX_DEPLOY);
String deployscriptContent = FileUtils.readFileToString(targetFile);
String expectedContent = "check python\n" + "python replace.py ../../app1/my_app/configure_myphpapp.sh /var/www/html/ /home/vcap/app/htdocs/\n" + "python replace.py ../../app2/database/dbinit.sh /var/www/html/ /home/vcap/app/htdocs/\n" + "cf push app -f ../manifest.yml --no-start\n" + "cf push appSec -f ../manifest.yml --no-start\n" + "python readCredentials.py app cleardb mysql cleardb\n" + "python configureMysql.py ../../app1/my_db/configSql.sql\n" + "cf start app\n" + "python executeCommand.py app /home/vcap/app/htdocs/my_app/configure_myphpapp.sh\n" + "python readCredentials.py appSec cleardb mysql mydb\n" + "python configureMysql.py ../../app2/database/config.sql\n" + "cf start appSec\n" + "python executeCommand.py appSec /home/vcap/app/database/dbinit.sh\n";
assertTrue(deployscriptContent.contains(expectedContent));
// assertEquals(expectedContent, deployscriptContent);
}
Aggregations