HiveDestinationServiceImpl implements HiveDestinationService { @Override public HiveDestinationModel getHiveDestination(String name) throws UnknownRoadException, UnknownDestinationException { HiveDestination hiveDestination = hiveDestinationAdminClient.getHiveDestination(name).orElseThrow( () -> new UnknownDestinationException("Hive", name)); HiveDestinationModel hiveDestinationModel = new HiveDestinationModel(); hiveDestinationModel.setEnabled(hiveDestination.isEnabled()); hiveDestinationModel.setLandingInterval(hiveDestination.getLandingInterval()); return hiveDestinationModel; } @Autowired  HiveDestinationServiceImpl(HiveDestinationAdminClient hiveDestinationAdminClient); @Override HiveDestinationModel getHiveDestination(String name); @Override void createHiveDestination(String name, HiveDestinationModel hiveDestinationModel); @Override void updateHiveDestination(String name, HiveDestinationModel hiveDestinationModel); @Override void deleteHiveDestination(String name);  }
@Test public void getHiveDestination() throws Exception { when(hiveDestinationAdminClient.getHiveDestination(NAME)).thenReturn(Optional.of(hiveDestination)); HiveDestinationModel result = underTest.getHiveDestination(NAME); hiveDestinationModel.setLandingInterval("PT1H"); assertThat(result, is(hiveDestinationModel)); }
@Test public void getHiveDestination_CustomInterval() throws Exception { hiveDestination.setLandingInterval("PT24H"); when(hiveDestinationAdminClient.getHiveDestination(NAME)).thenReturn(Optional.of(hiveDestination)); HiveDestinationModel result = underTest.getHiveDestination(NAME); hiveDestinationModel.setLandingInterval("PT24H"); assertThat(result, is(hiveDestinationModel)); }
@Test(expected = UnknownRoadException.class) public void getHiveDestination_UnknownRoad() throws Exception { doThrow(UnknownRoadException.class).when(hiveDestinationAdminClient).getHiveDestination(NAME); underTest.getHiveDestination(NAME); }
@Test(expected = UnknownDestinationException.class) public void getHiveDestination_UnknownDestination() throws Exception { when(hiveDestinationAdminClient.getHiveDestination(NAME)).thenReturn(Optional.empty()); underTest.getHiveDestination(NAME); }