use of org.killbill.billing.overdue.config.api.OverdueStateSet in project killbill by killbill.
the class DefaultOverdueApi method getOverdueStateFor.
@Override
public OverdueState getOverdueStateFor(final UUID accountId, final TenantContext tenantContext) throws OverdueApiException {
final InternalTenantContext internalTenantContext = internalCallContextFactory.createInternalTenantContext(accountId, tenantContext);
final BlockingState blockingStateForService = blockingInternalApi.getBlockingStateForService(accountId, BlockingStateType.ACCOUNT, OverdueService.OVERDUE_SERVICE_NAME, internalTenantContext);
final String stateName = blockingStateForService != null ? blockingStateForService.getStateName() : OverdueWrapper.CLEAR_STATE_NAME;
final OverdueConfig overdueConfig = overdueConfigCache.getOverdueConfig(internalTenantContext);
final OverdueStateSet states = ((DefaultOverdueConfig) overdueConfig).getOverdueStatesAccount();
return states.findState(stateName);
}
use of org.killbill.billing.overdue.config.api.OverdueStateSet 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");
}
Aggregations