protected void prepareNotifications() { notificationManager.setDisabled(false); dummyTransport.clearMessages(); }
@Override public void initSystem(Task initTask, OperationResult initResult) throws Exception { LOGGER.trace("initSystem"); dummyResourceCollection = new DummyResourceCollection(modelService); startResources(); dummyAuditService = DummyAuditService.getInstance(); InternalsConfig.reset(); InternalsConfig.setAvoidLoggingChange(true); // Make sure the checks are turned on InternalsConfig.turnOnAllChecks(); // By default, notifications are turned off because of performance implications. Individual tests turn them on for themselves. if (notificationManager != null) { notificationManager.setDisabled(true); } }
notificationManager.setDisabled(true); checkDummyTransportMessages("string-attachment", 1);
@Test public void test420AttachmentFromFile() throws Exception { final String TEST_NAME = "test420AttachmentFromFile"; TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN TestUtil.displayWhen(TEST_NAME); PrismObject<UserType> user = new UserType(prismContext) .name("testAttachmentFromFileUser") .asPrismObject(); addObject(user); // THEN TestUtil.displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess("addObject result", result); // Check notifications display("Notifications", dummyTransport); notificationManager.setDisabled(true); checkDummyTransportMessages("attachment-from-file", 1); Message message = dummyTransport.getMessages("dummy:attachment-from-file").get(0); assertEquals("Wrong # of attachments", 1, message.getAttachments().size()); assertEquals("Wrong contentType of attachment", "image/png", message.getAttachments().get(0).getContentType()); assertEquals("Wrong fileName of attachments", "alf.png", message.getAttachments().get(0).getFileName()); assertEquals("Wrong fileName of attachments", "/home/user/example.png", message.getAttachments().get(0).getContentFromFile()); assertEquals("Wrong fileName of attachments", null, message.getAttachments().get(0).getContent()); }
@Test public void test430ExpressionAttachment() throws Exception { final String TEST_NAME = "test430ExpressionAttachment"; TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = taskManager.createTaskInstance(TestNotifications.class.getName() + "." + TEST_NAME); OperationResult result = task.getResult(); preTestCleanup(AssignmentPolicyEnforcementType.FULL); // WHEN TestUtil.displayWhen(TEST_NAME); PrismObject<UserType> user = new UserType(prismContext) .name("testExpressionAttachmentUser") .asPrismObject(); addObject(user); // THEN TestUtil.displayThen(TEST_NAME); result.computeStatus(); TestUtil.assertSuccess("addObject result", result); // Check notifications display("Notifications", dummyTransport); notificationManager.setDisabled(true); checkDummyTransportMessages("expression-attachment", 1); Message message = dummyTransport.getMessages("dummy:expression-attachment").get(0); assertEquals("Wrong # of attachments", 1, message.getAttachments().size()); assertEquals("Wrong contentType of attachment", "text/html", message.getAttachments().get(0).getContentType()); assertEquals("Wrong content of attachments", "<!DOCTYPE html><html><body>Hello World!</body></html>", message.getAttachments().get(0).getContent()); assertEquals("Wrong fileName of attachments", "hello_world.html", message.getAttachments().get(0).getFileName()); assertEquals("Wrong fileName of attachments", null, message.getAttachments().get(0).getContentFromFile()); }
@Test public void test870AssignRoleScreaming() throws Exception { final String TEST_NAME = "test870AssignRoleScreaming"; displayTestTitle(TEST_NAME); assumeAssignmentPolicy(AssignmentPolicyEnforcementType.FULL); notificationManager.setDisabled(false); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); PrismObject<UserType> userJackBefore = getUser(USER_JACK_OID); display("user jack", userJackBefore); // WHEN displayWhen(TEST_NAME); assignRole(USER_JACK_OID, ROLE_SCREAMING_OID, getDefaultOptions(), task, result); // THEN displayThen(TEST_NAME); assertSuccess(result); PrismObject<UserType> userJackAfter = getUser(USER_JACK_OID); display("user after", userJackAfter); display("dummy transport", dummyTransport); List<Message> messages = dummyTransport.getMessages("dummy:policyRuleNotifier"); assertNotNull("No notification messages", messages); assertEquals("Wrong # of notification messages", 1, messages.size()); }
notificationManager.setDisabled(true);
@Test public void test507ScriptingUsersInBackgroundAssign() throws Exception { final String TEST_NAME = "test507ScriptingUsersInBackgroundAssign"; TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN Task task = createTask(DOT_CLASS + TEST_NAME); task.setOwner(getUser(USER_ADMINISTRATOR_OID)); OperationResult result = task.getResult(); ExecuteScriptType exec = prismContext.parserFor(SCRIPTING_USERS_IN_BACKGROUND_ASSIGN_FILE).parseRealValue(); // WHEN task.setExtensionPropertyValue(SchemaConstants.SE_EXECUTE_SCRIPT, exec); task.setHandlerUri(ModelPublicConstants.SCRIPT_EXECUTION_TASK_HANDLER_URI); dummyTransport.clearMessages(); boolean notificationsDisabled = notificationManager.isDisabled(); notificationManager.setDisabled(false); taskManager.switchToBackground(task, result); waitForTaskFinish(task.getOid(), false); task.refresh(result); // THEN display(task.getResult()); TestUtil.assertSuccess(task.getResult()); PrismObject<UserType> admin = getUser(USER_ADMINISTRATOR_OID); display("admin after operation", admin); assertAssignedRole(admin, ROLE_EMPTY_OID); display("dummy transport", dummyTransport); notificationManager.setDisabled(notificationsDisabled); assertEquals("Wrong # of messages in dummy transport", 1, emptyIfNull(dummyTransport.getMessages("dummy:simpleUserNotifier")).size()); }
notificationManager.setDisabled(true);
notificationManager.setDisabled(true);
notificationManager.setDisabled(false); notificationManager.setDisabled(notificationsDisabled);
notificationManager.setDisabled(true);
notificationManager.setDisabled(true);
notificationManager.setDisabled(true);
notificationManager.setDisabled(true);
notificationManager.setDisabled(true);
notificationManager.setDisabled(true);
notificationManager.setDisabled(true);
notificationManager.setDisabled(true);
notificationManager.setDisabled(true);