@Test void executeWithPermission() throws TemplateException, IOException { when(permissionService.hasPermission( new EntityTypeIdentity("entity"), newArrayList(EntityTypePermission.COUNT_DATA))) .thenReturn(true); Map<String, Object> params = Maps.newHashMap(); params.put("entityTypeId", "entity"); params.put("permission", "COUNT"); directive.execute( new Environment(fakeTemplate, null, envWriter), params, new TemplateModel[0], out -> out.write("PERMISSION")); assertEquals("PERMISSION", envWriter.toString()); }
@Override protected void execute(boolean hasPermission, Environment env, TemplateDirectiveBody body) throws TemplateException, IOException { if (hasPermission) { body.render(env.getOut()); } }
HasPermissionDirective extends PermissionDirective { @Override protected void execute(boolean hasPermission, Environment env, TemplateDirectiveBody body) throws TemplateException, IOException { if (hasPermission) { body.render(env.getOut()); } } }
HasPermissionDirective extends PermissionDirective { @Override protected void execute(boolean hasPermission, Environment env, TemplateDirectiveBody body) throws TemplateException, IOException { if (hasPermission) { body.render(env.getOut()); } } HasPermissionDirective(UserPermissionEvaluator permissionService); }
HasPermissionDirective extends PermissionDirective { @Override protected void execute(boolean hasPermission, Environment env, TemplateDirectiveBody body) throws TemplateException, IOException { if (hasPermission) { body.render(env.getOut()); } } HasPermissionDirective(UserPermissionEvaluator permissionService);  }
HasPermissionDirective extends PermissionDirective { @Override protected void execute(boolean hasPermission, Environment env, TemplateDirectiveBody body) throws TemplateException, IOException { if (hasPermission) { body.render(env.getOut()); } } HasPermissionDirective(UserPermissionEvaluator permissionService);   }