SubscriptionService { public Subscription searchSubscription(Subscription subscription, String alarmId) { LOGGER.debug("Searched identical subscription to: {}", subscription); Alarm alarm = seyrenRepository.getAlarm(alarmId); return alarm.getSubscriptions().stream().filter(s -> s.equals(subscription)).findAny().orElse(null); }  Subscription getSubscription(String alarmId, String subscriptionId); void addSubscription(Subscription subscription, String alarmId); Subscription searchSubscription(Subscription subscription, String alarmId); void updateSubscription(Subscription subscription, String alarmId); SubscriptionService.DeletedSubscriptionStatus deleteSubscription(String alarmId, String subscriptionId);  }
@Test public void searchSubscription() throws Exception { Subscription s = subscriptionService.searchSubscription(TestUtils.getDefaultSubscription(), TestUtils.DEFAULT_ALARM_ID); assertNotNull(s); assertEquals(TestUtils.DEFAULT_SUBSCRIPTION_ID, s.getId()); }
@Test public void searchNonExistentSubscription() { Subscription fakeSub = TestUtils.getDefaultSubscription(); fakeSub.setToTime("2333"); fakeSub.setFromTime("0123"); Subscription s = subscriptionService.searchSubscription(fakeSub, TestUtils.DEFAULT_ALARM_ID); assertNull(s); }