private void processOverdue(final UUID accountId, final InternalCallContext context) { try { factory.createOverdueWrapperFor(accountId, context).refresh(context); } catch (BillingExceptionBase e) { log.error(String.format("Error processing Overdue for blockable %s", accountId), e); } }
@Override public OverdueState refreshOverdueStateFor(final Account blockable, final CallContext context) throws OverdueException, OverdueApiException { log.info("Refresh of blockable {} ({}) requested", blockable.getId(), blockable.getClass()); final OverdueWrapper wrapper = factory.createOverdueWrapperFor(blockable); return wrapper.refresh(createInternalCallContext(blockable, context)); }
@Test(groups = "slow") public void testWrapperNoConfig() throws Exception { overdueWrapperFactory.setOverdueConfig(null); final Account account; final OverdueWrapper wrapper; final OverdueState state; final InputStream is = new ByteArrayInputStream(testOverdueHelper.getConfigXml().getBytes()); final OverdueConfig config = XMLLoader.getObjectFromStreamNoValidation(is, OverdueConfig.class); state = config.getStateSet().findState(DefaultBlockingState.CLEAR_STATE_NAME); account = testOverdueHelper.createAccount(clock.getUTCToday().minusDays(31)); wrapper = overdueWrapperFactory.createOverdueWrapperFor(account); final OverdueState result = wrapper.refresh(internalCallContext); Assert.assertEquals(result.getName(), state.getName()); Assert.assertEquals(result.blockChanges(), state.blockChanges()); Assert.assertEquals(result.disableEntitlementAndChangesBlocked(), state.disableEntitlementAndChangesBlocked()); } }
@Test(groups = "slow") public void testWrapperBasic() throws Exception { final InputStream is = new ByteArrayInputStream(testOverdueHelper.getConfigXml().getBytes()); final OverdueConfig config = XMLLoader.getObjectFromStreamNoValidation(is, OverdueConfig.class); overdueWrapperFactory.setOverdueConfig(config); Account account; OverdueWrapper wrapper; OverdueState state; state = config.getStateSet().findState("OD1"); account = testOverdueHelper.createAccount(clock.getUTCToday().minusDays(31)); wrapper = overdueWrapperFactory.createOverdueWrapperFor(account); wrapper.refresh(internalCallContext); testOverdueHelper.checkStateApplied(state); state = config.getStateSet().findState("OD2"); account = testOverdueHelper.createAccount(clock.getUTCToday().minusDays(41)); wrapper = overdueWrapperFactory.createOverdueWrapperFor(account); wrapper.refresh(internalCallContext); testOverdueHelper.checkStateApplied(state); state = config.getStateSet().findState("OD3"); account = testOverdueHelper.createAccount(clock.getUTCToday().minusDays(51)); wrapper = overdueWrapperFactory.createOverdueWrapperFor(account); wrapper.refresh(internalCallContext); testOverdueHelper.checkStateApplied(state); }