use of java.util.HashMap in project camel by apache.
the class ProcessBuilder method findOrCreateProcessDefinition.
protected ProcessDefinition findOrCreateProcessDefinition() {
Map<String, Object> params = new HashMap<String, Object>(1);
params.put("name", processName);
List<ProcessDefinition> list = entityManagerTemplate.find(ProcessDefinition.class, "select x from " + QueryUtils.getTypeName(ProcessDefinition.class) + " x where x.name = :name", params);
if (!list.isEmpty()) {
return list.get(0);
} else {
ProcessDefinition answer = new ProcessDefinition();
answer.setName(processName);
entityManagerTemplate.persist(answer);
return answer;
}
}
use of java.util.HashMap 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 java.util.HashMap 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 java.util.HashMap in project camel by apache.
the class RecipientListErrorHandlingIssueTest method testUsingInterceptor.
@Test
public void testUsingInterceptor() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
onException(Exception.class).handled(true).to("mock:error");
interceptSendToEndpoint("(ftp|direct):.*").process(new Processor() {
public void process(Exchange exchange) throws Exception {
String target = exchange.getIn().getHeader(Exchange.INTERCEPTED_ENDPOINT, String.class);
exchange.getIn().setHeader("target", target);
}
});
from("direct:start").recipientList(header("foo"));
from("direct:foo").setBody(constant("Bye World")).to("mock:foo");
}
});
context.start();
getMockEndpoint("mock:foo").expectedMessageCount(1);
getMockEndpoint("mock:error").expectedMessageCount(1);
getMockEndpoint("mock:error").message(0).header("target").isEqualTo(getFtpUrl());
String foo = "direct:foo," + getFtpUrl();
Map<String, Object> headers = new HashMap<String, Object>();
headers.put("foo", foo);
headers.put(Exchange.FILE_NAME, "hello.txt");
template.sendBodyAndHeaders("direct:start", "Hello World", headers);
assertMockEndpointsSatisfied();
}
use of java.util.HashMap in project camel by apache.
the class RecipientListErrorHandlingIssueTest method testUsingExistingHeaders.
@Test
public void testUsingExistingHeaders() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
onException(Exception.class).handled(true).to("mock:error");
from("direct:start").recipientList(header("foo"));
from("direct:foo").setBody(constant("Bye World")).to("mock:foo");
}
});
context.start();
getMockEndpoint("mock:foo").expectedMessageCount(1);
getMockEndpoint("mock:foo").message(0).header(Exchange.TO_ENDPOINT).isEqualTo("mock://foo");
getMockEndpoint("mock:error").expectedMessageCount(1);
getMockEndpoint("mock:error").message(0).header(Exchange.FAILURE_ENDPOINT).isEqualTo(getFtpUrl());
String foo = "direct:foo," + getFtpUrl();
Map<String, Object> headers = new HashMap<String, Object>();
headers.put("foo", foo);
headers.put(Exchange.FILE_NAME, "hello.txt");
template.sendBodyAndHeaders("direct:start", "Hello World", headers);
assertMockEndpointsSatisfied();
}
Aggregations