Skip to content

Commit

Permalink
Merge pull request #299 from Backbase/CONT-2684-qa-cont-update-bb-fue…
Browse files Browse the repository at this point in the history
…l-to-ingest-additional-approvals-policy-with-logical-items

CONT-2684: add approvals policy with logicalItems
  • Loading branch information
varesik authored Sep 20, 2024
2 parents 792b01b + 8583704 commit 20199ee
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static com.backbase.ct.bbfuel.data.ApprovalsDataGenerator.createPostApprovalTypeRequest;
import static com.backbase.ct.bbfuel.data.ApprovalsDataGenerator.createPostBulkApprovalTypesAssignmentRequest;
import static com.backbase.ct.bbfuel.data.ApprovalsDataGenerator.createPostLogicalPolicyRequest;
import static com.backbase.ct.bbfuel.data.ApprovalsDataGenerator.createPostPolicyAssignmentBulkRequest;
import static com.backbase.ct.bbfuel.data.ApprovalsDataGenerator.createPostPolicyRequest;
import static com.backbase.ct.bbfuel.data.ApprovalsDataGenerator.createPostPolicyRequestWithZeroPolicyItems;
Expand Down Expand Up @@ -114,6 +115,16 @@ public String createZeroApprovalPolicy() {
.getId();
}

public String createPolicyWithLogicalItems(String policyName, List<CreatePolicyItemDto> policyItems) {
return createPolicy(createPostLogicalPolicyRequest(policyName, policyItems))
.then()
.statusCode(SC_CREATED)
.extract()
.as(PostPolicyResponse.class)
.getPolicy()
.getId();
}

public void assignPolicies(List<IntegrationPolicyAssignmentRequest> policyAssignmentRequests) {
assignPolicies(createPostPolicyAssignmentBulkRequest(policyAssignmentRequests))
.then()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class ApprovalsConfigurator {
private String policyAId;
private String policyABId;
private String policyABCId;
private String policyAOr2BId;

public void setupApprovalTypesAndPolicies() {
createApprovalTypes();
Expand Down Expand Up @@ -132,6 +133,12 @@ private void createPolicies() {
createPolicyItemDto(approvalTypeCId, 1)));

log.info("Policy with approval types A, B and C [{}] created", policyABCId);

policyAOr2BId = approvalIntegrationRestClient.createPolicyWithLogicalItems("Logical policy approver A OR 2B", asList(
createPolicyItemDto(approvalTypeAId, 1),
createPolicyItemDto(approvalTypeBId, 2)));

log.info("Policy with logical approval A or 2B [{}] created", policyAOr2BId);
}

private void assignCurrencyBoundPolicies(String externalServiceAgreementId, int numberOfUsers, String resource,
Expand Down Expand Up @@ -196,6 +203,8 @@ private List<IntegrationPolicyAssignmentRequest> getCurrencyPolicyAssignments(

policyBoundMap.put(policyABCId, null);

policyBoundMap.put(policyAOr2BId, null);

for (Map.Entry<String, Currency> entry : policyBoundMap.entrySet()) {
String policyId = entry.getKey();
Currency upperBound = entry.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.backbase.dbs.approval.integration.spec.IntegrationPostBulkApprovalTypeAssignmentRequest;
import com.backbase.dbs.approval.integration.spec.IntegrationPostPolicyAssignmentBulkRequest;
import com.backbase.dbs.approval.spec.CreatePolicyItemDto;
import com.backbase.dbs.approval.spec.LogicalOperator;
import com.backbase.dbs.approval.spec.LogicalPolicyItemDto;
import com.backbase.dbs.approval.spec.PostApprovalTypeRequest;
import com.backbase.dbs.approval.spec.PostPolicyRequest;
import com.backbase.rest.spec.common.types.Currency;
Expand Down Expand Up @@ -51,6 +53,14 @@ public static CreatePolicyItemDto createPolicyItemDto(String approvalTypeId, int
return policyItem;
}

public static LogicalPolicyItemDto createLogicalPolicyItemDto(List<CreatePolicyItemDto> policyItems) {
LogicalPolicyItemDto policyItem = new LogicalPolicyItemDto();
policyItem.setRank(1);
policyItem.setOperator(LogicalOperator.OR);
policyItem.setItems(policyItems);
return policyItem;
}

public static PostPolicyRequest createPostPolicyRequestWithZeroPolicyItems() {
String name = "0 approvers";

Expand All @@ -60,6 +70,14 @@ public static PostPolicyRequest createPostPolicyRequestWithZeroPolicyItems() {
.withItems(emptyList());
}

public static PostPolicyRequest createPostLogicalPolicyRequest(String policyName,
List<CreatePolicyItemDto> policyItems) {
return new PostPolicyRequest()
.withName(policyName)
.withDescription(policyName)
.withLogicalItems(singletonList(createLogicalPolicyItemDto(policyItems)));
}

public static IntegrationPostPolicyAssignmentBulkRequest createPostPolicyAssignmentBulkRequest(
List<IntegrationPolicyAssignmentRequest> policyAssignmentRequests) {
return new IntegrationPostPolicyAssignmentBulkRequest()
Expand Down

0 comments on commit 20199ee

Please sign in to comment.