Search in sources :

Example 1 with OverdueStateSet

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);
}
Also used : OverdueStateSet(org.killbill.billing.overdue.config.api.OverdueStateSet) InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext) BlockingState(org.killbill.billing.entitlement.api.BlockingState) DefaultOverdueConfig(org.killbill.billing.overdue.config.DefaultOverdueConfig) DefaultOverdueConfig(org.killbill.billing.overdue.config.DefaultOverdueConfig)

Example 2 with OverdueStateSet

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");
}
Also used : ImmutableAccountData(org.killbill.billing.account.api.ImmutableAccountData) OverdueStateSet(org.killbill.billing.overdue.config.api.OverdueStateSet) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) DefaultOverdueConfig(org.killbill.billing.overdue.config.DefaultOverdueConfig) OverdueState(org.killbill.billing.overdue.api.OverdueState) Test(org.testng.annotations.Test)

Aggregations

DefaultOverdueConfig (org.killbill.billing.overdue.config.DefaultOverdueConfig)2 OverdueStateSet (org.killbill.billing.overdue.config.api.OverdueStateSet)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 ImmutableAccountData (org.killbill.billing.account.api.ImmutableAccountData)1 InternalTenantContext (org.killbill.billing.callcontext.InternalTenantContext)1 BlockingState (org.killbill.billing.entitlement.api.BlockingState)1 OverdueState (org.killbill.billing.overdue.api.OverdueState)1 Test (org.testng.annotations.Test)1