public static void compareCommands(Command expected, Command actual, boolean ignoreSortOrder) {
    // The reason we use compare-command, rather than simply getting the serialized output and comparing
    // for partition-based commands is that the partition specification order can be different in different
    // serializations, but still be effectively the same. (a="42",b="abc") should be the same as (b="abc",a="42")
    assertEquals(expected.getClass(),actual.getClass());
    assertEquals(expected.getEventId(),actual.getEventId());
    assertEquals(expected.isUndoable(),actual.isUndoable());
    assertEquals(expected.isRetriable(),actual.isRetriable());

    assertEquals(expected.get().size(),actual.get().size());
    Iterator<String> actualIter = actual.get().iterator();
    for (String s : expected.get()){
      if (ignoreSortOrder){
        // compare sorted strings, rather than comparing exact strings.
        assertSortedEquals(s, actualIter.next());
      } else {
        assertEquals(s,actualIter.next());
      }
    }

    if (expected.isUndoable()){
      Iterator<String> actualUndoIter = actual.getUndo().iterator();
      for (String s: expected.getUndo()){
        if (ignoreSortOrder){
          assertSortedEquals(s,actualUndoIter.next());
        } else {
          assertEquals(s,actualIter.next());
        }
      }
    }
  }
Class which provides several useful methods to test commands, but is itself not a test.
hcatalog/webhcat/java-client/src/test/java/org/apache/hive/hcatalog/api/repl/CommandTestUtils.java