/** This operation checks that Materials.equals() and Materials.hashCode() work. */ @Test public void checkEquality() { // Create two test materials to compare against each other Material testMat1 = TestMaterialFactory.createCO2(); Material testMat2 = TestMaterialFactory.createCO2(); // They should be equal assertTrue(testMat1.equals(testMat2)); // Make sure that a self comparison works assertTrue(testMat1.equals(testMat1)); // Make sure that passing something else in fails assertFalse(testMat1.equals(1)); // Check that the hash code doesn't change with no changes in state assertEquals(testMat1.hashCode(), testMat1.hashCode()); // Check that they have the same hash codes assertEquals(testMat1.hashCode(), testMat2.hashCode()); }