@Test(groups = "slow")
  public void testApplicator() throws Exception {
    final InputStream is = new ByteArrayInputStream(testOverdueHelper.getConfigXml().getBytes());
    final OverdueConfig config = XMLLoader.getObjectFromStreamNoValidation(is, OverdueConfig.class);
    overdueWrapperFactory.setOverdueConfig(config);

    final SubscriptionBundle bundle = Mockito.mock(SubscriptionBundle.class);
    Mockito.when(bundle.getId()).thenReturn(UUID.randomUUID());

    OverdueState<SubscriptionBundle> state;

    state = config.getBundleStateSet().findState("OD1");
    applicator.apply(
        null, null, bundle, DefaultBlockingState.CLEAR_STATE_NAME, state, internalCallContext);
    testOverdueHelper.checkStateApplied(state);
    checkBussEvent("OD1");

    state = config.getBundleStateSet().findState("OD2");
    applicator.apply(
        null, null, bundle, DefaultBlockingState.CLEAR_STATE_NAME, state, internalCallContext);
    testOverdueHelper.checkStateApplied(state);
    checkBussEvent("OD2");

    state = config.getBundleStateSet().findState("OD3");
    applicator.apply(
        null, null, bundle, DefaultBlockingState.CLEAR_STATE_NAME, state, internalCallContext);
    testOverdueHelper.checkStateApplied(state);
    checkBussEvent("OD3");
  }
Ejemplo n.º 2
0
  @LifecycleHandlerType(LifecycleLevel.LOAD_CATALOG)
  public synchronized void loadConfig() throws ServiceException {
    if (!isConfigLoaded) {
      try {
        final URI u = new URI(properties.getConfigURI());
        overdueConfig = XMLLoader.getObjectFromUri(u, OverdueConfig.class);
        // File not found?
        if (overdueConfig == null) {
          log.warn("Unable to load the overdue config from " + properties.getConfigURI());
          overdueConfig = new OverdueConfig();
        }

        isConfigLoaded = true;
      } catch (final URISyntaxException e) {
        overdueConfig = new OverdueConfig();
      } catch (final IllegalArgumentException e) {
        overdueConfig = new OverdueConfig();
      } catch (final Exception e) {
        throw new ServiceException(e);
      }

      factory.setOverdueConfig(overdueConfig);
      ((DefaultOverdueUserApi) userApi).setOverdueConfig(overdueConfig);
    }
  }