Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorddunne2011-05-20 14:03:01 -0400
committerRyan D. Brooks2011-05-20 14:03:01 -0400
commit26092c8506d68907539583a42195249f2b2884ff (patch)
tree0203a51208704478a9eda48844bfbf70c8e77bb5 /plugins/org.eclipse.osee.ats.core.test
parentfb6f6d04469e126dfe133bffcc3bacf0842564f0 (diff)
downloadorg.eclipse.osee-26092c8506d68907539583a42195249f2b2884ff.tar.gz
org.eclipse.osee-26092c8506d68907539583a42195249f2b2884ff.tar.xz
org.eclipse.osee-26092c8506d68907539583a42195249f2b2884ff.zip
refactor: Add ats.core.test
Diffstat (limited to 'plugins/org.eclipse.osee.ats.core.test')
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/.classpath7
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/.project28
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/META-INF/MANIFEST.MF9
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/build.properties4
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_Validation_Suite.java39
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXIntegerValidatorTest.java45
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidatorTest.java183
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/MockValueProvider.java42
-rw-r--r--plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/ValidatorTestUtil.java24
9 files changed, 381 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.ats.core.test/.classpath b/plugins/org.eclipse.osee.ats.core.test/.classpath
new file mode 100644
index 0000000000..ad32c83a78
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.ats.core.test/.project b/plugins/org.eclipse.osee.ats.core.test/.project
new file mode 100644
index 0000000000..564e2e3d7f
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.ats.core.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
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
new file mode 100644
index 0000000000..ebc2ca5ee4
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: ATS Core Test
+Bundle-SymbolicName: org.eclipse.osee.ats.core.test
+Bundle-Version: 1.0.0.qualifier
+Bundle-Vendor: The Boeing Company
+Fragment-Host: org.eclipse.osee.ats.core
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.junit
diff --git a/plugins/org.eclipse.osee.ats.core.test/build.properties b/plugins/org.eclipse.osee.ats.core.test/build.properties
new file mode 100644
index 0000000000..34d2e4d2da
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
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/AtsCore_Validation_Suite.java
new file mode 100644
index 0000000000..085c92f3dd
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/AtsCore_Validation_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.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;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({AtsXWidgetValidatorTest.class, AtsXIntegerValidatorTest.class})
+/**
+ * This test suite contains tests that must be run against demo database
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsCore_Validation_Suite {
+ @BeforeClass
+ public static void setUp() throws Exception {
+ OseeProperties.setIsInTest(true);
+ System.out.println("\n\nBegin " + AtsCore_Validation_Suite.class.getSimpleName());
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ System.out.println("End " + AtsCore_Validation_Suite.class.getSimpleName());
+ }
+}
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
new file mode 100644
index 0000000000..af0264de19
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXIntegerValidatorTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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 AtsXIntegerValidatorTest extends AtsXIntegerValidator {
+
+ @org.junit.Test
+ public void testValidateTransition() throws OseeCoreException {
+ AtsXIntegerValidator validator = new AtsXIntegerValidator();
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.setXWidgetName("xList");
+
+ StateDefinition toStateDef = new StateDefinition("working");
+ toStateDef.setWorkPageType(WorkPageType.Working);
+
+ // Valid for anything not XIntegerDam
+ WidgetResult result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, toStateDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ widgetDef.setXWidgetName("XIntegerDam");
+
+ result = validator.validateTransition(ValidatorTestUtil.emptyValueProvider, widgetDef, 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);
+ 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
new file mode 100644
index 0000000000..a1bbda7748
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/AtsXWidgetValidatorTest.java
@@ -0,0 +1,183 @@
+/*
+ * Created on May 19, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.validator;
+
+import java.util.Arrays;
+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;
+import org.eclipse.osee.framework.jdk.core.util.Strings;
+import org.junit.Assert;
+
+/**
+ * Test unit for {@link AtsXWidgetValidator}
+ *
+ * @author Donald G. Dunne
+ */
+public class AtsXWidgetValidatorTest {
+
+ private static AtsXWidgetValidator validator = new AtsXWidgetValidator() {
+
+ @Override
+ public WidgetResult validateTransition(IValueProvider valueProvider, WidgetDefinition widgetDef, StateDefinition toStateDef) {
+ return null;
+ }
+ };
+
+ @org.junit.Test
+ public void testIsTransitionToComplete() {
+ StateDefinition stateDef = new StateDefinition("test state");
+ stateDef.setWorkPageType(WorkPageType.Working);
+ Assert.assertFalse(validator.isTransitionToComplete(stateDef));
+ stateDef.setWorkPageType(WorkPageType.Completed);
+ Assert.assertTrue(validator.isTransitionToComplete(stateDef));
+ stateDef.setWorkPageType(WorkPageType.Cancelled);
+ Assert.assertFalse(validator.isTransitionToComplete(stateDef));
+ }
+
+ @org.junit.Test
+ public void testIsRequiredForTransition() {
+ WidgetDefinition widgetDef = new WidgetDefinition("test widget");
+ Assert.assertFalse(validator.isRequiredForTransition(widgetDef));
+
+ widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+ Assert.assertTrue(validator.isRequiredForTransition(widgetDef));
+ }
+
+ @org.junit.Test
+ public void testIsRequiredForCompleted() {
+ WidgetDefinition widgetDef = new WidgetDefinition("test widget");
+ Assert.assertFalse(validator.isRequiredForCompletion(widgetDef));
+
+ widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_COMPLETION);
+ Assert.assertTrue(validator.isRequiredForCompletion(widgetDef));
+ }
+
+ @org.junit.Test
+ public void testIsEmptyValue() throws OseeCoreException {
+ Assert.assertTrue(validator.isEmptyValue(ValidatorTestUtil.emptyValueProvider));
+
+ Assert.assertFalse(validator.isEmptyValue(new MockValueProvider(Arrays.asList("hello"))));
+ }
+
+ @org.junit.Test
+ public void testalidateWidgetIsRequired() throws OseeCoreException {
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+ widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_TRANSITION);
+
+ StateDefinition toStateDef = new StateDefinition("working state");
+ 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);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ Assert.assertEquals(widgetDef.getName(), result.getWidgetDef().getName());
+ Assert.assertTrue(Strings.isValid(result.getDetails()));
+
+ toStateDef.setName("completed");
+ toStateDef.setWorkPageType(WorkPageType.Completed);
+
+ // widget required_for_transition, state is completed state, returns incomplete state and details
+ result = validator.validateWidgetIsRequired(ValidatorTestUtil.emptyValueProvider, widgetDef, toStateDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ Assert.assertEquals(widgetDef.getName(), result.getWidgetDef().getName());
+ Assert.assertTrue(Strings.isValid(result.getDetails()));
+
+ // change widget to required_for_completed, turn off required_for_transition
+ widgetDef.getOptions().add(WidgetOption.NOT_REQUIRED_FOR_TRANSITION);
+ widgetDef.getOptions().add(WidgetOption.REQUIRED_FOR_COMPLETION);
+
+ toStateDef.setName("working state");
+ 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);
+ 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);
+ Assert.assertEquals(WidgetStatus.Invalid_Incompleted, result.getStatus());
+ Assert.assertEquals(widgetDef.getName(), result.getWidgetDef().getName());
+ Assert.assertTrue(Strings.isValid(result.getDetails()));
+ }
+
+ @org.junit.Test
+ public void testIsInteger() {
+ Assert.assertFalse(validator.isInteger("asf"));
+
+ Assert.assertFalse(validator.isInteger("4.5"));
+
+ Assert.assertTrue(validator.isInteger("345"));
+ }
+
+ @org.junit.Test
+ public void testGetInteger() {
+ Assert.assertEquals(null, validator.getInteger("asf"));
+
+ Assert.assertEquals(null, validator.getInteger("4.5"));
+
+ Assert.assertEquals(new Integer(345), validator.getInteger("345"));
+ }
+
+ @org.junit.Test
+ public void testGetConstraintOfType() {
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+
+ Assert.assertNull(validator.getConstraintOfType(widgetDef, WidgetDefinitionIntMinMaxConstraint.class));
+
+ WidgetDefinitionIntMinMaxConstraint constraint = new WidgetDefinitionIntMinMaxConstraint(34, 45);
+ widgetDef.getConstraints().add(constraint);
+
+ Assert.assertEquals(constraint,
+ validator.getConstraintOfType(widgetDef, WidgetDefinitionIntMinMaxConstraint.class));
+ }
+
+ @org.junit.Test
+ public void testGetIntMinMaxValueSet() {
+
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+
+ Assert.assertNull(validator.getConstraintOfType(widgetDef, WidgetDefinitionIntMinMaxConstraint.class));
+ Assert.assertEquals(null, validator.getIntMinValueSet(widgetDef));
+ Assert.assertEquals(null, validator.getIntMaxValueSet(widgetDef));
+
+ WidgetDefinitionIntMinMaxConstraint constraint = new WidgetDefinitionIntMinMaxConstraint(34, 45);
+ widgetDef.getConstraints().add(constraint);
+
+ Assert.assertEquals(new Integer(34), validator.getIntMinValueSet(widgetDef));
+ Assert.assertEquals(new Integer(45), validator.getIntMaxValueSet(widgetDef));
+ }
+
+ @org.junit.Test
+ public void testIsValidInteger() throws OseeCoreException {
+ WidgetDefinition widgetDef = new WidgetDefinition("test");
+
+ WidgetResult result = validator.isValidInteger(new MockValueProvider(Arrays.asList("asdf", "345")), widgetDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Type, result.getStatus());
+ Assert.assertEquals(widgetDef.getName(), result.getWidgetDef().getName());
+ Assert.assertTrue(Strings.isValid(result.getDetails()));
+
+ result = validator.isValidInteger(new MockValueProvider(Arrays.asList("23", "345")), widgetDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ WidgetDefinitionIntMinMaxConstraint constraint = new WidgetDefinitionIntMinMaxConstraint(34, 45);
+ widgetDef.getConstraints().add(constraint);
+ result = validator.isValidInteger(new MockValueProvider(Arrays.asList("37", "42")), widgetDef);
+ ValidatorTestUtil.assertValidResult(result);
+
+ result = validator.isValidInteger(new MockValueProvider(Arrays.asList("12", "42")), widgetDef);
+ Assert.assertEquals(WidgetStatus.Invalid_Range, result.getStatus());
+ Assert.assertEquals(widgetDef.getName(), result.getWidgetDef().getName());
+ Assert.assertTrue(Strings.isValid(result.getDetails()));
+ }
+
+}
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
new file mode 100644
index 0000000000..393c6b0534
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/MockValueProvider.java
@@ -0,0 +1,42 @@
+/*
+ * Created on May 19, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.validator;
+
+import java.util.Collection;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class MockValueProvider implements IValueProvider {
+
+ private final Collection<String> values;
+ private final String name;
+
+ public MockValueProvider(Collection<String> values) {
+ this("test", values);
+ }
+
+ public MockValueProvider(String name, Collection<String> values) {
+ this.name = name;
+ this.values = values;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return values.isEmpty();
+ }
+
+ @Override
+ public Collection<String> getValues() {
+ return values;
+ }
+
+}
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
new file mode 100644
index 0000000000..b5dccaa917
--- /dev/null
+++ b/plugins/org.eclipse.osee.ats.core.test/src/org/eclipse/osee/ats/core/validator/ValidatorTestUtil.java
@@ -0,0 +1,24 @@
+/*
+ * Created on May 20, 2011
+ *
+ * PLACE_YOUR_DISTRIBUTION_STATEMENT_RIGHT_HERE
+ */
+package org.eclipse.osee.ats.core.validator;
+
+import java.util.ArrayList;
+import org.junit.Assert;
+
+/**
+ * @author Donald G. Dunne
+ */
+public class ValidatorTestUtil {
+
+ public static MockValueProvider emptyValueProvider = new MockValueProvider(new ArrayList<String>());
+
+ public static void assertValidResult(WidgetResult result) {
+ Assert.assertEquals(WidgetStatus.Valid, result.getStatus());
+ Assert.assertNull(result.getWidgetDef());
+ Assert.assertEquals("", result.getDetails());
+ }
+
+}

Back to the top