/** @param objectAsXML */
  public void initialization(final String objectAsXML) throws MuthurException {
    super.initialization(objectAsXML);

    dataObject = DataObjectFactory.getDataObject(getDataType());

    if (dataObject == null) {
      throw new MuthurException(
          "DataObjectFactory.getDataObject() returned a null object for [" + getDataType() + "]");
    }

    dataObject.initialization(objectAsXML);
  }
  @Test
  public void testCreateOrUpdateObjectRequestWithAircraftTaxOutObject() {

    AircraftTaxiOut atod = null;

    try {
      atod = new AircraftTaxiOut(tailNumber, acid);
    } catch (Exception e) {
      fail(e.getLocalizedMessage());
    }

    assertNotNull(atod);

    assertEquals(atod.getCallSign(), acid);
    assertEquals(atod.getTailNumber(), tailNumber);
    assertNotNull(atod.getDataObjectUUID());
    assertFalse(atod.getDataObjectUUID().equalsIgnoreCase(""));
    assertTrue(atod.getObjectCreateTimeMSecs() != 0L);

    // gate taxiing from

    atod.setTaxiOutGate("C17");

    // taxi out data

    atod.setTaxiOutTimeMSecs(System.currentTimeMillis() + 30);

    // create a CreateOrUpdateObjectRequest

    CreateOrUpdateObjectRequest cor = new CreateOrUpdateObjectRequest();
    assertNotNull(cor);

    cor.setFederationExecutionHandle(UUID.randomUUID().toString());
    cor.setFederateRegistrationHandle(UUID.randomUUID().toString());
    cor.setFederationExecutionModelHandle(UUID.randomUUID().toString());
    cor.setSourceOfEvent("NexSim");
    cor.setDataObject(atod);

    // serialize the object

    String corAsXML = cor.serialize();

    // do standard validation

    assertNotNull(corAsXML);
    assertFalse(corAsXML.equals(""));

    // create another object from previous object's serialized form

    CreateOrUpdateObjectRequest objectFromXML = new CreateOrUpdateObjectRequest();

    try {
      objectFromXML.initialization(corAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // ensure that the two objects are equal

    assertTrue(objectFromXML.equals(cor));

    // get the serialized version of the new object

    String newObjSerializedAsXML = objectFromXML.serialize();

    assertNotNull(newObjSerializedAsXML);
    assertFalse(newObjSerializedAsXML.equals(""));

    IBaseDataObject bdo = objectFromXML.getDataObject();

    assertNotNull(bdo);
    assertTrue(bdo instanceof AircraftTaxiOut);

    /** Initialize the internal data object from the serialized containing object */
    try {
      bdo.initialization(newObjSerializedAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // check the serialized form of the data object
    String bdoSerialized = bdo.serialize();
    assertNotNull(bdoSerialized);
  }
  @Test
  public void testCreateOrUpdateObjectRequestWithFlightPositionObject() {

    FlightPosition flightPosition = null;

    try {
      flightPosition = new FlightPosition(tailNumber, acid);
    } catch (Exception e) {
      fail(e.getLocalizedMessage());
    }

    assertNotNull(flightPosition);

    assertEquals(flightPosition.getCallSign(), acid);
    assertEquals(flightPosition.getTailNumber(), tailNumber);
    assertNotNull(flightPosition.getDataObjectUUID());
    assertFalse(flightPosition.getDataObjectUUID().equalsIgnoreCase(""));
    assertTrue(flightPosition.getObjectCreateTimeMSecs() != 0L);

    // position data

    flightPosition.setLatitudeDegrees(42.65);
    flightPosition.setLongitudeDegrees(-76.72);
    flightPosition.setAltitudeFt(30000);
    flightPosition.setGroundspeedKts(400);
    flightPosition.setHeadingDegrees(90);
    flightPosition.setAirspeedKts(444);
    flightPosition.setPitchDegrees(0.5);
    flightPosition.setRollDegrees(0);
    flightPosition.setYawDegrees(0);
    flightPosition.setSector("ZOB48");
    flightPosition.setCenter("ZOB");

    flightPosition.setVerticalspeedKts(verticalspeedKts);
    flightPosition.setAircraftOnGround(aircraftOnGround);
    flightPosition.setAircraftTransmissionFrequency(aircraftTransmissionFrequency);
    flightPosition.setSquawkCode(squawkCode);
    flightPosition.setIdent(ident);

    // create a CreateOrUpdateObjectRequest

    CreateOrUpdateObjectRequest cor = new CreateOrUpdateObjectRequest();
    assertNotNull(cor);

    cor.setFederationExecutionHandle(UUID.randomUUID().toString());
    cor.setFederateRegistrationHandle(UUID.randomUUID().toString());
    cor.setFederationExecutionModelHandle(UUID.randomUUID().toString());
    cor.setSourceOfEvent("NexSim");
    cor.setDataObject(flightPosition);

    // serialize the object

    String corAsXML = cor.serialize();

    // do standard validation

    assertNotNull(corAsXML);
    assertFalse(corAsXML.equals(""));

    // create another object from previous object's serialized form

    CreateOrUpdateObjectRequest objectFromXML = new CreateOrUpdateObjectRequest();

    try {
      objectFromXML.initialization(corAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // ensure that the two objects are equal

    assertTrue(objectFromXML.equals(cor));

    // get the serialized version of the new object

    String newObjSerializedAsXML = objectFromXML.serialize();

    assertNotNull(newObjSerializedAsXML);
    assertFalse(newObjSerializedAsXML.equals(""));

    IBaseDataObject bdo = objectFromXML.getDataObject();

    assertNotNull(bdo);
    assertTrue(bdo instanceof FlightPosition);

    /** Initialize the internal data object from the serialized containing object */
    try {
      bdo.initialization(newObjSerializedAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // check the serialized form of the data object
    String bdoSerialized = bdo.serialize();
    assertNotNull(bdoSerialized);
  }
  @Test
  public void testCreateOrUpdateObjectRequestWithFlightPlanObject() {

    FlightPlan flightPlan = null;

    try {
      flightPlan = new FlightPlan(tailNumber, acid);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    assertNotNull(flightPlan);

    assertEquals(flightPlan.getCallSign(), acid);
    assertEquals(flightPlan.getTailNumber(), tailNumber);
    assertNotNull(flightPlan.getDataObjectUUID());
    assertFalse(flightPlan.getDataObjectUUID().equalsIgnoreCase(""));
    assertTrue(flightPlan.getObjectCreateTimeMSecs() != 0L);

    // flight plan data

    flightPlan.setSource("Flight");
    flightPlan.setAircraftType("B771");
    flightPlan.setPlannedDepartureTimeMSecs(System.currentTimeMillis() + 10);
    flightPlan.setPlannedDepartureRunway("1R");
    flightPlan.setPlannedTaxiOutGate("D31");
    flightPlan.setDepartureFix("DEFIX");
    flightPlan.setDepartureCenter("ZID");

    flightPlan.setPlannedArrivalTimeMSecs(System.currentTimeMillis() + 20);
    flightPlan.setPlannedArrivalRunway("8L");
    flightPlan.setPlannedTaxiInGate("C11");
    flightPlan.setArrivalCenter("ZBW");
    flightPlan.setArrivalFix("ARFIX");

    flightPlan.setCruiseSpeedKts(400);
    flightPlan.setCruiseAltitudeFt(330);
    flightPlan.setRoutePlan("IND..ROD.J29.PLB.J595.BGR..BGR");
    flightPlan.setPhysicalAircraftClass("J");
    flightPlan.setWeightAircraftClass("H");
    flightPlan.setUserAircraftClass("C");
    flightPlan.setNumOfAircraft(1);
    flightPlan.setAirborneEquipmentQualifier("R");
    flightPlan.setFlightPlanStatus(FlightPlanStatus.CANCELLED);

    // create a CreateOrUpdateObjectRequest

    CreateOrUpdateObjectRequest cor = new CreateOrUpdateObjectRequest();
    assertNotNull(cor);

    cor.setFederationExecutionHandle(UUID.randomUUID().toString());
    cor.setFederateRegistrationHandle(UUID.randomUUID().toString());
    cor.setFederationExecutionModelHandle(UUID.randomUUID().toString());
    cor.setSourceOfEvent("NexSim");
    cor.setDataObject(flightPlan);

    // serialize the object

    String corAsXML = cor.serialize();

    writeToFile(cor, false);

    // do standard validation

    assertNotNull(corAsXML);
    assertFalse(corAsXML.equals(""));

    // create another object from previous object's serialized form

    CreateOrUpdateObjectRequest objectFromXML = new CreateOrUpdateObjectRequest();

    try {
      objectFromXML.initialization(corAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // ensure that the two objects are equal

    assertTrue(objectFromXML.equals(cor));

    // get the serialized version of the new object

    String newObjSerializedAsXML = objectFromXML.serialize();

    assertNotNull(newObjSerializedAsXML);
    assertFalse(newObjSerializedAsXML.equals(""));

    IBaseDataObject bdo = objectFromXML.getDataObject();

    assertNotNull(bdo);
    assertTrue(bdo instanceof FlightPlan);

    /** Initialize the internal data object from the serialized containing object */
    try {
      bdo.initialization(newObjSerializedAsXML);
    } catch (MuthurException e) {
      fail(e.getLocalizedMessage());
    }

    // check the serialized form of the data object
    String bdoSerialized = bdo.serialize();
    assertNotNull(bdoSerialized);
  }