### Question:
SettingService { @Transactional public Map<String, String> getValues(long projectId) { return projectsValuesCache.computeIfAbsent(projectId, key -> Collections.synchronizedMap(repository.getProjectSettings(projectId))); }  @Transactional(readOnly = true) List<SettingGroupDTO> getTree(long projectId); @Transactional(readOnly = true) String get(long projectId, String code); @Transactional(readOnly = true) int getInt(long projectId, String code); @Transactional(readOnly = true) boolean getBoolean(long projectId, String code); @Transactional(readOnly = true) List<String> getList(long projectId, String code); @Transactional void update(long projectId, String code, String newValue); @Transactional Map<String, String> getValues(long projectId); void validateNewValue(String newValue, SettingDTO settingDefinition); void clearProjectsValuesCache();  }### Answer:
@Test public void getValues_ShouldReturnValuesFromRepository_WhenCalledForAProject() { final Map<String, String> expectedValues = new HashMap<>(); expectedValues.put("key", "value"); when(repository.getProjectSettings(A_PROJECT_ID)).thenReturn(expectedValues); final Map<String, String> actualValues = cut.getValues(A_PROJECT_ID); assertThat(actualValues).containsOnlyKeys("key"); }
@Test public void getValues_ShouldCallRepositoryOnlyOnce_WhenCalledForAProject() { final Map<String, String> expectedValues = new HashMap<>(); expectedValues.put("key", "value"); when(repository.getProjectSettings(A_PROJECT_ID)).thenReturn(expectedValues); cut.getValues(A_PROJECT_ID); final Map<String, String> actualValues = cut.getValues(A_PROJECT_ID); assertThat(actualValues).containsOnlyKeys("key"); verify(repository, times(1)).getProjectSettings(A_PROJECT_ID); }