Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonald.g.dunne2014-08-19 03:10:44 +0000
committerRoberto E. Escobar2014-09-29 22:55:23 +0000
commit1c33a705cf7938d1b54025530e1680b78ac3abe0 (patch)
tree6e9f0efddc8138cd448cbb4a869a0101f824039a
parent926511e9a869dd0d169958de9cc973232da50577 (diff)
downloadorg.eclipse.osee-1c33a705cf7938d1b54025530e1680b78ac3abe0.tar.gz
org.eclipse.osee-1c33a705cf7938d1b54025530e1680b78ac3abe0.tar.xz
org.eclipse.osee-1c33a705cf7938d1b54025530e1680b78ac3abe0.zip
feature[ats_ATS64164]: CPA: ATS Notify add WorkItemNotificationProcessorTest
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/team/IAtsWorkItemFactory.java2
-rw-r--r--plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/user/IAtsUserService.java3
-rw-r--r--plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/user/AtsUserServiceImpl.java11
-rw-r--r--plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/AllAtsImplTestSuite.java3
-rw-r--r--plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/internal/notify/AtsImpl_Notify_Suite.java35
-rw-r--r--plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/internal/notify/WorkItemNotificationProcessorTest.java335
-rw-r--r--plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/AtsServerImpl.java2
-rw-r--r--plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/notify/AtsNotificationEventProcessor.java2
-rw-r--r--plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/notify/WorkItemNotificationProcessor.java21
-rw-r--r--plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/user/AtsUserServiceImpl.java12
-rw-r--r--plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/WorkItemFactory.java7
11 files changed, 412 insertions, 21 deletions
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/team/IAtsWorkItemFactory.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/team/IAtsWorkItemFactory.java
index 5eee148d5f2..610b7bff4e8 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/team/IAtsWorkItemFactory.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/team/IAtsWorkItemFactory.java
@@ -35,4 +35,6 @@ public interface IAtsWorkItemFactory {
IAtsAction getAction(Object artifact);
+ IAtsWorkItem getWorkItemByAtsId(String atsId);
+
}
diff --git a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/user/IAtsUserService.java b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/user/IAtsUserService.java
index 877bf068211..e31d5afb039 100644
--- a/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/user/IAtsUserService.java
+++ b/plugins/org.eclipse.osee.ats.api/src/org/eclipse/osee/ats/api/user/IAtsUserService.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.ats.api.user;
import java.util.Collection;
import java.util.List;
+import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.framework.core.enums.Active;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -48,4 +49,6 @@ public interface IAtsUserService {
void releaseUser();
+ Collection<IAtsUser> getSubscribed(IAtsWorkItem workItem);
+
}
diff --git a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/user/AtsUserServiceImpl.java b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/user/AtsUserServiceImpl.java
index 274442f058e..a332a09816f 100644
--- a/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/user/AtsUserServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.core.client/src/org/eclipse/osee/ats/core/client/internal/user/AtsUserServiceImpl.java
@@ -15,6 +15,8 @@ import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import org.eclipse.osee.ats.api.IAtsWorkItem;
+import org.eclipse.osee.ats.api.data.AtsRelationTypes;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.core.client.IAtsUserServiceClient;
import org.eclipse.osee.ats.core.client.util.AtsGroup;
@@ -225,4 +227,13 @@ public class AtsUserServiceImpl extends AbstractAtsUserService implements IAtsUs
return oseeUsers;
}
+ @Override
+ public List<IAtsUser> getSubscribed(IAtsWorkItem workItem) throws OseeCoreException {
+ ArrayList<IAtsUser> arts = new ArrayList<IAtsUser>();
+ for (Artifact art : ((Artifact) workItem.getStoreObject()).getRelatedArtifacts(AtsRelationTypes.SubscribedUser_User)) {
+ arts.add(getUserById((String) art.getSoleAttributeValue(CoreAttributeTypes.UserId)));
+ }
+ return arts;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/AllAtsImplTestSuite.java b/plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/AllAtsImplTestSuite.java
index ff82c4bfcdd..505daf8f210 100644
--- a/plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/AllAtsImplTestSuite.java
+++ b/plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/AllAtsImplTestSuite.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.ats.impl;
import org.eclipse.osee.ats.impl.internal.model.ModelTestSuite;
+import org.eclipse.osee.ats.impl.internal.notify.AtsImpl_Notify_Suite;
import org.eclipse.osee.ats.impl.internal.workdef.WorkDefTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -19,7 +20,7 @@ import org.junit.runners.Suite;
* @author Donald G. Dunne
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({WorkDefTestSuite.class, ModelTestSuite.class})
+@Suite.SuiteClasses({WorkDefTestSuite.class, ModelTestSuite.class, AtsImpl_Notify_Suite.class})
public class AllAtsImplTestSuite {
// Test Suite
}
diff --git a/plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/internal/notify/AtsImpl_Notify_Suite.java b/plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/internal/notify/AtsImpl_Notify_Suite.java
new file mode 100644
index 00000000000..5638a54a986
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/internal/notify/AtsImpl_Notify_Suite.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.ats.impl.internal.notify;
+
+import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Donald G. Dunne
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({WorkItemNotificationProcessorTest.class})
+public class AtsImpl_Notify_Suite {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ OseeProperties.setIsInTest(true);
+ System.out.println("\n\nBegin " + AtsImpl_Notify_Suite.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ System.out.println("End " + AtsImpl_Notify_Suite.class.getSimpleName());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/internal/notify/WorkItemNotificationProcessorTest.java b/plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/internal/notify/WorkItemNotificationProcessorTest.java
new file mode 100644
index 00000000000..c3a3fde5eca
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.impl.test/src/org/eclipse/osee/ats/impl/internal/notify/WorkItemNotificationProcessorTest.java
@@ -0,0 +1,335 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.ats.impl.internal.notify;
+
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.when;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.eclipse.osee.ats.api.ai.IAtsActionableItem;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
+import org.eclipse.osee.ats.api.notify.AtsNotificationCollector;
+import org.eclipse.osee.ats.api.notify.AtsNotificationEvent;
+import org.eclipse.osee.ats.api.notify.AtsNotifyType;
+import org.eclipse.osee.ats.api.notify.AtsWorkItemNotificationEvent;
+import org.eclipse.osee.ats.api.review.IAtsPeerToPeerReview;
+import org.eclipse.osee.ats.api.team.IAtsTeamDefinition;
+import org.eclipse.osee.ats.api.team.IAtsWorkItemFactory;
+import org.eclipse.osee.ats.api.user.IAtsUser;
+import org.eclipse.osee.ats.api.user.IAtsUserService;
+import org.eclipse.osee.ats.api.workdef.IAtsStateDefinition;
+import org.eclipse.osee.ats.api.workdef.IAttributeResolver;
+import org.eclipse.osee.ats.api.workdef.StateType;
+import org.eclipse.osee.ats.api.workflow.IAtsTeamWorkflow;
+import org.eclipse.osee.ats.api.workflow.state.IAtsStateManager;
+import org.eclipse.osee.ats.impl.IAtsServer;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.orcs.OrcsApi;
+import org.junit.Assert;
+import org.junit.Before;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test unit for {@link WorkItemNotificationProcessor}
+ *
+ * @author Donald G. Dunne
+ */
+public class WorkItemNotificationProcessorTest {
+
+ // @formatter:off
+ @Mock IAtsUser joeSmith_CurrentUser, kay_ValidEmail, jason_ValidEmail, alex_NoValidEmail, inactiveSteve;
+ @Mock IAtsTeamWorkflow teamWf;
+ @Mock IAtsPeerToPeerReview peerReview;
+ @Mock IAtsStateManager stateMgr;
+ @Mock IAtsServer atsServer;
+ @Mock OrcsApi orcsApi;
+ @Mock IAtsWorkItemFactory workItemFactory;
+ @Mock IAtsUserService userService;
+ @Mock IAttributeResolver attrResolver;
+ @Mock IAtsStateDefinition stateDef;
+ @Mock IAtsTeamDefinition teamDef;
+ @Mock IAtsActionableItem ai;
+
+ // @formatter:on
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+
+ setupUser(joeSmith_CurrentUser, "ABNRvbZxXHICYklfslwA", "Joe Smith", "joe@boeing.com", "Joe Smith", true, false);
+ setupUser(kay_ValidEmail, "ABNRvuB8x3VARkkn3YAA", "Kay Jones", "kay@boeing.com", "Kay Jones", true, false);
+ setupUser(jason_ValidEmail, "ABNRvuHWtXAdxbG3mUAA", "Jason Michael", "jason@boeing.com", "Jason Michael", true,
+ false);
+ setupUser(alex_NoValidEmail, "ABNRvuKDIWOcPDe4X0wA", "Alex Kay", "", "Alex Kay", true, false);
+ setupUser(inactiveSteve, "ABNRvuRG6jKwKnEoX4gA", "Inactive Steve", "insactiveSteve@boeing.com", "Inactive Steve",
+ false, false);
+
+ when(teamWf.getName()).thenReturn(WorkItemNotificationProcessorTest.class.getSimpleName() + "-testNotify");
+ List<IAtsUser> assignees = new ArrayList<IAtsUser>();
+ assignees.addAll(Arrays.asList(inactiveSteve, alex_NoValidEmail, jason_ValidEmail, kay_ValidEmail,
+ joeSmith_CurrentUser));
+ String atsId = "ATS003";
+ when(teamWf.getAtsId()).thenReturn(atsId);
+ when(workItemFactory.getWorkItemByAtsId(atsId)).thenReturn(teamWf);
+ when(attrResolver.getSoleAttributeValue(teamWf, AtsAttributeTypes.LegacyPcrId, "")).thenReturn(atsId);
+ when(atsServer.getConfigValue(eq("ActionUrl"))).thenReturn("http://ats/action/UUID/");
+ when(teamWf.getGuid()).thenReturn("myguid");
+ when(teamWf.getArtifactTypeName()).thenReturn("Team Workflow");
+ when(teamWf.getStateMgr()).thenReturn(stateMgr);
+ when(stateMgr.getCurrentStateName()).thenReturn("Analyze");
+ when(stateMgr.getAssignees()).thenReturn(assignees);
+
+ when(teamWf.getStateDefinition()).thenReturn(stateDef);
+ when(teamWf.getTeamDefinition()).thenReturn(teamDef);
+ Set<IAtsActionableItem> ais = new HashSet<IAtsActionableItem>();
+ ais.add(ai);
+ when(teamWf.getActionableItems()).thenReturn(ais);
+
+ }
+
+ @org.junit.Test
+ public void testNotifyOriginator() throws OseeCoreException {
+
+ WorkItemNotificationProcessor processor =
+ new WorkItemNotificationProcessor(atsServer, workItemFactory, userService, attrResolver);
+ AtsNotificationCollector notifications = new AtsNotificationCollector();
+ AtsWorkItemNotificationEvent event = new AtsWorkItemNotificationEvent();
+ event.setFromUserId(joeSmith_CurrentUser.getUserId());
+ event.setNotifyType(AtsNotifyType.Originator);
+ event.getAtsIds().add(teamWf.getAtsId());
+ when(teamWf.getCreatedBy()).thenReturn(kay_ValidEmail);
+
+ processor.run(notifications, event);
+
+ Assert.assertEquals(1, notifications.getNotificationEvents().size());
+ AtsNotificationEvent notifyEvent = notifications.getNotificationEvents().get(0);
+ Assert.assertEquals(AtsNotifyType.Originator.name(), notifyEvent.getType());
+ Assert.assertEquals(kay_ValidEmail.getUserId(), notifyEvent.getUserIds().iterator().next());
+ Assert.assertEquals(
+ "You have been set as the originator of [Team Workflow] state [Analyze] titled [WorkItemNotificationProcessorTest-testNotify]",
+ notifyEvent.getDescription());
+
+ notifications = new AtsNotificationCollector();
+ when(teamWf.getCreatedBy()).thenReturn(inactiveSteve);
+ processor.run(notifications, event);
+ Assert.assertEquals(0, notifications.getNotificationEvents().size());
+
+ }
+
+ @org.junit.Test
+ public void testNotifyAssignee() throws OseeCoreException {
+
+ WorkItemNotificationProcessor processor =
+ new WorkItemNotificationProcessor(atsServer, workItemFactory, userService, attrResolver);
+ AtsNotificationCollector notifications = new AtsNotificationCollector();
+ AtsWorkItemNotificationEvent event = new AtsWorkItemNotificationEvent();
+ event.setFromUserId(joeSmith_CurrentUser.getUserId());
+ event.setNotifyType(AtsNotifyType.Assigned);
+ event.getAtsIds().add(teamWf.getAtsId());
+ event.getUserIds().add(kay_ValidEmail.getUserId());
+
+ processor.run(notifications, event);
+ Assert.assertEquals(1, notifications.getNotificationEvents().size());
+ AtsNotificationEvent notifyEvent = notifications.getNotificationEvents().get(0);
+ Assert.assertEquals(AtsNotifyType.Assigned.name(), notifyEvent.getType());
+
+ // joe smith should be removed from list cause it's current user
+ // alex should be removed cause not valid email
+ List<String> expectedUserIds = new ArrayList<String>();
+ expectedUserIds.add(jason_ValidEmail.getUserId());
+ expectedUserIds.add(kay_ValidEmail.getUserId());
+ List<IAtsUser> users = new ArrayList<IAtsUser>();
+ for (String userId : event.getUserIds()) {
+ users.add(userService.getUserById(userId));
+ }
+ event.getUserIds().clear();
+
+ notifications = new AtsNotificationCollector();
+ processor.run(notifications, event);
+ Assert.assertEquals(1, notifications.getNotificationEvents().size());
+ notifyEvent = notifications.getNotificationEvents().get(0);
+
+ Assert.assertTrue(org.eclipse.osee.framework.jdk.core.util.Collections.isEqual(expectedUserIds,
+ notifyEvent.getUserIds()));
+ Assert.assertEquals(
+ "You have been set as the assignee of [Team Workflow] in state [Analyze] titled [WorkItemNotificationProcessorTest-testNotify]",
+ notifyEvent.getDescription());
+
+ notifications = new AtsNotificationCollector();
+ event.getUserIds().add(jason_ValidEmail.getUserId());
+ processor.run(notifications, event);
+ Assert.assertEquals(1, notifications.getNotificationEvents().size());
+ notifyEvent = notifications.getNotificationEvents().get(0);
+
+ Assert.assertEquals(AtsNotifyType.Assigned.name(), notifyEvent.getType());
+ // only alex should be emailed cause sent in list
+ Assert.assertEquals(1, notifyEvent.getUserIds().size());
+ Assert.assertEquals(jason_ValidEmail.getUserId(), notifyEvent.getUserIds().iterator().next());
+ Assert.assertEquals(
+ "You have been set as the assignee of [Team Workflow] in state [Analyze] titled [WorkItemNotificationProcessorTest-testNotify]",
+ notifyEvent.getDescription());
+ }
+
+ @org.junit.Test
+ public void testNotifySubscribe() throws OseeCoreException {
+
+ when(userService.getSubscribed(teamWf)).thenReturn(Arrays.asList(kay_ValidEmail));
+ AtsWorkItemNotificationEvent event = new AtsWorkItemNotificationEvent();
+ event.setFromUserId(joeSmith_CurrentUser.getUserId());
+ event.setNotifyType(AtsNotifyType.Subscribed);
+ event.getAtsIds().add(teamWf.getAtsId());
+
+ WorkItemNotificationProcessor processor =
+ new WorkItemNotificationProcessor(atsServer, workItemFactory, userService, attrResolver);
+ AtsNotificationCollector notifications = new AtsNotificationCollector();
+ processor.run(notifications, event);
+
+ Assert.assertEquals(1, notifications.getNotificationEvents().size());
+ AtsNotificationEvent notifyEvent = notifications.getNotificationEvents().get(0);
+
+ Assert.assertEquals(AtsNotifyType.Subscribed.name(), notifyEvent.getType());
+ // only alex should be emailed cause sent in list
+ Assert.assertEquals(1, notifyEvent.getUserIds().size());
+ Assert.assertEquals(kay_ValidEmail.getUserId(), notifyEvent.getUserIds().iterator().next());
+ Assert.assertEquals(
+ "[Team Workflow] titled [WorkItemNotificationProcessorTest-testNotify] transitioned to [Analyze] and you subscribed for notification.",
+ notifyEvent.getDescription());
+
+ }
+
+ @org.junit.Test
+ public void testNotifyCompleted() throws OseeCoreException {
+
+ AtsWorkItemNotificationEvent event = new AtsWorkItemNotificationEvent();
+ event.setFromUserId(joeSmith_CurrentUser.getUserId());
+ event.setNotifyType(AtsNotifyType.Completed);
+ event.getAtsIds().add(teamWf.getAtsId());
+ when(teamWf.isTask()).thenReturn(false);
+ when(stateDef.getStateType()).thenReturn(StateType.Completed);
+ when(teamWf.getCreatedBy()).thenReturn(inactiveSteve);
+ when(stateMgr.getCurrentStateName()).thenReturn("Completed");
+
+ WorkItemNotificationProcessor processor =
+ new WorkItemNotificationProcessor(atsServer, workItemFactory, userService, attrResolver);
+ AtsNotificationCollector notifications = new AtsNotificationCollector();
+
+ processor.run(notifications, event);
+ Assert.assertEquals(0, notifications.getNotificationEvents().size());
+
+ notifications = new AtsNotificationCollector();
+ when(teamWf.getCreatedBy()).thenReturn(kay_ValidEmail);
+ processor.run(notifications, event);
+ Assert.assertEquals(1, notifications.getNotificationEvents().size());
+ AtsNotificationEvent notifyEvent = notifications.getNotificationEvents().get(0);
+ Assert.assertEquals(AtsNotifyType.Completed.name(), notifyEvent.getType());
+ Assert.assertEquals(kay_ValidEmail.getUserId(), notifyEvent.getUserIds().iterator().next());
+ Assert.assertEquals("[Team Workflow] titled [WorkItemNotificationProcessorTest-testNotify] is [Completed]",
+ notifyEvent.getDescription());
+
+ notifications = new AtsNotificationCollector();
+ when(teamWf.getCreatedBy()).thenReturn(inactiveSteve);
+ Assert.assertEquals(0, notifications.getNotificationEvents().size());
+
+ }
+
+ @org.junit.Test
+ public void testNotifyCancelled() throws OseeCoreException {
+
+ AtsWorkItemNotificationEvent event = new AtsWorkItemNotificationEvent();
+ event.setFromUserId(joeSmith_CurrentUser.getUserId());
+ event.setNotifyType(AtsNotifyType.Cancelled);
+ event.getAtsIds().add(teamWf.getAtsId());
+ when(teamWf.isTask()).thenReturn(false);
+ when(stateDef.getStateType()).thenReturn(StateType.Cancelled);
+ when(teamWf.getCreatedBy()).thenReturn(inactiveSteve);
+ when(teamWf.getCancelledReason()).thenReturn("this is the reason");
+ when(teamWf.getCancelledFromState()).thenReturn("Analyze");
+ when(stateMgr.getCurrentStateName()).thenReturn("Cancelled");
+
+ WorkItemNotificationProcessor processor =
+ new WorkItemNotificationProcessor(atsServer, workItemFactory, userService, attrResolver);
+ AtsNotificationCollector notifications = new AtsNotificationCollector();
+
+ processor.run(notifications, event);
+ Assert.assertEquals(0, notifications.getNotificationEvents().size());
+
+ notifications = new AtsNotificationCollector();
+ when(teamWf.getCreatedBy()).thenReturn(kay_ValidEmail);
+ processor.run(notifications, event);
+ Assert.assertEquals(1, notifications.getNotificationEvents().size());
+ AtsNotificationEvent notifyEvent = notifications.getNotificationEvents().get(0);
+ Assert.assertEquals(AtsNotifyType.Cancelled.name(), notifyEvent.getType());
+ Assert.assertEquals(kay_ValidEmail.getUserId(), notifyEvent.getUserIds().iterator().next());
+ Assert.assertTrue(notifyEvent.getDescription().startsWith(
+ "[Team Workflow] titled [WorkItemNotificationProcessorTest-testNotify] was [Cancelled] from the [Analyze] state on"));
+ Assert.assertTrue(notifyEvent.getDescription().endsWith(".<br>Reason: [this is the reason]"));
+
+ notifications = new AtsNotificationCollector();
+ when(teamWf.getCreatedBy()).thenReturn(inactiveSteve);
+ Assert.assertEquals(0, notifications.getNotificationEvents().size());
+
+ }
+
+ @org.junit.Test
+ public void testNotifySubscribedTeamOrAi() throws OseeCoreException {
+
+ AtsWorkItemNotificationEvent event = new AtsWorkItemNotificationEvent();
+ event.setFromUserId(joeSmith_CurrentUser.getUserId());
+ event.setNotifyType(AtsNotifyType.SubscribedTeamOrAi);
+ event.getAtsIds().add(teamWf.getAtsId());
+ when(teamWf.isTeamWorkflow()).thenReturn(true);
+ when(stateDef.getStateType()).thenReturn(StateType.Working);
+ when(stateMgr.getCurrentStateName()).thenReturn(StateType.Working.name());
+
+ WorkItemNotificationProcessor processor =
+ new WorkItemNotificationProcessor(atsServer, workItemFactory, userService, attrResolver);
+
+ AtsNotificationCollector notifications = new AtsNotificationCollector();
+ processor.run(notifications, event);
+ when(teamDef.getSubscribed()).thenReturn(new ArrayList<IAtsUser>());
+ when(ai.getSubscribed()).thenReturn(new ArrayList<IAtsUser>());
+ Assert.assertEquals(0, notifications.getNotificationEvents().size());
+
+ notifications = new AtsNotificationCollector();
+ when(teamDef.getSubscribed()).thenReturn(Arrays.asList(kay_ValidEmail));
+ when(ai.getSubscribed()).thenReturn(new ArrayList<IAtsUser>());
+ processor.run(notifications, event);
+ Assert.assertEquals(1, notifications.getNotificationEvents().size());
+
+ notifications = new AtsNotificationCollector();
+ when(teamDef.getSubscribed()).thenReturn(new ArrayList<IAtsUser>());
+ when(ai.getSubscribed()).thenReturn(Arrays.asList(kay_ValidEmail));
+ processor.run(notifications, event);
+ Assert.assertEquals(1, notifications.getNotificationEvents().size());
+
+ notifications = new AtsNotificationCollector();
+ when(teamDef.getSubscribed()).thenReturn(Arrays.asList(jason_ValidEmail));
+ when(ai.getSubscribed()).thenReturn(Arrays.asList(kay_ValidEmail));
+ processor.run(notifications, event);
+ Assert.assertEquals(2, notifications.getNotificationEvents().size());
+
+ }
+
+ private void setupUser(IAtsUser user, String guid, String name, String email, String userId, boolean active, boolean admin) {
+ when(user.getGuid()).thenReturn(guid);
+ when(user.getName()).thenReturn(name);
+ when(user.getEmail()).thenReturn(email);
+ when(user.isActive()).thenReturn(active);
+ when(user.getUserId()).thenReturn(userId);
+
+ when(userService.getUserById(userId)).thenReturn(user);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/AtsServerImpl.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/AtsServerImpl.java
index 42ecb05f7f9..40ea26c53f5 100644
--- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/AtsServerImpl.java
+++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/AtsServerImpl.java
@@ -343,7 +343,7 @@ public class AtsServerImpl implements IAtsServer {
public void sendNotifications(AtsNotificationCollector notifications) {
if (notificationEventProcessor == null) {
workItemNotificationProcessor =
- new WorkItemNotificationProcessor(this, orcsApi, workItemFactory, userService, attributeResolverService);
+ new WorkItemNotificationProcessor(this, workItemFactory, userService, attributeResolverService);
notificationEventProcessor =
new AtsNotificationEventProcessor(workItemNotificationProcessor, userService,
getConfigValue("NoReplyEmail"));
diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/notify/AtsNotificationEventProcessor.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/notify/AtsNotificationEventProcessor.java
index ce392fac6c3..af2c01b6161 100644
--- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/notify/AtsNotificationEventProcessor.java
+++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/notify/AtsNotificationEventProcessor.java
@@ -36,7 +36,7 @@ public class AtsNotificationEventProcessor {
workItemNotificationProcessor.run(notifications, workItemEvent);
}
- String testingUserEmail = "donald.g.dunne@boeing.com"; // change to email address for testing purposes; all emails will go there
+ String testingUserEmail = ""; // change to email address for testing purposes; all emails will go there
String fromUserEmail = getFromUserEmail(notifications);
for (IAtsNotifierServer notifier : notifiers) {
diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/notify/WorkItemNotificationProcessor.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/notify/WorkItemNotificationProcessor.java
index 2540ff35914..aeb47c3cb70 100644
--- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/notify/WorkItemNotificationProcessor.java
+++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/notify/WorkItemNotificationProcessor.java
@@ -19,7 +19,6 @@ import java.util.logging.Level;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.ai.IAtsActionableItem;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
-import org.eclipse.osee.ats.api.data.AtsRelationTypes;
import org.eclipse.osee.ats.api.notify.AtsNotificationCollector;
import org.eclipse.osee.ats.api.notify.AtsNotificationEventFactory;
import org.eclipse.osee.ats.api.notify.AtsNotifyType;
@@ -37,15 +36,11 @@ import org.eclipse.osee.ats.core.review.UserRoleManager;
import org.eclipse.osee.ats.core.users.AtsCoreUsers;
import org.eclipse.osee.ats.core.users.AtsUsersUtility;
import org.eclipse.osee.ats.impl.IAtsServer;
-import org.eclipse.osee.ats.impl.internal.util.AtsUtilServer;
-import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.DateUtil;
import org.eclipse.osee.framework.jdk.core.util.EmailUtil;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.logging.OseeLog;
-import org.eclipse.osee.orcs.OrcsApi;
-import org.eclipse.osee.orcs.data.ArtifactReadable;
/**
* @author Donald G. Dunne
@@ -54,14 +49,12 @@ public class WorkItemNotificationProcessor {
private final IAtsUserService userService;
private final IAttributeResolver attrResolver;
- private final OrcsApi orcsApi;
private final IAtsWorkItemFactory workItemFactory;
private final IAtsServer atsServer;
private static String actionUrl;
- public WorkItemNotificationProcessor(IAtsServer atsServer, OrcsApi orcsApi, IAtsWorkItemFactory workItemFactory, IAtsUserService userService, IAttributeResolver attrResolver) throws OseeCoreException {
+ public WorkItemNotificationProcessor(IAtsServer atsServer, IAtsWorkItemFactory workItemFactory, IAtsUserService userService, IAttributeResolver attrResolver) throws OseeCoreException {
this.atsServer = atsServer;
- this.orcsApi = orcsApi;
this.workItemFactory = workItemFactory;
this.userService = userService;
this.attrResolver = attrResolver;
@@ -81,7 +74,7 @@ public class WorkItemNotificationProcessor {
notifyUsers.add(userService.getUserById(userId));
}
for (String atsId : event.getAtsIds()) {
- IAtsWorkItem workItem = workItemFactory.getWorkItem(AtsUtilServer.getArtifactByAtsId(orcsApi, atsId));
+ IAtsWorkItem workItem = workItemFactory.getWorkItemByAtsId(atsId);
if (types.contains(AtsNotifyType.Originator)) {
IAtsUser originator = workItem.getCreatedBy();
@@ -125,7 +118,7 @@ public class WorkItemNotificationProcessor {
}
if (types.contains(AtsNotifyType.Subscribed)) {
Collection<IAtsUser> subscribed = new HashSet<IAtsUser>();
- subscribed.addAll(getSubscribed(workItem));
+ subscribed.addAll(userService.getSubscribed(workItem));
subscribed = AtsUsersUtility.getValidEmailUsers(subscribed);
subscribed = AtsUsersUtility.getActiveEmailUsers(subscribed);
if (subscribed.size() > 0) {
@@ -236,14 +229,6 @@ public class WorkItemNotificationProcessor {
return fromUser;
}
- private List<IAtsUser> getSubscribed(IAtsWorkItem workItem) throws OseeCoreException {
- ArrayList<IAtsUser> arts = new ArrayList<IAtsUser>();
- for (ArtifactReadable art : ((ArtifactReadable) workItem).getRelated(AtsRelationTypes.SubscribedUser_User)) {
- arts.add(userService.getUserById((String) art.getSoleAttributeValue(CoreAttributeTypes.UserId)));
- }
- return arts;
- }
-
private String getIdString(IAtsWorkItem workItem) {
try {
String legacyPcrId = attrResolver.getSoleAttributeValue(workItem, AtsAttributeTypes.LegacyPcrId, "");
diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/user/AtsUserServiceImpl.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/user/AtsUserServiceImpl.java
index 6dba0c5833b..179bc4867e8 100644
--- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/user/AtsUserServiceImpl.java
+++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/user/AtsUserServiceImpl.java
@@ -12,7 +12,9 @@ package org.eclipse.osee.ats.impl.internal.user;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.data.AtsArtifactToken;
+import org.eclipse.osee.ats.api.data.AtsRelationTypes;
import org.eclipse.osee.ats.api.user.IAtsUser;
import org.eclipse.osee.ats.core.users.AbstractAtsUserService;
import org.eclipse.osee.ats.core.util.AtsUtilCore;
@@ -160,4 +162,14 @@ public class AtsUserServiceImpl extends AbstractAtsUserService {
}
return hasPermission;
}
+
+ @Override
+ public List<IAtsUser> getSubscribed(IAtsWorkItem workItem) throws OseeCoreException {
+ ArrayList<IAtsUser> arts = new ArrayList<IAtsUser>();
+ for (ArtifactReadable art : ((ArtifactReadable) workItem).getRelated(AtsRelationTypes.SubscribedUser_User)) {
+ arts.add(getUserById((String) art.getSoleAttributeValue(CoreAttributeTypes.UserId)));
+ }
+ return arts;
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/WorkItemFactory.java b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/WorkItemFactory.java
index 6d7023679b8..6486b3e445a 100644
--- a/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/WorkItemFactory.java
+++ b/plugins/org.eclipse.osee.ats.impl/src/org/eclipse/osee/ats/impl/internal/workitem/WorkItemFactory.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.ats.impl.internal.workitem;
import org.eclipse.osee.ats.api.IAtsWorkItem;
import org.eclipse.osee.ats.api.data.AtsArtifactTypes;
+import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.api.review.IAtsAbstractReview;
import org.eclipse.osee.ats.api.team.IAtsWorkItemFactory;
import org.eclipse.osee.ats.api.workflow.IAtsAction;
@@ -121,4 +122,10 @@ public class WorkItemFactory implements IAtsWorkItemFactory {
return action;
}
+ @Override
+ public IAtsWorkItem getWorkItemByAtsId(String atsId) {
+ ArtifactReadable artifact = atsServer.getQuery().and(AtsAttributeTypes.AtsId, atsId).getResults().getOneOrNull();
+ return getWorkItem(artifact);
+ }
+
}

Back to the top