Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddunne2011-05-20 12:08:58 -0400
committerRyan D. Brooks2011-05-20 12:08:58 -0400
commit7840f46b12b20a1bb3ef8b3bb934421e9fc75709 (patch)
treed8da4c3259349a190bee93f3fa9da457b853f399 /plugins/org.eclipse.osee.ats.core.test
parentf28113b5cd91d824b975255c6ca0cd51bb1b84ee (diff)
downloadorg.eclipse.osee-7840f46b12b20a1bb3ef8b3bb934421e9fc75709.tar.gz
org.eclipse.osee-7840f46b12b20a1bb3ef8b3bb934421e9fc75709.tar.xz
org.eclipse.osee-7840f46b12b20a1bb3ef8b3bb934421e9fc75709.zip
feature: ATS Programatic Transition Validation
Diffstat (limited to 'plugins/org.eclipse.osee.ats.core.test')
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/META-INF/MANIFEST.MF5
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_JT_Suite.java39
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_PT_Suite.java44
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsTestUtil.java378
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsTestUtilTest.java39
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/AtsCore_Review_JT_Suite.java45
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/AtsCore_Review_PT_Suite.java (renamed from plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_Validation_Suite.java)18
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/DecisionReviewDefinitionManagerTest.java133
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/DecisionReviewManagerTest.java162
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/PeerReviewDefinitionManagerTest.java86
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/PeerToPeerReviewManagerTest.java86
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/defect/AtsXDefectValidatorTest.java113
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/defect/MockDefectValueProvider.java47
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/defect/ReviewDefectItemTest.java38
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/role/AtsXUserRoleValidatorTest.java95
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/role/MockUserRoleValueProvider.java47
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/role/UserRoleTest.java27
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/task/AtsCore_Task_PT_Suite.java37
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/task/TaskManagerTest.java120
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsCore_Validator_JT_Suite.java45
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXComboBooleanValidatorTest.java50
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXComboValidatorTest.java48
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXDateValidatorTest.java93
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXFloatValidatorTest.java90
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXIntegerValidatorTest.java55
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXListValidatorTest.java91
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXTextValidatorTest.java48
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidatorTest.java105
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/MockDateValueProvider.java29
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/MockValueProvider.java7
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/ValidatorTestUtil.java2
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/transition/AtsCore_Transition_PT_Suite.java37
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/transition/TestTransitionHelper.java99
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/transition/TransitionManagerTest.java523
34 files changed, 2860 insertions, 21 deletions
diff --git a/plugins/org.eclipse.osee.ats.core.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.ats.core.test/META-INF/MANIFEST.MF
index ebc2ca5ee4..0c23f0862a 100644
--- a/plugins/org.eclipse.osee.ats.core.test/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.ats.core.test/META-INF/MANIFEST.MF
@@ -7,3 +7,8 @@ Bundle-Vendor: The Boeing Company
Fragment-Host: org.eclipse.osee.ats.core
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: org.junit
+Export-Package: org.eclipse.osee.ats.core,
+ org.eclipse.osee.ats.core.validator
+Import-Package: org.eclipse.osee.framework.database.core,
+ org.eclipse.osee.framework.skynet.core,
+ org.eclipse.osee.support.test.util
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_JT_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_JT_Suite.java
new file mode 100644
index 0000000000..fba270ef83
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_JT_Suite.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * 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.core;
+
+import org.eclipse.osee.ats.core.review.AtsCore_Review_JT_Suite;
+import org.eclipse.osee.ats.core.validator.AtsCore_Validator_JT_Suite;
+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;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({AtsCore_Review_JT_Suite.class, AtsCore_Validator_JT_Suite.class})
+/**
+ * This test suite contains tests that can be run as stand-alone JUnit tests (JT)
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsCore_JT_Suite {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ OseeProperties.setIsInTest(true);
+ System.out.println("\n\nBegin " + AtsCore_JT_Suite.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ System.out.println("End " + AtsCore_JT_Suite.class.getSimpleName());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_PT_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_PT_Suite.java
new file mode 100644
index 0000000000..ec6ef7b92d
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_PT_Suite.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.core;
+
+import org.eclipse.osee.ats.core.review.AtsCore_Review_PT_Suite;
+import org.eclipse.osee.ats.core.task.AtsCore_Task_PT_Suite;
+import org.eclipse.osee.ats.core.workflow.transition.AtsCore_Transition_PT_Suite;
+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;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ AtsTestUtilTest.class,
+ AtsCore_Task_PT_Suite.class,
+ AtsCore_Review_PT_Suite.class,
+ AtsCore_Transition_PT_Suite.class})
+/**
+ * This test suite contains tests that must be run as PDE Junit (PT) through test launch config
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsCore_PT_Suite {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ OseeProperties.setIsInTest(true);
+ System.out.println("\n\nBegin " + AtsCore_PT_Suite.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ System.out.println("End " + AtsCore_PT_Suite.class.getSimpleName());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsTestUtil.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsTestUtil.java
new file mode 100644
index 0000000000..91fd1feee1
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsTestUtil.java
@@ -0,0 +1,378 @@
+/*
+ * Created on Jun 6, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core;
+
+import static org.eclipse.osee.framework.core.enums.DeletionFlag.EXCLUDE_DELETED;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import org.eclipse.osee.ats.core.config.ActionableItemArtifact;
+import org.eclipse.osee.ats.core.config.TeamDefinitionArtifact;
+import org.eclipse.osee.ats.core.review.AbstractReviewArtifact;
+import org.eclipse.osee.ats.core.review.DecisionReviewArtifact;
+import org.eclipse.osee.ats.core.review.DecisionReviewManager;
+import org.eclipse.osee.ats.core.review.DecisionReviewState;
+import org.eclipse.osee.ats.core.review.ReviewManager;
+import org.eclipse.osee.ats.core.task.TaskArtifact;
+import org.eclipse.osee.ats.core.team.TeamWorkFlowArtifact;
+import org.eclipse.osee.ats.core.type.AtsArtifactTypes;
+import org.eclipse.osee.ats.core.type.AtsAttributeTypes;
+import org.eclipse.osee.ats.core.type.AtsRelationTypes;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
+import org.eclipse.osee.ats.core.version.VersionArtifact;
+import org.eclipse.osee.ats.core.workdef.DecisionReviewOption;
+import org.eclipse.osee.ats.core.workdef.ReviewBlockType;
+import org.eclipse.osee.ats.core.workdef.StateDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinition;
+import org.eclipse.osee.ats.core.workdef.WorkDefinition;
+import org.eclipse.osee.ats.core.workdef.WorkDefinitionFactory;
+import org.eclipse.osee.ats.core.workflow.ActionArtifact;
+import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeStateException;
+import org.eclipse.osee.framework.core.model.IBasicUser;
+import org.eclipse.osee.framework.core.util.WorkPageType;
+import org.eclipse.osee.framework.skynet.core.UserManager;
+import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactCache;
+import org.eclipse.osee.framework.skynet.core.artifact.ArtifactTypeManager;
+import org.eclipse.osee.framework.skynet.core.artifact.PurgeArtifacts;
+import org.eclipse.osee.framework.skynet.core.artifact.search.ArtifactQuery;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
+import org.eclipse.osee.support.test.util.TestUtil;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class AtsTestUtil {
+
+ private static TeamWorkFlowArtifact teamArt = null;
+ private static TeamDefinitionArtifact teamDef = null;
+ private static VersionArtifact verArt1 = null, verArt2 = null;
+ private static DecisionReviewArtifact decRevArt = null;
+ private static TaskArtifact taskArt = null;
+ private static ActionableItemArtifact testAi = null;
+ private static ActionArtifact actionArt = null;
+ private static StateDefinition analyze = null, implement = null, completed = null, cancelled = null;
+ private static WorkDefinition workDef = null;
+ public static String WORK_DEF_NAME = "Test_Team _Workflow_Definition";
+ private static WidgetDefinition estHoursWidgetDef, workPackageWidgetDef;
+ private static String postFixName;
+
+ public static void validateArtifactCache() throws OseeStateException {
+ if (ArtifactCache.getDirtyArtifacts().size() > 0) {
+ for (Artifact artifact : ArtifactCache.getDirtyArtifacts()) {
+ System.err.println(String.format("Artifact [%s] is dirty [%s]", artifact.toStringWithId(),
+ Artifacts.getDirtyReport(artifact)));
+ }
+ throw new OseeStateException("[%d] Dirty Artifacts found after populate (see console for details)",
+ ArtifactCache.getDirtyArtifacts().size());
+ }
+ }
+
+ public static WorkDefinition getWorkDef() throws OseeCoreException {
+ ensureLoaded();
+ return workDef;
+ }
+
+ public static StateDefinition getAnalyzeStateDef() throws OseeCoreException {
+ ensureLoaded();
+ return analyze;
+ }
+
+ public static WidgetDefinition getEstHoursWidgetDef() throws OseeCoreException {
+ ensureLoaded();
+ return estHoursWidgetDef;
+ }
+
+ public static WidgetDefinition getWorkPackageWidgetDef() throws OseeCoreException {
+ ensureLoaded();
+ return workPackageWidgetDef;
+ }
+
+ public static StateDefinition getImplementStateDef() throws OseeCoreException {
+ ensureLoaded();
+ return implement;
+ }
+
+ public static StateDefinition getCompletedStateDef() throws OseeCoreException {
+ ensureLoaded();
+ return completed;
+ }
+
+ public static StateDefinition getCancelledStateDef() throws OseeCoreException {
+ ensureLoaded();
+ return cancelled;
+ }
+
+ private static void ensureLoaded() throws OseeCoreException {
+ if (workDef == null) {
+ throw new OseeStateException("Must call cleanAndReset before using this method");
+ }
+ }
+
+ private static void clearCaches() {
+ if (workDef != null) {
+ WorkDefinitionFactory.removeWorkDefinition(workDef);
+ }
+ analyze = null;
+ implement = null;
+ completed = null;
+ cancelled = null;
+ workDef = null;
+ estHoursWidgetDef = null;
+ workPackageWidgetDef = null;
+ teamArt = null;
+ teamDef = null;
+ taskArt = null;
+ testAi = null;
+ actionArt = null;
+ verArt1 = null;
+ verArt2 = null;
+ }
+
+ private static String getTitle(String objectName, String postFixName) {
+ return String.format("%s - %s [%s]", AtsTestUtil.class.getSimpleName(), objectName, postFixName);
+ }
+
+ /**
+ * Clear workDef from cache, clear all objects and create new objects with postFixName in titles
+ */
+ private static void reset(String postFixName) throws OseeCoreException {
+ AtsTestUtil.postFixName = postFixName;
+ SkynetTransaction transaction =
+ new SkynetTransaction(AtsUtilCore.getAtsBranch(), AtsTestUtil.class.getSimpleName());
+ workDef = new WorkDefinition(WORK_DEF_NAME);
+
+ analyze = new StateDefinition("Analyze");
+ analyze.setWorkDefinition(workDef);
+ analyze.setWorkPageType(WorkPageType.Working);
+ analyze.setOrdinal(1);
+ workDef.getStates().add(analyze);
+
+ workDef.setStartState(analyze);
+
+ implement = new StateDefinition("Implement");
+ implement.setWorkDefinition(workDef);
+ implement.setWorkPageType(WorkPageType.Working);
+ implement.setOrdinal(2);
+ workDef.getStates().add(implement);
+
+ completed = new StateDefinition("Completed");
+ completed.setWorkDefinition(workDef);
+ completed.setWorkPageType(WorkPageType.Completed);
+ completed.setOrdinal(3);
+ workDef.getStates().add(completed);
+
+ cancelled = new StateDefinition("Cancelled");
+ cancelled.setWorkDefinition(workDef);
+ cancelled.setWorkPageType(WorkPageType.Cancelled);
+ cancelled.setOrdinal(4);
+ workDef.getStates().add(cancelled);
+
+ analyze.setDefaultToState(implement);
+ analyze.getToStates().addAll(Arrays.asList(implement, completed, cancelled));
+ analyze.getOverrideAttributeValidationStates().addAll(Arrays.asList(cancelled));
+
+ implement.setDefaultToState(completed);
+ implement.getToStates().addAll(Arrays.asList(analyze, completed, cancelled));
+ implement.getOverrideAttributeValidationStates().addAll(Arrays.asList(cancelled, analyze));
+
+ completed.setDefaultToState(completed);
+ completed.getToStates().addAll(Arrays.asList(implement));
+ completed.getOverrideAttributeValidationStates().addAll(Arrays.asList(implement));
+
+ cancelled.getToStates().addAll(Arrays.asList(analyze, implement));
+ cancelled.getOverrideAttributeValidationStates().addAll(Arrays.asList(analyze, implement));
+
+ estHoursWidgetDef = new WidgetDefinition(AtsAttributeTypes.EstimatedHours.getUnqualifiedName());
+ estHoursWidgetDef.setAttributeName(AtsAttributeTypes.EstimatedHours.getName());
+ estHoursWidgetDef.setXWidgetName("XFloatDam");
+
+ workPackageWidgetDef = new WidgetDefinition(AtsAttributeTypes.WorkPackage.getUnqualifiedName());
+ workPackageWidgetDef.setAttributeName(AtsAttributeTypes.WorkPackage.getName());
+ workPackageWidgetDef.setXWidgetName("XTextDam");
+
+ WorkDefinitionFactory.addWorkDefinition(workDef);
+
+ testAi =
+ (ActionableItemArtifact) ArtifactTypeManager.addArtifact(AtsArtifactTypes.ActionableItem,
+ AtsUtilCore.getAtsBranchToken(), getTitle("AI", postFixName));
+ testAi.setSoleAttributeValue(CoreAttributeTypes.Active, true);
+ testAi.setSoleAttributeValue(AtsAttributeTypes.Actionable, true);
+
+ teamDef =
+ (TeamDefinitionArtifact) ArtifactTypeManager.addArtifact(AtsArtifactTypes.TeamDefinition,
+ AtsUtilCore.getAtsBranchToken(), getTitle("Team Def", postFixName));
+ teamDef.setSoleAttributeValue(AtsAttributeTypes.WorkflowDefinition, WORK_DEF_NAME);
+ teamDef.setSoleAttributeValue(CoreAttributeTypes.Active, true);
+ teamDef.setSoleAttributeValue(AtsAttributeTypes.TeamUsesVersions, true);
+
+ testAi.addRelation(AtsRelationTypes.TeamActionableItem_Team, teamDef);
+
+ verArt1 =
+ (VersionArtifact) ArtifactTypeManager.addArtifact(AtsArtifactTypes.Version, AtsUtilCore.getAtsBranchToken(),
+ getTitle("ver 1.0", postFixName));
+ verArt1.addRelation(AtsRelationTypes.TeamDefinitionToVersion_TeamDefinition, teamDef);
+
+ verArt2 =
+ (VersionArtifact) ArtifactTypeManager.addArtifact(AtsArtifactTypes.Version, AtsUtilCore.getAtsBranchToken(),
+ getTitle("ver 2.0", postFixName));
+ verArt2.addRelation(AtsRelationTypes.TeamDefinitionToVersion_TeamDefinition, teamDef);
+
+ teamArt =
+ (TeamWorkFlowArtifact) ArtifactTypeManager.addArtifact(AtsArtifactTypes.TeamWorkflow,
+ AtsUtilCore.getAtsBranchToken(), getTitle("Team WF", postFixName));
+ teamArt.setTeamDefinition(teamDef);
+ teamArt.getActionableItemsDam().addActionableItem(testAi);
+ teamArt.initializeNewStateMachine(getAnalyzeStateDef(), Arrays.asList((IBasicUser) UserManager.getUser()),
+ new Date(), UserManager.getUser());
+
+ actionArt =
+ (ActionArtifact) ArtifactTypeManager.addArtifact(AtsArtifactTypes.Action, AtsUtilCore.getAtsBranchToken(),
+ "Test Action");
+ actionArt.addRelation(AtsRelationTypes.ActionToWorkflow_WorkFlow, teamArt);
+
+ testAi.persist(transaction);
+ teamDef.persist(transaction);
+ verArt1.persist(transaction);
+ verArt2.persist(transaction);
+ teamArt.persist(transaction);
+ actionArt.persist(transaction);
+ transaction.execute();
+ }
+
+ public static TaskArtifact getOrCreateTask() throws OseeCoreException {
+ ensureLoaded();
+ if (taskArt == null) {
+ taskArt = teamArt.createNewTask(getTitle("Task", postFixName), new Date(), UserManager.getUser());
+ taskArt.setSoleAttributeValue(AtsAttributeTypes.RelatedToState, teamArt.getCurrentStateName());
+ taskArt.persist("AtsTestUtil - addTask");
+ }
+ return taskArt;
+ }
+
+ public static DecisionReviewArtifact getOrCreateDecisionReview(ReviewBlockType reviewBlockType, String relatedToState) throws OseeCoreException {
+ ensureLoaded();
+ if (decRevArt == null) {
+ List<DecisionReviewOption> options = new ArrayList<DecisionReviewOption>();
+ options.add(new DecisionReviewOption(DecisionReviewState.Completed.getPageName(), false, null));
+ options.add(new DecisionReviewOption(DecisionReviewState.Followup.getPageName(), true,
+ Arrays.asList(UserManager.getUser().getUserId())));
+ decRevArt =
+ DecisionReviewManager.createNewDecisionReview(teamArt, reviewBlockType,
+ AtsTestUtil.class.getSimpleName() + " Test Decision Review", relatedToState, "Decision Review", options,
+ Arrays.asList((IBasicUser) UserManager.getUser()), new Date(), UserManager.getUser());
+ }
+ return decRevArt;
+ }
+
+ public static TeamWorkFlowArtifact getTeamWf() throws OseeCoreException {
+ ensureLoaded();
+ return teamArt;
+ }
+
+ public static ActionableItemArtifact getTestAi() throws OseeCoreException {
+ ensureLoaded();
+ return testAi;
+
+ }
+
+ public static TeamDefinitionArtifact getTestTeamDef() throws OseeCoreException {
+ ensureLoaded();
+ return teamDef;
+ }
+
+ /**
+ * All team defs, AIs, action and workflows will be deleted and new ones created with "name" as part of object
+ * names/titles. In addition, ArtifactCache will validate that it is not dirty or display errors if it is.
+ *
+ * @throws OseeCoreException
+ */
+ public static void cleanupAndReset(String name) throws OseeCoreException {
+ cleanup();
+ reset(name);
+ }
+
+ /**
+ * Cleanup all artifacts and confirm that ArtifactCache has no dirty artifacts. Should be called at beginning at end
+ * of each test.
+ */
+ public static void cleanup() throws OseeCoreException {
+ SkynetTransaction transaction =
+ new SkynetTransaction(AtsUtilCore.getAtsBranch(), AtsTestUtil.class.getSimpleName() + " - cleanup");
+ if (decRevArt != null) {
+ decRevArt.deleteAndPersist(transaction);
+ }
+ if (taskArt != null) {
+ taskArt.deleteAndPersist(transaction);
+ }
+ if (teamArt != null) {
+ for (TaskArtifact taskArt : teamArt.getTaskArtifacts()) {
+ taskArt.deleteAndPersist(transaction);
+ }
+ for (AbstractReviewArtifact revArt : ReviewManager.getReviews(teamArt)) {
+ revArt.deleteAndPersist(transaction);
+ }
+ teamArt.deleteAndPersist(transaction);
+ }
+ if (actionArt != null) {
+ actionArt.deleteAndPersist(transaction);
+ }
+ transaction.execute();
+ transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), AtsTestUtil.class.getSimpleName() + " - cleanup");
+ if (testAi != null) {
+ testAi.deleteAndPersist(transaction);
+ }
+ if (verArt1 != null) {
+ verArt1.deleteAndPersist(transaction);
+ }
+ if (verArt2 != null) {
+ verArt2.deleteAndPersist(transaction);
+ }
+ if (teamDef != null) {
+ teamDef.deleteAndPersist(transaction);
+ }
+ transaction.execute();
+
+ clearCaches();
+
+ // validate that there are no dirty artifacts in cache
+ AtsTestUtil.validateArtifactCache();
+ }
+
+ public static VersionArtifact getVerArt1() {
+ return verArt1;
+ }
+
+ public static VersionArtifact getVerArt2() {
+ return verArt2;
+ }
+
+ /**
+ * Deletes any artifact with name that starts with title
+ */
+ public static void cleanupSimpleTest(String title) throws Exception {
+ cleanupSimpleTest(Arrays.asList(title));
+ }
+
+ /**
+ * Deletes all artifacts with names that start with any title given
+ */
+ public static void cleanupSimpleTest(Collection<String> titles) throws Exception {
+ List<Artifact> artifacts = new ArrayList<Artifact>();
+ for (String title : titles) {
+ artifacts.addAll(ArtifactQuery.getArtifactListFromName(title + "%", AtsUtilCore.getAtsBranch(),
+ EXCLUDE_DELETED));
+ }
+ new PurgeArtifacts(artifacts).execute();
+ TestUtil.sleep(4000);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsTestUtilTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsTestUtilTest.java
new file mode 100644
index 0000000000..6f112bd809
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsTestUtilTest.java
@@ -0,0 +1,39 @@
+/*
+ * Created on Jun 8, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core;
+
+import junit.framework.Assert;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.exception.OseeStateException;
+
+/**
+ * Test unit for {@link AtsTestUtil}
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsTestUtilTest extends AtsTestUtil {
+
+ @org.junit.Test
+ public void testCleanupAndReset() throws OseeCoreException {
+ boolean exceptionThrown = false;
+ try {
+ Assert.assertNull(AtsTestUtil.getWorkDef());
+ } catch (OseeStateException ex) {
+ Assert.assertEquals(ex.getMessage(), "Must call cleanAndReset before using this method");
+ exceptionThrown = true;
+ }
+ Assert.assertTrue("Exeception should have been thrown", exceptionThrown);
+
+ AtsTestUtil.cleanupAndReset("AtsTestUtilTest");
+
+ AtsTestUtil.validateArtifactCache();
+
+ AtsTestUtil.cleanup();
+
+ AtsTestUtil.validateArtifactCache();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/AtsCore_Review_JT_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/AtsCore_Review_JT_Suite.java
new file mode 100644
index 0000000000..99f7877e86
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/AtsCore_Review_JT_Suite.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.core.review;
+
+import org.eclipse.osee.ats.core.review.defect.AtsXDefectValidatorTest;
+import org.eclipse.osee.ats.core.review.defect.ReviewDefectItemTest;
+import org.eclipse.osee.ats.core.review.role.AtsXUserRoleValidatorTest;
+import org.eclipse.osee.ats.core.review.role.UserRoleTest;
+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;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ ReviewDefectItemTest.class,
+ AtsXDefectValidatorTest.class,
+ UserRoleTest.class,
+ AtsXUserRoleValidatorTest.class})
+/**
+ * This test suite contains tests that must be run against demo database as Plugin JUnit (PT)
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsCore_Review_JT_Suite {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ OseeProperties.setIsInTest(true);
+ System.out.println("\n\nBegin " + AtsCore_Review_JT_Suite.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ System.out.println("End " + AtsCore_Review_JT_Suite.class.getSimpleName());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_Validation_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/AtsCore_Review_PT_Suite.java
index 085c92f3dd..c9b1492e7e 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_Validation_Suite.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/AtsCore_Review_PT_Suite.java
@@ -8,10 +8,8 @@
* Contributors:
* Boeing - initial API and implementation
*******************************************************************************/
-package org.eclipse.osee.ats.core;
+package org.eclipse.osee.ats.core.review;
-import org.eclipse.osee.ats.core.validator.AtsXIntegerValidatorTest;
-import org.eclipse.osee.ats.core.validator.AtsXWidgetValidatorTest;
import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
import org.junit.AfterClass;
import org.junit.BeforeClass;
@@ -19,21 +17,25 @@ import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
-@Suite.SuiteClasses({AtsXWidgetValidatorTest.class, AtsXIntegerValidatorTest.class})
+@Suite.SuiteClasses({
+ DecisionReviewManagerTest.class,
+ DecisionReviewDefinitionManagerTest.class,
+ PeerToPeerReviewManagerTest.class,
+ PeerReviewDefinitionManagerTest.class})
/**
- * This test suite contains tests that must be run against demo database
+ * This test suite contains tests that must be run against demo database as Plugin JUnit (PT)
*
* @author Donald G. Dunne
*/
-public class AtsCore_Validation_Suite {
+public class AtsCore_Review_PT_Suite {
@BeforeClass
public static void setUp() throws Exception {
OseeProperties.setIsInTest(true);
- System.out.println("\n\nBegin " + AtsCore_Validation_Suite.class.getSimpleName());
+ System.out.println("\n\nBegin " + AtsCore_Review_PT_Suite.class.getSimpleName());
}
@AfterClass
public static void tearDown() throws Exception {
- System.out.println("End " + AtsCore_Validation_Suite.class.getSimpleName());
+ System.out.println("End " + AtsCore_Review_PT_Suite.class.getSimpleName());
}
}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/DecisionReviewDefinitionManagerTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/DecisionReviewDefinitionManagerTest.java
new file mode 100644
index 0000000000..573ed5a9d7
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/DecisionReviewDefinitionManagerTest.java
@@ -0,0 +1,133 @@
+/*
+ * Created on Jun 8, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.review;
+
+import java.util.Arrays;
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.AtsTestUtil;
+import org.eclipse.osee.ats.core.team.TeamWorkFlowArtifact;
+import org.eclipse.osee.ats.core.type.AtsAttributeTypes;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
+import org.eclipse.osee.ats.core.workdef.DecisionReviewDefinition;
+import org.eclipse.osee.ats.core.workdef.ReviewBlockType;
+import org.eclipse.osee.ats.core.workdef.StateDefinition;
+import org.eclipse.osee.ats.core.workdef.StateEventType;
+import org.eclipse.osee.ats.core.workflow.transition.TestTransitionHelper;
+import org.eclipse.osee.ats.core.workflow.transition.TransitionManager;
+import org.eclipse.osee.ats.core.workflow.transition.TransitionOption;
+import org.eclipse.osee.ats.core.workflow.transition.TransitionResults;
+import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.skynet.core.UserManager;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * Test unit for {@link DecisionReviewDefinitionManager}
+ *
+ * @author Donald G. Dunne
+ */
+public class DecisionReviewDefinitionManagerTest extends DecisionReviewDefinitionManager {
+
+ @BeforeClass
+ @AfterClass
+ public static void cleanup() throws Exception {
+ AtsTestUtil.cleanup();
+ }
+
+ @org.junit.Test
+ public void testCreateDecisionReviewDuringTransition_ToDecision() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("DecisionReviewDefinitionManagerTest - ToDecision");
+
+ // configure WorkDefinition to create a new Review on transition to Implement
+ StateDefinition implement = AtsTestUtil.getImplementStateDef();
+
+ DecisionReviewDefinition revDef = new DecisionReviewDefinition("Create New on Implement");
+ revDef.setAutoTransitionToDecision(true);
+ revDef.setBlockingType(ReviewBlockType.Transition);
+ revDef.setDescription("the description");
+ revDef.setRelatedToState(implement.getPageName());
+ revDef.setStateEventType(StateEventType.TransitionTo);
+ revDef.setReviewTitle("This is my review title");
+ revDef.getOptions().addAll(DecisionReviewManager.getDefaultDecisionReviewOptions());
+ revDef.getAssignees().add(SystemUser.UnAssigned.getUserId());
+
+ implement.getDecisionReviews().add(revDef);
+
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ Assert.assertEquals("No reviews should be present", 0, ReviewManager.getReviews(teamArt).size());
+
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ TestTransitionHelper helper =
+ new TestTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt), implement.getPageName(),
+ Arrays.asList(UserManager.getUser()), null, TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper, transaction);
+ TransitionResults results = transMgr.handleAll();
+ transaction.execute();
+
+ Assert.assertTrue(results.toString(), results.isEmpty());
+
+ Assert.assertEquals("One review should be present", 1, ReviewManager.getReviews(teamArt).size());
+ DecisionReviewArtifact decArt = (DecisionReviewArtifact) ReviewManager.getReviews(teamArt).iterator().next();
+
+ Assert.assertEquals(DecisionReviewState.Decision.getPageName(), decArt.getCurrentStateName());
+ Assert.assertEquals("UnAssigned", decArt.getStateMgr().getAssigneesStr());
+ Assert.assertEquals(ReviewBlockType.Transition.name(),
+ decArt.getSoleAttributeValue(AtsAttributeTypes.ReviewBlocks));
+ Assert.assertEquals("This is my review title", decArt.getName());
+ Assert.assertEquals("the description", decArt.getSoleAttributeValue(AtsAttributeTypes.Description));
+ Assert.assertEquals(implement.getPageName(), decArt.getSoleAttributeValue(AtsAttributeTypes.RelatedToState));
+
+ AtsTestUtil.validateArtifactCache();
+ }
+
+ @org.junit.Test
+ public void testCreateDecisionReviewDuringTransition_Prepare() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("DecisionReviewDefinitionManagerTest - Prepare");
+
+ // configure WorkDefinition to create a new Review on transition to Implement
+ StateDefinition implement = AtsTestUtil.getImplementStateDef();
+
+ DecisionReviewDefinition revDef = new DecisionReviewDefinition("Create New on Implement");
+ revDef.setAutoTransitionToDecision(false);
+ revDef.setBlockingType(ReviewBlockType.Commit);
+ revDef.setReviewTitle("This is the title");
+ revDef.setDescription("the description");
+ revDef.setRelatedToState(implement.getPageName());
+ revDef.setStateEventType(StateEventType.TransitionTo);
+ revDef.getOptions().addAll(DecisionReviewManager.getDefaultDecisionReviewOptions());
+
+ implement.getDecisionReviews().add(revDef);
+
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ Assert.assertEquals("No reviews should be present", 0, ReviewManager.getReviews(teamArt).size());
+
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ TestTransitionHelper helper =
+ new TestTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt), implement.getPageName(),
+ Arrays.asList(UserManager.getUser()), null, TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper, transaction);
+ TransitionResults results = transMgr.handleAll();
+ transaction.execute();
+
+ Assert.assertTrue(results.toString(), results.isEmpty());
+
+ Assert.assertEquals("One review should be present", 1, ReviewManager.getReviews(teamArt).size());
+ DecisionReviewArtifact decArt = (DecisionReviewArtifact) ReviewManager.getReviews(teamArt).iterator().next();
+
+ Assert.assertEquals(DecisionReviewState.Prepare.getPageName(), decArt.getCurrentStateName());
+ // Current user assigned if non specified
+ Assert.assertEquals("Joe Smith", decArt.getStateMgr().getAssigneesStr());
+ Assert.assertEquals(ReviewBlockType.Commit.name(), decArt.getSoleAttributeValue(AtsAttributeTypes.ReviewBlocks));
+ Assert.assertEquals("This is the title", decArt.getName());
+ Assert.assertEquals("the description", decArt.getSoleAttributeValue(AtsAttributeTypes.Description));
+ Assert.assertEquals(implement.getPageName(), decArt.getSoleAttributeValue(AtsAttributeTypes.RelatedToState));
+
+ AtsTestUtil.validateArtifactCache();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/DecisionReviewManagerTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/DecisionReviewManagerTest.java
new file mode 100644
index 0000000000..d4e84bf093
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/DecisionReviewManagerTest.java
@@ -0,0 +1,162 @@
+/*
+ * Created on Jun 7, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.review;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.AtsTestUtil;
+import org.eclipse.osee.ats.core.team.TeamState;
+import org.eclipse.osee.ats.core.team.TeamWorkFlowArtifact;
+import org.eclipse.osee.ats.core.type.AtsAttributeTypes;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
+import org.eclipse.osee.ats.core.workdef.DecisionReviewOption;
+import org.eclipse.osee.ats.core.workdef.ReviewBlockType;
+import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.IBasicUser;
+import org.eclipse.osee.framework.skynet.core.UserManager;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
+import org.eclipse.osee.support.test.util.DemoUsers;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * Test for {@link DecisionReviewManager}
+ *
+ * @author Donald G. Dunne
+ */
+public class DecisionReviewManagerTest extends DecisionReviewManager {
+
+ @BeforeClass
+ @AfterClass
+ public static void cleanup() throws Exception {
+ AtsTestUtil.cleanup();
+ }
+
+ @org.junit.Test
+ public void testGetDecisionReviewOptionsStr() throws OseeCoreException {
+ Assert.assertEquals("Yes;Followup;<Joe Smith>\nNo;Completed;\n",
+ DecisionReviewManager.getDecisionReviewOptionsString(DecisionReviewManager.getDefaultDecisionReviewOptions()));
+ }
+
+ @org.junit.Test
+ public void testCreateNewDecisionReviewAndTransitionToDecision__Normal() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("DecisionReviewManagerTest - Normal");
+ TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();
+
+ List<DecisionReviewOption> options = new ArrayList<DecisionReviewOption>();
+ options.add(new DecisionReviewOption(DecisionReviewState.Completed.getPageName(), false, null));
+ options.add(new DecisionReviewOption(DecisionReviewState.Followup.getPageName(), true,
+ Arrays.asList(UserManager.getUser().getUserId())));
+
+ // create and transition decision review
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ String reviewTitle = "Test Review - " + teamWf.getName();
+ DecisionReviewArtifact decRev =
+ DecisionReviewManager.createNewDecisionReviewAndTransitionToDecision(teamWf, reviewTitle, "my description",
+ AtsTestUtil.getAnalyzeStateDef().getPageName(), ReviewBlockType.Transition, options,
+ Arrays.asList((IBasicUser) UserManager.getUser()), new Date(), UserManager.getUser(), transaction);
+ transaction.execute();
+
+ Assert.assertNotNull(decRev);
+ Assert.assertFalse(
+ String.format("Decision Review artifact should not be dirty [%s]", Artifacts.getDirtyReport(decRev)),
+ decRev.isDirty());
+ Assert.assertEquals(DecisionReviewState.Decision.getPageName(), decRev.getCurrentStateName());
+ Assert.assertEquals("Joe Smith", decRev.getStateMgr().getAssigneesStr());
+
+ }
+
+ @org.junit.Test
+ public void testCreateNewDecisionReviewAndTransitionToDecision__UnAssigned() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("DecisionReviewManagerTest - UnAssigned");
+ TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();
+
+ List<DecisionReviewOption> options = new ArrayList<DecisionReviewOption>();
+ options.add(new DecisionReviewOption(DecisionReviewState.Completed.getPageName(), false, null));
+ options.add(new DecisionReviewOption(DecisionReviewState.Followup.getPageName(), true,
+ Arrays.asList(UserManager.getUser().getUserId())));
+
+ // create and transition decision review
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ String reviewTitle = "Test Review - " + teamWf.getName();
+ DecisionReviewArtifact decRev =
+ DecisionReviewManager.createNewDecisionReviewAndTransitionToDecision(teamWf, reviewTitle, "my description",
+ AtsTestUtil.getAnalyzeStateDef().getPageName(), ReviewBlockType.Transition, options,
+ Arrays.asList((IBasicUser) UserManager.getUser(SystemUser.UnAssigned)), new Date(), UserManager.getUser(),
+ transaction);
+ transaction.execute();
+
+ Assert.assertNotNull(decRev);
+ Assert.assertEquals(reviewTitle, decRev.getName());
+ Assert.assertFalse(
+ String.format("Decision Review artifact should not be dirty [%s]", Artifacts.getDirtyReport(decRev)),
+ decRev.isDirty());
+ Assert.assertEquals(DecisionReviewState.Decision.getPageName(), decRev.getCurrentStateName());
+ Assert.assertEquals("UnAssigned", decRev.getStateMgr().getAssigneesStr());
+
+ }
+
+ @org.junit.Test
+ public void testCreateNewDecisionReview__Base() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("DecisionReviewManagerTest - Base");
+ TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();
+
+ String reviewTitle = "Test Review - " + teamWf.getName();
+ DecisionReviewArtifact decRev =
+ DecisionReviewManager.createNewDecisionReview(teamWf, ReviewBlockType.Commit, reviewTitle,
+ TeamState.Implement.getPageName(), "description", DecisionReviewManager.getDefaultDecisionReviewOptions(),
+ Arrays.asList((IBasicUser) UserManager.getUser(DemoUsers.Alex_Kay)), new Date(), UserManager.getUser());
+
+ Assert.assertNotNull(decRev);
+ Assert.assertEquals(reviewTitle, decRev.getName());
+ Assert.assertEquals(DecisionReviewState.Prepare.getPageName(), decRev.getCurrentStateName());
+ Assert.assertEquals("Alex Kay", decRev.getStateMgr().getAssigneesStr());
+ Assert.assertEquals(TeamState.Implement.getPageName(),
+ decRev.getSoleAttributeValue(AtsAttributeTypes.RelatedToState));
+ Assert.assertEquals(ReviewBlockType.Commit.name(), decRev.getSoleAttributeValue(AtsAttributeTypes.ReviewBlocks));
+ }
+
+ @org.junit.Test
+ public void testCreateNewDecisionReview__BaseUnassigned() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("DecisionReviewManagerTest - BaseUnassigned");
+ TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();
+
+ String reviewTitle = "Test Review - " + teamWf.getName();
+ DecisionReviewArtifact decRev =
+ DecisionReviewManager.createNewDecisionReview(teamWf, ReviewBlockType.Commit, reviewTitle,
+ TeamState.Implement.getPageName(), "description", DecisionReviewManager.getDefaultDecisionReviewOptions(),
+ Arrays.asList((IBasicUser) UserManager.getUser(SystemUser.UnAssigned)), new Date(), UserManager.getUser());
+
+ Assert.assertNotNull(decRev);
+ Assert.assertEquals(reviewTitle, decRev.getName());
+ Assert.assertEquals("UnAssigned", decRev.getStateMgr().getAssigneesStr());
+ }
+
+ @org.junit.Test
+ public void testCreateNewDecisionReview__Sample() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("DecisionReviewManagerTest - Sample");
+ TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();
+
+ DecisionReviewArtifact decRev =
+ DecisionReviewManager.createNewDecisionReview(teamWf, ReviewBlockType.Commit, true, new Date(),
+ UserManager.getUser());
+
+ Assert.assertNotNull(decRev);
+ Assert.assertEquals("Should we do this? Yes will require followup, No will not", decRev.getName());
+ Assert.assertEquals(DecisionReviewState.Prepare.getPageName(), decRev.getCurrentStateName());
+ Assert.assertEquals("Joe Smith", decRev.getStateMgr().getAssigneesStr());
+ Assert.assertEquals(TeamState.Analyze.getPageName(),
+ decRev.getSoleAttributeValue(AtsAttributeTypes.RelatedToState));
+ Assert.assertEquals(ReviewBlockType.Commit.name(),
+ decRev.getSoleAttributeValue(AtsAttributeTypes.ReviewBlocks, ""));
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/PeerReviewDefinitionManagerTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/PeerReviewDefinitionManagerTest.java
new file mode 100644
index 0000000000..4b29a53e99
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/PeerReviewDefinitionManagerTest.java
@@ -0,0 +1,86 @@
+/*
+ * Created on Jun 8, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.review;
+
+import java.util.Arrays;
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.AtsTestUtil;
+import org.eclipse.osee.ats.core.team.TeamWorkFlowArtifact;
+import org.eclipse.osee.ats.core.type.AtsAttributeTypes;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
+import org.eclipse.osee.ats.core.workdef.PeerReviewDefinition;
+import org.eclipse.osee.ats.core.workdef.ReviewBlockType;
+import org.eclipse.osee.ats.core.workdef.StateDefinition;
+import org.eclipse.osee.ats.core.workdef.StateEventType;
+import org.eclipse.osee.ats.core.workflow.transition.TestTransitionHelper;
+import org.eclipse.osee.ats.core.workflow.transition.TransitionManager;
+import org.eclipse.osee.ats.core.workflow.transition.TransitionOption;
+import org.eclipse.osee.ats.core.workflow.transition.TransitionResults;
+import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.skynet.core.UserManager;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * Test unit for {@link PeerReviewDefinitionManager}
+ *
+ * @author Donald G. Dunne
+ */
+public class PeerReviewDefinitionManagerTest extends PeerReviewDefinitionManager {
+
+ @BeforeClass
+ @AfterClass
+ public static void cleanup() throws Exception {
+ AtsTestUtil.cleanup();
+ }
+
+ @org.junit.Test
+ public void testCreatePeerReviewDuringTransition() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("PeerReviewDefinitionManagerTest");
+
+ // configure WorkDefinition to create a new Review on transition to Implement
+ StateDefinition implement = AtsTestUtil.getImplementStateDef();
+
+ PeerReviewDefinition revDef = new PeerReviewDefinition("Create New on Implement");
+ revDef.setBlockingType(ReviewBlockType.Transition);
+ revDef.setDescription("the description");
+ revDef.setRelatedToState(implement.getPageName());
+ revDef.setStateEventType(StateEventType.TransitionTo);
+ revDef.setReviewTitle("This is my review title");
+ revDef.getAssignees().add(SystemUser.UnAssigned.getUserId());
+
+ implement.getPeerReviews().add(revDef);
+
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ Assert.assertEquals("No reviews should be present", 0, ReviewManager.getReviews(teamArt).size());
+
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ TestTransitionHelper helper =
+ new TestTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt), implement.getPageName(),
+ Arrays.asList(UserManager.getUser()), null, TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper, transaction);
+ TransitionResults results = transMgr.handleAll();
+ transaction.execute();
+
+ Assert.assertTrue(results.toString(), results.isEmpty());
+
+ Assert.assertEquals("One review should be present", 1, ReviewManager.getReviews(teamArt).size());
+ PeerToPeerReviewArtifact decArt = (PeerToPeerReviewArtifact) ReviewManager.getReviews(teamArt).iterator().next();
+
+ Assert.assertEquals(PeerToPeerReviewState.Prepare.getPageName(), decArt.getCurrentStateName());
+ Assert.assertEquals("UnAssigned", decArt.getStateMgr().getAssigneesStr());
+ Assert.assertEquals(ReviewBlockType.Transition.name(),
+ decArt.getSoleAttributeValue(AtsAttributeTypes.ReviewBlocks));
+ Assert.assertEquals("This is my review title", decArt.getName());
+ Assert.assertEquals("the description", decArt.getSoleAttributeValue(AtsAttributeTypes.Description));
+ Assert.assertEquals(implement.getPageName(), decArt.getSoleAttributeValue(AtsAttributeTypes.RelatedToState));
+
+ AtsTestUtil.validateArtifactCache();
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/PeerToPeerReviewManagerTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/PeerToPeerReviewManagerTest.java
new file mode 100644
index 0000000000..463238c585
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/PeerToPeerReviewManagerTest.java
@@ -0,0 +1,86 @@
+/*
+ * Created on Jun 8, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.review;
+
+import java.util.Date;
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.AtsTestUtil;
+import org.eclipse.osee.ats.core.team.TeamWorkFlowArtifact;
+import org.eclipse.osee.ats.core.type.AtsAttributeTypes;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
+import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.skynet.core.UserManager;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.framework.skynet.core.utility.Artifacts;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * Test unit for {@link PeerToPeerReviewManager}
+ *
+ * @author Donald G. Dunne
+ */
+public class PeerToPeerReviewManagerTest extends PeerToPeerReviewManager {
+
+ @BeforeClass
+ @AfterClass
+ public static void cleanup() throws Exception {
+ AtsTestUtil.cleanup();
+ }
+
+ @org.junit.Test
+ public void testCreateNewPeerToPeerReview__Base() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("PeerToPeerReviewManagerTest - Base");
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+
+ // create and transition peer review
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ String reviewTitle = "Test Review - " + teamArt.getName();
+
+ PeerToPeerReviewArtifact peerArt =
+ PeerToPeerReviewManager.createNewPeerToPeerReview(teamArt, reviewTitle,
+ AtsTestUtil.getAnalyzeStateDef().getPageName(), new Date(), UserManager.getUser(SystemUser.OseeSystem),
+ transaction);
+ transaction.execute();
+
+ Assert.assertNotNull(peerArt);
+ Assert.assertFalse(
+ String.format("PeerToPeer Review artifact should not be dirty [%s]", Artifacts.getDirtyReport(peerArt)),
+ peerArt.isDirty());
+ Assert.assertEquals(PeerToPeerReviewState.Prepare.getPageName(), peerArt.getCurrentStateName());
+ Assert.assertEquals("Joe Smith", peerArt.getStateMgr().getAssigneesStr());
+ Assert.assertEquals("OSEE System", peerArt.getCreatedBy().getName());
+ Assert.assertEquals(AtsTestUtil.getAnalyzeStateDef().getPageName(),
+ peerArt.getSoleAttributeValue(AtsAttributeTypes.RelatedToState));
+
+ }
+
+ @org.junit.Test
+ public void testCreateNewPeerToPeerReview__Simple() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("PeerToPeerReviewManagerTest - Simple");
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+
+ // create and transition peer review
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ String reviewTitle = "Test Review - " + teamArt.getName();
+
+ PeerToPeerReviewArtifact peerArt =
+ PeerToPeerReviewManager.createNewPeerToPeerReview(teamArt, reviewTitle,
+ AtsTestUtil.getAnalyzeStateDef().getPageName(), transaction);
+ transaction.execute();
+
+ Assert.assertNotNull(peerArt);
+ Assert.assertFalse(
+ String.format("PeerToPeer Review artifact should not be dirty [%s]", Artifacts.getDirtyReport(peerArt)),
+ peerArt.isDirty());
+ Assert.assertEquals(PeerToPeerReviewState.Prepare.getPageName(), peerArt.getCurrentStateName());
+ Assert.assertEquals("Joe Smith", peerArt.getStateMgr().getAssigneesStr());
+ Assert.assertEquals(AtsTestUtil.getAnalyzeStateDef().getPageName(),
+ peerArt.getSoleAttributeValue(AtsAttributeTypes.RelatedToState));
+
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/defect/AtsXDefectValidatorTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/defect/AtsXDefectValidatorTest.java
new file mode 100644
index 0000000000..b74462edc8
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/defect/AtsXDefectValidatorTest.java
@@ -0,0 +1,113 @@
+/*
+ * Created on May 20, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.review.defect;
+
+import java.util.Arrays;
+import java.util.Date;
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.review.defect.ReviewDefectItem.Disposition;
+import org.eclipse.osee.ats.core.review.defect.ReviewDefectItem.InjectionActivity;
+import org.eclipse.osee.ats.core.review.defect.ReviewDefectItem.Severity;
+import org.eclipse.osee.ats.core.validator.ValidatorTestUtil;
+import org.eclipse.osee.ats.core.validator.WidgetResult;
+import org.eclipse.osee.ats.core.validator.WidgetStatus;
+import org.eclipse.osee.ats.core.workdef.StateDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetOption;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.WorkPageType;
+
+/**
+ * Test unit for {@link AtsXDefectValidator}
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsXDefectValidatorTest {
+
+ @org.junit.Test
+ public void testValidateTransition() throws OseeCoreException {
+ AtsXDefectValidator validator = new AtsXDefectValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("xList");
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ // Valid for anything not XDefectViewer
+ WidgetResult result =
+ validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.setXWidgetName("XDefectViewer");
+
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+
+ // Reviews do not require Defects to be entered, even if required for transition
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Valid, result.getStatus());
+ }
+
+ @org.junit.Test
+ public void testValidateTransition__Defect() throws OseeCoreException {
+ AtsXDefectValidator validator = new AtsXDefectValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("XDefectViewer");
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ ReviewDefectItem item = getValidItem();
+ MockDefectValueProvider itemValueProvider = new MockDefectValueProvider(Arrays.asList(item));
+
+ // Valid defect
+ WidgetResult result = validator.validateTransition(itemValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Valid, result.getStatus());
+
+ // Invalid Severity
+ item = getValidItem();
+ item.setSeverity(Severity.None);
+ itemValueProvider = new MockDefectValueProvider(Arrays.asList(item));
+ result = validator.validateTransition(itemValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ Assert.assertEquals(ReviewDefectError.AllItemsMustBeMarkedAndClosed.getError(), result.getDetails());
+
+ // Invalid Disposition
+ item = getValidItem();
+ item.setDisposition(Disposition.None);
+ itemValueProvider = new MockDefectValueProvider(Arrays.asList(item));
+ result = validator.validateTransition(itemValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ Assert.assertEquals(ReviewDefectError.AllItemsMustBeMarkedAndClosed.getError(), result.getDetails());
+
+ // Invalid closed
+ item = getValidItem();
+ item.setClosed(false);
+ itemValueProvider = new MockDefectValueProvider(Arrays.asList(item));
+ result = validator.validateTransition(itemValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ Assert.assertEquals(ReviewDefectError.AllItemsMustBeMarkedAndClosed.getError(), result.getDetails());
+
+ }
+
+ private ReviewDefectItem getValidItem() {
+ Date date = new Date();
+ String userId = "1234";
+ ReviewDefectItem item =
+ new ReviewDefectItem(userId, Severity.Issue, Disposition.Accept, InjectionActivity.Software_Design,
+ "this is the description", "this is the resolution", "this is the location", date);
+ item.setClosed(true);
+ return item;
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/defect/MockDefectValueProvider.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/defect/MockDefectValueProvider.java
new file mode 100644
index 0000000000..db13c0c27a
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/defect/MockDefectValueProvider.java
@@ -0,0 +1,47 @@
+/*
+ * Created on Jun 13, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.review.defect;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import org.eclipse.osee.ats.core.validator.IValueProvider;
+import org.eclipse.osee.framework.jdk.core.util.AXml;
+
+public class MockDefectValueProvider implements IValueProvider {
+
+ private final List<ReviewDefectItem> defectItems;
+
+ public MockDefectValueProvider(List<ReviewDefectItem> defectItems) {
+ this.defectItems = defectItems;
+ }
+
+ @Override
+ public String getName() {
+ return "Defects";
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return defectItems.isEmpty();
+ }
+
+ @Override
+ public Collection<String> getValues() {
+ List<String> values = new ArrayList<String>();
+ for (ReviewDefectItem item : defectItems) {
+ values.add(AXml.addTagData("Item", item.toXml()));
+ }
+ return values;
+ }
+
+ @Override
+ public Collection<Date> getDateValues() {
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/defect/ReviewDefectItemTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/defect/ReviewDefectItemTest.java
new file mode 100644
index 0000000000..3aac472851
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/defect/ReviewDefectItemTest.java
@@ -0,0 +1,38 @@
+/*
+ * Created on Jun 13, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.review.defect;
+
+import java.util.Date;
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.review.defect.ReviewDefectItem.Disposition;
+import org.eclipse.osee.ats.core.review.defect.ReviewDefectItem.InjectionActivity;
+import org.eclipse.osee.ats.core.review.defect.ReviewDefectItem.Severity;
+
+/**
+ * Test unit for {@link ReviewDefectItem}
+ *
+ * @author Donald G. Dunne
+ */
+public class ReviewDefectItemTest {
+
+ @org.junit.Test
+ public void testToXmlFromXml() {
+ Date date = new Date();
+ ReviewDefectItem item =
+ new ReviewDefectItem("1234", Severity.Issue, Disposition.Duplicate, InjectionActivity.Software_Design,
+ "this is the description", "this is the resolution", "this is the location", date);
+
+ ReviewDefectItem fromItem = new ReviewDefectItem(item.toXml());
+ Assert.assertEquals("1234", fromItem.getUserId());
+ Assert.assertEquals(item.getSeverity(), fromItem.getSeverity());
+ Assert.assertEquals(item.getDisposition(), fromItem.getDisposition());
+ Assert.assertEquals(item.getInjectionActivity(), fromItem.getInjectionActivity());
+ Assert.assertEquals(item.getDescription(), fromItem.getDescription());
+ Assert.assertEquals(item.getResolution(), fromItem.getResolution());
+ Assert.assertEquals(item.getLocation(), fromItem.getLocation());
+ Assert.assertEquals(item.getDate(), fromItem.getDate());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/role/AtsXUserRoleValidatorTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/role/AtsXUserRoleValidatorTest.java
new file mode 100644
index 0000000000..7ef86c27e0
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/role/AtsXUserRoleValidatorTest.java
@@ -0,0 +1,95 @@
+/*
+ * Created on May 20, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.review.role;
+
+import java.util.Arrays;
+import java.util.List;
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.validator.ValidatorTestUtil;
+import org.eclipse.osee.ats.core.validator.WidgetResult;
+import org.eclipse.osee.ats.core.validator.WidgetStatus;
+import org.eclipse.osee.ats.core.workdef.StateDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetOption;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.WorkPageType;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class AtsXUserRoleValidatorTest {
+
+ @org.junit.Test
+ public void testValidateTransition() throws OseeCoreException {
+ AtsXUserRoleValidator validator = new AtsXUserRoleValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("xList");
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ // Valid for anything not XIntegerDam
+ WidgetResult result =
+ validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.setXWidgetName("XUserRoleViewer");
+
+ // Not valid to have no roles
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ Assert.assertEquals(UserRoleError.OneRoleEntryRequired.getError(), result.getDetails());
+
+ widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+
+ // Not valid to have no roles
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ Assert.assertEquals(UserRoleError.OneRoleEntryRequired.getError(), result.getDetails());
+ }
+
+ @org.junit.Test
+ public void testValidateTransition_Roles() throws OseeCoreException {
+ AtsXUserRoleValidator validator = new AtsXUserRoleValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("XUserRoleViewer");
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ UserRole author = new UserRole(Role.Author, "2134", 0.0, false);
+ UserRole reviewer = new UserRole(Role.Reviewer, "123");
+ List<UserRole> roles = Arrays.asList(author, reviewer);
+
+ MockUserRoleValueProvider provider = new MockUserRoleValueProvider(roles);
+
+ // Valid Roles
+ WidgetResult result = validator.validateTransition(provider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ // Not valid to have no author
+ roles = Arrays.asList(reviewer);
+ provider = new MockUserRoleValueProvider(roles);
+ result = validator.validateTransition(provider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ Assert.assertEquals(UserRoleError.MustHaveAtLeastOneAuthor.getError(), result.getDetails());
+
+ // Not valid to have no reviewer
+ roles = Arrays.asList(author);
+ provider = new MockUserRoleValueProvider(roles);
+ result = validator.validateTransition(provider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ Assert.assertEquals(UserRoleError.MustHaveAtLeastOneReviewer.getError(), result.getDetails());
+
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/role/MockUserRoleValueProvider.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/role/MockUserRoleValueProvider.java
new file mode 100644
index 0000000000..94291cc128
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/role/MockUserRoleValueProvider.java
@@ -0,0 +1,47 @@
+/*
+ * Created on Jun 13, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.review.role;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import org.eclipse.osee.ats.core.validator.IValueProvider;
+import org.eclipse.osee.framework.jdk.core.util.AXml;
+
+public class MockUserRoleValueProvider implements IValueProvider {
+
+ private final List<UserRole> roles;
+
+ public MockUserRoleValueProvider(List<UserRole> roles) {
+ this.roles = roles;
+ }
+
+ @Override
+ public String getName() {
+ return "Roles";
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return roles.isEmpty();
+ }
+
+ @Override
+ public Collection<String> getValues() {
+ List<String> values = new ArrayList<String>();
+ for (UserRole item : roles) {
+ values.add(AXml.addTagData("Role", item.toXml()));
+ }
+ return values;
+ }
+
+ @Override
+ public Collection<Date> getDateValues() {
+ return null;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/role/UserRoleTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/role/UserRoleTest.java
new file mode 100644
index 0000000000..477c6e8da8
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/review/role/UserRoleTest.java
@@ -0,0 +1,27 @@
+/*
+ * Created on Jun 13, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.review.role;
+
+import junit.framework.Assert;
+
+/**
+ * Test unit for {@link UserRole}
+ *
+ * @author Donald G. Dunne
+ */
+public class UserRoleTest {
+
+ @org.junit.Test
+ public void testToXmlFromXml() {
+ UserRole item = new UserRole(Role.Author, "1233", 23.3, true);
+
+ UserRole fromItem = new UserRole(item.toXml());
+ Assert.assertEquals("1233", fromItem.getUserId());
+ Assert.assertEquals(item.getRole(), fromItem.getRole());
+ Assert.assertEquals(item.getHoursSpent(), fromItem.getHoursSpent());
+ Assert.assertEquals(item.isCompleted(), fromItem.isCompleted());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/task/AtsCore_Task_PT_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/task/AtsCore_Task_PT_Suite.java
new file mode 100644
index 0000000000..377c766d02
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/task/AtsCore_Task_PT_Suite.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.core.task;
+
+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;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({TaskManagerTest.class})
+/**
+ * This test suite contains tests that must be run against demo database as Plugin JUnit (PT)
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsCore_Task_PT_Suite {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ OseeProperties.setIsInTest(true);
+ System.out.println("\n\nBegin " + AtsCore_Task_PT_Suite.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ System.out.println("End " + AtsCore_Task_PT_Suite.class.getSimpleName());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/task/TaskManagerTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/task/TaskManagerTest.java
new file mode 100644
index 0000000000..2eb13c9d4e
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/task/TaskManagerTest.java
@@ -0,0 +1,120 @@
+/*
+ * Created on Jun 8, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.task;
+
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.AtsTestUtil;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
+import org.eclipse.osee.ats.core.workflow.HoursSpentUtil;
+import org.eclipse.osee.ats.core.workflow.PercentCompleteTotalUtil;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.Result;
+import org.eclipse.osee.framework.skynet.core.UserManager;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * Test unit for {@link TaskManager}
+ *
+ * @author Donald G. Dunne
+ */
+public class TaskManagerTest extends TaskManager {
+
+ @BeforeClass
+ @AfterClass
+ public static void cleanup() throws OseeCoreException {
+ AtsTestUtil.cleanup();
+ }
+
+ @org.junit.Test
+ public void testTransitionToCompletedThenInWork() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("TaskManagerTest - TransitionToCompleted");
+
+ TaskArtifact taskArt = AtsTestUtil.getOrCreateTask();
+
+ // ensure nothing dirty
+ AtsTestUtil.validateArtifactCache();
+
+ // transition to Completed
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ Result result = TaskManager.transitionToCompleted(taskArt, 0.0, 3, transaction);
+ Assert.assertEquals(Result.TrueResult, result);
+ transaction.execute();
+
+ Assert.assertEquals(TaskStates.Completed.getPageName(), taskArt.getCurrentStateName());
+ Assert.assertEquals(3.0, HoursSpentUtil.getHoursSpentTotal(taskArt));
+ Assert.assertEquals("", taskArt.getStateMgr().getAssigneesStr());
+
+ // ensure nothing dirty
+ AtsTestUtil.validateArtifactCache();
+
+ // transition back to InWork
+ transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ result = TaskManager.transitionToInWork(taskArt, UserManager.getUser(), 45, .5, transaction);
+ Assert.assertEquals(Result.TrueResult, result);
+ transaction.execute();
+
+ Assert.assertEquals(TaskStates.InWork.getPageName(), taskArt.getCurrentStateName());
+ Assert.assertEquals(3.5, HoursSpentUtil.getHoursSpentTotal(taskArt));
+ Assert.assertEquals("Joe Smith", taskArt.getStateMgr().getAssigneesStr());
+
+ }
+
+ @org.junit.Test
+ public void testStatusPercentChanged() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("TaskManagerTest - StatusPercentChanged");
+
+ TaskArtifact taskArt = AtsTestUtil.getOrCreateTask();
+
+ // ensure nothing dirty
+ AtsTestUtil.validateArtifactCache();
+
+ // status 34% completed
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ Result result = TaskManager.statusPercentChanged(taskArt, 3, 34, transaction);
+ Assert.assertEquals(Result.TrueResult, result);
+ transaction.execute();
+
+ Assert.assertEquals(TaskStates.InWork.getPageName(), taskArt.getCurrentStateName());
+ Assert.assertEquals(3.0, HoursSpentUtil.getHoursSpentTotal(taskArt));
+ Assert.assertEquals(34, PercentCompleteTotalUtil.getPercentCompleteTotal(taskArt));
+ Assert.assertEquals("Joe Smith", taskArt.getStateMgr().getAssigneesStr());
+
+ // ensure nothing dirty
+ AtsTestUtil.validateArtifactCache();
+
+ // status 100% completed
+ transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ result = TaskManager.statusPercentChanged(taskArt, 3, 100, transaction);
+ Assert.assertEquals(Result.TrueResult, result);
+ transaction.execute();
+
+ Assert.assertEquals(TaskStates.Completed.getPageName(), taskArt.getCurrentStateName());
+ Assert.assertEquals(6.0, HoursSpentUtil.getHoursSpentTotal(taskArt));
+ Assert.assertEquals(100, PercentCompleteTotalUtil.getPercentCompleteTotal(taskArt));
+ Assert.assertEquals("", taskArt.getStateMgr().getAssigneesStr());
+
+ // ensure nothing dirty
+ AtsTestUtil.validateArtifactCache();
+
+ // status back to 25%
+ transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ result = TaskManager.statusPercentChanged(taskArt, 1, 25, transaction);
+ Assert.assertEquals(Result.TrueResult, result);
+ transaction.execute();
+
+ Assert.assertEquals(TaskStates.InWork.getPageName(), taskArt.getCurrentStateName());
+ Assert.assertEquals(7.0, HoursSpentUtil.getHoursSpentTotal(taskArt));
+ Assert.assertEquals(25, PercentCompleteTotalUtil.getPercentCompleteTotal(taskArt));
+ Assert.assertEquals("Joe Smith", taskArt.getStateMgr().getAssigneesStr());
+
+ // ensure nothing dirty
+ AtsTestUtil.validateArtifactCache();
+
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsCore_Validator_JT_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsCore_Validator_JT_Suite.java
new file mode 100644
index 0000000000..d63f9fc4aa
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsCore_Validator_JT_Suite.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * 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.core.validator;
+
+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;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ AtsXWidgetValidatorTest.class,
+ AtsXTextValidatorTest.class,
+ AtsXIntegerValidatorTest.class,
+ AtsXFloatValidatorTest.class,
+ AtsXDateValidatorTest.class,
+ AtsXListValidatorTest.class,
+ AtsXComboBooleanValidatorTest.class,
+ AtsXComboValidatorTest.class})
+/**
+ * This test suite contains tests that can be run as stand-alone JUnit tests (JT)
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsCore_Validator_JT_Suite {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ OseeProperties.setIsInTest(true);
+ System.out.println("\n\nBegin " + AtsCore_Validator_JT_Suite.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ System.out.println("End " + AtsCore_Validator_JT_Suite.class.getSimpleName());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXComboBooleanValidatorTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXComboBooleanValidatorTest.java
new file mode 100644
index 0000000000..fef9fbc389
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXComboBooleanValidatorTest.java
@@ -0,0 +1,50 @@
+/*
+ * Created on May 20, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.validator;
+
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.workdef.StateDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetOption;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.WorkPageType;
+
+/**
+ * Test unit for {@link AtsXComboBooleanValidator}
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsXComboBooleanValidatorTest {
+
+ @org.junit.Test
+ public void testValidateTransition() throws OseeCoreException {
+ AtsXComboBooleanValidator validator = new AtsXComboBooleanValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("xLabel");
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ // Valid for anything not XIntegerDam
+ WidgetResult result =
+ validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.setXWidgetName("XComboBooleanDam");
+
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+
+ // Not valid if widgetDef required and no values set
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXComboValidatorTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXComboValidatorTest.java
new file mode 100644
index 0000000000..3263089b6e
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXComboValidatorTest.java
@@ -0,0 +1,48 @@
+/*
+ * Created on May 20, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.validator;
+
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.workdef.StateDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetOption;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.WorkPageType;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class AtsXComboValidatorTest {
+
+ @org.junit.Test
+ public void testValidateTransition() throws OseeCoreException {
+ AtsXComboValidator validator = new AtsXComboValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("xLabel");
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ // Valid for anything not XIntegerDam
+ WidgetResult result =
+ validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.setXWidgetName("XComboDam");
+
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+
+ // Not valid if widgetDef required and no values set
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXDateValidatorTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXDateValidatorTest.java
new file mode 100644
index 0000000000..da1b350ac0
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXDateValidatorTest.java
@@ -0,0 +1,93 @@
+/*
+ * Created on May 20, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.validator;
+
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.workdef.StateDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetOption;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.WorkPageType;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class AtsXDateValidatorTest {
+
+ @org.junit.Test
+ public void testValidateTransition() throws OseeCoreException {
+ AtsXDateValidator validator = new AtsXDateValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("xList");
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ // Valid for anything not XIntegerDam
+ WidgetResult result =
+ validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.setXWidgetName("XDateDam");
+
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+
+ // Not valid if widgetDef required and no values set
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ }
+
+ @org.junit.Test
+ public void testValidateTransition_validDate() throws OseeCoreException {
+ AtsXDateValidator validator = new AtsXDateValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("XDateDam");
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ MockDateValueProvider dateProvider = new MockDateValueProvider(Arrays.asList(new Date()));
+
+ // Valid for valid date
+ WidgetResult result = validator.validateTransition(dateProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Valid, result.getStatus());
+ }
+
+ @org.junit.Test
+ public void testValidateTransition_validRange() throws OseeCoreException {
+ AtsXDateValidator validator = new AtsXDateValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("XDateDam");
+ widgetDef.getOptions().add(WidgetOption.FUTURE_DATE_REQUIRED);
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ Calendar cal = new GregorianCalendar(2010, 02, 05);
+ Date pastDate = cal.getTime();
+ MockDateValueProvider dateProvider = new MockDateValueProvider(Arrays.asList(pastDate, new Date()));
+
+ // Not valid for pastDate
+ WidgetResult result = validator.validateTransition(dateProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Range, result.getStatus());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXFloatValidatorTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXFloatValidatorTest.java
new file mode 100644
index 0000000000..2d5ad559ac
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXFloatValidatorTest.java
@@ -0,0 +1,90 @@
+/*
+ * Created on May 20, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.validator;
+
+import java.util.Arrays;
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.workdef.StateDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinitionFloatMinMaxConstraint;
+import org.eclipse.osee.ats.core.workdef.WidgetOption;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.WorkPageType;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class AtsXFloatValidatorTest {
+
+ @org.junit.Test
+ public void testValidateTransition() throws OseeCoreException {
+ AtsXFloatValidator validator = new AtsXFloatValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("xList");
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ // Valid for anything not XIntegerDam
+ WidgetResult result =
+ validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.setXWidgetName("XFloatDam");
+
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+
+ // Not valid if widgetDef required and no values set
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ }
+
+ @org.junit.Test
+ public void testValidateTransition_MinMaxConstraint() throws OseeCoreException {
+ AtsXFloatValidator validator = new AtsXFloatValidator();
+
+ WidgetDefinitionFloatMinMaxConstraint constraint = new WidgetDefinitionFloatMinMaxConstraint("0.0", "0.0");
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("XFloatDam");
+ widgetDef.getConstraints().add(constraint);
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ // Valid is nothing entered
+ WidgetResult result =
+ validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ //Invalid_Range if > than what should be
+ constraint.set(0.0, 2.0);
+ MockValueProvider provider = new MockValueProvider(Arrays.asList("0.0", "2.0", "3.0"));
+ result = validator.validateTransition(provider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Range, result.getStatus());
+
+ //Invalid_Range if less than supposed to
+ constraint.set(1.0, 2.0);
+ provider = new MockValueProvider(Arrays.asList("0.0"));
+ result = validator.validateTransition(provider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Range, result.getStatus());
+
+ //Valid if == what supposed to be
+ constraint.set(2.0, 2.0);
+ provider = new MockValueProvider(Arrays.asList("2.0", "2.0"));
+ result = validator.validateTransition(provider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXIntegerValidatorTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXIntegerValidatorTest.java
index af0264de19..bdea0cd9d1 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXIntegerValidatorTest.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXIntegerValidatorTest.java
@@ -5,9 +5,11 @@
*/
package org.eclipse.osee.ats.core.validator;
+import java.util.Arrays;
import junit.framework.Assert;
import org.eclipse.osee.ats.core.workdef.StateDefinition;
import org.eclipse.osee.ats.core.workdef.WidgetDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinitionIntMinMaxConstraint;
import org.eclipse.osee.ats.core.workdef.WidgetOption;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.WorkPageType;
@@ -15,7 +17,7 @@ import org.eclipse.osee.framework.core.util.WorkPageType;
/**
* @author Donald G. Dunne
*/
-public class AtsXIntegerValidatorTest extends AtsXIntegerValidator {
+public class AtsXIntegerValidatorTest {
@org.junit.Test
public void testValidateTransition() throws OseeCoreException {
@@ -24,22 +26,65 @@ public class AtsXIntegerValidatorTest extends AtsXIntegerValidator {
WidgetDefinition widgetDef = new WidgetDefinition("test");
widgetDef.setXWidgetName("xList");
- StateDefinition toStateDef = new StateDefinition("working");
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
toStateDef.setWorkPageType(WorkPageType.Working);
// Valid for anything not XIntegerDam
- WidgetResult result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, toStateDef);
+ WidgetResult result =
+ validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
ValidatorTestUtil.assertValidResult(result);
widgetDef.setXWidgetName("XIntegerDam");
- result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, toStateDef);
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
ValidatorTestUtil.assertValidResult(result);
widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
// Not valid if widgetDef required and no values set
- result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, toStateDef);
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
}
+
+ @org.junit.Test
+ public void testValidateTransition_MinMaxConstraint() throws OseeCoreException {
+ AtsXIntegerValidator validator = new AtsXIntegerValidator();
+
+ WidgetDefinitionIntMinMaxConstraint constraint = new WidgetDefinitionIntMinMaxConstraint("0", "0");
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("XIntegerDam");
+ widgetDef.getConstraints().add(constraint);
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ // Valid is nothing entered
+ WidgetResult result =
+ validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ //Invalid_Range if > than what should be
+ constraint.set(0, 2);
+ MockValueProvider provider = new MockValueProvider(Arrays.asList("0", "2", "3"));
+ result = validator.validateTransition(provider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Range, result.getStatus());
+
+ //Invalid_Range if less than supposed to
+ constraint.set(1, 2);
+ provider = new MockValueProvider(Arrays.asList("0"));
+ result = validator.validateTransition(provider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Range, result.getStatus());
+
+ //Valid if == what supposed to be
+ constraint.set(2, 2);
+ provider = new MockValueProvider(Arrays.asList("2", "2"));
+ result = validator.validateTransition(provider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXListValidatorTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXListValidatorTest.java
new file mode 100644
index 0000000000..26c822ddb3
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXListValidatorTest.java
@@ -0,0 +1,91 @@
+/*
+ * Created on May 20, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.validator;
+
+import java.util.Arrays;
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.workdef.StateDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinitionListMinMaxSelectedConstraint;
+import org.eclipse.osee.ats.core.workdef.WidgetOption;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.WorkPageType;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class AtsXListValidatorTest {
+
+ @org.junit.Test
+ public void testValidateTransition() throws OseeCoreException {
+ AtsXListValidator validator = new AtsXListValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("xLabel");
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ // Valid for anything not XIntegerDam
+ WidgetResult result =
+ validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.setXWidgetName("XListDam");
+
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+
+ // Not valid if widgetDef required and no values set
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ }
+
+ @org.junit.Test
+ public void testValidateTransition_MinMaxConstraint() throws OseeCoreException {
+ AtsXListValidator validator = new AtsXListValidator();
+
+ WidgetDefinitionListMinMaxSelectedConstraint constraint =
+ new WidgetDefinitionListMinMaxSelectedConstraint("0", "0");
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("XListDam");
+ widgetDef.getConstraints().add(constraint);
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ // Valid is nothing entered
+ WidgetResult result =
+ validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ //Invalid_Range if select more than supposed to
+ constraint.set(0, 2);
+ MockValueProvider provider = new MockValueProvider(Arrays.asList("this", "is", "selected"));
+ result = validator.validateTransition(provider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Range, result.getStatus());
+
+ //Invalid_Range if less than supposed to
+ constraint.set(2, 2);
+ provider = new MockValueProvider(Arrays.asList("this"));
+ result = validator.validateTransition(provider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Range, result.getStatus());
+
+ //Valid if less what supposed to
+ constraint.set(2, 2);
+ provider = new MockValueProvider(Arrays.asList("this", "is"));
+ result = validator.validateTransition(provider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXTextValidatorTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXTextValidatorTest.java
new file mode 100644
index 0000000000..1b072cd54e
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXTextValidatorTest.java
@@ -0,0 +1,48 @@
+/*
+ * Created on May 20, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.validator;
+
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.workdef.StateDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetOption;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.util.WorkPageType;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class AtsXTextValidatorTest {
+
+ @org.junit.Test
+ public void testValidateTransition() throws OseeCoreException {
+ AtsXTextValidator validator = new AtsXTextValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("xList");
+
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ // Valid for anything not XIntegerDam
+ WidgetResult result =
+ validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.setXWidgetName("XTextDam");
+
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+
+ // Not valid if widgetDef required and no values set
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidatorTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidatorTest.java
index a1bbda7748..fe5f9addbb 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidatorTest.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidatorTest.java
@@ -6,9 +6,12 @@
package org.eclipse.osee.ats.core.validator;
import java.util.Arrays;
+import java.util.Date;
import org.eclipse.osee.ats.core.workdef.StateDefinition;
import org.eclipse.osee.ats.core.workdef.WidgetDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinitionFloatMinMaxConstraint;
import org.eclipse.osee.ats.core.workdef.WidgetDefinitionIntMinMaxConstraint;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinitionListMinMaxSelectedConstraint;
import org.eclipse.osee.ats.core.workdef.WidgetOption;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.util.WorkPageType;
@@ -25,7 +28,7 @@ public class AtsXWidgetValidatorTest {
private static AtsXWidgetValidator validator = new AtsXWidgetValidator() {
@Override
- public WidgetResult validateTransition(IValueProvider valueProvider, WidgetDefinition widgetDef, StateDefinition toStateDef) {
+ public WidgetResult validateTransition(IValueProvider valueProvider, WidgetDefinition widgetDef, StateDefinition fromStateDef, StateDefinition toStateDef) {
return null;
}
};
@@ -67,15 +70,18 @@ public class AtsXWidgetValidatorTest {
}
@org.junit.Test
- public void testalidateWidgetIsRequired() throws OseeCoreException {
+ public void testValidateWidgetIsRequired() throws OseeCoreException {
WidgetDefinition widgetDef = new WidgetDefinition("test");
widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
- StateDefinition toStateDef = new StateDefinition("working state");
+ StateDefinition fromStateDef = new StateDefinition("from");
+ fromStateDef.setWorkPageType(WorkPageType.Working);
+ StateDefinition toStateDef = new StateDefinition("to");
toStateDef.setWorkPageType(WorkPageType.Working);
// widget required_for_transition, state is working state returns incomplete state and details
- WidgetResult result = validator.validateWidgetIsRequired(ValidatorTestUtil.emptyValueProvider, widgetDef, toStateDef);
+ WidgetResult result =
+ validator.validateWidgetIsRequired(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
Assert.assertEquals(widgetDef.getName(), result.getWidgetDef().getName());
Assert.assertTrue(Strings.isValid(result.getDetails()));
@@ -84,7 +90,8 @@ public class AtsXWidgetValidatorTest {
toStateDef.setWorkPageType(WorkPageType.Completed);
// widget required_for_transition, state is completed state, returns incomplete state and details
- result = validator.validateWidgetIsRequired(ValidatorTestUtil.emptyValueProvider, widgetDef, toStateDef);
+ result =
+ validator.validateWidgetIsRequired(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
Assert.assertEquals(widgetDef.getName(), result.getWidgetDef().getName());
Assert.assertTrue(Strings.isValid(result.getDetails()));
@@ -97,14 +104,16 @@ public class AtsXWidgetValidatorTest {
toStateDef.setWorkPageType(WorkPageType.Working);
// widget required_for_completed, state is working state returns Valid state and no details
- result = validator.validateWidgetIsRequired(ValidatorTestUtil.emptyValueProvider, widgetDef, toStateDef);
+ result =
+ validator.validateWidgetIsRequired(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
ValidatorTestUtil.assertValidResult(result);
toStateDef.setName("completed");
toStateDef.setWorkPageType(WorkPageType.Completed);
// widget required_for_completed, state is completed state, returns incomplete state and details
- result = validator.validateWidgetIsRequired(ValidatorTestUtil.emptyValueProvider, widgetDef, toStateDef);
+ result =
+ validator.validateWidgetIsRequired(ValidatorTestUtil.emptyValueProvider, widgetDef, fromStateDef, toStateDef);
Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
Assert.assertEquals(widgetDef.getName(), result.getWidgetDef().getName());
Assert.assertTrue(Strings.isValid(result.getDetails()));
@@ -180,4 +189,86 @@ public class AtsXWidgetValidatorTest {
Assert.assertTrue(Strings.isValid(result.getDetails()));
}
+ @org.junit.Test
+ public void testIsFloat() {
+ Assert.assertFalse(validator.isFloat("asf"));
+
+ Assert.assertFalse(validator.isFloat("4a"));
+
+ Assert.assertTrue(validator.isFloat("345.0"));
+ }
+
+ @org.junit.Test
+ public void testGetFloat() {
+ Assert.assertEquals(null, validator.getFloat("asf"));
+
+ Assert.assertEquals(null, validator.getFloat("4a"));
+
+ Assert.assertEquals(new Double(345.0), validator.getFloat("345.0"));
+ }
+
+ @org.junit.Test
+ public void testGetFloatMinMaxValueSet() {
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+
+ Assert.assertNull(validator.getConstraintOfType(widgetDef, WidgetDefinitionFloatMinMaxConstraint.class));
+ Assert.assertEquals(null, validator.getFloatMinValueSet(widgetDef));
+ Assert.assertEquals(null, validator.getFloatMaxValueSet(widgetDef));
+
+ WidgetDefinitionFloatMinMaxConstraint constraint = new WidgetDefinitionFloatMinMaxConstraint(34.3, 45.5);
+ widgetDef.getConstraints().add(constraint);
+
+ Assert.assertEquals(new Double(34.3), validator.getFloatMinValueSet(widgetDef));
+ Assert.assertEquals(new Double(45.5), validator.getFloatMaxValueSet(widgetDef));
+ }
+
+ @org.junit.Test
+ public void testIsValidFloat() throws OseeCoreException {
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+
+ WidgetResult result = validator.isValidFloat(new MockValueProvider(Arrays.asList("asdf", "345.0")), widgetDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Type, result.getStatus());
+ Assert.assertEquals(widgetDef.getName(), result.getWidgetDef().getName());
+ Assert.assertTrue(Strings.isValid(result.getDetails()));
+
+ result = validator.isValidFloat(new MockValueProvider(Arrays.asList("23.2", "345.0")), widgetDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ WidgetDefinitionFloatMinMaxConstraint constraint = new WidgetDefinitionFloatMinMaxConstraint(34.3, 45.5);
+ widgetDef.getConstraints().add(constraint);
+ result = validator.isValidFloat(new MockValueProvider(Arrays.asList("37.3", "42.1")), widgetDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ result = validator.isValidFloat(new MockValueProvider(Arrays.asList("12.0", "42.1")), widgetDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Range, result.getStatus());
+ Assert.assertEquals(widgetDef.getName(), result.getWidgetDef().getName());
+ Assert.assertTrue(Strings.isValid(result.getDetails()));
+ }
+
+ @org.junit.Test
+ public void testIsValidDate() throws OseeCoreException {
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+
+ WidgetResult result = validator.isValidDate(new MockDateValueProvider(Arrays.asList(new Date())), widgetDef);
+ Assert.assertEquals(WidgetStatus.Valid, result.getStatus());
+
+ }
+
+ @org.junit.Test
+ public void testGetListMinMaxValueSelected() {
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+
+ Assert.assertNull(validator.getConstraintOfType(widgetDef, WidgetDefinitionListMinMaxSelectedConstraint.class));
+ Assert.assertEquals(null, validator.getListMinSelected(widgetDef));
+ Assert.assertEquals(null, validator.getListMaxSelected(widgetDef));
+
+ WidgetDefinitionListMinMaxSelectedConstraint constraint = new WidgetDefinitionListMinMaxSelectedConstraint(2, 4);
+ widgetDef.getConstraints().add(constraint);
+
+ Assert.assertEquals(new Integer(2), validator.getListMinSelected(widgetDef));
+ Assert.assertEquals(new Integer(4), validator.getListMaxSelected(widgetDef));
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/MockDateValueProvider.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/MockDateValueProvider.java
new file mode 100644
index 0000000000..38665291c2
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/MockDateValueProvider.java
@@ -0,0 +1,29 @@
+/*
+ * Created on Jun 9, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.validator;
+
+import java.util.Collection;
+import java.util.Date;
+
+public class MockDateValueProvider extends MockValueProvider {
+
+ private final Collection<Date> dateValues;
+
+ public MockDateValueProvider(Collection<Date> dateValues) {
+ this(null, dateValues);
+ }
+
+ public MockDateValueProvider(String name, Collection<Date> dateValues) {
+ super(name, null);
+ this.dateValues = dateValues;
+ }
+
+ @Override
+ public Collection<Date> getDateValues() {
+ return dateValues;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/MockValueProvider.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/MockValueProvider.java
index 393c6b0534..b3d6b0a7bd 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/MockValueProvider.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/MockValueProvider.java
@@ -6,6 +6,8 @@
package org.eclipse.osee.ats.core.validator;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
/**
* @author Donald G. Dunne
@@ -39,4 +41,9 @@ public class MockValueProvider implements IValueProvider {
return values;
}
+ @Override
+ public Collection<Date> getDateValues() {
+ return Collections.emptyList();
+ }
+
}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/ValidatorTestUtil.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/ValidatorTestUtil.java
index b5dccaa917..16375d9172 100644
--- a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/ValidatorTestUtil.java
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/ValidatorTestUtil.java
@@ -18,7 +18,7 @@ public class ValidatorTestUtil {
public static void assertValidResult(WidgetResult result) {
Assert.assertEquals(WidgetStatus.Valid, result.getStatus());
Assert.assertNull(result.getWidgetDef());
- Assert.assertEquals("", result.getDetails());
+ Assert.assertEquals(WidgetStatus.Valid.name(), result.getDetails());
}
}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/transition/AtsCore_Transition_PT_Suite.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/transition/AtsCore_Transition_PT_Suite.java
new file mode 100644
index 0000000000..9cf017b541
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/transition/AtsCore_Transition_PT_Suite.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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.core.workflow.transition;
+
+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;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({TransitionManagerTest.class})
+/**
+ * This test suite contains tests that must be run against demo database as Plugin JUnit (PT)
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsCore_Transition_PT_Suite {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ OseeProperties.setIsInTest(true);
+ System.out.println("\n\nBegin " + AtsCore_Transition_PT_Suite.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ System.out.println("End " + AtsCore_Transition_PT_Suite.class.getSimpleName());
+ }
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/transition/TestTransitionHelper.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/transition/TestTransitionHelper.java
new file mode 100644
index 0000000000..5fc61bde63
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/transition/TestTransitionHelper.java
@@ -0,0 +1,99 @@
+/*
+ * Created on Jun 6, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.workflow.transition;
+
+import java.util.Collection;
+import org.eclipse.osee.ats.core.team.TeamWorkFlowArtifact;
+import org.eclipse.osee.ats.core.workflow.AbstractWorkflowArtifact;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.IBasicUser;
+
+/**
+ * Allows setting of workingBranchInWork and branchInCommit for testing purposes. If not set, uses default from
+ * TransitionHelper
+ *
+ * @author Donald G. Dunne
+ */
+public class TestTransitionHelper extends TransitionHelper {
+ public Boolean workingBranchInWork = null;
+ public Boolean branchInCommit = null;
+ public Boolean systemUser = null;
+ public Boolean systemUserAssigned = null;
+ public Boolean overrideTransitionValidityCheck = null;
+
+ public TestTransitionHelper(String name, Collection<? extends AbstractWorkflowArtifact> awas, String toStateName, Collection<? extends IBasicUser> toAssignees, String cancellationReason, TransitionOption... transitionOption) {
+ super(name, awas, toStateName, toAssignees, cancellationReason, transitionOption);
+ }
+
+ @Override
+ public boolean isWorkingBranchInWork(TeamWorkFlowArtifact teamArt) throws OseeCoreException {
+ if (workingBranchInWork != null) {
+ return workingBranchInWork;
+ }
+ return super.isWorkingBranchInWork(teamArt);
+ }
+
+ @Override
+ public boolean isBranchInCommit(TeamWorkFlowArtifact teamArt) throws OseeCoreException {
+ if (branchInCommit != null) {
+ return branchInCommit;
+ }
+ return super.isBranchInCommit(teamArt);
+ }
+
+ public Boolean getWorkingBranchInWork() {
+ return workingBranchInWork;
+ }
+
+ public void setWorkingBranchInWork(Boolean workingBranchInWork) {
+ this.workingBranchInWork = workingBranchInWork;
+ }
+
+ public Boolean getBranchInCommit() {
+ return branchInCommit;
+ }
+
+ public void setBranchInCommit(Boolean branchInCommit) {
+ this.branchInCommit = branchInCommit;
+ }
+
+ @Override
+ public boolean isSystemUser() throws OseeCoreException {
+ if (systemUser != null) {
+ return systemUser;
+ }
+ return super.isSystemUser();
+ }
+
+ public void setSystemUser(Boolean systemUser) {
+ this.systemUser = systemUser;
+ }
+
+ @Override
+ public boolean isSystemUserAssingee(AbstractWorkflowArtifact awa) throws OseeCoreException {
+ if (systemUserAssigned != null) {
+ return systemUserAssigned;
+ }
+ return super.isSystemUserAssingee(awa);
+ }
+
+ public void setSystemUserAssigned(Boolean systemUserAssigned) {
+ this.systemUserAssigned = systemUserAssigned;
+ }
+
+ @Override
+ public boolean isOverrideTransitionValidityCheck() {
+ if (overrideTransitionValidityCheck != null) {
+ return overrideTransitionValidityCheck;
+ }
+ return super.isOverrideTransitionValidityCheck();
+ }
+
+ public void setOverrideTransitionValidityCheck(Boolean overrideTransitionValidityCheck) {
+ this.overrideTransitionValidityCheck = overrideTransitionValidityCheck;
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/transition/TransitionManagerTest.java b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/transition/TransitionManagerTest.java
new file mode 100644
index 0000000000..64a3de5784
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/workflow/transition/TransitionManagerTest.java
@@ -0,0 +1,523 @@
+/**
+ * @author Donald G. Dunne
+ */
+package org.eclipse.osee.ats.core.workflow.transition;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import junit.framework.Assert;
+import org.eclipse.osee.ats.core.AtsTestUtil;
+import org.eclipse.osee.ats.core.review.DecisionReviewArtifact;
+import org.eclipse.osee.ats.core.review.DecisionReviewManager;
+import org.eclipse.osee.ats.core.review.DecisionReviewState;
+import org.eclipse.osee.ats.core.task.TaskArtifact;
+import org.eclipse.osee.ats.core.task.TaskManager;
+import org.eclipse.osee.ats.core.team.TeamState;
+import org.eclipse.osee.ats.core.team.TeamWorkFlowArtifact;
+import org.eclipse.osee.ats.core.type.AtsAttributeTypes;
+import org.eclipse.osee.ats.core.type.AtsRelationTypes;
+import org.eclipse.osee.ats.core.util.AtsUtilCore;
+import org.eclipse.osee.ats.core.workdef.ReviewBlockType;
+import org.eclipse.osee.ats.core.workdef.RuleDefinition;
+import org.eclipse.osee.ats.core.workdef.RuleDefinitionOption;
+import org.eclipse.osee.ats.core.workdef.StateDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetDefinition;
+import org.eclipse.osee.ats.core.workdef.WidgetOption;
+import org.eclipse.osee.ats.core.workflow.AbstractWorkflowArtifact;
+import org.eclipse.osee.framework.core.enums.SystemUser;
+import org.eclipse.osee.framework.core.exception.OseeCoreException;
+import org.eclipse.osee.framework.core.model.IBasicUser;
+import org.eclipse.osee.framework.core.util.IWorkPage;
+import org.eclipse.osee.framework.skynet.core.UserManager;
+import org.eclipse.osee.framework.skynet.core.transaction.SkynetTransaction;
+import org.eclipse.osee.support.test.util.DemoUsers;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * Test unit for {@link TransitionManager}
+ *
+ * @author Donald G. Dunne
+ */
+public class TransitionManagerTest {
+
+ private static List<AbstractWorkflowArtifact> EMPTY_AWAS = new ArrayList<AbstractWorkflowArtifact>();
+
+ @BeforeClass
+ @AfterClass
+ public static void cleanup() throws OseeCoreException {
+ AtsTestUtil.cleanup();
+ }
+
+ @org.junit.Test
+ public void testHandleTransitionPrep() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("TransitionManagerTest");
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ // make change that should be persisted
+ teamArt.setSoleAttributeValue(AtsAttributeTypes.PriorityType, "5");
+
+ Assert.assertTrue("Team WF should be dirty", teamArt.isDirty());
+
+ TransitionHelper helper =
+ new TransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt),
+ AtsTestUtil.getImplementStateDef().getPageName(), Arrays.asList(UserManager.getUser()), null,
+ TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+ transMgr.handleTransitionPrep(results);
+ Assert.assertTrue(results.isEmpty());
+
+ Assert.assertFalse("Team WF should NOT be dirty", teamArt.isDirty());
+ }
+
+ @org.junit.Test
+ public void testHandleTransitionValidation__NoAwas() throws OseeCoreException {
+ TransitionHelper helper =
+ new TransitionHelper(getClass().getSimpleName(), EMPTY_AWAS, AtsTestUtil.getImplementStateDef().getPageName(),
+ Arrays.asList(UserManager.getUser()), null, TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(TransitionResult.NO_WORKFLOWS_PROVIDED_FOR_TRANSITION));
+ }
+
+ @org.junit.Test
+ public void testHandleTransitionValidation__ToStateNotNull() throws OseeCoreException {
+ TransitionHelper helper =
+ new TransitionHelper(getClass().getSimpleName(), Arrays.asList(AtsTestUtil.getTeamWf()), null,
+ Arrays.asList(UserManager.getUser()), null, TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(TransitionResult.TO_STATE_CANT_BE_NULL));
+ }
+
+ @org.junit.Test
+ public void testHandleTransitionValidation__InvalidToState() throws OseeCoreException {
+ TransitionHelper helper =
+ new TransitionHelper(getClass().getSimpleName(), Arrays.asList(AtsTestUtil.getTeamWf()), "InvalidStateName",
+ Arrays.asList(UserManager.getUser()), null, TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains("Transition-To State [InvalidStateName] does not exist for Work Definition [" + AtsTestUtil.getTeamWf().getWorkDefinition().getName() + "]"));
+ }
+
+ @org.junit.Test
+ public void testHandleTransitionValidation__MustBeAssigned() throws OseeCoreException {
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ TransitionHelper helper =
+ new TransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt),
+ AtsTestUtil.getImplementStateDef().getPageName(), Arrays.asList(UserManager.getUser()), null,
+ TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+
+ // First transition should be valid cause Joe Smith is assigned cause he created
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.toString(), results.isEmpty());
+
+ // Un-Assign Joe Smith
+ results.clear();
+ Assert.assertFalse(helper.isPriviledgedEditEnabled());
+ Assert.assertFalse(helper.isOverrideAssigneeCheck());
+ teamArt.getStateMgr().setAssignee(UserManager.getUser(DemoUsers.Alex_Kay));
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(AtsTestUtil.getTeamWf(), TransitionResult.MUST_BE_ASSIGNED));
+
+ // Set PriviledgedEditEnabled edit enabled; no errors
+ results.clear();
+ Assert.assertFalse(helper.isOverrideAssigneeCheck());
+ helper.addTransitionOption(TransitionOption.PriviledgedEditEnabled);
+ Assert.assertTrue(helper.isPriviledgedEditEnabled());
+ teamArt.getStateMgr().setAssignee(UserManager.getUser(DemoUsers.Alex_Kay));
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ // Set OverrideAssigneeCheck
+ results.clear();
+ helper.removeTransitionOption(TransitionOption.PriviledgedEditEnabled);
+ helper.addTransitionOption(TransitionOption.OverrideAssigneeCheck);
+ Assert.assertFalse(helper.isPriviledgedEditEnabled());
+ Assert.assertTrue(helper.isOverrideAssigneeCheck());
+ teamArt.getStateMgr().setAssignee(UserManager.getUser(DemoUsers.Alex_Kay));
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ // Set UnAssigned, should be able to transition cause will be assigned as convenience
+ results.clear();
+ helper.removeTransitionOption(TransitionOption.OverrideAssigneeCheck);
+ Assert.assertFalse(helper.isPriviledgedEditEnabled());
+ Assert.assertFalse(helper.isOverrideAssigneeCheck());
+ teamArt.getStateMgr().setAssignee(UserManager.getUser(SystemUser.UnAssigned));
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ // cleanup test
+ teamArt.getStateMgr().setAssignee(UserManager.getUser(SystemUser.UnAssigned));
+ }
+
+ @org.junit.Test
+ public void testHandleTransitionValidation__WorkingBranchTransitionable() throws OseeCoreException {
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ TestTransitionHelper helper =
+ new TestTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt),
+ AtsTestUtil.getImplementStateDef().getPageName(), Arrays.asList(UserManager.getUser()), null,
+ TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+
+ // this should pass
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue("Test wasn't reset to allow transition", results.isEmpty());
+
+ // attempt to transition to Implement with working branch
+ helper.setWorkingBranchInWork(true);
+ helper.setBranchInCommit(false);
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(AtsTestUtil.getTeamWf(), TransitionResult.WORKING_BRANCH_EXISTS));
+
+ // attempt to cancel workflow with working branch
+ results.clear();
+ helper.setWorkingBranchInWork(true);
+ helper.setBranchInCommit(false);
+ helper.setToStateName(TeamState.Cancelled.getPageName());
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(AtsTestUtil.getTeamWf(), TransitionResult.DELETE_WORKING_BRANCH_BEFORE_CANCEL));
+
+ // attempt to transition workflow with branch being committed
+ results.clear();
+ helper.setWorkingBranchInWork(true);
+ helper.setBranchInCommit(true);
+ helper.setToStateName(TeamState.Implement.getPageName());
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(AtsTestUtil.getTeamWf(), TransitionResult.WORKING_BRANCH_BEING_COMMITTED));
+ }
+
+ @org.junit.Test
+ public void testHandleTransitionValidation__NoSystemUser() throws OseeCoreException {
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ TestTransitionHelper helper =
+ new TestTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt),
+ AtsTestUtil.getImplementStateDef().getPageName(), Arrays.asList(UserManager.getUser()), null,
+ TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+
+ // First transition should be valid cause Joe Smith is assigned cause he created
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ helper.setSystemUser(true);
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(TransitionResult.CAN_NOT_TRANSITION_AS_SYSTEM_USER));
+
+ results.clear();
+ helper.setSystemUser(false);
+ helper.setSystemUserAssigned(true);
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(teamArt, TransitionResult.CAN_NOT_TRANSITION_WITH_SYSTEM_USER_ASSIGNED));
+ }
+
+ @org.junit.Test
+ public void testIsStateTransitionable__ValidateXWidgets__RequiredForTransition() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("TransitionManagerTest-1");
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ TestTransitionHelper helper =
+ new TestTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt),
+ AtsTestUtil.getImplementStateDef().getPageName(), Arrays.asList(UserManager.getUser()), null,
+ TransitionOption.None);
+ StateDefinition fromStateDef = AtsTestUtil.getAnalyzeStateDef();
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+
+ // test that normal transition works
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue("Test wasn't reset to allow transition", results.isEmpty());
+
+ WidgetDefinition estHoursWidget = AtsTestUtil.getEstHoursWidgetDef();
+ fromStateDef.getStateItems().add(estHoursWidget);
+ WidgetDefinition workPackageWidget = AtsTestUtil.getWorkPackageWidgetDef();
+ fromStateDef.getStateItems().add(workPackageWidget);
+
+ // test that two widgets validate
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ // test that estHours required fails validation
+ results.clear();
+ estHoursWidget.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains("[Estimated Hours] is required for transition"));
+
+ // test that workPackage required fails both widgets
+ results.clear();
+ workPackageWidget.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains("[Estimated Hours] is required for transition"));
+ Assert.assertTrue(results.contains("[Work Package] is required for transition"));
+ }
+
+ @org.junit.Test
+ public void testIsStateTransitionable__ValidateXWidgets__RequiredForCompletion() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("TransitionManagerTest-2");
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ TestTransitionHelper helper =
+ new TestTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt),
+ AtsTestUtil.getImplementStateDef().getPageName(), Arrays.asList(UserManager.getUser()), null,
+ TransitionOption.None);
+ StateDefinition fromStateDef = AtsTestUtil.getAnalyzeStateDef();
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+
+ // test that normal transition works
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue("Test wasn't reset to allow transition", results.isEmpty());
+
+ WidgetDefinition estHoursWidget = AtsTestUtil.getEstHoursWidgetDef();
+ fromStateDef.getStateItems().add(estHoursWidget);
+ WidgetDefinition workPackageWidget = AtsTestUtil.getWorkPackageWidgetDef();
+ fromStateDef.getStateItems().add(workPackageWidget);
+
+ // test that two widgets validate
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ // test that Work Package only widget required for normal transition
+ results.clear();
+ helper.setToStateName(AtsTestUtil.getImplementStateDef().getPageName());
+ estHoursWidget.getOptions().add(WidgetOption.REQUIRED_FOR_COMPLETION);
+ workPackageWidget.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains("[Work Package] is required for transition"));
+
+ // test that Estimated House and Work Package required for transition to completed
+ results.clear();
+ helper.setToStateName(AtsTestUtil.getCompletedStateDef().getPageName());
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains("[Estimated Hours] is required for transition to [Completed]"));
+ Assert.assertTrue(results.contains("[Work Package] is required for transition"));
+
+ // test that neither are required for transition to canceled
+ results.clear();
+ helper.setToStateName(AtsTestUtil.getCancelledStateDef().getPageName());
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ // test that neither are required for transition to completed if overrideValidation is set
+ results.clear();
+ helper.setToStateName(AtsTestUtil.getCompletedStateDef().getPageName());
+ helper.setOverrideTransitionValidityCheck(true);
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+ }
+
+ @org.junit.Test
+ public void testIsStateTransitionable__ValidateTasks() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("TransitionManagerTest-3");
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ TestTransitionHelper helper =
+ new TestTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt),
+ AtsTestUtil.getImplementStateDef().getPageName(), Arrays.asList(UserManager.getUser()), null,
+ TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+
+ // validate that can transition
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ // validate that can't transition with InWork task
+ TaskArtifact taskArt = teamArt.createNewTask("New Tasks", new Date(), UserManager.getUser());
+ results.clear();
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(teamArt, TransitionResult.TASKS_NOT_COMPLETED));
+
+ // transition task to completed
+ results.clear();
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ TaskManager.transitionToCompleted(taskArt, 0.0, 0.1, transaction);
+ transaction.execute();
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ }
+
+ @org.junit.Test
+ public void testIsStateTransitionable__RequireTargetedVersion__FromTeamDef() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("TransitionManagerTest-4");
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ TestTransitionHelper helper =
+ new TestTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt),
+ AtsTestUtil.getImplementStateDef().getPageName(), Arrays.asList(UserManager.getUser()), null,
+ TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+
+ // validate that can transition
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ // validate that can't transition without targeted version when team def rule is set
+ teamArt.getTeamDefinition().addAttribute(AtsAttributeTypes.RuleDefinition,
+ RuleDefinitionOption.RequireTargetedVersion.name());
+ results.clear();
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(teamArt, TransitionResult.MUST_BE_TARGETED_FOR_VERSION));
+
+ // set targeted version; transition validation should succeed
+ results.clear();
+ teamArt.addRelation(AtsRelationTypes.TeamWorkflowTargetedForVersion_Version, AtsTestUtil.getVerArt1());
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+ }
+
+ @org.junit.Test
+ public void testIsStateTransitionable__RequireTargetedVersion__FromPageDef() throws OseeCoreException {
+ AtsTestUtil.cleanupAndReset("TransitionManagerTest-5");
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ TestTransitionHelper helper =
+ new TestTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt),
+ AtsTestUtil.getImplementStateDef().getPageName(), Arrays.asList(UserManager.getUser()), null,
+ TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+
+ // validate that can transition
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ // validate that can't transition without targeted version when team def rule is set
+ AtsTestUtil.getAnalyzeStateDef().addRule(new RuleDefinition(RuleDefinitionOption.RequireTargetedVersion),
+ "from test");
+ results.clear();
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(teamArt, TransitionResult.MUST_BE_TARGETED_FOR_VERSION));
+
+ // set targeted version; transition validation should succeed
+ results.clear();
+ teamArt.addRelation(AtsRelationTypes.TeamWorkflowTargetedForVersion_Version, AtsTestUtil.getVerArt1());
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+ }
+
+ @org.junit.Test
+ public void testIsStateTransitionable__ReviewsCompleted() throws OseeCoreException {
+
+ AtsTestUtil.cleanupAndReset("TransitionManagerTest-6");
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ TestTransitionHelper helper =
+ new TestTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt),
+ AtsTestUtil.getImplementStateDef().getPageName(), Arrays.asList(UserManager.getUser()), null,
+ TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+
+ // validate that can transition
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ DecisionReviewArtifact decArt =
+ AtsTestUtil.getOrCreateDecisionReview(ReviewBlockType.None, AtsTestUtil.getAnalyzeStateDef().getPageName());
+ teamArt.addRelation(AtsRelationTypes.TeamWorkflowToReview_Review, decArt);
+
+ // validate that can transition cause non-blocking review
+ results.clear();
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ // validate that can transition cause no transition blocking review
+ results.clear();
+ decArt.setSoleAttributeValue(AtsAttributeTypes.ReviewBlocks, ReviewBlockType.Commit.name());
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ // validate that can NOT transition cause blocking review
+ results.clear();
+ decArt.setSoleAttributeValue(AtsAttributeTypes.ReviewBlocks, ReviewBlockType.Transition.name());
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(teamArt, TransitionResult.COMPLETE_BLOCKING_REVIEWS));
+
+ // validate that can transition cause review completed
+ results.clear();
+ SkynetTransaction transaction = new SkynetTransaction(AtsUtilCore.getAtsBranch(), getClass().getSimpleName());
+ DecisionReviewManager.transitionTo(decArt, DecisionReviewState.Completed, UserManager.getUser(), false,
+ transaction);
+ transaction.execute();
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+ }
+
+ @org.junit.Test
+ public void testHandleTransitionValidation__ExtensionPointCheck() throws OseeCoreException {
+
+ AtsTestUtil.cleanupAndReset("TransitionManagerTest-7");
+ TeamWorkFlowArtifact teamArt = AtsTestUtil.getTeamWf();
+ TestTransitionHelper helper =
+ new TestTransitionHelper(getClass().getSimpleName(), Arrays.asList(teamArt),
+ AtsTestUtil.getImplementStateDef().getPageName(), Arrays.asList(UserManager.getUser()), null,
+ TransitionOption.None);
+ TransitionManager transMgr = new TransitionManager(helper);
+ TransitionResults results = new TransitionResults();
+
+ // validate that can transition
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.isEmpty());
+
+ // add transition listeners and verify can't transition
+ final String reason1 = "Don't want you to transition";
+ final String reason2 = "Don't transition yet";
+ final String exceptionStr = "This is the exception message";
+ ITransitionListener listener1 = new TransitionAdapter() {
+
+ @Override
+ public void transitioning(TransitionResults results, AbstractWorkflowArtifact sma, IWorkPage fromState, IWorkPage toState, Collection<? extends IBasicUser> toAssignees) {
+ results.addResult(new TransitionResult(reason1));
+ }
+
+ };
+ ITransitionListener listener2 = new TransitionAdapter() {
+
+ @Override
+ public void transitioning(TransitionResults results, AbstractWorkflowArtifact sma, IWorkPage fromState, IWorkPage toState, Collection<? extends IBasicUser> toAssignees) {
+ results.addResult(sma, new TransitionResult(reason2));
+ }
+
+ };
+ ITransitionListener listener3 = new TransitionAdapter() {
+
+ @Override
+ public void transitioning(TransitionResults results, AbstractWorkflowArtifact sma, IWorkPage fromState, IWorkPage toState, Collection<? extends IBasicUser> toAssignees) {
+ // do nothing
+ }
+
+ };
+ ITransitionListener listener4 = new TransitionAdapter() {
+
+ @Override
+ public void transitioning(TransitionResults results, AbstractWorkflowArtifact sma, IWorkPage fromState, IWorkPage toState, Collection<? extends IBasicUser> toAssignees) throws OseeCoreException {
+ throw new OseeCoreException(exceptionStr);
+ }
+
+ };
+ try {
+ TransitionManager.addListener(listener1);
+ TransitionManager.addListener(listener2);
+ TransitionManager.addListener(listener3);
+ TransitionManager.addListener(listener4);
+
+ transMgr.handleTransitionValidation(results);
+ Assert.assertTrue(results.contains(reason1));
+ Assert.assertTrue(results.contains(reason2));
+ Assert.assertTrue(results.contains(exceptionStr));
+ } finally {
+ TransitionManager.removeListener(listener1);
+ TransitionManager.removeListener(listener2);
+ TransitionManager.removeListener(listener3);
+ TransitionManager.removeListener(listener4);
+ }
+ }
+}

Back to the top