@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"); }
@Test(groups = "slow") public void testAddAndRemoveTagsForBundle() throws Exception { final String name = UUID.randomUUID().toString().substring(0, 20); final CallContext callContext = callContextFactory.createCallContext( UUID.randomUUID().toString(), CallOrigin.TEST, UserType.TEST); final String externalKey = UUID.randomUUID().toString(); final Account accountData = new MockAccountBuilder().currency(Currency.MXN).build(); final Account account = accountUserApi.createAccount(accountData, callContext); final SubscriptionBundle bundle = entitlementUserApi.createBundleForAccount(account.getId(), externalKey, callContext); final UUID bundleId = bundle.getId(); Assert.assertEquals( subscriptionTransitionTagSqlDao .getTagsForBusinessSubscriptionTransitionByKey(externalKey) .size(), 0); tagRecorder.tagAdded(ObjectType.BUNDLE, bundleId, name); Assert.assertEquals( subscriptionTransitionTagSqlDao .getTagsForBusinessSubscriptionTransitionByKey(externalKey) .size(), 1); tagRecorder.tagRemoved(ObjectType.BUNDLE, bundleId, name); Assert.assertEquals( subscriptionTransitionTagSqlDao .getTagsForBusinessSubscriptionTransitionByKey(externalKey) .size(), 0); }