@Test(expected = AuthorizationException.class) public void delete_no_permissions() { // given when(subject.isPermitted(any(OptionPermission.class))).thenReturn(false); when(defaultHierarchy.rankName(1)).thenReturn("specific"); OptionCacheKey cacheKey = new OptionCacheKey(defaultHierarchy, SPECIFIC_RANK, 1, optionKey2); when(optionCache.delete(cacheKey)).thenAnswer(answerOf(3)); // when Object actual = option.delete(1, optionKey2); // then }
@Test public void delete() { // given when(subject.isPermitted(any(OptionPermission.class))).thenReturn(true); when(defaultHierarchy.rankName(1)).thenReturn("specific"); OptionCacheKey cacheKey = new OptionCacheKey(defaultHierarchy, SPECIFIC_RANK, 1, optionKey2); when(optionCache.delete(cacheKey)).thenAnswer(answerOf(3)); // when Object actual = option.delete(1, optionKey2); // then assertThat(actual).isEqualTo(Optional.of(3)); verify(optionCache).delete(cacheKey); }