use of org.killbill.billing.overdue.api.OverdueState in project killbill by killbill.
the class TestOverdueWrapper method testWrapperBasic.
@Test(groups = "slow")
public void testWrapperBasic() throws Exception {
final InputStream is = new ByteArrayInputStream(testOverdueHelper.getConfigXml().getBytes());
final DefaultOverdueConfig config = XMLLoader.getObjectFromStreamNoValidation(is, DefaultOverdueConfig.class);
((MockOverdueConfigCache) overdueConfigCache).loadOverwriteDefaultOverdueConfig(config);
Account account;
OverdueWrapper wrapper;
OverdueState state;
state = config.getOverdueStatesAccount().findState("OD1");
account = testOverdueHelper.createAccount(clock.getUTCToday().minusDays(31));
wrapper = overdueWrapperFactory.createOverdueWrapperFor(account, internalCallContext);
wrapper.refresh(clock.getUTCNow(), internalCallContext);
testOverdueHelper.checkStateApplied(state);
state = config.getOverdueStatesAccount().findState("OD2");
account = testOverdueHelper.createAccount(clock.getUTCToday().minusDays(41));
wrapper = overdueWrapperFactory.createOverdueWrapperFor(account, internalCallContext);
wrapper.refresh(clock.getUTCNow(), internalCallContext);
testOverdueHelper.checkStateApplied(state);
state = config.getOverdueStatesAccount().findState("OD3");
account = testOverdueHelper.createAccount(clock.getUTCToday().minusDays(51));
wrapper = overdueWrapperFactory.createOverdueWrapperFor(account, internalCallContext);
wrapper.refresh(clock.getUTCNow(), internalCallContext);
testOverdueHelper.checkStateApplied(state);
}
use of org.killbill.billing.overdue.api.OverdueState in project killbill by killbill.
the class OverdueWrapper method refreshWithLock.
private OverdueState refreshWithLock(final DateTime effectiveDate, final InternalCallContext context) throws OverdueException, OverdueApiException {
final BillingState billingState = billingState(context);
final BlockingState blockingStateForService = api.getBlockingStateForService(overdueable.getId(), BlockingStateType.ACCOUNT, OverdueService.OVERDUE_SERVICE_NAME, context);
final String previousOverdueStateName = blockingStateForService != null ? blockingStateForService.getStateName() : OverdueWrapper.CLEAR_STATE_NAME;
final OverdueState currentOverdueState = overdueStateSet.findState(previousOverdueStateName);
final OverdueState nextOverdueState = overdueStateSet.calculateOverdueState(billingState, clock.getToday(billingState.getAccountTimeZone()));
overdueStateApplicator.apply(effectiveDate, overdueStateSet, billingState, overdueable, currentOverdueState, nextOverdueState, context);
return nextOverdueState;
}
use of org.killbill.billing.overdue.api.OverdueState in project killbill by killbill.
the class OverdueWrapper method clearWithLock.
private void clearWithLock(final DateTime effectiveDate, final InternalCallContext context) throws OverdueException, OverdueApiException {
final BlockingState blockingStateForService = api.getBlockingStateForService(overdueable.getId(), BlockingStateType.ACCOUNT, OverdueService.OVERDUE_SERVICE_NAME, context);
final String previousOverdueStateName = blockingStateForService != null ? blockingStateForService.getStateName() : OverdueWrapper.CLEAR_STATE_NAME;
final OverdueState previousOverdueState = overdueStateSet.findState(previousOverdueStateName);
overdueStateApplicator.clear(effectiveDate, overdueable, previousOverdueState, overdueStateSet.getClearState(), context);
}
use of org.killbill.billing.overdue.api.OverdueState in project killbill by killbill.
the class TestOverdueStateApplicator method testApplicator.
@Test(groups = "slow")
public void testApplicator() throws Exception {
final InputStream is = new ByteArrayInputStream(testOverdueHelper.getConfigXml().getBytes());
final DefaultOverdueConfig config = XMLLoader.getObjectFromStreamNoValidation(is, DefaultOverdueConfig.class);
final ImmutableAccountData account = Mockito.mock(ImmutableAccountData.class);
Mockito.when(account.getId()).thenReturn(UUID.randomUUID());
final OverdueStateSet overdueStateSet = config.getOverdueStatesAccount();
final OverdueState clearState = config.getOverdueStatesAccount().findState(OverdueWrapper.CLEAR_STATE_NAME);
OverdueState state;
state = config.getOverdueStatesAccount().findState("OD1");
applicator.apply(clock.getUTCNow(), overdueStateSet, null, account, clearState, state, internalCallContext);
testOverdueHelper.checkStateApplied(state);
checkBussEvent("OD1");
state = config.getOverdueStatesAccount().findState("OD2");
applicator.apply(clock.getUTCNow(), overdueStateSet, null, account, clearState, state, internalCallContext);
testOverdueHelper.checkStateApplied(state);
checkBussEvent("OD2");
state = config.getOverdueStatesAccount().findState("OD3");
applicator.apply(clock.getUTCNow(), overdueStateSet, null, account, clearState, state, internalCallContext);
testOverdueHelper.checkStateApplied(state);
checkBussEvent("OD3");
}
use of org.killbill.billing.overdue.api.OverdueState in project killbill by killbill.
the class TestOverdueWrapper method testWrapperNoConfig.
@Test(groups = "slow")
public void testWrapperNoConfig() throws Exception {
final Account account;
final OverdueWrapper wrapper;
final OverdueState state;
final InputStream is = new ByteArrayInputStream(testOverdueHelper.getConfigXml().getBytes());
final DefaultOverdueConfig config = XMLLoader.getObjectFromStreamNoValidation(is, DefaultOverdueConfig.class);
state = config.getOverdueStatesAccount().findState(OverdueWrapper.CLEAR_STATE_NAME);
account = testOverdueHelper.createAccount(clock.getUTCToday().minusDays(31));
wrapper = overdueWrapperFactory.createOverdueWrapperFor(account, internalCallContext);
final OverdueState result = wrapper.refresh(clock.getUTCNow(), internalCallContext);
Assert.assertEquals(result.getName(), state.getName());
Assert.assertEquals(result.isBlockChanges(), state.isBlockChanges());
Assert.assertEquals(result.isDisableEntitlementAndChangesBlocked(), state.isDisableEntitlementAndChangesBlocked());
}
Aggregations