@Test public void beginRenderElse() { Block block = mock(Block.class); ReflectionTestUtils.setField(victim, "elseBlock", block); victim.setupRender(); assertEquals(victim.beginRender(), block); }
@Test public void beforeRenderBodyIfNotGranted() { ReflectionTestUtils.setField(victim, "ifNotGranted", PERMISSION + "," + PERMISSION_2); SecurityContextHolder.getContext() .setAuthentication(new TestingAuthenticationToken(USER, null)); victim.setupRender(); assertTrue(victim.beforeRenderBody()); }
@Test public void beginRender() { Block block = mock(Block.class); ReflectionTestUtils.setField(victim, "elseBlock", block); ReflectionTestUtils.setField(victim, "ifAnyGranted", PERMISSION); SecurityContextHolder.getContext() .setAuthentication(new TestingAuthenticationToken(USER, null, PERMISSION)); victim.setupRender(); assertNull(victim.beginRender()); }
@Test public void beforeRenderBodyNone() { victim.setupRender(); assertFalse(victim.beforeRenderBody()); }