tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-tapestry/junit/src/org/apache/tapestry/junit/form TestListEditMap.java
Date Wed, 26 Mar 2003 19:51:33 GMT
hlship      2003/03/26 11:51:33

  Added:       junit/src/org/apache/tapestry/junit/form
                        TestListEditMap.java
  Log:
  Add ListEditMap (helper class when using ListEdit component).
  
  Revision  Changes    Path
  1.1                  jakarta-tapestry/junit/src/org/apache/tapestry/junit/form/TestListEditMap.java
  
  Index: TestListEditMap.java
  ===================================================================
  package org.apache.tapestry.junit.form;
  
  import org.apache.tapestry.form.ListEditMap;
  import org.apache.tapestry.junit.TapestryTestCase;
  import org.apache.tapestry.spec.Direction;
  
  /**
   *  Suite of tests for {@link org.apache.tapestry.form.ListEditMap}.
   *
   *  @author Howard Lewis Ship
   *  @version $Id: TestListEditMap.java,v 1.1 2003/03/26 19:51:32 hlship Exp $
   *  @since 2.4
   *
   **/
  
  public class TestListEditMap extends TapestryTestCase
  {
  
      public TestListEditMap(String name)
      {
          super(name);
      }
  
      private ListEditMap create()
      {
          ListEditMap m = new ListEditMap();
  
          m.add("in", Direction.IN);
          m.add("auto", Direction.AUTO);
          m.add("custom", Direction.CUSTOM);
  
          return m;
      }
  
      public void testAdd()
      {
          ListEditMap m = create();
  
  		assertEquals("custom", m.getKey());
  
          checkList("keys", new Object[] { "in", "auto", "custom" }, m.getKeys());
          checkList(
              "all values",
              new Object[] { Direction.IN, Direction.AUTO, Direction.CUSTOM },
              m.getAllValues());
          checkList(
              "all values",
              new Object[] { Direction.IN, Direction.AUTO, Direction.CUSTOM },
              m.getValues());
  
          assertNull(m.getDeletedKeys());
      }
  
      public void testGet()
      {
          ListEditMap m = create();
  
          m.setKey("auto");
  
          assertEquals("auto", m.getKey());
          assertSame(Direction.AUTO, m.getValue());
      }
  
      public void testGetUnknown()
      {
          ListEditMap m = create();
  
          m.setKey("unknown");
  
          assertNull(m.getValue());
      }
  
      public void testMarkDeleted()
      {
          ListEditMap m = create();
  
          m.setKey("auto");
  
          assertEquals(false, m.isDeleted());
  
          m.setDeleted(true);
  
          assertEquals(true, m.isDeleted());
  
          checkList(
              "all values",
              new Object[] { Direction.IN, Direction.AUTO, Direction.CUSTOM },
              m.getAllValues());
  
          checkList(
              "undeleted values",
              new Object[] { Direction.IN, Direction.CUSTOM },
              m.getValues());
  
          checkList("deleted keys", new Object[] { "auto" }, m.getDeletedKeys());
      }
  
      public void testMarkAlreadyDeleted()
      {
  
          ListEditMap m = create();
  
          m.setKey("auto");
  
          assertEquals(false, m.isDeleted());
  
          m.setDeleted(false);
  
          assertEquals(false, m.isDeleted());
      }
  
      public void testMarkMultipleDeleted()
      {
          ListEditMap m = create();
  
          m.setKey("auto");
          m.setDeleted(true);
  
          m.setKey("custom");
          assertEquals(false, m.isDeleted());
          m.setDeleted(true);
  
          assertEquals(true, m.isDeleted());
  
          checkList("undeleted values", new Object[] { Direction.IN }, m.getValues());
      }
  
      public void testDeleteUndelete()
      {
          ListEditMap m = create();
  
          m.setKey("auto");
          m.setDeleted(true);
          m.setDeleted(false);
  
          m.setKey("custom");
          m.setDeleted(true);
  
          checkList("undeleted values", new Object[] { Direction.IN, Direction.AUTO }, m.getValues());
      }
  
  }
  
  

Mime
View raw message