These are now commited.

For some reason your contributions lack the last $ on the first line. I have
been adding those. Could you have a look at your template and where it came
from?

Is there a problem in the code template? Have you been removing everything
after the :?

There certainly is a problem since the name of the template appears. I have
disabled the keywords expansion for the code template file. Please try to
update and reapply in your workspace.

        /Linus


2008/3/24, Scott Roberts <[EMAIL PROTECTED]>:
>
> I've written 4 more unit tests for the org.argouml.cognitive namespace
> (patch below).  These tests verify the basic functionality of the
> following classes:
>
> Goal, GoalModel, Decision, EnabledCM, NotSnoozedCM, DesignGoalsCM,
> CurDecisionCM
>
> If these tests look good, please commit them to the repository when
> you get a chance.
>
> Thanks,
> Scott
>
> Patch:
>
> Index: tests/org/argouml/cognitive/TestStandardCM.java
> ===================================================================
> --- tests/org/argouml/cognitive/TestStandardCM.java     (revision 0)
> +++ tests/org/argouml/cognitive/TestStandardCM.java     (revision 0)
> @@ -0,0 +1,156 @@
> +// $Id
> +// Copyright (c) 2008 The Regents of the University of California. All
> +// Rights Reserved. Permission to use, copy, modify, and distribute this
> +// software and its documentation without fee, and without a written
> +// agreement is hereby granted, provided that the above copyright notice
> +// and this paragraph appear in all copies.  This software program and
> +// documentation are copyrighted by The Regents of the University of
> +// California. The software program and documentation are supplied "AS
> +// IS", without any accompanying services from The Regents. The Regents
> +// does not warrant that the operation of the program will be
> +// uninterrupted or error-free. The end-user understands that the program
> +// was developed for research purposes and is advised not to rely
> +// exclusively on the program for any reason.  IN NO EVENT SHALL THE
> +// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
> +// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
> +// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
> +// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
> +// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
> +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
> +// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
> +// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
> +// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
> +
> +package org.argouml.cognitive;
> +
> +import junit.framework.TestCase;
> +
> +/**
> + * Testing the initialization of a Decision.
> + */
> +public class TestStandardCM extends TestCase {
> +
> +    /**
> +     * The constructor.
> +     *
> +     * @param name the name of the test.
> +     */
> +    public TestStandardCM(String name) {
> +       super(name);
> +    }
> +
> +    /**
> +     * @see junit.framework.TestCase#setUp()
> +     */
> +    @Override
> +    protected void setUp() throws Exception {
> +       super.setUp();
> +    }
> +
> +    /**
> +     * Test isRelevant method of EnabledCM.
> +     */
> +    public void testEnabledCM() {
> +
> +       Critic critic = new Critic();
> +       EnabledCM cm = new EnabledCM();
> +
> +       // EnabledCM isRelevant checks if the critic is enabled
> +       // initialize this to true to verify isRelevant returns true
> +       critic.setEnabled(true);
> +
> +       // verify isRelevant returns true
> +       assertTrue("EnabledCM.isRelevant(Critic, Designer) is incorrect",
> +               cm.isRelevant(critic, Designer.theDesigner()));
> +
> +       // set enabled to false and check the opposite condition
> +       critic.setEnabled(false);
> +
> +       // verify isRelevant not is false
> +       assertTrue("EnabledCM.isRelevant(Critic, Designer) is incorrect",
> +               !cm.isRelevant(critic, Designer.theDesigner()));
> +    }
> +
> +    /**
> +     * Test isRelevant method of NotSnoozedCM.
> +     */
> +    public void testNotSnoozedCM() {
> +
> +       Critic critic = new Critic();
> +       NotSnoozedCM cm = new NotSnoozedCM();
> +
> +       // NotSnoozedCM isRelevant checks if the critic is snoozed
> +       // snooze the critic to verify isRelevant returns false
> +       critic.snooze();
> +
> +       // verify isRelevant returns true
> +       assertTrue("NotSnoozedCM.isRelevant(Critic, Designer) is incorrect
> " +
> +                       "when critic snoozed",
> +               !cm.isRelevant(critic, Designer.theDesigner()));
> +
> +       // unsnooze the critic to verify the critic is not relevant
> +       critic.unsnooze();
> +
> +       // verify isRelevant is true
> +       assertTrue("NotSnoozedCM.isRelevant(Critic, Designer) is incorrect
> " +
> +                       "when critic not snoozed",
> +               cm.isRelevant(critic, Designer.theDesigner()));
> +    }
> +
> +    /**
> +     * Test isRelevant method of DesignGoalsCM.
> +     */
> +    public void testDesignGoalsCM() {
> +
> +       Critic critic = new Critic();
> +       DesignGoalsCM cm = new DesignGoalsCM();
> +
> +       // DesignGoalsCM checks if the critic isRelevantToGoals of the
> Designer
> +       // this value is always true for the Critic base class so
> DesignerGoalsCM
> +       // should always return true in this condition
> +       assertTrue("DesignGoalsCM.isRelevant(Critic, Designer) is
> incorrect",
> +               cm.isRelevant(critic, Designer.theDesigner()));
> +    }
> +
> +    /**
> +     * Test isRelevant method of CurDecisionCM.
> +     */
> +    public void testCurDecisionCM() {
> +
> +       Critic critic = new Critic();
> +       CurDecisionCM cm = new CurDecisionCM();
> +
> +       // CurDecisionCM isRelevant checks to see if the critic has
> +       // any decisions that have a priority > 0 and less than the
> +       // priority of the critic.  By default the critic has no
> +       // decisions so isRelevant should return false.
> +       assertTrue("CurDecisionCM.isRelevant(Critic, Designer) is
> incorrect " +
> +                       "when critic has 0 decisions",
> +               !cm.isRelevant(critic, Designer.theDesigner()));
> +
> +       // add a decision but set the critic priority to 0 so isRelevant
> +       // should still be false
> +       critic.setPriority(0);
> +       critic.addSupportedDecision(Decision.UNSPEC);
> +
> +       // verify isRelevant is still false
> +       assertTrue("CurDecisionCM.isRelevant(Critic, Designer) is " +
> +                       "incorrect with one decision and critic has
> priority 0",
> +               !cm.isRelevant(critic, Designer.theDesigner()));
> +
> +       // update the priority of the critic to be the same priority as
> the decision
> +       critic.setPriority(Decision.UNSPEC.getPriority());
> +
> +       // isRelevant should now be true
> +       assertTrue("CurDecisionCM.isRelevant(Critic, Designer) is
> incorrect with " +
> +                       "one decision and priority has equal priority",
> +               cm.isRelevant(critic, Designer.theDesigner()));
> +
> +       critic.setPriority(Decision.UNSPEC.getPriority()+1);
> +       // isRelevant should still be true
> +       assertTrue("CurDecisionCM.isRelevant(Critic, Designer) is
> incorrect
> with one " +
> +                       "decision and priority has greater priority",
> +               cm.isRelevant(critic, Designer.theDesigner()));
> +    }
> + }
> Index: tests/org/argouml/cognitive/TestGoal.java
> ===================================================================
> --- tests/org/argouml/cognitive/TestGoal.java   (revision 0)
> +++ tests/org/argouml/cognitive/TestGoal.java   (revision 0)
> @@ -0,0 +1,101 @@
> +// $Id
> +// Copyright (c) 2008 The Regents of the University of California. All
> +// Rights Reserved. Permission to use, copy, modify, and distribute this
> +// software and its documentation without fee, and without a written
> +// agreement is hereby granted, provided that the above copyright notice
> +// and this paragraph appear in all copies.  This software program and
> +// documentation are copyrighted by The Regents of the University of
> +// California. The software program and documentation are supplied "AS
> +// IS", without any accompanying services from The Regents. The Regents
> +// does not warrant that the operation of the program will be
> +// uninterrupted or error-free. The end-user understands that the program
> +// was developed for research purposes and is advised not to rely
> +// exclusively on the program for any reason.  IN NO EVENT SHALL THE
> +// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
> +// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
> +// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
> +// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
> +// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
> +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
> +// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
> +// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
> +// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
> +
> +package org.argouml.cognitive;
> +
> +import junit.framework.TestCase;
> +
> +/**
> + * Testing the initialization of a Decision.
> + */
> +public class TestGoal extends TestCase {
> +
> +    /**
> +     * The constructor.
> +     *
> +     * @param name the name of the test.
> +     */
> +    public TestGoal(String name) {
> +       super(name);
> +    }
> +
> +    /**
> +     * @see junit.framework.TestCase#setUp()
> +     */
> +    @Override
> +    protected void setUp() throws Exception {
> +       super.setUp();
> +    }
> +
> +    /**
> +     * Test constructor and some basic methods.
> +     */
> +    public void testBasics() {
> +
> +       // initialize the GoalModel
> +       GoalModel goalModel = new GoalModel();
> +       Goal unspecifiedGoal = Goal.getUnspecifiedGoal();
> +
> +       // check that the model was initialized with one goal
> +       assertTrue("GoalModel not initialized with one goal",
> +               goalModel.getGoalList().size() == 1);
> +
> +       // check that the model was initialized with the unspecified goal
> +       assertTrue("GoalModel not initilized with UnspecifiedGoal",
> +               goalModel.hasGoal(unspecifiedGoal.getName()));
> +
> +       // update the priority of the unspecified goal so we can verify it
> was updated
> +       goalModel.setGoalPriority(unspecifiedGoal.getName(),
> +               unspecifiedGoal.getPriority()+1);
> +
> +       // first verify that the set goal priority did not add an extra
> goal
> +       assertTrue("GoalModel.setGoalPriority added an extra Goal",
> +               goalModel.getGoalList().size() == 1);
> +
> +       // check that the model correctly updates a goals priority
> +       assertTrue("GoalModel not correctly updating goal priority",
> +               goalModel.getGoalList().get(0).getPriority() ==
> unspecifiedGoal.getPriority()+1);
> +
> +       // test the removal of a goal
> +       goalModel.removeGoal(unspecifiedGoal);
> +
> +       // number of goals should now be 0
> +       assertTrue("GoalModel.removeGoal(goalName) failed",
> +               goalModel.getGoalList().size() == 0);
> +
> +       // start desiring a goal which should add a goal and bump the size
> to one
> +       goalModel.startDesiring(unspecifiedGoal.getName());
> +
> +       // number of goals should now be 1
> +       assertTrue("GoalModel.startDesiring did not add a Goal",
> +               goalModel.getGoalList().size() == 1);
> +
> +       // stop desiring the goal which should remove it from the model
> +       goalModel.stopDesiring(unspecifiedGoal.getName());
> +
> +       // number of goals should now be 0
> +       assertTrue("GoalModel.stopDesiring(goalName) failed",
> +               goalModel.getGoalList().size() == 0);
> +    }
> +}
> Index: tests/org/argouml/cognitive/TestGoalModel.java
> ===================================================================
> --- tests/org/argouml/cognitive/TestGoalModel.java      (revision 0)
> +++ tests/org/argouml/cognitive/TestGoalModel.java      (revision 0)
> @@ -0,0 +1,97 @@
> +// $Id
> +// Copyright (c) 2008 The Regents of the University of California. All
> +// Rights Reserved. Permission to use, copy, modify, and distribute this
> +// software and its documentation without fee, and without a written
> +// agreement is hereby granted, provided that the above copyright notice
> +// and this paragraph appear in all copies.  This software program and
> +// documentation are copyrighted by The Regents of the University of
> +// California. The software program and documentation are supplied "AS
> +// IS", without any accompanying services from The Regents. The Regents
> +// does not warrant that the operation of the program will be
> +// uninterrupted or error-free. The end-user understands that the program
> +// was developed for research purposes and is advised not to rely
> +// exclusively on the program for any reason.  IN NO EVENT SHALL THE
> +// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
> +// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
> +// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
> +// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
> +// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
> +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
> +// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
> +// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
> +// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
> +
> +package org.argouml.cognitive;
> +
> +import junit.framework.TestCase;
> +
> +/**
> + * Testing the initialization of a Decision.
> + */
> +public class TestGoalModel extends TestCase {
> +
> +    /**
> +     * The constructor.
> +     *
> +     * @param name the name of the test.
> +     */
> +    public TestGoalModel(String name) {
> +       super(name);
> +    }
> +
> +    /**
> +     * @see junit.framework.TestCase#setUp()
> +     */
> +    @Override
> +    protected void setUp() throws Exception {
> +       super.setUp();
> +    }
> +
> +    /**
> +     * Test constructor and some basic methods.
> +     */
> +    public void testBasics() {
> +
> +       // initialize basic parameters that are
> +       // different from Decision.UNSPEC
> +       int priority = 2;
> +       String name = "misc.decision.inheritance";
> +       String translatedName = Translator.localize(name);
> +
> +       // initialize a decision object with parameters
> +       Decision decision = new Decision(name, priority);
> +
> +       // verify parameters were initialized correctly by the constructor
> +       assertTrue("Decision.getName() is incorrect",
> +               decision.getName() == translatedName);
> +       assertTrue("Decision.toString() is incorrect",
> +               decision.toString() == translatedName);
> +       assertTrue("Decision.getPriority() is incorrect",
> +               decision.getPriority() == priority);
> +
> +       // set the priority to a different value
> +       priority = 1;
> +       decision.setPriority(priority);
> +
> +       // verify the priority was correctly updated
> +       assertTrue("Decision.setPriority() failed",
> +               decision.getPriority() == priority);
> +
> +       // set the name to a different value
> +       name = "misc.decision.uncategorized";
> +       translatedName = Translator.localize(name);
> +       decision.setName(translatedName);
> +
> +       // verify the name property was correctly updated
> +       assertTrue("Decision.setName() failed",
> +               decision.getName() == translatedName);
> +       assertTrue("Decision.toString() is incorrect",
> +               decision.toString() == translatedName);
> +
> +       // following the update the priority should be
> +       // equivalent to Decision.UNSPEC
> +       assertTrue("Decision.equals(Decision) failed",
> +               decision.equals(Decision.UNSPEC));
> +    }
> +}
> Index: tests/org/argouml/cognitive/TestDecision.java
> ===================================================================
> --- tests/org/argouml/cognitive/TestDecision.java       (revision 0)
> +++ tests/org/argouml/cognitive/TestDecision.java       (revision 0)
> @@ -0,0 +1,97 @@
> +// $Id
> +// Copyright (c) 2008 The Regents of the University of California. All
> +// Rights Reserved. Permission to use, copy, modify, and distribute this
> +// software and its documentation without fee, and without a written
> +// agreement is hereby granted, provided that the above copyright notice
> +// and this paragraph appear in all copies.  This software program and
> +// documentation are copyrighted by The Regents of the University of
> +// California. The software program and documentation are supplied "AS
> +// IS", without any accompanying services from The Regents. The Regents
> +// does not warrant that the operation of the program will be
> +// uninterrupted or error-free. The end-user understands that the program
> +// was developed for research purposes and is advised not to rely
> +// exclusively on the program for any reason.  IN NO EVENT SHALL THE
> +// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
> +// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
> +// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
> +// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
> +// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
> +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
> +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
> +// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
> +// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
> +// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
> +
> +package org.argouml.cognitive;
> +
> +import junit.framework.TestCase;
> +
> +/**
> + * Testing the initialization of a Decision.
> + */
> +public class TestDecision extends TestCase {
> +
> +    /**
> +     * The constructor.
> +     *
> +     * @param name the name of the test.
> +     */
> +    public TestDecision(String name) {
> +       super(name);
> +    }
> +
> +    /**
> +     * @see junit.framework.TestCase#setUp()
> +     */
> +    @Override
> +    protected void setUp() throws Exception {
> +       super.setUp();
> +    }
> +
> +    /**
> +     * Test constructor and some basic methods.
> +     */
> +    public void testBasics() {
> +
> +       // initialize basic parameters that are
> +       // different from Decision.UNSPEC
> +       int priority = 2;
> +       String name = "misc.decision.inheritance";
> +       String translatedName = Translator.localize(name);
> +
> +       // initialize a decision object with parameters
> +       Decision decision = new Decision(name, priority);
> +
> +       // verify parameters were initialized correctly by the constructor
> +       assertTrue("Decision.getName() is incorrect",
> +               decision.getName() == translatedName);
> +       assertTrue("Decision.toString() is incorrect",
> +               decision.toString() == translatedName);
> +       assertTrue("Decision.getPriority() is incorrect",
> +               decision.getPriority() == priority);
> +
> +       // set the priority to a different value
> +       priority = 1;
> +       decision.setPriority(priority);
> +
> +       // verify the priority was correctly updated
> +       assertTrue("Decision.setPriority() failed",
> +               decision.getPriority() == priority);
> +
> +       // set the name to a different value
> +       name = "misc.decision.uncategorized";
> +       translatedName = Translator.localize(name);
> +       decision.setName(translatedName);
> +
> +       // verify the name property was correctly updated
> +       assertTrue("Decision.setName() failed",
> +               decision.getName() == translatedName);
> +       assertTrue("Decision.toString() is incorrect",
> +               decision.toString() == translatedName);
> +
> +       // following the update the priority should be
> +       // equivalent to Decision.UNSPEC
> +       assertTrue("Decision.equals(Decision) failed",
> +               decision.equals(Decision.UNSPEC));
> +    }
> +}
> \ No newline at end of file
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to