@Test public void shouldFailWhenSomeGroupDoesNotExist() throws OperationException { DocumentModel doc = session.createDocumentModel("/", "src", "File"); assertNotNull(doc.getACP()); assertNull(doc.getACP().getACL("local")); List<String> users = Arrays.asList("existingGroup", "unexistingGroup", "existingUser"); when(userManager.getUserModel("existingUser")).thenReturn(SimpleDocumentModel.ofSchemas("user")); when(userManager.getGroupModel("existingGroup")).thenReturn(SimpleDocumentModel.ofSchemas("group")); when(userManager.getGroupModel("unexistingGroup")).thenReturn(null); ctx.setInput(doc); Map<String, Object> params = getParametersForAddOperation(null, users, null, "Write", null, null, null, false, false, null); try { automationService.run(ctx, AddPermission.ID, params); fail(); } catch (IllegalParameterException e) { String expectedMsg = "The following set of User or Group names do not exist: [unexistingGroup]. Please provide valid ones."; assertEquals(expectedMsg, e.getOriginalMessage()); verifyUserOrGroup("existingGroup", GROUP); verifyUserOrGroup("unexistingGroup", UNKNOWN); verifyUserOrGroup("existingUser", USER); verifyNoMoreInteractions(userManager); } }
@OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { validateParameters(); addPermission(doc); return doc; }
AddPermission { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { validateParameters(); addPermission(doc); return doc; } }
AddPermission { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { validateParameters(); addPermission(doc); return doc; }  }
AddPermission { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { validateParameters(); addPermission(doc); return doc; }  @OperationMethod(collector = DocumentModelCollector.class) DocumentModel run(DocumentModel doc); @OperationMethod(collector = DocumentModelCollector.class) DocumentModel run(DocumentRef docRef); }
AddPermission { @OperationMethod(collector = DocumentModelCollector.class) public DocumentModel run(DocumentModel doc) { validateParameters(); addPermission(doc); return doc; }  @OperationMethod(collector = DocumentModelCollector.class) DocumentModel run(DocumentModel doc); @OperationMethod(collector = DocumentModelCollector.class) DocumentModel run(DocumentRef docRef); static final String ID; static final String NOTIFY_KEY; static final String COMMENT_KEY; static final String ALLOW_VIRTUAL_USER; }