public void testUpateAircraftTaxiOutObjectAttributes() { // set the attributes to be updated // AircraftTaxiOut newAircraftTaxiOut = new AircraftTaxiOut(); // NOTE: Used only since the unit testing is conducted in the VM. // Changing // this emulates what would happen if the objects were residing on // separate // machines and thus address spaces. newAircraftTaxiOut.setDataObjectUUID(aircraftTaxiOut.getDataObjectUUID()); newAircraftTaxiOut.setCallSign(callSign); newAircraftTaxiOut.setTailNumber(tailNumber); newAircraftTaxiOut.setTaxiOutGate(newTaxiOutGate); newAircraftTaxiOut.setTaxiOutTimeMSecs(System.currentTimeMillis()); Set<String> fieldsToUpdate = new HashSet<String>(); fieldsToUpdate.add(EventAttributeName.taxiOutGate.toString()); fieldsToUpdate.add(EventAttributeName.taxiOutTimeMSecs.toString()); try { objectService.updateObjectAttributes( federationExecutionID, newAircraftTaxiOut, fieldsToUpdate); } catch (MuthurException e) { fail(e.getLocalizedMessage()); } // will retrieve the updated object from the object service and compare // it // to the object which should accurately test whether the update was // applied assertObjectExists(aircraftTaxiOut); }
public void testAddAircraftTaxiOutObject() { aircraftTaxiOut = null; try { aircraftTaxiOut = new AircraftTaxiOut(tailNumber, callSign); } catch (MuthurException e) { fail(e.getLocalizedMessage()); } aircraftTaxiOut.setTaxiOutTimeMSecs(System.currentTimeMillis()); aircraftTaxiOut.setTaxiOutGate(taxiOutGate); // add the aircraft taxi in try { objectService.addDataObject(federationExecutionID, aircraftTaxiOut); } catch (MuthurException e) { fail(e.getLocalizedMessage()); } assertObjectExists(aircraftTaxiOut); }
@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); }