/** * This operation checks that the Material class can properly manage a set of component Materials * that define its detailed composition. */ @Test public void checkComponents() { // Local Declarations Material testMaterial = TestMaterialFactory.createCO2(); // Check its components assertNotNull(testMaterial.getComponents()); List<MaterialStack> components = testMaterial.getComponents(); assertEquals(2, components.size()); // Get the Materials Material firstMaterial = components.get(0).getMaterial(); Material secondMaterial = components.get(1).getMaterial(); // Check them in an order independent way. It is enough to check that // the components are there. There is no need to check their sizes. assertTrue( ("C".equals(firstMaterial.getName()) && "O".equals(secondMaterial.getName())) || ("O".equals(firstMaterial.getName()) && "C".equals(secondMaterial.getName()))); }