public void testAddAircraftTaxiInObject() { aircraftTaxiIn = null; try { aircraftTaxiIn = new AircraftTaxiIn(tailNumber, callSign); } catch (MuthurException e) { fail(e.getLocalizedMessage()); } aircraftTaxiIn.setTaxiInTimeMSecs(System.currentTimeMillis()); aircraftTaxiIn.setTaxiInGate(taxiInGate); // add the aircraft taxi in try { objectService.addDataObject(federationExecutionID, aircraftTaxiIn); } catch (MuthurException e) { fail(e.getLocalizedMessage()); } assertObjectExists(aircraftTaxiIn); }
public void testUpateAircraftTaxiInObjectAttributes() { // set the attributes to be updated // AircraftTaxiIn newAircraftTaxiIn = new AircraftTaxiIn(); // 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. newAircraftTaxiIn.setDataObjectUUID(aircraftTaxiIn.getDataObjectUUID()); newAircraftTaxiIn.setCallSign(callSign); newAircraftTaxiIn.setTailNumber(tailNumber); newAircraftTaxiIn.setTaxiInGate(newTaxiInGate); newAircraftTaxiIn.setTaxiInTimeMSecs(System.currentTimeMillis()); Set<String> fieldsToUpdate = new HashSet<String>(); fieldsToUpdate.add(EventAttributeName.taxiInGate.toString()); fieldsToUpdate.add(EventAttributeName.taxiInTimeMSecs.toString()); try { objectService.updateObjectAttributes( federationExecutionID, newAircraftTaxiIn, 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(aircraftTaxiIn); }
@Test public void testCreateOrUpdateObjectRequestWithAircraftTaxInObject() { AircraftTaxiIn aircraftTaxiInData = null; try { aircraftTaxiInData = new AircraftTaxiIn(tailNumber, acid); } catch (Exception e) { fail(e.getLocalizedMessage()); } assertNotNull(aircraftTaxiInData); assertEquals(aircraftTaxiInData.getCallSign(), acid); assertEquals(aircraftTaxiInData.getTailNumber(), tailNumber); assertNotNull(aircraftTaxiInData.getDataObjectUUID()); assertFalse(aircraftTaxiInData.getDataObjectUUID().equalsIgnoreCase("")); assertTrue(aircraftTaxiInData.getObjectCreateTimeMSecs() != 0L); // gate taxiing to aircraftTaxiInData.setTaxiInGate("D5"); // taxi in data aircraftTaxiInData.setTaxiInTimeMSecs(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(aircraftTaxiInData); // 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 AircraftTaxiIn); /** 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); }