MonitorDataService { public void addSubscription( String environmentId, String subscriberId ) throws DaoException { Preconditions.checkNotNull( environmentId, INVALID_ENV_ID ); Preconditions.checkArgument( !StringUtils.isBlank( subscriberId ), "Invalid subscriber id" ); subscriberDao.update( environmentId, subscriberId ); } MonitorDataService( EntityManagerFactory emf ); void addSubscription( String environmentId, String subscriberId ); void removeSubscription( String environmentId, String subscriberId ); Set<String> findHandlersByEnvironment( String environmentId );  }
@Test public void testAddSubscription() throws Exception { monitorDao.addSubscription( ENVIRONMENT_ID, SUBSCRIBER_ID ); assertTrue( monitorDao.findHandlersByEnvironment( ENVIRONMENT_ID ).contains( SUBSCRIBER_ID ) ); }
@Test( expected = DaoException.class ) public void testAddSubscriptionException() throws Exception { throwDbException(); monitorDao.addSubscription( ENVIRONMENT_ID, SUBSCRIBER_ID ); }