use of org.apache.camel.component.bonita.api.model.FileInput in project camel by apache.
the class BonitaAPIUtil method prepareInputs.
public Map<String, Serializable> prepareInputs(ProcessDefinitionResponse processDefinition, Map<String, Serializable> inputs) throws Exception {
for (Entry<String, Serializable> entry : inputs.entrySet()) {
if (entry.getValue() instanceof FileInput) {
FileInput file = (FileInput) entry.getValue();
String tmpFile = uploadFile(processDefinition, file).getTempPath();
HashMap<String, Serializable> fileInput = new HashMap<String, Serializable>();
fileInput.put("filename", file.getFilename());
fileInput.put("tempPath", tmpFile);
entry.setValue(fileInput);
}
}
return inputs;
}
use of org.apache.camel.component.bonita.api.model.FileInput in project camel by apache.
the class BonitaAPIUtilPrepareInputsTest method testPrepareInputsOneFile.
@Test
public void testPrepareInputsOneFile() throws Exception {
Map<String, Serializable> rawInputs = new HashMap<String, Serializable>();
FileInput file = new FileInput("filename", "String".getBytes());
rawInputs.put("myVariable", 1);
rawInputs.put("filename", file);
BonitaAPIUtil bonitaApiUtilMod = Mockito.spy(bonitaApiUtil);
UploadFileResponse uploadFileResponse = new UploadFileResponse();
uploadFileResponse.setTempPath("temp");
Mockito.doReturn(uploadFileResponse).when(bonitaApiUtilMod).uploadFile(Matchers.any(), Matchers.any());
Map<String, Serializable> inputs = bonitaApiUtilMod.prepareInputs(processDefinition, rawInputs);
assertEquals(rawInputs.size(), inputs.size());
}
use of org.apache.camel.component.bonita.api.model.FileInput in project camel by apache.
the class BonitaAPIUtilPrepareInputsTest method testPrepareInputsFileType.
@Test
public void testPrepareInputsFileType() throws Exception {
Map<String, Serializable> rawInputs = new HashMap<String, Serializable>();
FileInput file = new FileInput("filename", "String".getBytes());
rawInputs.put("filename", file);
BonitaAPIUtil bonitaApiUtilMod = Mockito.spy(bonitaApiUtil);
UploadFileResponse uploadFileResponse = new UploadFileResponse();
uploadFileResponse.setTempPath("temp");
Mockito.doReturn(uploadFileResponse).when(bonitaApiUtilMod).uploadFile(Matchers.any(), Matchers.any());
Map<String, Serializable> inputs = bonitaApiUtilMod.prepareInputs(processDefinition, rawInputs);
assertTrue(Map.class.isInstance(inputs.get("filename")));
}
use of org.apache.camel.component.bonita.api.model.FileInput in project camel by apache.
the class BonitaAPIUtilPrepareInputsTest method testPrepareInputsTempFilePath.
@Test
public void testPrepareInputsTempFilePath() throws Exception {
Map<String, Serializable> rawInputs = new HashMap<String, Serializable>();
FileInput file = new FileInput("filename", "String".getBytes());
rawInputs.put("filename", file);
BonitaAPIUtil bonitaApiUtilMod = Mockito.spy(bonitaApiUtil);
UploadFileResponse uploadFileResponse = new UploadFileResponse();
uploadFileResponse.setTempPath("temp");
Mockito.doReturn(uploadFileResponse).when(bonitaApiUtilMod).uploadFile(Matchers.any(), Matchers.any());
Map<String, Serializable> inputs = bonitaApiUtilMod.prepareInputs(processDefinition, rawInputs);
Map<String, Serializable> fileMap = (Map<String, Serializable>) inputs.get("filename");
assertEquals("temp", fileMap.get("tempPath"));
}
Aggregations