### Question:
TechnologySettingService { @Transactional(readOnly = true) public Optional<String> getSettingValue(Long projectId, AvailableTechnologySettings availableTechnologySettings) { String code = availableTechnologySettings.getCode(); Technology technology = availableTechnologySettings.getTechnology(); Optional<TechnologySetting> savedSetting = technologySettingRepository.findByProjectIdAndCodeAndTechnology(projectId, code, technology); String value = null; if (savedSetting.isPresent()) { return Optional.of(savedSetting.get().getValue()); } Optional<SettingDTO> setting = getSettingDefinitionFromTechnologyAndCode(technology, code); if (setting.isPresent()) { value = setting.get().getDefaultValue(); } return Optional.ofNullable(value); }  @Transactional(readOnly = true) List<TechnologySettingGroupDTO> getAllGroups(Long projectId); @Transactional(readOnly = true) Optional<String> getSettingValue(Long projectId, AvailableTechnologySettings availableTechnologySettings); @Transactional void update(Long projectId, String code, Technology technology, String newValue);  }### Answer:
@Test public void getSettingValue_returnValue_whenFound() { Long projectId = 1L; TechnologySetting savedSetting = mock(TechnologySetting.class); when(technologySettingRepository.findByProjectIdAndCodeAndTechnology(projectId, CucumberSettings.REPORT_PATH.getCode(), Technology.CUCUMBER)).thenReturn(Optional.of(savedSetting)); when(savedSetting.getValue()).thenReturn("/new/cucumber/path"); Optional<String> value = technologySettingService.getSettingValue(projectId, CucumberSettings.REPORT_PATH); assertThat(value).isPresent(); assertThat(value).hasValue("/new/cucumber/path"); }
@Test public void getSettingValue_returnDefaultValue_whenNotFound() { Long projectId = 1L; TechnologySetting savedSetting = mock(TechnologySetting.class); when(technologySettingRepository.findByProjectIdAndCodeAndTechnology(projectId, CucumberSettings.REPORT_PATH.getCode(), Technology.CUCUMBER)).thenReturn(Optional.empty()); Optional<String> value = technologySettingService.getSettingValue(projectId, CucumberSettings.REPORT_PATH); assertThat(value).isPresent(); assertThat(value).hasValue(CucumberSettings.REPORT_PATH.getDefaultValue()); }