Skip to content
Permalink
Browse files
Merge pull request #9 from markusgeiss/develop
removed cash draw limit check while opening and closing a teller
  • Loading branch information
markusgeiss committed Sep 12, 2017
2 parents ee39db7 + 63e6c19 commit 793400050ca6722baec1d31b688536beaec4332f
Showing 2 changed files with 41 additions and 7 deletions.
@@ -497,6 +497,47 @@ public void shouldNotCreateTellerMaximumCashWithdrawalLimitViolation() throws Ex
super.testSubject.create(officeIdentifier, teller);
}

@Test
public void shouldCloseTellerEvenCashDrawLimitExceeding() throws Exception {
final String officeIdentifier = RandomStringUtils.randomAlphabetic(32);
final Teller teller = TellerGenerator.createRandomTeller();
teller.setCashdrawLimit(BigDecimal.valueOf(1000.00D));

Mockito.doAnswer(invocation -> true)
.when(super.organizationServiceSpy).officeExists(Matchers.eq(officeIdentifier));

Mockito.doAnswer(invocation -> Optional.of(new Account()))
.when(super.accountingServiceSpy).findAccount(Matchers.eq(teller.getTellerAccountIdentifier()));

Mockito.doAnswer(invocation -> Optional.of(new Account()))
.when(super.accountingServiceSpy).findAccount(Matchers.eq(teller.getVaultAccountIdentifier()));

super.testSubject.create(officeIdentifier, teller);

super.eventRecorder.wait(EventConstants.POST_TELLER, teller.getCode());

final TellerManagementCommand openCommand = new TellerManagementCommand();
openCommand.setAction(TellerManagementCommand.Action.OPEN.name());
openCommand.setAdjustment(TellerManagementCommand.Adjustment.DEBIT.name());
openCommand.setAmount(BigDecimal.valueOf(1100.00D));
openCommand.setAssignedEmployeeIdentifier(RandomStringUtils.randomAlphanumeric(32));

Mockito.doAnswer(invocation -> true)
.when(super.organizationServiceSpy).employeeExists(Matchers.eq(openCommand.getAssignedEmployeeIdentifier()));

super.testSubject.post(officeIdentifier, teller.getCode(), openCommand);

super.eventRecorder.wait(EventConstants.OPEN_TELLER, teller.getCode());

final TellerManagementCommand closeCommand = new TellerManagementCommand();
closeCommand.setAction(TellerManagementCommand.Action.CLOSE.name());
closeCommand.setAdjustment(TellerManagementCommand.Adjustment.CREDIT.name());
closeCommand.setAmount(BigDecimal.valueOf(1100.00D));

super.testSubject.post(officeIdentifier, teller.getCode(), closeCommand);
Assert.assertTrue(super.eventRecorder.wait(EventConstants.CLOSE_TELLER, teller.getCode()));
}

private void compareTeller(final Teller expected, final Teller actual) {
Assert.assertEquals(expected.getCode(), actual.getCode());
Assert.assertEquals(expected.getTellerAccountIdentifier(), actual.getTellerAccountIdentifier());
@@ -299,13 +299,6 @@ private void encryptPassword(final Teller teller, final TellerEntity tellerEntit
}

private JournalEntry createJournalEntry(final TellerEntity tellerEntity, final TellerManagementCommand tellerManagementCommand) {

if (tellerManagementCommand.getAmount().compareTo(tellerEntity.getCashdrawLimit()) > 0) {
this.logger.warn("Adjustment {} exceeds cashdraw limit {}.", tellerManagementCommand.getAmount(),
tellerEntity.getCashdrawLimit());
throw new IllegalArgumentException("Adjustment exceeds cashdraw limit.");
}

final JournalEntry journalEntry = new JournalEntry();
journalEntry.setTransactionIdentifier(RandomStringUtils.randomNumeric(32));
journalEntry.setTransactionDate(DateConverter.toIsoString(LocalDateTime.now(Clock.systemUTC())));

0 comments on commit 7934000

Please sign in to comment.