### Question:
DelinquentAccountEventHandler implements ContextualEventMessageHandler<Account> { @Override public void handleEvent(Account account, PlatformMessage message) { Preconditions.checkArgument(account != null, "No account context was provided."); try{ IrisSubscription irisSubscription = this.getIrisSubscription(account); String messageKey = irisSubscription.getServiceLevels().parallelStream().anyMatch(serv -> serv.isPromon()) ? Notifications.DelinquentAccountPro.KEY : Notifications.DelinquentAccount.KEY; updateSubscription(account); notification(account, messageKey); }catch (Exception e){ FAILURE_TOTAL_COUNTER.inc(); LOGGER.error("Error processing delinquent account", e); } } @Inject  DelinquentAccountEventHandler(PlaceDAO placeDao, SubscriptionUpdater subscriptionUpdater, PlatformMessageBus platformBus, SubscriptionManager subscriptionManager); @Override void handleEvent(Account account, PlatformMessage message); @Override String getEventType();  }### Answer:
@Test public void testHandleDelinquentAccount() throws Exception { EasyMock.expect(subscriptionManager.extractSubscription(ImmutableSet.of(firstPlace))).andReturn(irisSubscription); EasyMock.expect(irisSubscription.getServiceLevels()).andReturn(ImmutableSet.of(ServiceLevel.PREMIUM)); replay(); firstPlace.setServiceLevel(ServiceLevel.PREMIUM); assertEquals(ServiceLevel.PREMIUM,firstPlace.getServiceLevel()); handler.handleEvent(account, createDelinquentAccountEvent(account)); verifySubscriptionLevelChangeEvent(platformBus.take(),ServiceLevel.BASIC.toString()); verifyNotification(platformBus.take(), account.getOwner(), false); verifySubscriptionUpdates(); }
@Test public void testHandleDelinquentAccountPro() throws Exception { EasyMock.expect(subscriptionManager.extractSubscription(ImmutableSet.of(firstPlace))).andReturn(irisSubscription); EasyMock.expect(irisSubscription.getServiceLevels()).andReturn(ImmutableSet.of(ServiceLevel.PREMIUM_PROMON)); replay(); firstPlace.setServiceLevel(ServiceLevel.PREMIUM_PROMON); assertEquals(ServiceLevel.PREMIUM_PROMON,firstPlace.getServiceLevel()); handler.handleEvent(account, createDelinquentAccountEvent(account)); verifySubscriptionLevelChangeEvent(platformBus.take(),ServiceLevel.BASIC.toString()); verifyNotification(platformBus.take(), account.getOwner(), true); verifySubscriptionUpdates(); }
@Test public void testHandleDelinquentAccountProAnnual() throws Exception { EasyMock.expect(subscriptionManager.extractSubscription(ImmutableSet.of(firstPlace))).andReturn(irisSubscription); EasyMock.expect(irisSubscription.getServiceLevels()).andReturn(ImmutableSet.of(ServiceLevel.PREMIUM_PROMON_ANNUAL)); replay(); firstPlace.setServiceLevel(ServiceLevel.PREMIUM_PROMON_ANNUAL); assertEquals(ServiceLevel.PREMIUM_PROMON_ANNUAL,firstPlace.getServiceLevel()); handler.handleEvent(account, createDelinquentAccountEvent(account)); verifySubscriptionLevelChangeEvent(platformBus.take(),ServiceLevel.BASIC.toString()); verifyNotification(platformBus.take(), account.getOwner(), true); verifySubscriptionUpdates(); }