@Test @Deploy("org.nuxeo.ecm.automation.core:test-allow-virtual-user.xml") public void shouldFailWhenPermissionDoesNotExist() throws OperationException { DocumentModel doc = session.createDocumentModel("/", "src", "File"); OperationContext ctx = new OperationContext(session); ctx.setInput(doc); List<String> users = List.of("foo"); String invalidPermission = "<a href=www.evil.com>New"; Map<String, Object> params = getParametersForAddOperation(null, users, null, invalidPermission, null, null, null, false, false, null); try { automationService.run(ctx, AddPermission.ID, params); fail(String.format("Calling %s with an invalid permission %s should fail.", AddPermission.ID, invalidPermission)); } catch (IllegalParameterException e) { assertEquals(String.format("Permission %s is invalid.", invalidPermission), e.getOriginalMessage()); } }
@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; }