@Test public void shouldThrowException_whenApplicationDoesNotExist() { when(applicationsApiMock.getByName(APPLICATION_NAME)).thenReturn(Optional.empty()); expectedException.expect(NewRelicSyncException.class); expectedException.expectMessage(format("Application %s does not exist", APPLICATION_NAME)); testee.sync(CONFIGURATION); }
void sync(@NonNull ApplicationConfiguration config) { LOG.info("Synchronizing application {}...", config.getApplicationName()); Application application = api.getApplicationsApi().getByName(config.getApplicationName()).orElseThrow( () -> new NewRelicSyncException(format("Application %s does not exist", config.getApplicationName()))); ApplicationSettings settings = ApplicationSettings.builder() .appApdexThreshold(config.getAppApdexThreshold()) .endUserApdexThreshold(config.getEndUserApdexThreshold()) .enableRealUserMonitoring(config.isEnableRealUserMonitoring()) .build(); Application applicationUpdate = Application.builder() .name(config.getApplicationName()) .settings(settings) .build(); api.getApplicationsApi().update(application.getId(), applicationUpdate); LOG.info("Application {} synchronized", config.getApplicationName()); }
ApplicationConfigurator { void sync(@NonNull ApplicationConfiguration config) { LOG.info("Synchronizing application {}...", config.getApplicationName()); Application application = api.getApplicationsApi().getByName(config.getApplicationName()).orElseThrow( () -> new NewRelicSyncException(format("Application %s does not exist", config.getApplicationName()))); ApplicationSettings settings = ApplicationSettings.builder() .appApdexThreshold(config.getAppApdexThreshold()) .endUserApdexThreshold(config.getEndUserApdexThreshold()) .enableRealUserMonitoring(config.isEnableRealUserMonitoring()) .build(); Application applicationUpdate = Application.builder() .name(config.getApplicationName()) .settings(settings) .build(); api.getApplicationsApi().update(application.getId(), applicationUpdate); LOG.info("Application {} synchronized", config.getApplicationName()); } }
ApplicationConfigurator { void sync(@NonNull ApplicationConfiguration config) { LOG.info("Synchronizing application {}...", config.getApplicationName()); Application application = api.getApplicationsApi().getByName(config.getApplicationName()).orElseThrow( () -> new NewRelicSyncException(format("Application %s does not exist", config.getApplicationName()))); ApplicationSettings settings = ApplicationSettings.builder() .appApdexThreshold(config.getAppApdexThreshold()) .endUserApdexThreshold(config.getEndUserApdexThreshold()) .enableRealUserMonitoring(config.isEnableRealUserMonitoring()) .build(); Application applicationUpdate = Application.builder() .name(config.getApplicationName()) .settings(settings) .build(); api.getApplicationsApi().update(application.getId(), applicationUpdate); LOG.info("Application {} synchronized", config.getApplicationName()); } ApplicationConfigurator(@NonNull NewRelicApi api); }
ApplicationConfigurator { void sync(@NonNull ApplicationConfiguration config) { LOG.info("Synchronizing application {}...", config.getApplicationName()); Application application = api.getApplicationsApi().getByName(config.getApplicationName()).orElseThrow( () -> new NewRelicSyncException(format("Application %s does not exist", config.getApplicationName()))); ApplicationSettings settings = ApplicationSettings.builder() .appApdexThreshold(config.getAppApdexThreshold()) .endUserApdexThreshold(config.getEndUserApdexThreshold()) .enableRealUserMonitoring(config.isEnableRealUserMonitoring()) .build(); Application applicationUpdate = Application.builder() .name(config.getApplicationName()) .settings(settings) .build(); api.getApplicationsApi().update(application.getId(), applicationUpdate); LOG.info("Application {} synchronized", config.getApplicationName()); } ApplicationConfigurator(@NonNull NewRelicApi api);  }
ApplicationConfigurator { void sync(@NonNull ApplicationConfiguration config) { LOG.info("Synchronizing application {}...", config.getApplicationName()); Application application = api.getApplicationsApi().getByName(config.getApplicationName()).orElseThrow( () -> new NewRelicSyncException(format("Application %s does not exist", config.getApplicationName()))); ApplicationSettings settings = ApplicationSettings.builder() .appApdexThreshold(config.getAppApdexThreshold()) .endUserApdexThreshold(config.getEndUserApdexThreshold()) .enableRealUserMonitoring(config.isEnableRealUserMonitoring()) .build(); Application applicationUpdate = Application.builder() .name(config.getApplicationName()) .settings(settings) .build(); api.getApplicationsApi().update(application.getId(), applicationUpdate); LOG.info("Application {} synchronized", config.getApplicationName()); } ApplicationConfigurator(@NonNull NewRelicApi api);   }