use of org.killbill.billing.overdue.config.DefaultOverdueConfig 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.config.DefaultOverdueConfig in project killbill by killbill.
the class EhCacheOverdueConfigCache method initializeCacheLoaderArgument.
private CacheLoaderArgument initializeCacheLoaderArgument() {
final LoaderCallback loaderCallback = new LoaderCallback() {
@Override
public Object loadOverdueConfig(final String overdueConfigXML) throws OverdueApiException {
final InputStream overdueConfigStream = new ByteArrayInputStream(overdueConfigXML.getBytes());
final URI uri;
try {
uri = new URI("/overdueConfig");
final DefaultOverdueConfig overdueConfig = XMLLoader.getObjectFromStream(uri, overdueConfigStream, DefaultOverdueConfig.class);
return overdueConfig;
} catch (final Exception e) {
throw new OverdueApiException(ErrorCode.OVERDUE_INVALID_FOR_TENANT, "Problem encountered loading overdue config ", e);
}
}
};
final Object[] args = new Object[1];
args[0] = loaderCallback;
final ObjectType irrelevant = null;
final InternalTenantContext notUsed = null;
return new CacheLoaderArgument(irrelevant, args, notUsed);
}
use of org.killbill.billing.overdue.config.DefaultOverdueConfig in project killbill by killbill.
the class EhCacheOverdueConfigCache method loadDefaultOverdueConfig.
@Override
public void loadDefaultOverdueConfig(@Nullable final String configURI) throws OverdueApiException {
boolean missingOrCorruptedDefaultConfig;
try {
if (configURI == null || configURI.isEmpty()) {
missingOrCorruptedDefaultConfig = true;
} else {
final URI u = new URI(configURI);
defaultOverdueConfig = XMLLoader.getObjectFromUri(u, DefaultOverdueConfig.class);
missingOrCorruptedDefaultConfig = (defaultOverdueConfig == null);
}
} catch (final Exception e) {
missingOrCorruptedDefaultConfig = true;
log.warn("Exception loading default overdue config from " + configURI, e);
}
if (missingOrCorruptedDefaultConfig) {
log.warn("Overdue system disabled: unable to load the overdue config from " + configURI);
}
}
use of org.killbill.billing.overdue.config.DefaultOverdueConfig 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.DefaultOverdueConfig in project killbill by killbill.
the class TestOverdueBase method beforeMethod.
@Override
@BeforeMethod(groups = "slow")
public void beforeMethod() throws Exception {
super.beforeMethod();
final String configXml = getOverdueConfig();
final InputStream is = new ByteArrayInputStream(configXml.getBytes());
final DefaultOverdueConfig config = XMLLoader.getObjectFromStreamNoValidation(is, DefaultOverdueConfig.class);
overdueConfigCache.loadDefaultOverdueConfig(config);
productName = "Shotgun";
term = BillingPeriod.MONTHLY;
paymentPlugin.clear();
}
Aggregations