예제 #1
0
 @Test(expected = AuthorizationException.class)
 public void setNoPermissions() {
   // given
   when(subject.isPermitted(any(OptionPermission.class))).thenReturn(false);
   when(defaultHierarchy.rankName(0)).thenReturn("specific");
   OptionCacheKey cacheKey = new OptionCacheKey(defaultHierarchy, SPECIFIC_RANK, 0, optionKey1);
   // when
   option.set(5, optionKey1);
   // then
 }
예제 #2
0
 @Test
 public void set_simplest() {
   // given
   when(subject.isPermitted(any(OptionPermission.class))).thenReturn(true);
   when(defaultHierarchy.rankName(0)).thenReturn("specific");
   OptionCacheKey cacheKey = new OptionCacheKey(defaultHierarchy, SPECIFIC_RANK, 0, optionKey1);
   // when
   option.set(5, optionKey1);
   // then
   verify(optionCache).write(cacheKey, Optional.of(5));
 }
예제 #3
0
 @Test(expected = IllegalArgumentException.class)
 public void set_with_all_args_rank_too_low() {
   // given
   when(subject.isPermitted(any(OptionPermission.class))).thenReturn(true);
   when(defaultHierarchy.rankName(2)).thenReturn("specific");
   OptionKey<Integer> optionKey2 =
       new OptionKey<>(999, context, TestLabelKey.key1, TestLabelKey.key1, "q");
   OptionCacheKey cacheKey = new OptionCacheKey(defaultHierarchy, SPECIFIC_RANK, 2, optionKey2);
   // when
   option.set(5, -1, optionKey2);
   // then
 }