/** Accuracy Test of the <code>getValueAt(int, int)</code> method. */ public void testgetValueAt() { // creat a new vlaues. List<String> row = new ArrayList<String>(); row.add("col1"); row.add("col2"); List<List<String>> values = new ArrayList<List<String>>(); for (int i = 0; i < 4; i++) { values.add(row); } // create a new value objects TaggedValue taggedObject = new TaggedValueImpl(); List<TaggedValue> valueObjects = new ArrayList<TaggedValue>(); for (int i = 0; i < 4; i++) { valueObjects.add(taggedObject); } // update the new values. tagTable.updateValues(values, valueObjects); // get the cell (3, 1) to check the method. assertEquals("The value expected to be equal", "col2", tagTable.getValueAt(3, 1)); // get the cell (2, 0) to check the method. assertEquals("The value expected to be equal", "col1", tagTable.getValueAt(2, 0)); // get the cell (4, 0) to check the method. assertEquals("The value expected to be equal", DEFAULT_TAG_PROMPT, tagTable.getValueAt(4, 0)); // get the cell (4, 1) to check the method. assertEquals("The value expected to be equal", "", tagTable.getValueAt(4, 1)); // get the cell out of range to check the method. assertNull("The value expected to be null", tagTable.getValueAt(10, 0)); }
/** Accuracy Test of the <code>setValueAt(Objectint, int)</code> method. */ public void testsetValueAt() { // creat a new vlaues. List<String> row = new ArrayList<String>(); row.add("col1"); row.add("col2"); List<List<String>> values = new ArrayList<List<String>>(); for (int i = 0; i < 4; i++) { values.add(row); } // create a new value objects TaggedValue taggedObject = new TaggedValueImpl(); List<TaggedValue> valueObjects = new ArrayList<TaggedValue>(); for (int i = 0; i < 4; i++) { valueObjects.add(taggedObject); } // update the new values. tagTable.updateValues(values, valueObjects); // get the row number to check the method. assertEquals("The value expected to be equal", 5, tagTable.getRowCount()); // delete the row 3 tagTable.setValueAt("", 2, 1); // get the row number to check the method. assertEquals("The value expected to be equal", 4, tagTable.getRowCount()); // update the row 2; tagTable.setValueAt("my", 1, 1); // get the cell (2, 0) to check the method. assertEquals("The value expected to be equal", "my", tagTable.getValueAt(1, 1)); // creat a new row tagTable.setValueAt("new Row", 3, 0); // get the cell (3, 0) to check the method. assertTrue( "The value expected to be equal", tagTable.getValueAt(3, 0).toString().endsWith("new Row")); // get the cell (3, 0) to check the method. assertEquals("The value expected to be equal", DEFAULT_VALUE_PROMPT, tagTable.getValueAt(3, 1)); }