use of org.apache.camel.component.salesforce.api.dto.approval.Approvals.Info 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());
}
use of org.apache.camel.component.salesforce.api.dto.approval.Approvals.Info in project camel by apache.
the class ApprovalsTest method shouldDeserialize.
@Test
public void shouldDeserialize() throws JsonProcessingException, IOException {
final ObjectMapper mapper = new ObjectMapper();
final Object read = mapper.readerFor(Approvals.class).readValue(//
"{\n" + //
" \"approvals\" : {\n" + //
" \"Account\" : [ {\n" + //
" \"description\" : null,\n" + //
" \"id\" : \"04aD00000008Py9\",\n" + //
" \"name\" : \"Account Approval Process\",\n" + //
" \"object\" : \"Account\",\n" + //
" \"sortOrder\" : 1\n" + //
" } ]\n" + //
" }\n" + "}");
assertThat("Should deserialize Approvals", read, instanceOf(Approvals.class));
final Approvals approvals = (Approvals) read;
final Map<String, List<Info>> approvalsMap = approvals.getApprovals();
assertEquals("Deserialized approvals should have one entry", 1, approvalsMap.size());
final List<Info> accountApprovals = approvalsMap.get("Account");
assertNotNull("Deserialized approvals should contain list of `Account` type approvals", accountApprovals);
assertEquals("There should be one approval of `Account` type", 1, accountApprovals.size());
final Info accountInfo = accountApprovals.get(0);
assertNull("Deserialized `Account` approval should have null description", accountInfo.getDescription());
assertEquals("Deserialized `Account` approval should have defined id", "04aD00000008Py9", accountInfo.getId());
assertEquals("Deserialized `Account` approval should have defined name", "Account Approval Process", accountInfo.getName());
assertEquals("Deserialized `Account` approval should have defined object", "Account", accountInfo.getObject());
assertEquals("Deserialized `Account` approval should have defined sortOrder", 1, accountInfo.getSortOrder());
}
Aggregations