/** * This operation checks that a set of materials can properly sort itself using the compare to * method on the material's names. For example, sorting a list such as b, c, 1c, d, f, 5c should * give the resulting order of a, b, c, 1c, 5c, d, f. */ @Test public void checkSorting() { // Make some test materials Material A = new Material(); A.setName("A"); Material B = new Material(); B.setName("B"); Material co2 = TestMaterialFactory.createCO2(); Material B1 = new Material(); B1.setName("3B"); // Make sure that alphabetical order is followed assertTrue(A.compareTo(B) < 0); // Make sure that isotopes go in numeric order assertTrue(B.compareTo(B1) < 0); // Make sure that a blank material would be at the front of a list assertTrue(A.compareTo(new Material()) > 0); // Make sure that if materials have the same name they are the same when // compared. Material A1 = new Material(); A1.setName(A.getName()); assertTrue(A.compareTo(A1) == 0); // Make sure that the compound is in proper alphabetic order (no numeric // sorting). assertTrue(co2.compareTo(B1) > 0); Material C = new Material(); C.setName("C"); assertTrue(C.compareTo(co2) < 0); }