public void testAddAircraftArrivalObject() { aircraftArrival = null; try { aircraftArrival = new AircraftArrival(tailNumber, callSign); } catch (MuthurException e) { fail(e.getLocalizedMessage()); } aircraftArrival.setActualArrivalTimeMSecs(System.currentTimeMillis()); aircraftArrival.setArrivalAirportCode(arrivalAirportCode); aircraftArrival.setArrivalRunway(arrivalRunwayName); // add the aircraft arrival try { objectService.addDataObject(federationExecutionID, aircraftArrival); } catch (MuthurException e) { fail(e.getLocalizedMessage()); } assertObjectExists(aircraftArrival); }
public void testUpateAircraftArrivalObjectAttributes() { // set the attributes to be updated // AircraftArrival newAircraftArrival = new AircraftArrival(); // 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. newAircraftArrival.setDataObjectUUID(aircraftArrival.getDataObjectUUID()); newAircraftArrival.setCallSign(callSign); newAircraftArrival.setTailNumber(tailNumber); newAircraftArrival.setActualArrivalTimeMSecs(System.currentTimeMillis()); newAircraftArrival.setArrivalRunway(arrivalRunwayName); newAircraftArrival.setArrivalAirportCode(arrivalAirportCode); Set<String> fieldsToUpdate = new HashSet<String>(); fieldsToUpdate.add(EventAttributeName.arrivalRunway.toString()); fieldsToUpdate.add(EventAttributeName.arrivalAirportCode.toString()); try { objectService.updateObjectAttributes( federationExecutionID, newAircraftArrival, 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(aircraftArrival); }
@Test public void testCreateOrUpdateObjectRequestWithAircraftArrivalObject() { AircraftArrival acad = null; try { acad = new AircraftArrival(tailNumber, acid); } catch (Exception e) { fail(e.getLocalizedMessage()); } assertNotNull(acad); assertEquals(acad.getCallSign(), acid); assertEquals(acad.getTailNumber(), tailNumber); assertNotNull(acad.getDataObjectUUID()); assertFalse(acad.getDataObjectUUID().equalsIgnoreCase("")); assertTrue(acad.getObjectCreateTimeMSecs() != 0L); // arrival time acad.setActualArrivalTimeMSecs(System.currentTimeMillis() + 40); // arrival APs acad.setArrivalAirportCode("ORD"); // set runway acad.setArrivalRunway("7R"); // create a CreateObjectRequest 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(acad); // 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 AircraftArrival); /** 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); }