SubscriptionMapper { public Subscription mapNewSubscriptionFormToSeyren(Subscription subscription) throws CerebroException { subscription.setId(null); subscription.setType(SubscriptionType.EMAIL); setDefaultFromToTimeIfEmptyOrNull(subscription); return subscription; }  Subscription mapNewSubscriptionFormToSeyren(Subscription subscription); Subscription mapUpdateSubscriptionFormToSeyren(Subscription subscription); static final String DEFAULT_FROM_TIME; static final String DEFAULT_TO_TIME; }
@Test public void testMapNewSubscriptionTypeIsMailIdIsNull() throws Exception { Subscription subscription = this.defaultSubscription; assertNotNull(subscription.getId()); subscription.setType(SubscriptionType.HIPCHAT); Subscription alarm = subscriptionMapper.mapNewSubscriptionFormToSeyren(subscription); assertNull(alarm.getId()); assertEquals(SubscriptionType.EMAIL, subscription.getType()); }
@Test public void testMapNewSetNullFromToTimeToDefaultValues() throws Exception { Subscription s = this.defaultSubscription; s.setFromTime(null); s.setToTime(null); s = subscriptionMapper.mapNewSubscriptionFormToSeyren(s); assertEquals(SubscriptionMapper.DEFAULT_FROM_TIME, s.getFromTime()); assertEquals(SubscriptionMapper.DEFAULT_TO_TIME, s.getToTime()); }
@Test public void testMapNewSetEmptyFromToTimeToDefaultValues() throws Exception { Subscription s = this.defaultSubscription; s.setFromTime(""); s.setToTime(""); s = subscriptionMapper.mapNewSubscriptionFormToSeyren(s); assertEquals(SubscriptionMapper.DEFAULT_FROM_TIME, s.getFromTime()); assertEquals(SubscriptionMapper.DEFAULT_TO_TIME, s.getToTime()); }