Search in sources :

Example 1 with ApprovalResult

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

the class ApprovalExamplesIntegrationTest method example1.

@Test
public void example1() {
    // tag::example1Usage
    final Map<String, String> body = new HashMap<>();
    body.put("contextId", accountIds.iterator().next());
    body.put("nextApproverIds", userId);
    final ApprovalResult result = template.requestBody("direct:example1", body, ApprovalResult.class);
    // end::example1Usage
    assertNotNull("Result should be received", result);
}
Also used : HashMap(java.util.HashMap) ApprovalResult(org.apache.camel.component.salesforce.api.dto.approval.ApprovalResult) Test(org.junit.Test)

Example 2 with ApprovalResult

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

the class ApprovalIntegrationTest method shouldSubmitAndFetchApprovals.

@Test
public void shouldSubmitAndFetchApprovals() {
    final ApprovalResult approvalResult = template.requestBody(String.format(//
    "salesforce:approval?" + //
    "format=%s" + //
    "&approvalActionType=Submit" + //
    "&approvalContextId=%s" + //
    "&approvalNextApproverIds=%s" + //
    "&approvalComments=Integration test" + "&approvalProcessDefinitionNameOrId=Test_Account_Process", format, accountIds.get(0), userId), NOT_USED, ApprovalResult.class);
    assertNotNull("Approval should have resulted in value", approvalResult);
    assertEquals("There should be one Account waiting approval", 1, approvalResult.size());
    assertEquals("Instance status of the item in approval result should be `Pending`", "Pending", approvalResult.iterator().next().getInstanceStatus());
    // as it stands on 18.11.2016. the GET method on /vXX.X/process/approvals/ with Accept other than
    // `application/json` results in HTTP status 500, so only JSON is supported
    final Approvals approvals = template.requestBody("salesforce:approvals", NOT_USED, Approvals.class);
    assertNotNull("Approvals should be fetched", approvals);
    final List<Info> accountApprovals = approvals.approvalsFor("Account");
    assertEquals("There should be one Account waiting approval", 1, accountApprovals.size());
}
Also used : Approvals(org.apache.camel.component.salesforce.api.dto.approval.Approvals) ApprovalResult(org.apache.camel.component.salesforce.api.dto.approval.ApprovalResult) Info(org.apache.camel.component.salesforce.api.dto.approval.Approvals.Info) Test(org.junit.Test)

Example 3 with ApprovalResult

use of org.apache.camel.component.salesforce.api.dto.approval.ApprovalResult 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 4 with ApprovalResult

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

the class ApprovalExamplesIntegrationTest method example2.

@Test
public void example2() {
    // tag::example2Usage
    final Map<String, String> body = new HashMap<>();
    body.put("contextId", accountIds.iterator().next());
    body.put("nextApproverIds", userId);
    final ApprovalResult result = template.requestBody("direct:example2", body, ApprovalResult.class);
    // end::example2Usage
    assertNotNull("Result should be received", result);
}
Also used : HashMap(java.util.HashMap) ApprovalResult(org.apache.camel.component.salesforce.api.dto.approval.ApprovalResult) Test(org.junit.Test)

Aggregations

ApprovalResult (org.apache.camel.component.salesforce.api.dto.approval.ApprovalResult)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)2 Approvals (org.apache.camel.component.salesforce.api.dto.approval.Approvals)2 Info (org.apache.camel.component.salesforce.api.dto.approval.Approvals.Info)2 ParallelParameterized (com.googlecode.junittoolbox.ParallelParameterized)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 ApprovalRequest (org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest)1 Action (org.apache.camel.component.salesforce.api.dto.approval.ApprovalRequest.Action)1 RunWith (org.junit.runner.RunWith)1 Parameters (org.junit.runners.Parameterized.Parameters)1