Search in sources :

Example 6 with ApprovalRequest

use of org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest in project camel by apache.

the class AbstractRestProcessorApprovalTest method shouldFetchApprovalRequestFromHeader.

@Test
public void shouldFetchApprovalRequestFromHeader() throws SalesforceException {
    final ApprovalRequest request = new ApprovalRequest();
    request.setComments("hi there");
    final TestRestProcessor processor = sendBodyAndHeader(null, request);
    verify(processor).getRequestStream(new ApprovalRequests(request));
}
Also used : ApprovalRequests(org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequests) ApprovalRequest(org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest) Test(org.junit.Test)

Example 7 with ApprovalRequest

use of org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest in project camel by apache.

the class AbstractRestProcessorApprovalTest method requestWithComment.

static ApprovalRequest requestWithComment(final String comment) {
    final ApprovalRequest approvalRequest = new ApprovalRequest();
    approvalRequest.setComments(comment);
    return approvalRequest;
}
Also used : ApprovalRequest(org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest)

Example 8 with ApprovalRequest

use of org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest in project camel by apache.

the class ApprovalIntegrationTest method shouldSubmitBulkApprovals.

@Test
public void shouldSubmitBulkApprovals() {
    final List<ApprovalRequest> approvalRequests = accountIds.stream().map(id -> {
        final ApprovalRequest request = new ApprovalRequest();
        request.setContextId(id);
        request.setComments("Approval for " + id);
        request.setActionType(Action.Submit);
        return request;
    }).collect(Collectors.toList());
    final ApprovalResult approvalResult = template.requestBody(String.format(//
    "salesforce:approval?" + //
    "format=%s" + //
    "&approvalActionType=Submit" + //
    "&approvalNextApproverIds=%s" + "&approvalProcessDefinitionNameOrId=Test_Account_Process", format, userId), approvalRequests, ApprovalResult.class);
    assertEquals("Should have same number of approval results as requests", approvalRequests.size(), approvalResult.size());
}
Also used : Arrays(java.util.Arrays) Info(org.apache.camel.component.salesforce.api.dto.approval.Approvals.Info) ApprovalRequest(org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) ApprovalResult(org.apache.camel.component.salesforce.api.dto.approval.ApprovalResult) Test(org.junit.Test) Collectors(java.util.stream.Collectors) Approvals(org.apache.camel.component.salesforce.api.dto.approval.Approvals) ParallelParameterized(com.googlecode.junittoolbox.ParallelParameterized) List(java.util.List) RouteBuilder(org.apache.camel.builder.RouteBuilder) Action(org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest.Action) ApprovalRequest(org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest) ApprovalResult(org.apache.camel.component.salesforce.api.dto.approval.ApprovalResult) Test(org.junit.Test)

Example 9 with ApprovalRequest

use of org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest in project camel by apache.

the class ApprovalExamplesIntegrationTest method createRegistry.

@Override
protected JndiRegistry createRegistry() throws Exception {
    final JndiRegistry jndi = super.createRegistry();
    final ApprovalRequest approvalTemplate = new ApprovalRequest();
    approvalTemplate.setActionType(ApprovalRequest.Action.Submit);
    approvalTemplate.setComments("Sample approval template");
    approvalTemplate.setProcessDefinitionNameOrId("Test_Account_Process");
    approvalTemplate.setSkipEntryCriteria(true);
    jndi.bind("approvalTemplate", approvalTemplate);
    return jndi;
}
Also used : JndiRegistry(org.apache.camel.impl.JndiRegistry) ApprovalRequest(org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest)

Example 10 with ApprovalRequest

use of org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest in project camel by apache.

the class AbstractRestProcessorApprovalTest method shouldFetchApprovalRequestFromHeaderEvenIfBodyIsDefinedButNotConvertable.

@Test
public void shouldFetchApprovalRequestFromHeaderEvenIfBodyIsDefinedButNotConvertable() throws SalesforceException {
    final ApprovalRequest request = new ApprovalRequest();
    request.setComments("hi there");
    final TestRestProcessor processor = sendBodyAndHeaders("Nothing to see here", request, Collections.singletonMap("approval.ContextId", "context-id"));
    final ApprovalRequest combined = new ApprovalRequest();
    combined.setComments("hi there");
    combined.setContextId("context-id");
    verify(processor).getRequestStream(new ApprovalRequests(combined));
}
Also used : ApprovalRequests(org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequests) ApprovalRequest(org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest) Test(org.junit.Test)

Aggregations

ApprovalRequest (org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest)12 ApprovalRequests (org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequests)9 Test (org.junit.Test)9 HashMap (java.util.HashMap)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 ParallelParameterized (com.googlecode.junittoolbox.ParallelParameterized)1 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 URLEncoder (java.net.URLEncoder)1 Arrays (java.util.Arrays)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 StreamSupport (java.util.stream.StreamSupport)1 AsyncCallback (org.apache.camel.AsyncCallback)1 Exchange (org.apache.camel.Exchange)1