Commit 483fa864 authored by Spiros Koulouzis's avatar Spiros Koulouzis

removed status. It is now set as current state

parent 98c7bd7a
...@@ -155,6 +155,10 @@ node_types: ...@@ -155,6 +155,10 @@ node_types:
ssh_keys: ssh_keys:
type: tosca.datatypes.ARTICONF.Credential type: tosca.datatypes.ARTICONF.Credential
required: false required: false
artifacts:
provisioned_files:
type: string
required: false
interfaces: interfaces:
CloudsStorm: CloudsStorm:
type: tosca.interfaces.ARTICONF.CloudsStorm type: tosca.interfaces.ARTICONF.CloudsStorm
......
...@@ -290,16 +290,6 @@ public class ToscaHelper { ...@@ -290,16 +290,6 @@ public class ToscaHelper {
return "vm_user"; return "vm_user";
} }
public CloudsStormSubTopology.StatusEnum getVMTopologyTemplateStatus(NodeTemplateMap nodeTemplateMap) throws TypeExeption {
NodeTemplate nodeTemplate = nodeTemplateMap.getNodeTemplate();
if (nodeTemplate.getType().equals(VM_TOPOLOGY)) {
String status = (String) nodeTemplate.getAttributes().get("status");
return CloudsStormSubTopology.StatusEnum.fromValue(status);
} else {
throw new TypeExeption("NodeTemplateMap is not of type: " + VM_TOPOLOGY + " it is of type: " + nodeTemplate.getType());
}
}
public NODE_STATES getNodeCurrentState(NodeTemplateMap node) { public NODE_STATES getNodeCurrentState(NodeTemplateMap node) {
return getNodeState(node, "current_state"); return getNodeState(node, "current_state");
} }
......
...@@ -420,25 +420,6 @@ public class ToscaHelperTest { ...@@ -420,25 +420,6 @@ public class ToscaHelperTest {
} }
} }
/**
* Test of getVMTopologyTemplateStatus method, of class ToscaHelper.
*/
@Test
public void testGetVMTopologyTemplateStatus() throws Exception {
if (serviceUp) {
System.out.println("getVMTopologyTemplateStatus");
toscaTemplateWithCredentials = null;
instance.uploadToscaTemplate(provisionedToscaTemplate);
List<NodeTemplateMap> vmTopologies = instance.getVMTopologyTemplates();
for (NodeTemplateMap vmTopology : vmTopologies) {
CloudsStormSubTopology.StatusEnum status = instance.getVMTopologyTemplateStatus(vmTopology);
assertEquals(CloudsStormSubTopology.StatusEnum.RUNNING, status);
}
}
}
/** /**
* Test of getKeyPairsFromVM method, of class ToscaHelper. * Test of getKeyPairsFromVM method, of class ToscaHelper.
......
...@@ -160,7 +160,6 @@ public class DRIPService { ...@@ -160,7 +160,6 @@ public class DRIPService {
if (nodeNames == null || nodeNames.isEmpty()) { if (nodeNames == null || nodeNames.isEmpty()) {
List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates(); List<NodeTemplateMap> vmTopologies = helper.getVMTopologyTemplates();
for (NodeTemplateMap vmTopology : vmTopologies) { for (NodeTemplateMap vmTopology : vmTopologies) {
CloudsStormSubTopology.StatusEnum status = helper.getVMTopologyTemplateStatus(vmTopology);
toscaTemplate = setDesieredSate(toscaTemplate, vmTopologies, NODE_STATES.DELETED); toscaTemplate = setDesieredSate(toscaTemplate, vmTopologies, NODE_STATES.DELETED);
} }
return execute(toscaTemplate, provisionerQueueName); return execute(toscaTemplate, provisionerQueueName);
......
...@@ -113,7 +113,7 @@ class CloudStormService { ...@@ -113,7 +113,7 @@ class CloudStormService {
} }
public ToscaTemplate execute() throws FileNotFoundException, JSchException, IOException, ApiException, Exception { public ToscaTemplate execute() throws FileNotFoundException, JSchException, IOException, ApiException, Exception {
String tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator; String tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator;
File tempInputDir = new File(tempInputDirPath); File tempInputDir = new File(tempInputDirPath);
if (!(tempInputDir.mkdirs())) { if (!(tempInputDir.mkdirs())) {
......
...@@ -26,12 +26,8 @@ import nl.uva.sne.drip.model.NodeTemplateMap; ...@@ -26,12 +26,8 @@ import nl.uva.sne.drip.model.NodeTemplateMap;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormInfrasCode; import nl.uva.sne.drip.model.cloud.storm.CloudsStormInfrasCode;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology; import nl.uva.sne.drip.model.cloud.storm.CloudsStormSubTopology;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormTopTopology; import nl.uva.sne.drip.model.cloud.storm.CloudsStormTopTopology;
import nl.uva.sne.drip.model.cloud.storm.CloudsStormVM;
import nl.uva.sne.drip.model.cloud.storm.CredentialInfo;
import nl.uva.sne.drip.model.cloud.storm.InfrasCode; import nl.uva.sne.drip.model.cloud.storm.InfrasCode;
import nl.uva.sne.drip.model.cloud.storm.OpCode; import nl.uva.sne.drip.model.cloud.storm.OpCode;
import nl.uva.sne.drip.model.tosca.Credential;
import nl.uva.sne.drip.model.tosca.ToscaTemplate;
import static nl.uva.sne.drip.provisioner.CloudStormService.APP_FOLDER_NAME; import static nl.uva.sne.drip.provisioner.CloudStormService.APP_FOLDER_NAME;
import static nl.uva.sne.drip.provisioner.CloudStormService.INFRASTUCTURE_CODE_FILE_NAME; import static nl.uva.sne.drip.provisioner.CloudStormService.INFRASTUCTURE_CODE_FILE_NAME;
import static nl.uva.sne.drip.provisioner.CloudStormService.INFS_FOLDER_NAME; import static nl.uva.sne.drip.provisioner.CloudStormService.INFS_FOLDER_NAME;
...@@ -41,6 +37,7 @@ import static nl.uva.sne.drip.provisioner.CloudStormService.TOP_TOPOLOGY_FILE_NA ...@@ -41,6 +37,7 @@ import static nl.uva.sne.drip.provisioner.CloudStormService.TOP_TOPOLOGY_FILE_NA
import static nl.uva.sne.drip.provisioner.CloudStormService.UC_FOLDER_NAME; import static nl.uva.sne.drip.provisioner.CloudStormService.UC_FOLDER_NAME;
import static nl.uva.sne.drip.provisioner.CloudStormService.UD_FOLDER_NAME; import static nl.uva.sne.drip.provisioner.CloudStormService.UD_FOLDER_NAME;
import nl.uva.sne.drip.sure.tosca.client.ApiException; import nl.uva.sne.drip.sure.tosca.client.ApiException;
import org.apache.commons.io.FilenameUtils;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
...@@ -53,7 +50,7 @@ import static org.junit.Assert.*; ...@@ -53,7 +50,7 @@ import static org.junit.Assert.*;
* @author S. Koulouzis * @author S. Koulouzis
*/ */
public class CloudStormServiceTest { public class CloudStormServiceTest {
private static final String messageExampleDeleteRequestFilePath = ".." + File.separator + "example_messages" + File.separator + "message_delete_request.json"; private static final String messageExampleDeleteRequestFilePath = ".." + File.separator + "example_messages" + File.separator + "message_delete_request.json";
private static final String messageExampleProvisioneRequestFilePath = ".." + File.separator + "example_messages" + File.separator + "message_provision_request.json"; private static final String messageExampleProvisioneRequestFilePath = ".." + File.separator + "example_messages" + File.separator + "message_provision_request.json";
private final ObjectMapper objectMapper; private final ObjectMapper objectMapper;
...@@ -65,134 +62,118 @@ public class CloudStormServiceTest { ...@@ -65,134 +62,118 @@ public class CloudStormServiceTest {
private String infrasCodeTempInputDirPath; private String infrasCodeTempInputDirPath;
private String credentialsTempInputDirPath; private String credentialsTempInputDirPath;
private String providersDBTempInputDirPath; private String providersDBTempInputDirPath;
public CloudStormServiceTest() { public CloudStormServiceTest() {
this.objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER)); this.objectMapper = new ObjectMapper(new YAMLFactory().disable(YAMLGenerator.Feature.WRITE_DOC_START_MARKER));
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
} }
@BeforeClass @BeforeClass
public static void setUpClass() { public static void setUpClass() {
} }
@AfterClass @AfterClass
public static void tearDownClass() { public static void tearDownClass() {
} }
@Before @Before
public void setUp() throws IOException, JsonProcessingException, ApiException { public void setUp() throws IOException, JsonProcessingException, ApiException {
String[] argv = new String[0]; String[] argv = new String[0];
RPCServer.init(argv); RPCServer.init(argv);
sureToscaBasePath = RPCServer.getProp().getProperty("sure-tosca.base.path"); sureToscaBasePath = RPCServer.getProp().getProperty("sure-tosca.base.path");
initPaths(); initPaths();
} }
@After @After
public void tearDown() { public void tearDown() {
} }
// /** private void initPaths() throws FileNotFoundException {
// * Test of execute method, of class CloudStormService. tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator;
// */ tempInputDir = new File(tempInputDirPath);
if (!(tempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + tempInputDir.getAbsolutePath());
}
topologyTempInputDirPath = tempInputDirPath + TOPOLOGY_RELATIVE_PATH;
topologyTempInputDir = new File(topologyTempInputDirPath);
if (!(topologyTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
credentialsTempInputDirPath = tempInputDirPath + File.separator + INFS_FOLDER_NAME + File.separator + UC_FOLDER_NAME;
File credentialsTempInputDir = new File(credentialsTempInputDirPath);
if (!(credentialsTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + credentialsTempInputDir.getAbsolutePath());
}
providersDBTempInputDirPath = tempInputDirPath + File.separator + INFS_FOLDER_NAME + File.separator + UD_FOLDER_NAME;
File providersDBTempInputDir = new File(providersDBTempInputDirPath);
if (!(providersDBTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + providersDBTempInputDir.getAbsolutePath());
}
infrasCodeTempInputDirPath = tempInputDirPath + File.separator + APP_FOLDER_NAME;
File infrasCodeTempInputDir = new File(infrasCodeTempInputDirPath);
if (!(infrasCodeTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
}
private CloudStormService getService(String messagefilePath) throws IOException, JsonProcessingException, ApiException {
Message message = objectMapper.readValue(new File(messagefilePath), Message.class);
return new CloudStormService(RPCServer.getProp(), message.getToscaTemplate());
}
/**
* Test of execute method, of class CloudStormService.
*/
// @Test // @Test
// public void testExecute() throws Exception { // public void testExecute() throws Exception {
// System.out.println("execute"); // if (ToscaHelper.isServiceUp(sureToscaBasePath)) {
// CloudStormService instance = null; // System.out.println("execute");
// ToscaTemplate expResult = null; // CloudStormService instance = getService(messageExampleProvisioneRequestFilePath);
// ToscaTemplate result = instance.execute(); // instance.execute();
// assertEquals(expResult, result); // }
// // TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
// }
//
// /**
// * Test of writeCloudStormTopologyFiles method, of class CloudStormService.
// */
// @Test
// public void testWriteCloudStormTopologyFiles() throws Exception {
// System.out.println("writeCloudStormTopologyFiles");
// Map<String, Object> result = instance.writeCloudStormTopologyFiles(tempInputDirPath);
// assertNull(result);
// }
//
// /**
// * Test of buildSSHKeyPair method, of class CloudStormService.
// */
// @Test
// public void testBuildSSHKeyPair() throws Exception {
// System.out.println("buildSSHKeyPair");
// String result = instance.buildSSHKeyPair(tempInputDirPath, null);
// assertNotNull(result);
// String userPublicKeyName = "id_rsa.pub";
// String userPrivateName = FilenameUtils.removeExtension(userPublicKeyName);
// assertTrue(new File(tempInputDirPath + File.separator + userPrivateName).exists());
// assertTrue(new File(tempInputDirPath + File.separator + userPublicKeyName).exists());
//
// }
//
// /**
// * Test of getCloudsStormSubTopologiesAndVMs method, of class
// * CloudStormService.
// */
// @Test
// public void testGetCloudsStormSubTopologiesAndVMs() throws Exception {
// System.out.println("getCloudsStormSubTopologiesAndVMs");
// String tempInputDirPath = "";
// CloudStormService instance = null;
// Map<String, Object> expResult = null;
// Map<String, Object> result = instance.getCloudsStormSubTopologiesAndVMs(tempInputDirPath);
// assertEquals(expResult, result);
// // TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
// }
//
// /**
// * Test of getBestMatchingCloudStormVM method, of class CloudStormService.
// */
// @Test
// public void testGetBestMatchingCloudStormVM() throws Exception {
// System.out.println("getBestMatchingCloudStormVM");
// NodeTemplateMap vmMap = null;
// String provider = "";
// CloudStormService instance = null;
// CloudsStormVM expResult = null;
// CloudsStormVM result = instance.getBestMatchingCloudStormVM(vmMap, provider);
// assertEquals(expResult, result);
// // TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
// }
//
// /**
// * Test of writeCloudStormCredentialsFiles method, of class
// * CloudStormService.
// */
// @Test
// public void testWriteCloudStormCredentialsFiles() throws Exception {
// System.out.println("writeCloudStormCredentialsFiles");
// String credentialsTempInputDirPath = "";
// CloudStormService instance = null;
// instance.writeCloudStormCredentialsFiles(credentialsTempInputDirPath);
// // TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
// }
//
// /**
// * Test of getCloudStormCredentialInfo method, of class CloudStormService.
// */
// @Test
// public void testGetCloudStormCredentialInfo() throws Exception {
// System.out.println("getCloudStormCredentialInfo");
// Credential toscaCredentials = null;
// String tmpPath = "";
// CloudStormService instance = null;
// CredentialInfo expResult = null;
// CredentialInfo result = instance.getCloudStormCredentialInfo(toscaCredentials, tmpPath);
// assertEquals(expResult, result);
// // TODO review the generated test code and remove the default call to fail.
// fail("The test case is a prototype.");
// } // }
/**
* Test of writeCloudStormTopologyFiles method, of class CloudStormService.
*/
@Test
public void testWriteCloudStormTopologyFiles() throws Exception {
System.out.println("writeCloudStormTopologyFiles");
CloudStormService instance = getService(messageExampleProvisioneRequestFilePath);
Map<String, Object> result = instance.writeCloudStormTopologyFiles(tempInputDirPath);
assertNull(result);
}
/**
* Test of buildSSHKeyPair method, of class CloudStormService.
*/
@Test
public void testBuildSSHKeyPair() throws Exception {
System.out.println("buildSSHKeyPair");
CloudStormService instance = getService(messageExampleProvisioneRequestFilePath);
String result = instance.buildSSHKeyPair(tempInputDirPath, null);
assertNotNull(result);
String userPublicKeyName = "id_rsa.pub";
String userPrivateName = FilenameUtils.removeExtension(userPublicKeyName);
assertTrue(new File(tempInputDirPath + File.separator + userPrivateName).exists());
assertTrue(new File(tempInputDirPath + File.separator + userPublicKeyName).exists());
instance = getService(messageExampleDeleteRequestFilePath);
result = instance.buildSSHKeyPair(tempInputDirPath, null);
assertNotNull(result);
userPublicKeyName = "id_rsa.pub";
userPrivateName = FilenameUtils.removeExtension(userPublicKeyName);
assertTrue(new File(tempInputDirPath + File.separator + userPrivateName).exists());
assertTrue(new File(tempInputDirPath + File.separator + userPublicKeyName).exists());
}
/** /**
* Test of writeCloudStormInfrasCodeFiles method, of class * Test of writeCloudStormInfrasCodeFiles method, of class
* CloudStormService. * CloudStormService.
...@@ -203,11 +184,11 @@ public class CloudStormServiceTest { ...@@ -203,11 +184,11 @@ public class CloudStormServiceTest {
public void testWriteCloudStormInfrasCodeFiles() throws Exception { public void testWriteCloudStormInfrasCodeFiles() throws Exception {
if (ToscaHelper.isServiceUp(sureToscaBasePath)) { if (ToscaHelper.isServiceUp(sureToscaBasePath)) {
System.out.println("writeCloudStormInfrasCodeFiles"); System.out.println("writeCloudStormInfrasCodeFiles");
testWriteCloudStormInfrasFiles(messageExampleProvisioneRequestFilePath, CloudsStormSubTopology.StatusEnum.FRESH, OpCode.OperationEnum.PROVISION); testWriteCloudStormInfrasFiles(messageExampleProvisioneRequestFilePath, CloudsStormSubTopology.StatusEnum.FRESH, OpCode.OperationEnum.PROVISION);
testWriteCloudStormInfrasFiles(messageExampleDeleteRequestFilePath, CloudsStormSubTopology.StatusEnum.RUNNING, OpCode.OperationEnum.DELETE); testWriteCloudStormInfrasFiles(messageExampleDeleteRequestFilePath, CloudsStormSubTopology.StatusEnum.RUNNING, OpCode.OperationEnum.DELETE);
} }
} }
/** /**
...@@ -224,46 +205,11 @@ public class CloudStormServiceTest { ...@@ -224,46 +205,11 @@ public class CloudStormServiceTest {
result = instance.getKeyPair(); result = instance.getKeyPair();
assertNotNull(result); assertNotNull(result);
} }
}
private void initPaths() throws FileNotFoundException {
tempInputDirPath = System.getProperty("java.io.tmpdir") + File.separator + "Input-" + Long.toString(System.nanoTime()) + File.separator;
tempInputDir = new File(tempInputDirPath);
if (!(tempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + tempInputDir.getAbsolutePath());
}
topologyTempInputDirPath = tempInputDirPath + TOPOLOGY_RELATIVE_PATH;
topologyTempInputDir = new File(topologyTempInputDirPath);
if (!(topologyTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
credentialsTempInputDirPath = tempInputDirPath + File.separator + INFS_FOLDER_NAME + File.separator + UC_FOLDER_NAME;
File credentialsTempInputDir = new File(credentialsTempInputDirPath);
if (!(credentialsTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + credentialsTempInputDir.getAbsolutePath());
}
providersDBTempInputDirPath = tempInputDirPath + File.separator + INFS_FOLDER_NAME + File.separator + UD_FOLDER_NAME;
File providersDBTempInputDir = new File(providersDBTempInputDirPath);
if (!(providersDBTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + providersDBTempInputDir.getAbsolutePath());
}
infrasCodeTempInputDirPath = tempInputDirPath + File.separator + APP_FOLDER_NAME;
File infrasCodeTempInputDir = new File(infrasCodeTempInputDirPath);
if (!(infrasCodeTempInputDir.mkdirs())) {
throw new FileNotFoundException("Could not create input directory: " + topologyTempInputDir.getAbsolutePath());
}
}
private CloudStormService getService(String messagefilePath) throws IOException, JsonProcessingException, ApiException {
Message message = objectMapper.readValue(new File(messagefilePath), Message.class);
return new CloudStormService(RPCServer.getProp(), message.getToscaTemplate());
} }
private void testWriteCloudStormInfrasFiles(String path, CloudsStormSubTopology.StatusEnum status, OpCode.OperationEnum opCode) throws IOException, JsonProcessingException, ApiException, Exception { private void testWriteCloudStormInfrasFiles(String path, CloudsStormSubTopology.StatusEnum status, OpCode.OperationEnum opCode) throws IOException, JsonProcessingException, ApiException, Exception {
CloudStormService instance = getService(path); CloudStormService instance = getService(path);
initPaths(); initPaths();
...@@ -274,17 +220,17 @@ public class CloudStormServiceTest { ...@@ -274,17 +220,17 @@ public class CloudStormServiceTest {
CloudsStormTopTopology _top = objectMapper.readValue(new File(tempInputDirPath + TOPOLOGY_RELATIVE_PATH CloudsStormTopTopology _top = objectMapper.readValue(new File(tempInputDirPath + TOPOLOGY_RELATIVE_PATH
+ TOP_TOPOLOGY_FILE_NAME), + TOP_TOPOLOGY_FILE_NAME),
CloudsStormTopTopology.class); CloudsStormTopTopology.class);
for (CloudsStormSubTopology cloudsStormSubTopology : _top.getTopologies()) { for (CloudsStormSubTopology cloudsStormSubTopology : _top.getTopologies()) {
assertEquals(status, cloudsStormSubTopology.getStatus()); assertEquals(status, cloudsStormSubTopology.getStatus());
} }
List<CloudsStormSubTopology> cloudStormSubtopologies = (List<CloudsStormSubTopology>) subTopologiesAndVMs.get("cloud_storm_subtopologies"); List<CloudsStormSubTopology> cloudStormSubtopologies = (List<CloudsStormSubTopology>) subTopologiesAndVMs.get("cloud_storm_subtopologies");
instance.writeCloudStormInfrasCodeFiles(infrasCodeTempInputDirPath, cloudStormSubtopologies); instance.writeCloudStormInfrasCodeFiles(infrasCodeTempInputDirPath, cloudStormSubtopologies);
File infrasCodeFile = new File(infrasCodeTempInputDirPath + File.separator + INFRASTUCTURE_CODE_FILE_NAME); File infrasCodeFile = new File(infrasCodeTempInputDirPath + File.separator + INFRASTUCTURE_CODE_FILE_NAME);
assertTrue(infrasCodeFile.exists()); assertTrue(infrasCodeFile.exists());
CloudsStormInfrasCode cloudsStormInfrasCode = objectMapper.readValue(infrasCodeFile, CloudsStormInfrasCode.class); CloudsStormInfrasCode cloudsStormInfrasCode = objectMapper.readValue(infrasCodeFile, CloudsStormInfrasCode.class);
for (InfrasCode code : cloudsStormInfrasCode.getInfrasCodes()) { for (InfrasCode code : cloudsStormInfrasCode.getInfrasCodes()) {
assertEquals(opCode, code.getOpCode().getOperation()); assertEquals(opCode, code.getOpCode().getOperation());
} }
...@@ -314,16 +260,16 @@ public class CloudStormServiceTest { ...@@ -314,16 +260,16 @@ public class CloudStormServiceTest {
assertTrue(artifacts.containsKey("provisioned_files")); assertTrue(artifacts.containsKey("provisioned_files"));
Map<String, String> provisionedFiles = (Map<String, String>) artifacts.get("provisioned_files"); Map<String, String> provisionedFiles = (Map<String, String>) artifacts.get("provisioned_files");
assertNotNull(provisionedFiles); assertNotNull(provisionedFiles);
assertTrue(provisionedFiles.containsKey("file_contents")); assertTrue(provisionedFiles.containsKey("file_contents"));
String cloudStormZipFileContentsAsBase64 = provisionedFiles.get("file_contents"); String cloudStormZipFileContentsAsBase64 = provisionedFiles.get("file_contents");
String testZipPath = tempInputDirPath + File.separator + "test.zip"; String testZipPath = tempInputDirPath + File.separator + "test.zip";
Converter.decodeBase64BToFile(cloudStormZipFileContentsAsBase64, testZipPath); Converter.decodeBase64BToFile(cloudStormZipFileContentsAsBase64, testZipPath);
contentType = Files.probeContentType(Paths.get(testZipPath)); contentType = Files.probeContentType(Paths.get(testZipPath));
assertEquals("application/zip", contentType); assertEquals("application/zip", contentType);
assertEquals(Converter.getFileMD5(zipFile.getAbsolutePath()), Converter.getFileMD5(testZipPath)); assertEquals(Converter.getFileMD5(zipFile.getAbsolutePath()), Converter.getFileMD5(testZipPath));
assertTrue(provisionedFiles.containsKey("encoding")); assertTrue(provisionedFiles.containsKey("encoding"));
assertTrue(provisionedFiles.containsKey("file_ext")); assertTrue(provisionedFiles.containsKey("file_ext"));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment