Пример #1
0
  public void testIdentityCalculator() throws Exception {
    execute("CRUD.new");
    assertNoErrors();
    setValue("number", "-1"); // needed in this case because 0 is an existing key
    setValue("name", "JUNIT COLOR " + (int) (Math.random() * 200));
    execute("TypicalNotResetOnSave.save");
    assertNoErrors();
    String last = getValue("number");

    execute("CRUD.new");
    assertNoErrors();
    setValue("number", "-1"); // needed in this case because 0 is an existing key
    setValue("name", "JUNIT COLOR " + (int) (Math.random() * 200));
    execute("TypicalNotResetOnSave.save");
    assertNoErrors();
    String next = String.valueOf(Integer.parseInt(last) + 1);
    assertValue("number", next);
  }
 private int[] getWidths(TableModel tableModel) {
   int[] widths = new int[tableModel.getColumnCount()];
   for (int r = 0;
       r < Math.min(tableModel.getRowCount(), 500);
       r++) { // 500 is not for performance, but for using only a sample of data with huge table
     for (int c = 0; c < tableModel.getColumnCount(); c++) {
       Object o = tableModel.getValueAt(r, c);
       if (o instanceof String) {
         String s = ((String) o).trim();
         if (s.length() > widths[c]) widths[c] = s.length();
       }
     }
   }
   return widths;
 }