Package org.izi

Examples of org.izi.ModelForTests


   @Test
   public void shouldBindSelectedIndicesOfList()
   {
      // given
      ModelForTests model = new ModelForTests();
      Object[] items = {"a", "b", "c"};
      JList list = new JList(items);
      bind().selectedIndicesOf(list).to(model, ModelForTests.SELECTED_INDICES);
      // when
      list.setSelectedIndex(1);
      // then
      assertEquals(1, model.getSelectedIndices().length);
      assertEquals(1, model.getSelectedIndices()[0]);
   }
View Full Code Here


   @Test
   public void shouldBindSelectedRowsOfTable()
   {
      // given
      ModelForTests model = new ModelForTests();
      JTable table = new JTable(3, 2);
      bind().selectedRowIndicesOf(table).to(model, ModelForTests.SELECTED_INDICES);
      // when
      table.getSelectionModel().setSelectionInterval(1, 1);
      // then
      assertEquals(1, model.getSelectedIndices().length);
      assertEquals(1, model.getSelectedIndices()[0]);
   }
View Full Code Here

   @Test
   public void shouldNotPropagateValuesWhenUnbound()
   {
      // given
      JTextField textField = new JTextField();
      ModelForTests model = new ModelForTests();
      BindingRegistration bindingRegistration = bind().valueOf(model, ModelForTests.NAME).toTextOf(textField);
      model.setName("ABC123");
      bindingRegistration.unbind();
      // when
      model.setName("SomeOtherValue");
      // then
      assertEquals("ABC123", textField.getText());
   }
View Full Code Here

{
   @Test
   public void shouldBindArrayToComboBoxModel() throws Exception
   {
      // given
      ModelForTests model = new ModelForTests();
      JComboBox box = new JComboBox();
      Binding.bind().valueOf(model, ModelForTests.ITEMS).toItemsOf(box);
      Object[] items = {"a", "b"};
      // when
      model.setItems(items);
      // then
      assertEquals(2, box.getModel().getSize());
      assertEquals(items[0], box.getModel().getElementAt(0));
      assertEquals(items[1], box.getModel().getElementAt(1));
   }
View Full Code Here

   @Test
   public void shouldBindCollectionToComboBoxModel() throws Exception
   {
      // given
      ModelForTests model = new ModelForTests();
      JComboBox box = new JComboBox();
      Binding.bind().valueOf(model, ModelForTests.ITEMS_AS_LIST).toItemsOf(box);
      Object[] items = {"a", "b"};
      // when
      model.setItemsAsList(Arrays.asList(items));
      // then
      assertEquals(2, box.getModel().getSize());
      assertEquals(items[0], box.getModel().getElementAt(0));
      assertEquals(items[1], box.getModel().getElementAt(1));
   }
View Full Code Here

TOP

Related Classes of org.izi.ModelForTests

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.