/**
   * This operation checks the Material class to make sure that simple attributes such as names and
   * properties can be changed.
   */
  @Test
  public void checkSimpleAttributes() {

    // Local Declarations
    Material testMaterial = TestMaterialFactory.createCO2();

    // Check the name
    testMaterial.setName("CO2");
    assertEquals("CO2", testMaterial.getName());

    // Check properties - just test handling a few
    testMaterial.setProperty("molar mass (g/mol)", 44.01);
    double mass = testMaterial.getProperty("molar mass (g/mol)");
    assertEquals(44.01, mass, 1.0e-16);
    testMaterial.setProperty("vapor pressure (MPa)", 5.73);
    double pressure = testMaterial.getProperty("vapor pressure (MPa)");
    assertEquals(5.73, pressure, 1.0e-16);

    // Get all the properties and make sure they have molar mass and vapor
    // pressure.
    Map<String, Double> properties = testMaterial.getProperties();
    assertTrue(properties.containsKey("molar mass (g/mol)"));
    assertTrue(properties.containsKey("vapor pressure (MPa)"));

    // Make sure that requesting a property that isn't in the map returns
    // 0.0.
    assertEquals(0.0, testMaterial.getProperty("penguin"), 1.0e-8);

    // Make some more test materials
    Material carbon = new Material();
    carbon.setName("C");

    Material c1 = new Material();
    c1.setName("12C");

    // Test the get isotopic number and get elemental name
    assertEquals(12, c1.getIsotopicNumber());
    assertEquals(carbon.getName(), carbon.getElementalName());
    assertEquals(0, carbon.getIsotopicNumber());
    assertEquals(carbon.getName(), c1.getElementalName());

    return;
  }
  /**
   * This operation creates a simple H2O Material that can be used for testing.
   *
   * @return the test material
   */
  public static Material createH2O() {

    // Create a simple H2O Material
    Material testMaterial = new Material();
    testMaterial.setName("H2O");
    testMaterial.setProperty("molar mass (g/mol)", 18.01);
    // Vapor pressure at 273 K
    testMaterial.setProperty("vapor pressure (MPa)", 611.0e-6);

    // Create component 1 - Hydrogen
    Material hydrogen = new Material();
    hydrogen.setName("H");

    // Create component 2 - Oxygen
    Material oxygen = new Material();
    oxygen.setName("O");

    // Add them as components
    testMaterial.addComponent(hydrogen);
    testMaterial.addComponent(hydrogen);
    testMaterial.addComponent(oxygen);

    return testMaterial;
  }
  /**
   * This operation creates a simple CO2 Material that can be used for testing.
   *
   * @return the test material
   */
  public static Material createCO2() {

    // Create a simple CO2 Material
    Material testMaterial = new Material();
    testMaterial.setName("CO2");
    testMaterial.setProperty("molar mass (g/mol)", 44.01);
    testMaterial.setProperty("vapor pressure (MPa)", 5.73);

    // Create component 1 - Carbon
    Material carbon = new Material();
    carbon.setName("C");

    // Create component 2 - Oxygen
    Material oxygen = new Material();
    oxygen.setName("O");
    // Note that the "size" of O is 2 since we need O2

    // Add them as components
    testMaterial.addComponent(carbon);
    testMaterial.addComponent(oxygen);
    testMaterial.addComponent(oxygen);

    return testMaterial;
  }
  /** @throws java.lang.Exception */
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {

    // Create the Material for the test
    material = new Material();
    material.setName("Fluffy");
    material.setProperty("A", 1.0);
    material.setProperty("B", 2.0);

    // Store the property names
    columnNames = new ArrayList<String>();
    columnNames.addAll(material.getProperties().keySet());

    // Create the table format
    tableFormat = new MaterialWritableTableFormat(columnNames);

    return;
  }
  /**
   * Test method for {@link
   * org.eclipse.ice.materials.MaterialWritableTableFormat#getColumnValue(org.eclipse.ice.datastructures.form.Material,
   * int)} .
   */
  @Test
  public void testGetColumnValue() {

    // Reset the property values since the tests can run out of order.
    material.setProperty("A", 1.0);
    material.setProperty("B", 2.0);

    // Check that the value is either the value for A or the value for B.
    // Since there is no guarantee on order, this is the only good way to do
    // it.
    Object value = tableFormat.getColumnValue(material, 0);
    assertEquals(value, "Fluffy");
    Double dValue = (Double) tableFormat.getColumnValue(material, 1);
    assertTrue(dValue.equals(1.0) || dValue.equals(2.0));
    dValue = (Double) tableFormat.getColumnValue(material, 2);
    assertTrue(dValue.equals(1.0) || dValue.equals(2.0));

    return;
  }