FINERACT-1694-Event-Configuration-Apis

This commit is contained in:
Ruchi Dhamankar
2022-10-26 14:44:16 +02:00
committed by Arnold Gálovics
parent 2543e6f6a3
commit 8e0273bfc0
8 changed files with 785 additions and 0 deletions
@@ -3590,4 +3590,11 @@ public class CommandWrapperBuilder {
this.jobName = jobName;
return this;
}
public CommandWrapperBuilder updateExternalEventConfigurations() {
this.actionName = "UPDATE";
this.entityName = "EXTERNAL_EVENT_CONFIGURATION";
this.href = "/externaleventconfiguration";
return this;
}
}
@@ -0,0 +1,100 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.event.external.api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriInfo;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.commands.domain.CommandWrapper;
import org.apache.fineract.commands.service.CommandWrapperBuilder;
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
import org.apache.fineract.infrastructure.event.external.data.ExternalEventConfigurationData;
import org.apache.fineract.infrastructure.event.external.service.ExternalEventConfigurationReadPlatformService;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.springframework.stereotype.Component;
@RequiredArgsConstructor
@Path("/externalevents/configuration")
@Component
@Tag(name = "External event configuration", description = "External event configuration enables user to enable/disable event posting to downstream message channel")
public class ExternalEventConfigurationApiResource {
private static final Set<String> RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("type", "enabled"));
private static final String RESOURCE_NAME_FOR_PERMISSIONS = "EXTERNAL_EVENT_CONFIGURATION";
private final PlatformSecurityContext context;
private final ApiRequestParameterHelper apiRequestParameterHelper;
private final PortfolioCommandSourceWritePlatformService commandWritePlatformService;
private final DefaultToApiJsonSerializer<ExternalEventConfigurationData> jsonSerializer;
private final ExternalEventConfigurationReadPlatformService readPlatformService;
@GET
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "List all external event configurations", description = "")
@ApiResponses({
@ApiResponse(responseCode = "200", description = "List of all external event configurations", content = @Content(schema = @Schema(implementation = ExternalEventConfigurationApiResourceSwagger.GetExternalEventConfigurationsResponse.class))) })
public String retrieveExternalEventConfiguration(@Context final UriInfo uriInfo) {
context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
final ExternalEventConfigurationData configurationData = readPlatformService.findAllExternalEventConfigurations();
final ApiRequestJsonSerializationSettings settings = apiRequestParameterHelper.process(uriInfo.getQueryParameters());
return jsonSerializer.serialize(settings, configurationData, RESPONSE_DATA_PARAMETERS);
}
@PUT
@Consumes({ MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_JSON })
@Operation(summary = "Enable/Disable external events posting", description = "")
@RequestBody(required = true, content = @Content(schema = @Schema(implementation = ExternalEventConfigurationApiResourceSwagger.PutExternalEventConfigurationsRequest.class)))
@ApiResponses({
@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CommandProcessingResult.class))) })
public String updateExternalEventConfigurationsDetails(@Parameter(hidden = true) final String apiRequestBodyAsJson) {
context.authenticatedUser().validateHasUpdatePermission(RESOURCE_NAME_FOR_PERMISSIONS);
final CommandWrapper commandRequest = new CommandWrapperBuilder() //
.updateExternalEventConfigurations() //
.withJson(apiRequestBodyAsJson) //
.build();
final CommandProcessingResult result = this.commandWritePlatformService.logCommandSource(commandRequest);
return this.jsonSerializer.serialize(result);
}
}
@@ -0,0 +1,48 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.event.external.api;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import java.util.Map;
import org.apache.fineract.infrastructure.event.external.data.ExternalEventConfigurationItemData;
final class ExternalEventConfigurationApiResourceSwagger {
private ExternalEventConfigurationApiResourceSwagger() {}
@Schema(description = "GetExternalEventConfigurationsResponse")
public static final class GetExternalEventConfigurationsResponse {
private GetExternalEventConfigurationsResponse() {}
public List<ExternalEventConfigurationItemData> externalEventConfiguration;
}
@Schema(description = "PutExternalEventConfigurationsRequest")
public static final class PutExternalEventConfigurationsRequest {
private PutExternalEventConfigurationsRequest() {}
@Schema(example = "\"CentersCreateBusinessEvent\":true,\n" + "\"ClientActivateBusinessEvent\":true")
public Map<String, Map<String, Boolean>> externalEventConfigurations;
}
}
@@ -0,0 +1,43 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.infrastructure.event.external.handler;
import javax.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.apache.fineract.commands.annotation.CommandType;
import org.apache.fineract.commands.handler.NewCommandSourceHandler;
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.event.external.service.ExternalEventConfigurationWritePlatformService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@RequiredArgsConstructor
@Service
@CommandType(entity = "EXTERNAL_EVENT_CONFIGURATION", action = "UPDATE")
public class ExternalEventConfigurationUpdateHandler implements NewCommandSourceHandler {
private final ExternalEventConfigurationWritePlatformService writePlatformService;
@Transactional
@Override
public CommandProcessingResult processCommand(@NotNull final JsonCommand command) {
return writePlatformService.updateConfigurations(command);
}
}
@@ -82,4 +82,5 @@
<include file="parts/0060_add_job_name_to_command_source.xml" relativeToChangelogFile="true"/>
<include file="parts/0061_add_idempotency_key_to_command_source.xml" relativeToChangelogFile="true"/>
<include file="parts/0062_add_fraud_attribute_to_loan.xml" relativeToChangelogFile="true"/>
<include file="parts/0063_add_permissions_for_external_event_configuration.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
<changeSet author="fineract" id="1">
<insert tableName="m_permission">
<column name="grouping" value="configuration"/>
<column name="code" value="UPDATE_EXTERNAL_EVENT_CONFIGURATION"/>
<column name="entity_name" value="EXTERNAL_EVENT_CONFIGURATION"/>
<column name="action_name" value="UPDATE"/>
<column name="can_maker_checker" valueBoolean="false"/>
</insert>
<insert tableName="m_permission">
<column name="grouping" value="configuration"/>
<column name="code" value="READ_EXTERNAL_EVENT_CONFIGURATION"/>
<column name="entity_name" value="EXTERNAL_EVENT_CONFIGURATION"/>
<column name="action_name" value="READ"/>
<column name="can_maker_checker" valueBoolean="false"/>
</insert>
</changeSet>
</databaseChangeLog>
@@ -0,0 +1,87 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.integrationtests;
import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.http.ContentType;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList;
import java.util.Map;
import org.apache.fineract.integrationtests.common.ExternalEventConfigurationHelper;
import org.apache.fineract.integrationtests.common.Utils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class ExternalEventConfigurationIntegrationTest {
private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
@BeforeEach
public void setup() {
Utils.initializeRESTAssured();
this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
}
@Test
public void getExternalEventConfigurations() {
final ArrayList<Map<String, Object>> externalEventConfigurations = ExternalEventConfigurationHelper
.getAllExternalEventConfigurations(requestSpec, responseSpec);
Assertions.assertNotNull(externalEventConfigurations);
final ArrayList<Map<String, Object>> defaultConfigurations = ExternalEventConfigurationHelper
.getDefaultExternalEventConfigurations();
Assertions.assertEquals(defaultConfigurations.size(), externalEventConfigurations.size());
verifyAllEventConfigurations(externalEventConfigurations, defaultConfigurations);
}
private void verifyAllEventConfigurations(ArrayList<Map<String, Object>> actualEventConfigurations,
ArrayList<Map<String, Object>> defaultConfigurations) {
for (int index = 0; index < actualEventConfigurations.size(); index++) {
Assertions.assertTrue(defaultConfigurations.contains(actualEventConfigurations.get(index)));
}
}
@Test
public void updateExternalEventConfigurations() {
String updateRequestJson = ExternalEventConfigurationHelper.getExternalEventConfigurationsForUpdateJSON();
final Map<String, Boolean> updatedConfigurations = ExternalEventConfigurationHelper.updateExternalEventConfigurations(requestSpec,
responseSpec, updateRequestJson);
Assertions.assertEquals(updatedConfigurations.size(), 2);
Assertions.assertTrue(updatedConfigurations.containsKey("CentersCreateBusinessEvent"));
Assertions.assertTrue(updatedConfigurations.containsKey("ClientActivateBusinessEvent"));
Assertions.assertTrue(updatedConfigurations.get("CentersCreateBusinessEvent"));
Assertions.assertTrue(updatedConfigurations.get("ClientActivateBusinessEvent"));
}
@AfterEach
public void tearDown() {
ExternalEventConfigurationHelper.resetDefaultConfigurations(requestSpec, responseSpec);
}
}
@@ -0,0 +1,458 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.integrationtests.common;
import com.google.gson.Gson;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class ExternalEventConfigurationHelper {
private static final String EXTERNAL_EVENT_CONFIGURATION = "externalEventConfiguration";
private static final String EXTERNAL_EVENT_CONFIGURATION_RESPONSE = "externalEventConfigurations";
protected ExternalEventConfigurationHelper() {}
private static final String EXTERNAL_EVENT_CONFIGURATION_URL = "/fineract-provider/api/v1/externalevents/configuration?"
+ Utils.TENANT_IDENTIFIER;
public static ArrayList<Map<String, Object>> getAllExternalEventConfigurations(RequestSpecification requestSpec,
ResponseSpecification responseSpec) {
Map<String, ArrayList<Map<String, Object>>> response = Utils.performServerGet(requestSpec, responseSpec,
EXTERNAL_EVENT_CONFIGURATION_URL, "");
return response.get(EXTERNAL_EVENT_CONFIGURATION);
}
public static ArrayList<Map<String, Object>> getDefaultExternalEventConfigurations() {
ArrayList<Map<String, Object>> defaults = new ArrayList<>();
Map<String, Object> centersCreateBusinessEvent = new HashMap<>();
centersCreateBusinessEvent.put("type", "CentersCreateBusinessEvent");
centersCreateBusinessEvent.put("enabled", false);
defaults.add(centersCreateBusinessEvent);
Map<String, Object> clientActivateBusinessEvent = new HashMap<>();
clientActivateBusinessEvent.put("type", "ClientActivateBusinessEvent");
clientActivateBusinessEvent.put("enabled", false);
defaults.add(clientActivateBusinessEvent);
Map<String, Object> clientCreateBusinessEvent = new HashMap<>();
clientCreateBusinessEvent.put("type", "ClientCreateBusinessEvent");
clientCreateBusinessEvent.put("enabled", false);
defaults.add(clientCreateBusinessEvent);
Map<String, Object> clientRejectBusinessEvent = new HashMap<>();
clientRejectBusinessEvent.put("type", "ClientRejectBusinessEvent");
clientRejectBusinessEvent.put("enabled", false);
defaults.add(clientRejectBusinessEvent);
Map<String, Object> fixedDepositAccountCreateBusinessEvent = new HashMap<>();
fixedDepositAccountCreateBusinessEvent.put("type", "FixedDepositAccountCreateBusinessEvent");
fixedDepositAccountCreateBusinessEvent.put("enabled", false);
defaults.add(fixedDepositAccountCreateBusinessEvent);
Map<String, Object> groupsCreateBusinessEvent = new HashMap<>();
groupsCreateBusinessEvent.put("type", "GroupsCreateBusinessEvent");
groupsCreateBusinessEvent.put("enabled", false);
defaults.add(groupsCreateBusinessEvent);
Map<String, Object> loanAcceptTransferBusinessEvent = new HashMap<>();
loanAcceptTransferBusinessEvent.put("type", "LoanAcceptTransferBusinessEvent");
loanAcceptTransferBusinessEvent.put("enabled", false);
defaults.add(loanAcceptTransferBusinessEvent);
Map<String, Object> loanAddChargeBusinessEvent = new HashMap<>();
loanAddChargeBusinessEvent.put("type", "LoanAddChargeBusinessEvent");
loanAddChargeBusinessEvent.put("enabled", false);
defaults.add(loanAddChargeBusinessEvent);
Map<String, Object> loanAdjustTransactionBusinessEvent = new HashMap<>();
loanAdjustTransactionBusinessEvent.put("type", "LoanAdjustTransactionBusinessEvent");
loanAdjustTransactionBusinessEvent.put("enabled", false);
defaults.add(loanAdjustTransactionBusinessEvent);
Map<String, Object> loanApplyOverdueChargeBusinessEvent = new HashMap<>();
loanApplyOverdueChargeBusinessEvent.put("type", "LoanApplyOverdueChargeBusinessEvent");
loanApplyOverdueChargeBusinessEvent.put("enabled", false);
defaults.add(loanApplyOverdueChargeBusinessEvent);
Map<String, Object> loanApprovedBusinessEvent = new HashMap<>();
loanApprovedBusinessEvent.put("type", "LoanApprovedBusinessEvent");
loanApprovedBusinessEvent.put("enabled", false);
defaults.add(loanApprovedBusinessEvent);
Map<String, Object> loanBalanceChangedBusinessEvent = new HashMap<>();
loanBalanceChangedBusinessEvent.put("type", "LoanBalanceChangedBusinessEvent");
loanBalanceChangedBusinessEvent.put("enabled", false);
defaults.add(loanBalanceChangedBusinessEvent);
Map<String, Object> loanChargebackTransactionBusinessEvent = new HashMap<>();
loanChargebackTransactionBusinessEvent.put("type", "LoanChargebackTransactionBusinessEvent");
loanChargebackTransactionBusinessEvent.put("enabled", false);
defaults.add(loanChargebackTransactionBusinessEvent);
Map<String, Object> loanChargePaymentPostBusinessEvent = new HashMap<>();
loanChargePaymentPostBusinessEvent.put("type", "LoanChargePaymentPostBusinessEvent");
loanChargePaymentPostBusinessEvent.put("enabled", false);
defaults.add(loanChargePaymentPostBusinessEvent);
Map<String, Object> loanChargePaymentPreBusinessEvent = new HashMap<>();
loanChargePaymentPreBusinessEvent.put("type", "LoanChargePaymentPreBusinessEvent");
loanChargePaymentPreBusinessEvent.put("enabled", false);
defaults.add(loanChargePaymentPreBusinessEvent);
Map<String, Object> loanChargeRefundBusinessEvent = new HashMap<>();
loanChargeRefundBusinessEvent.put("type", "LoanChargeRefundBusinessEvent");
loanChargeRefundBusinessEvent.put("enabled", false);
defaults.add(loanChargeRefundBusinessEvent);
Map<String, Object> loanCloseAsRescheduleBusinessEvent = new HashMap<>();
loanCloseAsRescheduleBusinessEvent.put("type", "LoanCloseAsRescheduleBusinessEvent");
loanCloseAsRescheduleBusinessEvent.put("enabled", false);
defaults.add(loanCloseAsRescheduleBusinessEvent);
Map<String, Object> loanCloseBusinessEvent = new HashMap<>();
loanCloseBusinessEvent.put("type", "LoanCloseBusinessEvent");
loanCloseBusinessEvent.put("enabled", false);
defaults.add(loanCloseBusinessEvent);
Map<String, Object> loanCreatedBusinessEvent = new HashMap<>();
loanCreatedBusinessEvent.put("type", "LoanCreatedBusinessEvent");
loanCreatedBusinessEvent.put("enabled", false);
defaults.add(loanCreatedBusinessEvent);
Map<String, Object> loanCreditBalanceRefundPostBusinessEvent = new HashMap<>();
loanCreditBalanceRefundPostBusinessEvent.put("type", "LoanCreditBalanceRefundPostBusinessEvent");
loanCreditBalanceRefundPostBusinessEvent.put("enabled", false);
defaults.add(loanCreditBalanceRefundPostBusinessEvent);
Map<String, Object> loanCreditBalanceRefundPreBusinessEvent = new HashMap<>();
loanCreditBalanceRefundPreBusinessEvent.put("type", "LoanCreditBalanceRefundPreBusinessEvent");
loanCreditBalanceRefundPreBusinessEvent.put("enabled", false);
defaults.add(loanCreditBalanceRefundPreBusinessEvent);
Map<String, Object> loanDeleteChargeBusinessEvent = new HashMap<>();
loanDeleteChargeBusinessEvent.put("type", "LoanDeleteChargeBusinessEvent");
loanDeleteChargeBusinessEvent.put("enabled", false);
defaults.add(loanDeleteChargeBusinessEvent);
Map<String, Object> loanDisbursalBusinessEvent = new HashMap<>();
loanDisbursalBusinessEvent.put("type", "LoanDisbursalBusinessEvent");
loanDisbursalBusinessEvent.put("enabled", false);
defaults.add(loanDisbursalBusinessEvent);
Map<String, Object> loanDisbursalTransactionBusinessEvent = new HashMap<>();
loanDisbursalTransactionBusinessEvent.put("type", "LoanDisbursalTransactionBusinessEvent");
loanDisbursalTransactionBusinessEvent.put("enabled", false);
defaults.add(loanDisbursalTransactionBusinessEvent);
Map<String, Object> loanForeClosurePostBusinessEvent = new HashMap<>();
loanForeClosurePostBusinessEvent.put("type", "LoanForeClosurePostBusinessEvent");
loanForeClosurePostBusinessEvent.put("enabled", false);
defaults.add(loanForeClosurePostBusinessEvent);
Map<String, Object> loanForeClosurePreBusinessEvent = new HashMap<>();
loanForeClosurePreBusinessEvent.put("type", "LoanForeClosurePreBusinessEvent");
loanForeClosurePreBusinessEvent.put("enabled", false);
defaults.add(loanForeClosurePreBusinessEvent);
Map<String, Object> loanInitiateTransferBusinessEvent = new HashMap<>();
loanInitiateTransferBusinessEvent.put("type", "LoanInitiateTransferBusinessEvent");
loanInitiateTransferBusinessEvent.put("enabled", false);
defaults.add(loanInitiateTransferBusinessEvent);
Map<String, Object> loanInterestRecalculationBusinessEvent = new HashMap<>();
loanInterestRecalculationBusinessEvent.put("type", "LoanInterestRecalculationBusinessEvent");
loanInterestRecalculationBusinessEvent.put("enabled", false);
defaults.add(loanInterestRecalculationBusinessEvent);
Map<String, Object> loanProductCreateBusinessEvent = new HashMap<>();
loanProductCreateBusinessEvent.put("type", "LoanProductCreateBusinessEvent");
loanProductCreateBusinessEvent.put("enabled", false);
defaults.add(loanProductCreateBusinessEvent);
Map<String, Object> loanReassignOfficerBusinessEvent = new HashMap<>();
loanReassignOfficerBusinessEvent.put("type", "LoanReassignOfficerBusinessEvent");
loanReassignOfficerBusinessEvent.put("enabled", false);
defaults.add(loanReassignOfficerBusinessEvent);
Map<String, Object> loanRefundPostBusinessEvent = new HashMap<>();
loanRefundPostBusinessEvent.put("type", "LoanRefundPostBusinessEvent");
loanRefundPostBusinessEvent.put("enabled", false);
defaults.add(loanRefundPostBusinessEvent);
Map<String, Object> loanRefundPreBusinessEvent = new HashMap<>();
loanRefundPreBusinessEvent.put("type", "LoanRefundPreBusinessEvent");
loanRefundPreBusinessEvent.put("enabled", false);
defaults.add(loanRefundPreBusinessEvent);
Map<String, Object> loanRejectedBusinessEvent = new HashMap<>();
loanRejectedBusinessEvent.put("type", "LoanRejectedBusinessEvent");
loanRejectedBusinessEvent.put("enabled", false);
defaults.add(loanRejectedBusinessEvent);
Map<String, Object> loanRejectTransferBusinessEvent = new HashMap<>();
loanRejectTransferBusinessEvent.put("type", "LoanRejectTransferBusinessEvent");
loanRejectTransferBusinessEvent.put("enabled", false);
defaults.add(loanRejectTransferBusinessEvent);
Map<String, Object> loanRemoveOfficerBusinessEvent = new HashMap<>();
loanRemoveOfficerBusinessEvent.put("type", "LoanRemoveOfficerBusinessEvent");
loanRemoveOfficerBusinessEvent.put("enabled", false);
defaults.add(loanRemoveOfficerBusinessEvent);
Map<String, Object> loanRescheduledDueCalendarChangeBusinessEvent = new HashMap<>();
loanRescheduledDueCalendarChangeBusinessEvent.put("type", "LoanRescheduledDueCalendarChangeBusinessEvent");
loanRescheduledDueCalendarChangeBusinessEvent.put("enabled", false);
defaults.add(loanRescheduledDueCalendarChangeBusinessEvent);
Map<String, Object> loanRescheduledDueHolidayBusinessEvent = new HashMap<>();
loanRescheduledDueHolidayBusinessEvent.put("type", "LoanRescheduledDueHolidayBusinessEvent");
loanRescheduledDueHolidayBusinessEvent.put("enabled", false);
defaults.add(loanRescheduledDueHolidayBusinessEvent);
Map<String, Object> loanScheduleVariationsAddedBusinessEvent = new HashMap<>();
loanScheduleVariationsAddedBusinessEvent.put("type", "LoanScheduleVariationsAddedBusinessEvent");
loanScheduleVariationsAddedBusinessEvent.put("enabled", false);
defaults.add(loanScheduleVariationsAddedBusinessEvent);
Map<String, Object> loanScheduleVariationsDeletedBusinessEvent = new HashMap<>();
loanScheduleVariationsDeletedBusinessEvent.put("type", "LoanScheduleVariationsDeletedBusinessEvent");
loanScheduleVariationsDeletedBusinessEvent.put("enabled", false);
defaults.add(loanScheduleVariationsDeletedBusinessEvent);
Map<String, Object> loanStatusChangedBusinessEvent = new HashMap<>();
loanStatusChangedBusinessEvent.put("type", "LoanStatusChangedBusinessEvent");
loanStatusChangedBusinessEvent.put("enabled", false);
defaults.add(loanStatusChangedBusinessEvent);
Map<String, Object> loanTransactionGoodwillCreditPostBusinessEvent = new HashMap<>();
loanTransactionGoodwillCreditPostBusinessEvent.put("type", "LoanTransactionGoodwillCreditPostBusinessEvent");
loanTransactionGoodwillCreditPostBusinessEvent.put("enabled", false);
defaults.add(loanTransactionGoodwillCreditPostBusinessEvent);
Map<String, Object> loanTransactionGoodwillCreditPreBusinessEvent = new HashMap<>();
loanTransactionGoodwillCreditPreBusinessEvent.put("type", "LoanTransactionGoodwillCreditPreBusinessEvent");
loanTransactionGoodwillCreditPreBusinessEvent.put("enabled", false);
defaults.add(loanTransactionGoodwillCreditPreBusinessEvent);
Map<String, Object> loanTransactionMakeRepaymentPostBusinessEvent = new HashMap<>();
loanTransactionMakeRepaymentPostBusinessEvent.put("type", "LoanTransactionMakeRepaymentPostBusinessEvent");
loanTransactionMakeRepaymentPostBusinessEvent.put("enabled", false);
defaults.add(loanTransactionMakeRepaymentPostBusinessEvent);
Map<String, Object> loanTransactionMakeRepaymentPreBusinessEvent = new HashMap<>();
loanTransactionMakeRepaymentPreBusinessEvent.put("type", "LoanTransactionMakeRepaymentPreBusinessEvent");
loanTransactionMakeRepaymentPreBusinessEvent.put("enabled", false);
defaults.add(loanTransactionMakeRepaymentPreBusinessEvent);
Map<String, Object> loanTransactionMerchantIssuedRefundPostBusinessEvent = new HashMap<>();
loanTransactionMerchantIssuedRefundPostBusinessEvent.put("type", "LoanTransactionMerchantIssuedRefundPostBusinessEvent");
loanTransactionMerchantIssuedRefundPostBusinessEvent.put("enabled", false);
defaults.add(loanTransactionMerchantIssuedRefundPostBusinessEvent);
Map<String, Object> loanTransactionMerchantIssuedRefundPreBusinessEvent = new HashMap<>();
loanTransactionMerchantIssuedRefundPreBusinessEvent.put("type", "LoanTransactionMerchantIssuedRefundPreBusinessEvent");
loanTransactionMerchantIssuedRefundPreBusinessEvent.put("enabled", false);
defaults.add(loanTransactionMerchantIssuedRefundPreBusinessEvent);
Map<String, Object> loanTransactionPayoutRefundPostBusinessEvent = new HashMap<>();
loanTransactionPayoutRefundPostBusinessEvent.put("type", "LoanTransactionPayoutRefundPostBusinessEvent");
loanTransactionPayoutRefundPostBusinessEvent.put("enabled", false);
defaults.add(loanTransactionPayoutRefundPostBusinessEvent);
Map<String, Object> loanTransactionPayoutRefundPreBusinessEvent = new HashMap<>();
loanTransactionPayoutRefundPreBusinessEvent.put("type", "LoanTransactionPayoutRefundPreBusinessEvent");
loanTransactionPayoutRefundPreBusinessEvent.put("enabled", false);
defaults.add(loanTransactionPayoutRefundPreBusinessEvent);
Map<String, Object> loanTransactionRecoveryPaymentPostBusinessEvent = new HashMap<>();
loanTransactionRecoveryPaymentPostBusinessEvent.put("type", "LoanTransactionRecoveryPaymentPostBusinessEvent");
loanTransactionRecoveryPaymentPostBusinessEvent.put("enabled", false);
defaults.add(loanTransactionRecoveryPaymentPostBusinessEvent);
Map<String, Object> loanTransactionRecoveryPaymentPreBusinessEvent = new HashMap<>();
loanTransactionRecoveryPaymentPreBusinessEvent.put("type", "LoanTransactionRecoveryPaymentPreBusinessEvent");
loanTransactionRecoveryPaymentPreBusinessEvent.put("enabled", false);
defaults.add(loanTransactionRecoveryPaymentPreBusinessEvent);
Map<String, Object> loanUndoApprovalBusinessEvent = new HashMap<>();
loanUndoApprovalBusinessEvent.put("type", "LoanUndoApprovalBusinessEvent");
loanUndoApprovalBusinessEvent.put("enabled", false);
defaults.add(loanUndoApprovalBusinessEvent);
Map<String, Object> loanUndoDisbursalBusinessEvent = new HashMap<>();
loanUndoDisbursalBusinessEvent.put("type", "LoanUndoDisbursalBusinessEvent");
loanUndoDisbursalBusinessEvent.put("enabled", false);
defaults.add(loanUndoDisbursalBusinessEvent);
Map<String, Object> loanUndoLastDisbursalBusinessEvent = new HashMap<>();
loanUndoLastDisbursalBusinessEvent.put("type", "LoanUndoLastDisbursalBusinessEvent");
loanUndoLastDisbursalBusinessEvent.put("enabled", false);
defaults.add(loanUndoLastDisbursalBusinessEvent);
Map<String, Object> loanUndoWrittenOffBusinessEvent = new HashMap<>();
loanUndoWrittenOffBusinessEvent.put("type", "LoanUndoWrittenOffBusinessEvent");
loanUndoWrittenOffBusinessEvent.put("enabled", false);
defaults.add(loanUndoWrittenOffBusinessEvent);
Map<String, Object> loanUpdateChargeBusinessEvent = new HashMap<>();
loanUpdateChargeBusinessEvent.put("type", "LoanUpdateChargeBusinessEvent");
loanUpdateChargeBusinessEvent.put("enabled", false);
defaults.add(loanUpdateChargeBusinessEvent);
Map<String, Object> loanUpdateDisbursementDataBusinessEvent = new HashMap<>();
loanUpdateDisbursementDataBusinessEvent.put("type", "LoanUpdateDisbursementDataBusinessEvent");
loanUpdateDisbursementDataBusinessEvent.put("enabled", false);
defaults.add(loanUpdateDisbursementDataBusinessEvent);
Map<String, Object> loanWaiveChargeBusinessEvent = new HashMap<>();
loanWaiveChargeBusinessEvent.put("type", "LoanWaiveChargeBusinessEvent");
loanWaiveChargeBusinessEvent.put("enabled", false);
defaults.add(loanWaiveChargeBusinessEvent);
Map<String, Object> loanWaiveChargeUndoBusinessEvent = new HashMap<>();
loanWaiveChargeUndoBusinessEvent.put("type", "LoanWaiveChargeUndoBusinessEvent");
loanWaiveChargeUndoBusinessEvent.put("enabled", false);
defaults.add(loanWaiveChargeUndoBusinessEvent);
Map<String, Object> loanWaiveInterestBusinessEvent = new HashMap<>();
loanWaiveInterestBusinessEvent.put("type", "LoanWaiveInterestBusinessEvent");
loanWaiveInterestBusinessEvent.put("enabled", false);
defaults.add(loanWaiveInterestBusinessEvent);
Map<String, Object> loanWithdrawTransferBusinessEvent = new HashMap<>();
loanWithdrawTransferBusinessEvent.put("type", "LoanWithdrawTransferBusinessEvent");
loanWithdrawTransferBusinessEvent.put("enabled", false);
defaults.add(loanWithdrawTransferBusinessEvent);
Map<String, Object> loanWrittenOffPostBusinessEvent = new HashMap<>();
loanWrittenOffPostBusinessEvent.put("type", "LoanWrittenOffPostBusinessEvent");
loanWrittenOffPostBusinessEvent.put("enabled", false);
defaults.add(loanWrittenOffPostBusinessEvent);
Map<String, Object> loanWrittenOffPreBusinessEvent = new HashMap<>();
loanWrittenOffPreBusinessEvent.put("type", "LoanWrittenOffPreBusinessEvent");
loanWrittenOffPreBusinessEvent.put("enabled", false);
defaults.add(loanWrittenOffPreBusinessEvent);
Map<String, Object> recurringDepositAccountCreateBusinessEvent = new HashMap<>();
recurringDepositAccountCreateBusinessEvent.put("type", "RecurringDepositAccountCreateBusinessEvent");
recurringDepositAccountCreateBusinessEvent.put("enabled", false);
defaults.add(recurringDepositAccountCreateBusinessEvent);
Map<String, Object> savingsActivateBusinessEvent = new HashMap<>();
savingsActivateBusinessEvent.put("type", "SavingsActivateBusinessEvent");
savingsActivateBusinessEvent.put("enabled", false);
defaults.add(savingsActivateBusinessEvent);
Map<String, Object> savingsApproveBusinessEvent = new HashMap<>();
savingsApproveBusinessEvent.put("type", "SavingsApproveBusinessEvent");
savingsApproveBusinessEvent.put("enabled", false);
defaults.add(savingsApproveBusinessEvent);
Map<String, Object> savingsCloseBusinessEvent = new HashMap<>();
savingsCloseBusinessEvent.put("type", "SavingsCloseBusinessEvent");
savingsCloseBusinessEvent.put("enabled", false);
defaults.add(savingsCloseBusinessEvent);
Map<String, Object> savingsCreateBusinessEvent = new HashMap<>();
savingsCreateBusinessEvent.put("type", "SavingsCreateBusinessEvent");
savingsCreateBusinessEvent.put("enabled", false);
defaults.add(savingsCreateBusinessEvent);
Map<String, Object> savingsDepositBusinessEvent = new HashMap<>();
savingsDepositBusinessEvent.put("type", "SavingsDepositBusinessEvent");
savingsDepositBusinessEvent.put("enabled", false);
defaults.add(savingsDepositBusinessEvent);
Map<String, Object> savingsPostInterestBusinessEvent = new HashMap<>();
savingsPostInterestBusinessEvent.put("type", "SavingsPostInterestBusinessEvent");
savingsPostInterestBusinessEvent.put("enabled", false);
defaults.add(savingsPostInterestBusinessEvent);
Map<String, Object> savingsRejectBusinessEvent = new HashMap<>();
savingsRejectBusinessEvent.put("type", "SavingsRejectBusinessEvent");
savingsRejectBusinessEvent.put("enabled", false);
defaults.add(savingsRejectBusinessEvent);
Map<String, Object> savingsWithdrawalBusinessEvent = new HashMap<>();
savingsWithdrawalBusinessEvent.put("type", "SavingsWithdrawalBusinessEvent");
savingsWithdrawalBusinessEvent.put("enabled", false);
defaults.add(savingsWithdrawalBusinessEvent);
Map<String, Object> shareAccountApproveBusinessEvent = new HashMap<>();
shareAccountApproveBusinessEvent.put("type", "ShareAccountApproveBusinessEvent");
shareAccountApproveBusinessEvent.put("enabled", false);
defaults.add(shareAccountApproveBusinessEvent);
Map<String, Object> shareAccountCreateBusinessEvent = new HashMap<>();
shareAccountCreateBusinessEvent.put("type", "ShareAccountCreateBusinessEvent");
shareAccountCreateBusinessEvent.put("enabled", false);
defaults.add(shareAccountCreateBusinessEvent);
Map<String, Object> shareProductDividentsCreateBusinessEvent = new HashMap<>();
shareProductDividentsCreateBusinessEvent.put("type", "ShareProductDividentsCreateBusinessEvent");
shareProductDividentsCreateBusinessEvent.put("enabled", false);
defaults.add(shareProductDividentsCreateBusinessEvent);
return defaults;
}
public static String getExternalEventConfigurationsForUpdateJSON() {
Map<String, Map<String, Boolean>> configurationsForUpdate = new HashMap<>();
Map<String, Boolean> configurations = new HashMap<>();
configurations.put("CentersCreateBusinessEvent", true);
configurations.put("ClientActivateBusinessEvent", true);
configurationsForUpdate.put("externalEventConfigurations", configurations);
return new Gson().toJson(configurationsForUpdate);
}
public static Map<String, Boolean> updateExternalEventConfigurations(RequestSpecification requestSpec,
ResponseSpecification responseSpec, String json) {
Map<String, Map<String, Boolean>> response = Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_EVENT_CONFIGURATION_URL,
json, "changes");
return response.get(EXTERNAL_EVENT_CONFIGURATION_RESPONSE);
}
public static void resetDefaultConfigurations(RequestSpecification requestSpec, ResponseSpecification responseSpec) {
Map<String, Map<String, Boolean>> configurationsForReset = new HashMap<>();
Map<String, Boolean> configurations = new HashMap<>();
configurations.put("CentersCreateBusinessEvent", false);
configurations.put("ClientActivateBusinessEvent", false);
configurationsForReset.put("externalEventConfigurations", configurations);
String jsonForResettingConfigurations = new Gson().toJson(configurationsForReset);
Utils.performServerPut(requestSpec, responseSpec, EXTERNAL_EVENT_CONFIGURATION_URL, jsonForResettingConfigurations, "");
}
}