Author: tfmorris Date: 2008-04-04 12:23:39-0700 New Revision: 14283 Added: trunk/src/app/tests/org/argouml/application/events/ trunk/src/app/tests/org/argouml/application/events/TestArgoEventPump.java (contents, props changed) trunk/src/app/tests/org/argouml/cognitive/checklist/TestCheckItem.java (contents, props changed) trunk/src/app/tests/org/argouml/cognitive/checklist/TestChecklist.java (contents, props changed) trunk/src/app/tests/org/argouml/cognitive/checklist/TestChecklistStatus.java (contents, props changed) trunk/src/app/tests/org/argouml/cognitive/critics/TestSnoozeOrder.java (contents, props changed)
Log: New tests from Scott Roberts Added: trunk/src/app/tests/org/argouml/application/events/TestArgoEventPump.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/tests/org/argouml/application/events/TestArgoEventPump.java?view=auto&rev=14283 ============================================================================== --- (empty file) +++ trunk/src/app/tests/org/argouml/application/events/TestArgoEventPump.java 2008-04-04 12:23:39-0700 @@ -0,0 +1,608 @@ +// $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.application.events; + +import junit.framework.TestCase; + +/** + * Tests initialization of ArgoEventPump. + * + * @author Scott Roberts + */ +public class TestArgoEventPump extends TestCase { + + // initialize the event listener trackers which + // verify that all of the proper events were fired + private TArgoHelpEventListener helpTracker = + new TArgoHelpEventListener(); + + private TArgoStatusEventListener statusTracker = + new TArgoStatusEventListener(); + + private TArgoProfileEventListener profileTracker = + new TArgoProfileEventListener(); + + private TArgoNotationEventListener notationTracker = + new TArgoNotationEventListener(); + + private TArgoGeneratorEventListener generatorTracker = + new TArgoGeneratorEventListener(); + + private TArgoDiagramAppearanceEventListener diagramTracker = + new TArgoDiagramAppearanceEventListener(); + + /** + * The constructor. + * + * @param name the name of the test. + */ + public TestArgoEventPump(String name) { + super(name); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + + // register all of the event listener trackers + ArgoEventPump.addListener(ArgoEventTypes.HELP_CHANGED, helpTracker); + ArgoEventPump.addListener(ArgoEventTypes.HELP_REMOVED, helpTracker); + ArgoEventPump.addListener(ArgoEventTypes.STATUS_TEXT, statusTracker); + ArgoEventPump.addListener(ArgoEventTypes.STATUS_CLEARED, statusTracker); + ArgoEventPump.addListener(ArgoEventTypes.STATUS_PROJECT_SAVED, + statusTracker); + ArgoEventPump.addListener(ArgoEventTypes.STATUS_PROJECT_LOADED, + statusTracker); + ArgoEventPump.addListener(ArgoEventTypes.STATUS_PROJECT_MODIFIED, + statusTracker); + ArgoEventPump.addListener(ArgoEventTypes.PROFILE_ADDED, profileTracker); + ArgoEventPump.addListener(ArgoEventTypes.PROFILE_REMOVED, + profileTracker); + ArgoEventPump.addListener(ArgoEventTypes.NOTATION_CHANGED, + notationTracker); + ArgoEventPump.addListener(ArgoEventTypes.NOTATION_ADDED, + notationTracker); + ArgoEventPump.addListener(ArgoEventTypes.NOTATION_REMOVED, + notationTracker); + ArgoEventPump.addListener(ArgoEventTypes.NOTATION_PROVIDER_ADDED, + notationTracker); + ArgoEventPump.addListener(ArgoEventTypes.NOTATION_PROVIDER_REMOVED, + notationTracker); + ArgoEventPump.addListener(ArgoEventTypes.GENERATOR_CHANGED, + generatorTracker); + ArgoEventPump.addListener(ArgoEventTypes.GENERATOR_ADDED, + generatorTracker); + ArgoEventPump.addListener(ArgoEventTypes.GENERATOR_REMOVED, + generatorTracker); + ArgoEventPump.addListener(ArgoEventTypes.DIAGRAM_FONT_CHANGED, + diagramTracker); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + + // remove all of the listeners + ArgoEventPump.removeListener(ArgoEventTypes.HELP_CHANGED, helpTracker); + ArgoEventPump.removeListener(ArgoEventTypes.HELP_REMOVED, helpTracker); + ArgoEventPump.removeListener(ArgoEventTypes.STATUS_TEXT, statusTracker); + ArgoEventPump.removeListener(ArgoEventTypes.STATUS_CLEARED, + statusTracker); + ArgoEventPump.removeListener(ArgoEventTypes.STATUS_PROJECT_SAVED, + statusTracker); + ArgoEventPump.removeListener(ArgoEventTypes.STATUS_PROJECT_LOADED, + statusTracker); + ArgoEventPump.removeListener(ArgoEventTypes.STATUS_PROJECT_MODIFIED, + statusTracker); + ArgoEventPump.removeListener(ArgoEventTypes.PROFILE_ADDED, + profileTracker); + ArgoEventPump.removeListener(ArgoEventTypes.PROFILE_REMOVED, + profileTracker); + ArgoEventPump.removeListener(ArgoEventTypes.NOTATION_CHANGED, + notationTracker); + ArgoEventPump.removeListener(ArgoEventTypes.NOTATION_ADDED, + notationTracker); + ArgoEventPump.removeListener(ArgoEventTypes.NOTATION_REMOVED, + notationTracker); + ArgoEventPump.removeListener(ArgoEventTypes.NOTATION_PROVIDER_ADDED, + notationTracker); + ArgoEventPump.removeListener(ArgoEventTypes.NOTATION_PROVIDER_REMOVED, + notationTracker); + ArgoEventPump.removeListener(ArgoEventTypes.GENERATOR_CHANGED, + generatorTracker); + ArgoEventPump.removeListener(ArgoEventTypes.GENERATOR_ADDED, + generatorTracker); + ArgoEventPump.removeListener(ArgoEventTypes.GENERATOR_REMOVED, + generatorTracker); + ArgoEventPump.removeListener(ArgoEventTypes.DIAGRAM_FONT_CHANGED, + diagramTracker); + } + + private void resetTrackers() { + helpTracker.resetEventStatus(); + statusTracker.resetEventStatus(); + profileTracker.resetEventStatus(); + notationTracker.resetEventStatus(); + generatorTracker.resetEventStatus(); + diagramTracker.resetEventStatus(); + } + + /** + * Test firing of all events. + */ + public void testAllEvents() { + + resetTrackers(); + + // fire all of the status events + ArgoEvent evt = new ArgoStatusEvent(ArgoEventTypes.STATUS_TEXT, this, + "Test Event"); + ArgoEventPump.fireEvent(evt); + evt = new ArgoStatusEvent(ArgoEventTypes.STATUS_CLEARED, this, + "Test Event"); + ArgoEventPump.fireEvent(evt); + evt = new ArgoStatusEvent(ArgoEventTypes.STATUS_PROJECT_SAVED, this, + "Test Event"); + ArgoEventPump.fireEvent(evt); + evt = new ArgoStatusEvent(ArgoEventTypes.STATUS_PROJECT_LOADED, this, + "Test Event"); + ArgoEventPump.fireEvent(evt); + evt = new ArgoStatusEvent(ArgoEventTypes.STATUS_PROJECT_MODIFIED, this, + "Test Event"); + ArgoEventPump.fireEvent(evt); + + // fire all of the diagram events + evt = new ArgoDiagramAppearanceEvent( + ArgoEventTypes.DIAGRAM_FONT_CHANGED, this); + ArgoEventPump.fireEvent(evt); + + // fire all of the generator events + evt = new ArgoGeneratorEvent(ArgoEventTypes.GENERATOR_CHANGED, this); + ArgoEventPump.fireEvent(evt); + evt = new ArgoGeneratorEvent(ArgoEventTypes.GENERATOR_ADDED, this); + ArgoEventPump.fireEvent(evt); + evt = new ArgoGeneratorEvent(ArgoEventTypes.GENERATOR_REMOVED, this); + ArgoEventPump.fireEvent(evt); + + // fire all of the help events + evt = new ArgoHelpEvent(ArgoEventTypes.HELP_CHANGED, this, + "Test Event"); + ArgoEventPump.fireEvent(evt); + evt = new ArgoHelpEvent(ArgoEventTypes.HELP_REMOVED, this, + "Test Event"); + ArgoEventPump.fireEvent(evt); + + // fire all of the notation events + evt = new ArgoNotationEvent(ArgoEventTypes.NOTATION_CHANGED, this); + ArgoEventPump.fireEvent(evt); + evt = new ArgoNotationEvent(ArgoEventTypes.NOTATION_ADDED, this); + ArgoEventPump.fireEvent(evt); + evt = new ArgoNotationEvent(ArgoEventTypes.NOTATION_REMOVED, this); + ArgoEventPump.fireEvent(evt); + evt = new ArgoNotationEvent(ArgoEventTypes.NOTATION_PROVIDER_ADDED, + this); + ArgoEventPump.fireEvent(evt); + evt = new ArgoNotationEvent(ArgoEventTypes.NOTATION_PROVIDER_REMOVED, + this); + ArgoEventPump.fireEvent(evt); + + // fire all of the profile events + evt = new ArgoProfileEvent(ArgoEventTypes.PROFILE_ADDED, this); + ArgoEventPump.fireEvent(evt); + evt = new ArgoProfileEvent(ArgoEventTypes.PROFILE_REMOVED, this); + ArgoEventPump.fireEvent(evt); + + // verify all events were fired correctly + assertTrue("ArgoEventPump did not fire all " + + "ArgoStatusEvents", + statusTracker.allEventsFired()); + + assertTrue("ArgoEventPump incorrectly fired " + + "ArgoStatusEvents", + statusTracker.allEventsFiredCorrectly()); + + assertTrue("ArgoEventPump did not fire all " + + "ArgoDiagramAppearanceEvents", + diagramTracker.allEventsFired()); + + assertTrue("ArgoEventPump incorrectly fired " + + "ArgoDiagramAppearanceEvents", + diagramTracker.allEventsFiredCorrectly()); + + assertTrue("ArgoEventPump did not fire all " + + "ArgoGeneratorEvents", + generatorTracker.allEventsFired()); + + assertTrue("ArgoEventPump incorrectly fired " + + "ArgoGeneratorEvents", + generatorTracker.allEventsFiredCorrectly()); + + assertTrue("ArgoEventPump did not fire all " + + "ArgoHelpEvents", + helpTracker.allEventsFired()); + + assertTrue("ArgoEventPump incorrectly fired " + + "ArgoHelpEvents", + helpTracker.allEventsFiredCorrectly()); + + assertTrue("ArgoEventPump did not fire all " + + "ArgoNotationEvents", + notationTracker.allEventsFired()); + + assertTrue("ArgoEventPump incorrectly fired " + + "ArgoNotationEvents", + notationTracker.allEventsFiredCorrectly()); + + assertTrue("ArgoEventPump did not fire all " + + "ArgoProfileEvents", + profileTracker.allEventsFired()); + + assertTrue("ArgoEventPump incorrectly fired " + + "ArgoProfileEvents", + profileTracker.allEventsFiredCorrectly()); + } + + /** + * Used to track the status of events that have fired. + */ + public abstract class EventTracker { + private int numEvents = 0; + + private int totalEventsFired = 0; + + private int eventStatus = 0; + + /** + * Initialize a new EventTest + * + * @param numberOfEvents the number of events to be represented + */ + public EventTracker(int numberOfEvents) { + numEvents = numberOfEvents; + } + + /** + * Reset the event status. + */ + public void resetEventStatus() { + eventStatus = 0; + } + + /** + * Update the status of the event of an event as fired. + * + * @param event the an id that represents the event + */ + protected void setEvent(int event) { + // keep track of total events fired + totalEventsFired++; + + // keep track of which events fired + eventStatus |= (0x01 << event); + } + + /** + * Gets the total number of events that have been fired + * + * @return returns true if all events have been fired + */ + public int getTotalNumberOfEventsFired() { + return totalEventsFired; + } + + /** + * Gets the individual number of events that have been fired + * + * @return returns true if all events have been fired + */ + public int getNumberOfEventsFired() { + int eventsFired = 0; + + // counts each bit that has been fired + for (int events = eventStatus; events > 0; ++eventsFired) + events &= events - 1; + + return eventsFired; + } + + /** + * Determines if all events have been fired + * + * @return returns true if all events have been fired + */ + public boolean allEventsFired() { + return (getNumberOfEventsFired() == numEvents); + } + + /** + * Determines if the events were called the right number of times + * + * @return returns true if the total number of events fired is the same + * as all event types + */ + public boolean allEventsFiredCorrectly() { + return (getTotalNumberOfEventsFired() == numEvents); + } + } + + /** + * Represents a ArgoDiagramAppearanceEventListener and tracks the firing of + * its events + */ + public class TArgoDiagramAppearanceEventListener extends EventTracker + implements ArgoDiagramAppearanceEventListener { + /** + * Initialize the listener + */ + public TArgoDiagramAppearanceEventListener() { + super(1); + } + + /** + * Invoked when any aspect of the notation has been changed. + * + * @param e <code>ArgoNotationEvent</code> describing the change. + */ + public void diagramFontChanged(ArgoDiagramAppearanceEvent e) { + setEvent(0); + } + } + + /** + * Represents a ArgoGeneratorEventListener and tracks the firing of its + * events. + */ + public class TArgoGeneratorEventListener extends EventTracker implements + ArgoGeneratorEventListener { + /** + * Initialize the listener + */ + public TArgoGeneratorEventListener() { + super(3); + } + + /** + * Invoked when any aspect of the generator has been changed. + * + * @param e <code>ArgoGeneratorEvent</code> describing the change. + */ + public void generatorChanged(ArgoGeneratorEvent e) { + setEvent(0); + } + + /** + * Invoked when a CodeGenerator has been added. + * + * @param e <code>ArgoGeneratorEvent</code> describing the added + * notation. + */ + public void generatorAdded(ArgoGeneratorEvent e) { + setEvent(1); + } + + /** + * Invoked when a CodeGenerator has been removed. + * + * @param e <code>ArgoGeneratorEvent</code> describing the removed + * notation. + */ + public void generatorRemoved(ArgoGeneratorEvent e) { + setEvent(2); + } + } + + /** + * Represents a ArgoDiagramAppearanceEventListener and tracks the firing of + * its events + */ + public class TArgoHelpEventListener extends EventTracker implements + ArgoHelpEventListener { + /** + * Initialize the listener + */ + public TArgoHelpEventListener() { + super(2); + } + + /** + * Invoked when there is a new help text to be shown, that should + * replace any previous one. + * + * @param e <code>ArgoHelpEvent</code> describing the changed text + */ + public void helpChanged(ArgoHelpEvent e) { + setEvent(0); + } + + /** + * Invoked when a previously shown help text has to be removed. + * + * @param e <code>ArgoHelpEvent</code> describing the removed event + */ + public void helpRemoved(ArgoHelpEvent e) { + setEvent(1); + } + } + + /** + * Represents a ArgoNotationEventListener and tracks the firing of its + * events + */ + public class TArgoNotationEventListener extends EventTracker implements + ArgoNotationEventListener { + /** + * Initialize the listener + */ + public TArgoNotationEventListener() { + super(5); + } + + /** + * Invoked when any aspect of the notation has been changed. + * + * @param e <code>ArgoNotationEvent</code> describing the change. + */ + public void notationChanged(ArgoNotationEvent e) { + setEvent(0); + } + + /** + * Invoked when a notation has been added. + * + * @param e <code>ArgoNotationEvent</code> describing the added + * notation. + */ + public void notationAdded(ArgoNotationEvent e) { + setEvent(1); + } + + /** + * Invoked when a notation has been removed. + * + * @param e <code>ArgoNotationEvent</code> describing the removed + * notation. + */ + public void notationRemoved(ArgoNotationEvent e) { + setEvent(2); + } + + /** + * Invoked when a notation provider has been added. + * + * @param e <code>ArgoNotationEvent</code> describing the added + * notation provider. + */ + public void notationProviderAdded(ArgoNotationEvent e) { + setEvent(3); + } + + /** + * Invoked when a notation provider has been removed. + * + * @param e <code>ArgoNotationEvent</code> describing the removed + * notation provider. + */ + public void notationProviderRemoved(ArgoNotationEvent e) { + setEvent(4); + } + } + + /** + * Represents a ArgoProfileEventListener and tracks the firing of its events + */ + public class TArgoProfileEventListener extends EventTracker implements + ArgoProfileEventListener { + /** + * Initialize the listener + */ + public TArgoProfileEventListener() { + super(2); + } + + /** + * Invoked when a profile has been added. + * + * @param e <code>ArgoProfileEvent</code> describing the added + * notation. + */ + public void profileAdded(ArgoProfileEvent e) { + setEvent(0); + } + + /** + * Invoked when a profile has been removed. + * + * @param e <code>ArgoProfileEvent</code> describing the removed + * notation. + */ + public void profileRemoved(ArgoProfileEvent e) { + setEvent(1); + } + } + + /** + * Tracker for ArgoStatusEventListener. + */ + public class TArgoStatusEventListener extends EventTracker implements + ArgoStatusEventListener { + /** + * Initialize the listener + */ + public TArgoStatusEventListener() { + super(5); + } + + /** + * Invoked when there is a new status text to be shown, that should + * replace any previous one. + * + * @param e <code>ArgoStatusEvent</code> describing the changed text + */ + public void statusText(ArgoStatusEvent e) { + setEvent(0); + } + + /** + * Invoked when a previously shown status text has to be removed. + * + * @param e <code>ArgoStatusEvent</code> describing the removed event + */ + public void statusCleared(ArgoStatusEvent e) { + setEvent(1); + } + + /** + * A project has been saved. + * + * @param e <code>ArgoStatusEvent</code> with the name of the project + * that was saved. + */ + public void projectSaved(ArgoStatusEvent e) { + setEvent(2); + } + + /** + * A project has been loaded. + * + * @param e <code>ArgoStatusEvent</code> with the name of the project + * that was loaded. + */ + public void projectLoaded(ArgoStatusEvent e) { + setEvent(3); + } + + /** + * A project has been modified. + * + * @param e <code>ArgoStatusEvent</code> with the name of the project + * that was modified (ignored for current ArgoUML + * implementation where there is only a single project + * open at a time). + */ + public void projectModified(ArgoStatusEvent e) { + setEvent(4); + } + } +} Added: trunk/src/app/tests/org/argouml/cognitive/checklist/TestCheckItem.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/tests/org/argouml/cognitive/checklist/TestCheckItem.java?view=auto&rev=14283 ============================================================================== --- (empty file) +++ trunk/src/app/tests/org/argouml/cognitive/checklist/TestCheckItem.java 2008-04-04 12:23:39-0700 @@ -0,0 +1,113 @@ +// $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.checklist; + +import junit.framework.TestCase; +import org.tigris.gef.util.PredicateTrue; + +/** + * Tests initialization of CheckItem. + * + * @author Scott Roberts + */ +public class TestCheckItem extends TestCase { + + /** + * The constructor. + * + * @param name the name of the test. + */ + public TestCheckItem(String name) { + super(name); + } + + + /** + * Test constructor and some basic methods. + */ + public void testBasics() { + + // initialize test data + String category = "TestCheckItem Category"; + String description = "TestCheckItem Description"; + String moreInfo = "http://argouml.tigris.org/test"; + + // Construct a CheckItem + CheckItem item = new CheckItem(category, description, + moreInfo, PredicateTrue.theInstance()); + + // (1) test that the properties were correctly initialized + assertTrue("CheckItem.getDescription() incorrect " + + "after initialization (1)", + item.getDescription() == description); + assertTrue("CheckItem.getMoreInfoURL() incorrect " + + "after initialization (1)", + item.getMoreInfoURL() == moreInfo); + assertTrue("CheckItem.getCategory() incorrect after " + + "initialization (1)", + item.getCategory() == category); + assertTrue("CheckItem.getPredicate() incorrect after " + + "initialization (1)", + item.getPredicate() == PredicateTrue.theInstance()); + + // reset the values to something different + category += "- Set Test"; + description += "- Set Test"; + moreInfo += "- Set Test"; + + // update the values + item.setCategory(category); + item.setDescription(description); + item.setMoreInfoURL(moreInfo); + item.setPredicate(null); + + assertTrue("CheckItem.getDescription() incorrect after set", + item.getDescription() == description); + assertTrue("CheckItem.getMoreInfoURL() incorrect after set", + item.getMoreInfoURL() == moreInfo); + assertTrue("CheckItem.getCategory() incorrect after set", + item.getCategory() == category); + assertTrue("CheckItem.getPredicate() incorrect after set", + item.getPredicate() == null); + + // (2) Construct another CheckItem + CheckItem item2 = new CheckItem(category, description); + + // test that the properties were correctly initialized + assertTrue("CheckItem.getDescription() incorrect " + + "after initialization (2)", + item.getDescription() == description); + assertTrue("CheckItem.getMoreInfoURL() incorrect " + + "after initialization (2)", + item.getMoreInfoURL() == moreInfo); + assertTrue("CheckItem.getCategory() incorrect " + + "after initialization (2)", + item.getCategory() == category); + + // verify that the equivalence test works + assertTrue("CheckItem.equals(o) incorrect", item2.equals(item)); + + } +} Added: trunk/src/app/tests/org/argouml/cognitive/checklist/TestChecklist.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/tests/org/argouml/cognitive/checklist/TestChecklist.java?view=auto&rev=14283 ============================================================================== --- (empty file) +++ trunk/src/app/tests/org/argouml/cognitive/checklist/TestChecklist.java 2008-04-04 12:23:39-0700 @@ -0,0 +1,109 @@ +// $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.checklist; + +import junit.framework.TestCase; + +/** + * Tests initialization of Checklist. + * + * @author Scott Roberts + */ +public class TestChecklist extends TestCase { + + /** + * The constructor. + * + * @param name the name of the test. + */ + public TestChecklist(String name) { + super(name); + } + + /** + * Test constructor and some basic methods. + */ + public void testBasics() { + + // initialize the Checklist + Checklist list = new Checklist(); + + // add some test data + list.addItem("Test1"); + list.addItem("Test2"); + list.setNextCategory("Test Category"); + list.addItem("Test3"); + list.addItem("Test4"); + + // verify the size of the list + assertTrue("Checklist.size() is incorrect", list.size() == 4); + + // verify the items were correctly added + int iter = 0; + for (CheckItem item : list.getCheckItemList()) { + + String category = ""; + String description = ""; + + switch (++iter) + { + case 1: + category = "General"; + description = "Test1"; + break; + + case 2: + category = "General"; + description = "Test2"; + break; + + case 3: + category = "Test Category"; + description = "Test3"; + break; + + case 4: + category = "Test Category"; + description = "Test4"; + break; + } + + // test that the category and description are correct + assertTrue("Checklist items incorrectly added (category: " + + category + ", description: )" + description, + category == item.getCategory() + && description == item.getDescription()); + } + + // create a new list to test the addAll + Checklist list2 = new Checklist(); + + // add all of the test items from the first list + list2.addAll(list); + + // verify the size of the new list + assertTrue("Checklist.addAll(Checklist) failed", list2.size() == 4); + } +} Added: trunk/src/app/tests/org/argouml/cognitive/checklist/TestChecklistStatus.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/tests/org/argouml/cognitive/checklist/TestChecklistStatus.java?view=auto&rev=14283 ============================================================================== --- (empty file) +++ trunk/src/app/tests/org/argouml/cognitive/checklist/TestChecklistStatus.java 2008-04-04 12:23:39-0700 @@ -0,0 +1,110 @@ +// $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.checklist; + +import junit.framework.TestCase; + +/** + * Tests initialization of ChecklistStatus. + * + * @author Scott Roberts + */ +public class TestChecklistStatus extends TestCase { + + /** + * The constructor. + * + * @param name the name of the test. + */ + public TestChecklistStatus(String name) { + super(name); + } + + /** + * Test constructor and some basic methods. + */ + public void testBasics() { + + String category = ""; + String description = ""; + + // initialize the ChecklistStatus + ChecklistStatus list = new ChecklistStatus(); + + // add some test data + list.addItem("Test1"); + list.addItem("Test2"); + list.setNextCategory("Test Category"); + list.addItem("Test3"); + list.addItem("Test4"); + + // verify the size of the list + assertTrue("ChecklistStatus.size() is incorrect", list.size() == 4); + + // verify the items were correctly added + int iter = 0; + for (CheckItem item : list.getCheckItemList()) { + + switch (++iter) + { + case 1: + category = "General"; + description = "Test1"; + break; + + case 2: + category = "General"; + description = "Test2"; + break; + + case 3: + category = "Test Category"; + description = "Test3"; + break; + + case 4: + category = "Test Category"; + description = "Test4"; + break; + } + + // test that the category and description are correct + assertTrue("ChecklistStatus items incorrectly added (category: " + + category + ", description: )" + description, + category == item.getCategory() + && description == item.getDescription()); + } + + // create a new list to test the addAll + ChecklistStatus list2 = new ChecklistStatus(); + + // add all of the test items from the first list + list2.addAll(list); + + // verify the size of the new list + assertTrue("ChecklistStatus.addAll(Checklist) failed", + list2.size() == 4); + } +} \ No newline at end of file Added: trunk/src/app/tests/org/argouml/cognitive/critics/TestSnoozeOrder.java Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/app/tests/org/argouml/cognitive/critics/TestSnoozeOrder.java?view=auto&rev=14283 ============================================================================== --- (empty file) +++ trunk/src/app/tests/org/argouml/cognitive/critics/TestSnoozeOrder.java 2008-04-04 12:23:39-0700 @@ -0,0 +1,74 @@ +// $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.critics; + +import junit.framework.TestCase; + +/** + * Tests initialization of SnoozeOrder. + * + * @author Scott Roberts + */ +public class TestSnoozeOrder extends TestCase { + + /** + * The constructor. + * + * @param name the name of the test. + */ + public TestSnoozeOrder(String name) { + super(name); + } + + + /** + * Test constructor and some basic methods. + */ + public void testBasics() { + // initialize SnoozeOrder + SnoozeOrder snooze = new SnoozeOrder(); + + // verify SnoozeOrder starts off not snoozed + assertTrue("SnoozeOrder started as snoozed", !snooze.getSnoozed()); + + // snooze and verify its been enabled + snooze.snooze(); + assertTrue("SnoozeOrder.snoozed() failed", snooze.getSnoozed()); + + // unsnooze and verify its been disabled + snooze.unsnooze(); + assertTrue("SnoozeOrder.unsnoozed() failed", !snooze.getSnoozed()); + + // snooze and verify its been enabled + snooze.setSnoozed(true); + assertTrue("Snooze.Order.setSnoozed(true) failed", + snooze.getSnoozed()); + + // snooze and verify its been enabled + snooze.setSnoozed(false); + assertTrue("Snooze.Order.setSnoozed(false) failed", + !snooze.getSnoozed()); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
