Search in sources :

Example 51 with HashMap

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;
    }
}
Also used : HashMap(java.util.HashMap) ProcessDefinition(org.apache.camel.bam.model.ProcessDefinition)

Example 52 with HashMap

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;
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) FileInput(org.apache.camel.component.bonita.api.model.FileInput)

Example 53 with HashMap

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());
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) FileInput(org.apache.camel.component.bonita.api.model.FileInput) UploadFileResponse(org.apache.camel.component.bonita.api.model.UploadFileResponse) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 54 with HashMap

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();
}
Also used : Exchange(org.apache.camel.Exchange) Processor(org.apache.camel.Processor) RouteBuilder(org.apache.camel.builder.RouteBuilder) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 55 with HashMap

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();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)24090 ArrayList (java.util.ArrayList)5632 Map (java.util.Map)5586 Test (org.junit.Test)5079 List (java.util.List)2721 HashSet (java.util.HashSet)2103 IOException (java.io.IOException)1780 Set (java.util.Set)1465 File (java.io.File)1206 Iterator (java.util.Iterator)1198 LinkedHashMap (java.util.LinkedHashMap)1138 Test (org.testng.annotations.Test)884 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)680 Date (java.util.Date)545 LinkedList (java.util.LinkedList)494 URI (java.net.URI)415 Properties (java.util.Properties)381 InputStream (java.io.InputStream)343 Collection (java.util.Collection)342 TreeMap (java.util.TreeMap)333