@Test public void get_lowest() { // given when(defaultHierarchy.lowestRankName()).thenReturn("low"); OptionCacheKey cacheKey = new OptionCacheKey(defaultHierarchy, LOWEST_RANK, optionKey2); when(optionCache.get(Optional.of(5), cacheKey)).thenAnswer(answerOf(20)); // when Integer actual = option.getLowestRanked(optionKey2); // then assertThat(actual).isEqualTo(20); }
@Test public void get_none_found() { // given when(defaultHierarchy.highestRankName()).thenReturn("high"); OptionCacheKey cacheKey = new OptionCacheKey(defaultHierarchy, HIGHEST_RANK, optionKey2); when(optionCache.get(Optional.of(5), cacheKey)).thenReturn(Optional.empty()); // when Integer actual = option.get(optionKey2); // then assertThat(actual).isEqualTo(5); }