@SuppressWarnings("unchecked")
@Test
public void testSavingsAccount_REJECT_APPLICATION() {
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
SavingsAccountHelper savingsAccountHelperValidationError = new SavingsAccountHelper(this.requestSpec,
new ResponseSpecBuilder().build());
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
Assert.assertNotNull(clientID);
Integer groupID = GroupHelper.createGroup(this.requestSpec, this.responseSpec, true);
Assert.assertNotNull(groupID);
groupID = GroupHelper.associateClient(this.requestSpec, this.responseSpec, groupID.toString(), clientID.toString());
Assert.assertNotNull(groupID);
final String minBalanceForInterestCalculation = null;
final String minRequiredBalance = null;
final String enforceMinRequiredBalance = "false";
final Integer savingsProductID = createSavingsProduct(this.requestSpec, this.responseSpec, MINIMUM_OPENING_BALANCE,
minBalanceForInterestCalculation, minRequiredBalance, enforceMinRequiredBalance);
Assert.assertNotNull(savingsProductID);
final Integer savingsId = this.savingsAccountHelper.applyForSavingsApplication(groupID, savingsProductID, ACCOUNT_TYPE_GROUP);
Assert.assertNotNull(savingsId);
HashMap savingsStatusHashMap = SavingsStatusChecker.getStatusOfSavings(this.requestSpec, this.responseSpec, savingsId);
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
savingsStatusHashMap = this.savingsAccountHelper.approveSavings(savingsId);
SavingsStatusChecker.verifySavingsIsApproved(savingsStatusHashMap);
List<HashMap> error1 = savingsAccountHelperValidationError.rejectApplicationWithErrorCode(savingsId,
SavingsAccountHelper.CREATED_DATE_PLUS_ONE);
assertEquals("validation.msg.savingsaccount.reject.not.in.submittedandpendingapproval.state",
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
savingsStatusHashMap = this.savingsAccountHelper.undoApproval(savingsId);
SavingsStatusChecker.verifySavingsIsPending(savingsStatusHashMap);
error1 = savingsAccountHelperValidationError.rejectApplicationWithErrorCode(savingsId, SavingsAccountHelper.getFutureDate());
assertEquals("validation.msg.savingsaccount.reject.cannot.be.a.future.date",
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
error1 = savingsAccountHelperValidationError.rejectApplicationWithErrorCode(savingsId, SavingsAccountHelper.CREATED_DATE_MINUS_ONE);
assertEquals("validation.msg.savingsaccount.reject.cannot.be.before.submittal.date",
error1.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
savingsStatusHashMap = this.savingsAccountHelper.rejectApplication(savingsId);
SavingsStatusChecker.verifySavingsIsRejected(savingsStatusHashMap);