diff options
author | Kostiantyn Boskin <kostyaboskin@gmail.com> | 2020-08-11 21:31:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-11 14:31:18 -0400 |
commit | b40de485d587ddeac9be65ba91c142a125e976cd (patch) | |
tree | a565a6d346c4ddc140ed7737e8a7e90f9b5ecc88 /android | |
parent | 569aadfb5b9b20809080faedde0534f61e270283 (diff) | |
download | sdl_android-b40de485d587ddeac9be65ba91c142a125e976cd.tar.gz |
New vehicle data WindowStatus (#1396)
* [0261]
- Implement WindowState/WindowStatus structs
- Implement changes in proper requests responses related to new structs
* [0261]
- Fix tests
- Add new tests for WindowStatus/WindowState
- Fix updated Structs according to specification
* [0256]
- Update tests data after code review
- Add WindowStatus in Test.java
- Remove @NonNull from OnVehicleData
- Rename setVehicleDataResult --> setWindowStatus
* [0261]
- Extend testJsonConstructor with new tests
* [0261]
- Update tests after code review
* [0261]
- ValidateWindowStatuses --> ValidateWindowStatus
* [0261]
- Test --> TestValues
* [0261]
- 6.0.0 --> 7.0.0
* [0261]
- Regenerate using Generator
- Fix tests
* [0261]
- Rollback of formatting changes
* [0261]
- Fix compilation errors on merge
* [0261]
- Update javadoc
* Revert LF to CRLF line separators
Co-authored-by: kboskin <kboskin>
Co-authored-by: Vladyslav Mustafin <vmustafin@luxoft.com>
Diffstat (limited to 'android')
16 files changed, 333 insertions, 7 deletions
diff --git a/android/sdl_android/src/androidTest/assets/json/GetVehicleData.json b/android/sdl_android/src/androidTest/assets/json/GetVehicleData.json index 7cef581b7..3c8b6129b 100644 --- a/android/sdl_android/src/androidTest/assets/json/GetVehicleData.json +++ b/android/sdl_android/src/androidTest/assets/json/GetVehicleData.json @@ -32,7 +32,8 @@ "fuelRange":true, "turnSignal":true, "electronicParkBrakeStatus":true, - "oemCustomVehicleDataName":true + "oemCustomVehicleDataName":true, + "windowStatus": true } }, "response":{ @@ -170,7 +171,19 @@ "range":10.0 } ], - "oemCustomVehicleDataName":"oemCustomVehicleDataState" + "oemCustomVehicleDataName":"oemCustomVehicleDataState", + "windowStatus": [ + { + "location": { + "row": 2, + "col": 3 + }, + "state": { + "approximatePosition": 2, + "deviation": 3 + } + } + ] } } }
\ No newline at end of file diff --git a/android/sdl_android/src/androidTest/assets/json/SubscribeVehicleData.json b/android/sdl_android/src/androidTest/assets/json/SubscribeVehicleData.json index e1dfbd39a..a6ec021b0 100644 --- a/android/sdl_android/src/androidTest/assets/json/SubscribeVehicleData.json +++ b/android/sdl_android/src/androidTest/assets/json/SubscribeVehicleData.json @@ -32,6 +32,7 @@ "turnSignal":true, "electronicParkBrakeStatus":true, "oemCustomVehicleDataName":true, + "windowStatus": true, "handsOffSteering": true } }, @@ -158,6 +159,10 @@ "oemCustomVehicleDataName":{ "oemCustomDataType":"oemCustomVehicleDataName", "resultCode":"SUCCESS" + }, + "windowStatus":{ + "dataType":"VEHICLEDATA_WINDOWSTATUS", + "resultCode":"SUCCESS" } } } diff --git a/android/sdl_android/src/androidTest/assets/json/UnsubscribeVehicleData.json b/android/sdl_android/src/androidTest/assets/json/UnsubscribeVehicleData.json index 835fc958d..232e18b4d 100644 --- a/android/sdl_android/src/androidTest/assets/json/UnsubscribeVehicleData.json +++ b/android/sdl_android/src/androidTest/assets/json/UnsubscribeVehicleData.json @@ -32,7 +32,8 @@ "turnSignal":true, "electronicParkBrakeStatus":true, "handsOffSteering": true, - "oemCustomVehicleDataName":true + "oemCustomVehicleDataName":true, + "windowStatus": true } }, "response":{ @@ -158,6 +159,10 @@ "oemCustomVehicleDataName":{ "oemCustomDataType":"oemCustomVehicleDataName", "resultCode":"SUCCESS" + }, + "windowStatus":{ + "dataType":"VEHICLEDATA_WINDOWSTATUS", + "resultCode":"SUCCESS" } } } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java index 37cae48f4..b76fbade1 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/TestValues.java @@ -109,6 +109,8 @@ import com.smartdevicelink.proxy.rpc.WeatherData; import com.smartdevicelink.proxy.rpc.WeatherServiceData; import com.smartdevicelink.proxy.rpc.WeatherServiceManifest; import com.smartdevicelink.proxy.rpc.WindowCapability; +import com.smartdevicelink.proxy.rpc.WindowState; +import com.smartdevicelink.proxy.rpc.WindowStatus; import com.smartdevicelink.proxy.rpc.WindowTypeCapabilities; import com.smartdevicelink.proxy.rpc.enums.AmbientLightStatus; import com.smartdevicelink.proxy.rpc.enums.AppHMIType; @@ -295,6 +297,7 @@ public class TestValues { public static final SoftButtonType GENERAL_SOFTBUTTONTYPE = SoftButtonType.SBT_BOTH; public static final MassageZone GENERAL_MASSAGEZONE = MassageZone.LUMBAR; public static final MassageMode GENERAL_MASSAGEMODE = MassageMode.HIGH; + public static final WindowStatus GENERAL_WINDOW_STATUS = new WindowStatus(); public static final MassageCushion GENERAL_MASSAGECUSHION = MassageCushion.BACK_BOLSTERS; public static final SeatMemoryActionType GENERAL_SEATMEMORYACTIONTYPE = SeatMemoryActionType.SAVE; public static final SupportedSeat GENERAL_SUPPORTEDSEAT = SupportedSeat.DRIVER; @@ -437,6 +440,10 @@ public class TestValues { public static final SeatLocation GENERAL_SEAT_LOCATION = new SeatLocation(); public static final ModuleInfo GENERAL_MODULE_INFO = new ModuleInfo(); public static final WindowType GENERAL_WINDOWTYPE = WindowType.MAIN; + public static final Grid GENERAL_LOCATION_GRID = new Grid(2, 3); + public static final WindowState GENERAL_WINDOW_STATE = new WindowState(2, 3); + public static final Integer GENERAL_APPROX_POSITION = new Integer(3); + public static final Integer GENERAL_DEVIATION = new Integer(2); public static final List<Long> GENERAL_LONG_LIST = Arrays.asList(new Long[]{ 1L, 2L }); public static final List<Turn> GENERAL_TURN_LIST = new ArrayList<Turn>(); public static final List<Choice> GENERAL_CHOICE_LIST = new ArrayList<Choice>(); @@ -1117,6 +1124,8 @@ public class TestValues { GENERAL_MODULE_INFO.setModuleServiceArea(TestValues.GENERAL_GRID); GENERAL_MODULE_INFO.setMultipleAccessAllowance(TestValues.GENERAL_BOOLEAN); + GENERAL_WINDOW_STATUS.setLocation(TestValues.GENERAL_GRID); + GENERAL_WINDOW_STATUS.setState(TestValues.GENERAL_WINDOW_STATE); try { JSON_HMIPERMISSIONS.put(HMIPermissions.KEY_ALLOWED, GENERAL_HMILEVEL_LIST); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java index 69d32c33d..9cf1fdd85 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/Validator.java @@ -3826,4 +3826,67 @@ public class Validator{ } return validateGrid(cap1.getGrid(), cap2.getGrid()); } + + public static boolean validateWindowStatuses(List<WindowStatus> item1, List<WindowStatus> item2) { + if (item1 == null) { + return ( item2 == null ); + } + if (item2 == null) { + return ( item1 == null ); + } + + if (item1.size() != item2.size()) { + return false; + } + + Iterator<WindowStatus> iterator1 = item1.iterator(); + Iterator<WindowStatus> iterator2 = item2.iterator(); + + while(iterator1.hasNext() && iterator2.hasNext()){ + WindowStatus windowStatus1 = iterator1.next(); + WindowStatus windowStatus2 = iterator2.next(); + + if(!validateWindowStatus(windowStatus1, windowStatus2)){ + return false; + } + } + + return true; + } + + public static boolean validateWindowStatus(WindowStatus item1, WindowStatus item2) { + if (item1 == null) { + return ( item2 == null ); + } + if (item2 == null) { + return ( item1 == null ); + } + + if (!validateWindowStates(item1.getState(), item2.getState())) { + return false; + } + if (!validateGrid(item1.getLocation(), item2.getLocation())) { + return false; + } + + return true; + } + + public static boolean validateWindowStates (WindowState item1, WindowState item2) { + if (item1 == null) { + return ( item2 == null ); + } + if (item2 == null) { + return ( item1 == null ); + } + + Integer approxPosition1 = item1.getApproximatePosition(); + Integer approxPosition2 = item2.getApproximatePosition(); + + Integer deviation1 = item1.getDeviation(); + Integer deviation2 = item2.getDeviation(); + + + return approxPosition1.equals(approxPosition2) && deviation1.equals(deviation2); + } } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java index 1ab961d22..f200b46e7 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/VehicleDataHelper.java @@ -10,11 +10,14 @@ import com.smartdevicelink.proxy.rpc.EmergencyEvent; import com.smartdevicelink.proxy.rpc.FuelRange; import com.smartdevicelink.proxy.rpc.GPSData; import com.smartdevicelink.proxy.rpc.GetVehicleDataResponse; +import com.smartdevicelink.proxy.rpc.Grid; import com.smartdevicelink.proxy.rpc.HeadLampStatus; import com.smartdevicelink.proxy.rpc.MyKey; import com.smartdevicelink.proxy.rpc.OnVehicleData; import com.smartdevicelink.proxy.rpc.SingleTireStatus; import com.smartdevicelink.proxy.rpc.TireStatus; +import com.smartdevicelink.proxy.rpc.WindowState; +import com.smartdevicelink.proxy.rpc.WindowStatus; import com.smartdevicelink.proxy.rpc.enums.AmbientLightStatus; import com.smartdevicelink.proxy.rpc.enums.CarModeStatus; import com.smartdevicelink.proxy.rpc.enums.CompassDirection; @@ -72,6 +75,8 @@ public class VehicleDataHelper{ public static final AirbagStatus AIRBAG_STATUS = new AirbagStatus(); public static final EmergencyEvent EMERGENCY_EVENT = new EmergencyEvent(); public static final ClusterModeStatus CLUSTER_MODE_STATUS = new ClusterModeStatus(); + public static final WindowStatus WINDOW_STATUS = new WindowStatus(); + public static final List<WindowStatus> WINDOW_STATUS_LIST = new ArrayList<>(1); public static final MyKey MY_KEY = new MyKey(); public static final FuelRange FUEL_RANGE = new FuelRange(); public static final List<FuelRange> FUEL_RANGE_LIST = new ArrayList<FuelRange>(1); @@ -191,6 +196,10 @@ public class VehicleDataHelper{ public static final FuelType FUEL_RANGE_TYPE = FuelType.GASOLINE; public static final Float FUEL_RANGE_RANGE = TestValues.GENERAL_FLOAT; + // WindowStatus + public static final Grid LOCATION_GRID = TestValues.GENERAL_LOCATION_GRID; + public static final WindowState WINDOW_STATE = TestValues.GENERAL_WINDOW_STATE; + public static final JSONArray JSON_FUEL_RANGE = new JSONArray(); //the OnVehicleData which stores all the information above @@ -321,6 +330,10 @@ public class VehicleDataHelper{ FUEL_RANGE.setRange(FUEL_RANGE_RANGE); FUEL_RANGE_LIST.add(FUEL_RANGE); + //WINDOW_STATUS and WINDOW_STATUS_LIST set up + WINDOW_STATUS.setLocation(LOCATION_GRID); + WINDOW_STATUS.setState(WINDOW_STATE); + WINDOW_STATUS_LIST.add(WINDOW_STATUS); // FUEL_RANGE json array set up try { JSON_FUEL_RANGE.put(FUEL_RANGE.serializeJSON()); @@ -358,6 +371,7 @@ public class VehicleDataHelper{ VEHICLE_DATA.setFuelRange(FUEL_RANGE_LIST); VEHICLE_DATA.setTurnSignal(TURN_SIGNAL); VEHICLE_DATA.setElectronicParkBrakeStatus(ELECTRONIC_PARK_BRAKE_STATUS); + VEHICLE_DATA.setWindowStatus(WINDOW_STATUS_LIST); VEHICLE_DATA.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, OEM_CUSTOM_VEHICLE_DATA_STATE); VEHICLE_DATA.setHandsOffSteering(HANDS_OFF_STEERING); //set up the GetVehicleDataResponse object @@ -390,6 +404,7 @@ public class VehicleDataHelper{ VEHICLE_DATA_RESPONSE.setFuelRange(FUEL_RANGE_LIST); VEHICLE_DATA_RESPONSE.setTurnSignal(TURN_SIGNAL); VEHICLE_DATA_RESPONSE.setElectronicParkBrakeStatus(ELECTRONIC_PARK_BRAKE_STATUS); + VEHICLE_DATA_RESPONSE.setWindowStatus(WINDOW_STATUS_LIST); VEHICLE_DATA_RESPONSE.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, OEM_CUSTOM_VEHICLE_DATA_STATE); VEHICLE_DATA_RESPONSE.setHandsOffSteering(HANDS_OFF_STEERING); } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowStateTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowStateTests.java new file mode 100644 index 000000000..3289f1190 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowStateTests.java @@ -0,0 +1,52 @@ +package com.smartdevicelink.test.rpc.datatypes; + +import com.smartdevicelink.marshal.JsonRPCMarshaller; +import com.smartdevicelink.proxy.rpc.WindowState; +import com.smartdevicelink.test.TestValues; +import com.smartdevicelink.test.Validator; + +import junit.framework.TestCase; + +import org.json.JSONException; +import org.json.JSONObject; + +public class WindowStateTests extends TestCase { + private WindowState msg; + + @Override + protected void setUp() throws Exception { + msg = new WindowState(); + msg.setApproximatePosition(TestValues.GENERAL_APPROX_POSITION); + msg.setDeviation(TestValues.GENERAL_DEVIATION); + } + + public void testRpcValues() { + Integer approxPosition = msg.getApproximatePosition(); + Integer deviation = msg.getDeviation(); + + // Valid Tests + assertEquals(TestValues.MATCH, TestValues.GENERAL_APPROX_POSITION, approxPosition); + assertEquals(TestValues.MATCH, TestValues.GENERAL_DEVIATION, deviation); + } + + public void testJson() { + JSONObject reference = new JSONObject(); + + try { + reference.put(WindowState.KEY_APPROXIMATE_POSITION, TestValues.GENERAL_APPROX_POSITION); + reference.put(WindowState.KEY_DEVIATION, TestValues.GENERAL_DEVIATION); + + JSONObject underTest = msg.serializeJSON(); + assertEquals(TestValues.MATCH, reference.length(), underTest.length()); + + assertTrue(Validator.validateWindowStates( + new WindowState(JsonRPCMarshaller.deserializeJSONObject(reference)), + new WindowState(JsonRPCMarshaller.deserializeJSONObject(underTest))) + ); + + } catch (JSONException e) { + fail(TestValues.JSON_FAIL); + } + } +} + diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowStatusTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowStatusTests.java new file mode 100644 index 000000000..27fa8102c --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/datatypes/WindowStatusTests.java @@ -0,0 +1,53 @@ +package com.smartdevicelink.test.rpc.datatypes; + +import com.smartdevicelink.marshal.JsonRPCMarshaller; +import com.smartdevicelink.proxy.rpc.Grid; +import com.smartdevicelink.proxy.rpc.WindowState; +import com.smartdevicelink.proxy.rpc.WindowStatus; +import com.smartdevicelink.test.TestValues; +import com.smartdevicelink.test.Validator; + +import junit.framework.TestCase; + +import org.json.JSONException; +import org.json.JSONObject; + +public class WindowStatusTests extends TestCase { + private WindowStatus msg; + + @Override + protected void setUp() throws Exception { + msg = new WindowStatus(); + msg.setState(TestValues.GENERAL_WINDOW_STATE); + msg.setLocation(TestValues.GENERAL_LOCATION_GRID); + } + + public void testRpcValues() { + WindowState state = msg.getState(); + Grid locationGrid = msg.getLocation(); + + // Valid Tests + assertEquals(TestValues.MATCH, TestValues.GENERAL_WINDOW_STATE, state); + assertEquals(TestValues.MATCH, TestValues.GENERAL_LOCATION_GRID, locationGrid); + } + + public void testJson() { + JSONObject reference = new JSONObject(); + + try { + reference.put(WindowStatus.KEY_STATE, TestValues.GENERAL_WINDOW_STATE); + reference.put(WindowStatus.KEY_LOCATION, TestValues.GENERAL_LOCATION_GRID); + + JSONObject underTest = msg.serializeJSON(); + assertEquals(TestValues.MATCH, reference.length(), underTest.length()); + + assertTrue(Validator.validateWindowStatus( + new WindowStatus(JsonRPCMarshaller.deserializeJSONObject(reference)), + new WindowStatus(JsonRPCMarshaller.deserializeJSONObject(underTest))) + ); + + } catch (JSONException e) { + fail(TestValues.JSON_FAIL); + } + } +} diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java index e11fbe300..6b6b8a144 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataTypeTests.java @@ -84,7 +84,10 @@ public class VehicleDataTypeTests extends TestCase { VehicleDataType enumVehicleDataOemVehicleDataType= VehicleDataType.valueForString(example); example = "VEHICLEDATA_HANDSOFFSTEERING"; VehicleDataType enumVehicleDataHandsOffSteeringType= VehicleDataType.valueForString(example); - + + example = "VEHICLEDATA_WINDOWSTATUS"; + VehicleDataType enumVehicleDataTypeWindowStatus= VehicleDataType.valueForString(example); + assertNotNull("VEHICLEDATA_GPS returned null", enumVehicleDataGps); assertNotNull("VEHICLEDATA_SPEED returned null", enumVehicleDataSpeed); assertNotNull("VEHICLEDATA_RPM returned null", enumVehicleDataRpm); @@ -118,6 +121,7 @@ public class VehicleDataTypeTests extends TestCase { assertNotNull("VEHICLEDATA_CLOUDAPPVEHICLEID returned null", enumVehicleCloudAppVehicleId); assertNotNull("VEHICLEDATA_OEM_CUSTOM_DATA returned null", enumVehicleDataOemVehicleDataType); assertNotNull("VEHICLEDATA_HANDSOFFSTEERING returned null", enumVehicleDataHandsOffSteeringType); + assertNotNull("VEHICLEDATA_WINDOWSTATUS returned null", enumVehicleDataTypeWindowStatus); } /** @@ -188,6 +192,7 @@ public class VehicleDataTypeTests extends TestCase { enumTestList.add(VehicleDataType.VEHICLEDATA_CLOUDAPPVEHICLEID); enumTestList.add(VehicleDataType.VEHICLEDATA_OEM_CUSTOM_DATA); enumTestList.add(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING); + enumTestList.add(VehicleDataType.VEHICLEDATA_WINDOWSTATUS); assertTrue("Enum value list does not match enum class list", enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java index 29cf87bc7..45c3b29ee 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnVehicleDataTests.java @@ -17,6 +17,7 @@ import com.smartdevicelink.proxy.rpc.MyKey; import com.smartdevicelink.proxy.rpc.OnVehicleData; import com.smartdevicelink.proxy.rpc.SingleTireStatus; import com.smartdevicelink.proxy.rpc.TireStatus; +import com.smartdevicelink.proxy.rpc.WindowStatus; import com.smartdevicelink.proxy.rpc.enums.ComponentVolumeStatus; import com.smartdevicelink.proxy.rpc.enums.ElectronicParkBrakeStatus; import com.smartdevicelink.proxy.rpc.enums.PRNDL; @@ -100,6 +101,7 @@ public class OnVehicleDataTests extends BaseRpcTests{ result.put(OnVehicleData.KEY_TURN_SIGNAL, VehicleDataHelper.TURN_SIGNAL); result.put(OnVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS); result.put(OnVehicleData.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING); + result.put(OnVehicleData.KEY_WINDOW_STATUS, VehicleDataHelper.WINDOW_STATUS_LIST); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); } catch(JSONException e) { fail(TestValues.JSON_FAIL); @@ -141,6 +143,7 @@ public class OnVehicleDataTests extends BaseRpcTests{ ClusterModeStatus cluster = ( (OnVehicleData) msg).getClusterModeStatus(); MyKey key = ( (OnVehicleData) msg).getMyKey(); List<FuelRange> fuelRangeList = ( (OnVehicleData) msg).getFuelRange(); + List<WindowStatus> windowStatusList = ( (OnVehicleData) msg).getWindowStatus(); TurnSignal turnSignal = ( (OnVehicleData) msg).getTurnSignal(); ElectronicParkBrakeStatus electronicParkBrakeStatus = ( (OnVehicleData) msg).getElectronicParkBrakeStatus(); Object oemCustomVehicleData = ( (OnVehicleData) msg).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); @@ -173,6 +176,7 @@ public class OnVehicleDataTests extends BaseRpcTests{ assertTrue(TestValues.TRUE, Validator.validateClusterModeStatus(VehicleDataHelper.CLUSTER_MODE_STATUS, cluster)); assertTrue(TestValues.TRUE, Validator.validateMyKey(VehicleDataHelper.MY_KEY, key)); assertTrue(TestValues.TRUE, Validator.validateFuelRange(VehicleDataHelper.FUEL_RANGE_LIST, fuelRangeList)); + assertTrue(TestValues.TRUE, Validator.validateWindowStatuses(VehicleDataHelper.WINDOW_STATUS_LIST, windowStatusList)); assertEquals(TestValues.MATCH, VehicleDataHelper.TURN_SIGNAL, turnSignal); assertEquals(TestValues.MATCH, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS, electronicParkBrakeStatus); assertEquals(TestValues.MATCH, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE, oemCustomVehicleData); @@ -212,6 +216,7 @@ public class OnVehicleDataTests extends BaseRpcTests{ assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -232,8 +237,10 @@ public class OnVehicleDataTests extends BaseRpcTests{ JSONObject clusterModeStatusObj = new JSONObject(); JSONObject myKeyObj = new JSONObject(); JSONObject fuelRangeObj = new JSONObject(); + JSONObject windowStatusObj = new JSONObject(); JSONArray fuelRangeArrayObj = new JSONArray(); - + JSONArray windowStatusArrayObj = new JSONArray(); + try { //Set up the JSONObject to represent OnVehicleData: @@ -359,6 +366,11 @@ public class OnVehicleDataTests extends BaseRpcTests{ fuelRangeObj.put(FuelRange.KEY_RANGE, VehicleDataHelper.FUEL_RANGE_RANGE); fuelRangeArrayObj.put(fuelRangeObj); + // WINDOW_STATUS + windowStatusObj.put(WindowStatus.KEY_LOCATION, VehicleDataHelper.LOCATION_GRID); + windowStatusObj.put(WindowStatus.KEY_STATE, VehicleDataHelper.WINDOW_STATE); + windowStatusArrayObj.put(windowStatusObj); + reference.put(OnVehicleData.KEY_SPEED, VehicleDataHelper.SPEED); reference.put(OnVehicleData.KEY_RPM, VehicleDataHelper.RPM); reference.put(OnVehicleData.KEY_EXTERNAL_TEMPERATURE, VehicleDataHelper.EXTERNAL_TEMPERATURE); @@ -389,6 +401,7 @@ public class OnVehicleDataTests extends BaseRpcTests{ reference.put(OnVehicleData.KEY_TURN_SIGNAL, VehicleDataHelper.TURN_SIGNAL); reference.put(OnVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS); reference.put(OnVehicleData.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING); + reference.put(OnVehicleData.KEY_WINDOW_STATUS, windowStatusArrayObj); reference.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); JSONObject underTest = msg.serializeJSON(); @@ -508,6 +521,25 @@ public class OnVehicleDataTests extends BaseRpcTests{ assertTrue(TestValues.TRUE, Validator.validateFuelRange( fuelRangeRefereceList, fuelRangeUnderTestList)); + } else if (key.equals(OnVehicleData.KEY_WINDOW_STATUS)) { + JSONArray windowStatusArrayObjReference = JsonUtils.readJsonArrayFromJsonObject(reference, key); + List<WindowStatus> windowStatusReferenceList = new ArrayList<>(); + for (int index = 0; index < windowStatusArrayObjReference.length(); index++) { + WindowStatus windowStatus = new WindowStatus(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)windowStatusArrayObjReference.get(index) )); + windowStatusReferenceList.add(windowStatus); + } + + JSONArray windowStatusArrayObjTest = JsonUtils.readJsonArrayFromJsonObject(underTest, key); + List<WindowStatus> windowStatusUnderTestList = new ArrayList<>(); + for (int index = 0; index < windowStatusArrayObjTest.length(); index++) { + WindowStatus windowStatus = new WindowStatus(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)windowStatusArrayObjTest.get(index) )); + windowStatusUnderTestList.add(windowStatus); + } + + assertTrue("JSON value didn't match expected value for key \"" + key + "\".", + Validator.validateWindowStatuses( + windowStatusReferenceList, + windowStatusUnderTestList)); } else { assertEquals(TestValues.TRUE, JsonUtils.readObjectFromJsonObject(reference, key), JsonUtils.readObjectFromJsonObject(underTest, key)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java index 61bc42f54..93b267f02 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/GetVehicleDataTests.java @@ -62,6 +62,7 @@ public class GetVehicleDataTests extends BaseRpcTests { msg.setTurnSignal(TestValues.GENERAL_BOOLEAN); msg.setElectronicParkBrakeStatus(TestValues.GENERAL_BOOLEAN); msg.setHandsOffSteering(TestValues.GENERAL_BOOLEAN); + msg.setWindowStatus(TestValues.GENERAL_BOOLEAN); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); return msg; @@ -112,6 +113,7 @@ public class GetVehicleDataTests extends BaseRpcTests { result.put(GetVehicleData.KEY_TURN_SIGNAL, TestValues.GENERAL_BOOLEAN); result.put(GetVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_BOOLEAN); result.put(GetVehicleData.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_BOOLEAN); + result.put(GetVehicleData.KEY_WINDOW_STATUS, TestValues.GENERAL_BOOLEAN); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); }catch(JSONException e){ fail(TestValues.JSON_FAIL); @@ -157,6 +159,7 @@ public class GetVehicleDataTests extends BaseRpcTests { assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getTurnSignal()); assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getElectronicParkBrakeStatus()); assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getHandsOffSteering()); + assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getWindowStatus()); assertTrue(TestValues.TRUE, ( (GetVehicleData) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -194,6 +197,7 @@ public class GetVehicleDataTests extends BaseRpcTests { assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -247,6 +251,7 @@ public class GetVehicleDataTests extends BaseRpcTests { assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_TURN_SIGNAL), cmd.getTurnSignal()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS), cmd.getElectronicParkBrakeStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_HANDS_OFF_STEERING), cmd.getHandsOffSteering()); + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, GetVehicleData.KEY_WINDOW_STATUS), cmd.getWindowStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME), cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } catch (JSONException e) { fail(TestValues.JSON_FAIL); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java index 09b3d6af7..67b65ec77 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/SubscribeVehicleDataTests.java @@ -61,6 +61,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { msg.setTurnSignal(TestValues.GENERAL_BOOLEAN); msg.setElectronicParkBrakeStatus(TestValues.GENERAL_BOOLEAN); msg.setHandsOffSteering(TestValues.GENERAL_BOOLEAN); + msg.setWindowStatus(TestValues.GENERAL_BOOLEAN); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); return msg; @@ -110,6 +111,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { result.put(SubscribeVehicleData.KEY_TURN_SIGNAL, TestValues.GENERAL_BOOLEAN); result.put(SubscribeVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_BOOLEAN); result.put(SubscribeVehicleData.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_BOOLEAN); + result.put(SubscribeVehicleData.KEY_WINDOW_STATUS, TestValues.GENERAL_BOOLEAN); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); } catch (JSONException e) { fail(TestValues.JSON_FAIL); @@ -154,6 +156,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getTurnSignal()); assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getElectronicParkBrakeStatus()); assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getHandsOffSteering()); + assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getWindowStatus()); assertTrue(TestValues.MATCH,( (SubscribeVehicleData) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -190,6 +193,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -242,6 +246,7 @@ public class SubscribeVehicleDataTests extends BaseRpcTests { assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_TURN_SIGNAL), cmd.getTurnSignal()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS), cmd.getElectronicParkBrakeStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_HANDS_OFF_STEERING), cmd.getHandsOffSteering()); + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, SubscribeVehicleData.KEY_WINDOW_STATUS), cmd.getWindowStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME), cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } catch (JSONException e) { fail(TestValues.JSON_FAIL); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java index 50c6ff44b..4058dbddd 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java @@ -64,6 +64,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { msg.setElectronicParkBrakeStatus(TestValues.GENERAL_BOOLEAN); msg.setCloudAppVehicleID(TestValues.GENERAL_BOOLEAN); msg.setHandsOffSteering(TestValues.GENERAL_BOOLEAN); + msg.setWindowStatus(TestValues.GENERAL_BOOLEAN); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); return msg; @@ -114,6 +115,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { result.put(UnsubscribeVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_BOOLEAN); result.put(UnsubscribeVehicleData.KEY_CLOUD_APP_VEHICLE_ID, TestValues.GENERAL_BOOLEAN); result.put(UnsubscribeVehicleData.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_BOOLEAN); + result.put(UnsubscribeVehicleData.KEY_WINDOW_STATUS, TestValues.GENERAL_BOOLEAN); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_BOOLEAN); } catch (JSONException e) { fail(TestValues.JSON_FAIL); @@ -158,8 +160,8 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getElectronicParkBrakeStatus()); assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getCloudAppVehicleID()); assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getHandsOffSteering()); + assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getWindowStatus()); assertTrue(TestValues.TRUE,( (UnsubscribeVehicleData) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); - // Invalid/Null Tests UnsubscribeVehicleData msg = new UnsubscribeVehicleData(); assertNotNull(TestValues.NOT_NULL, msg); @@ -195,6 +197,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); assertNull(TestValues.NULL, msg.getCloudAppVehicleID()); assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -248,6 +251,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_ELECTRONIC_PARK_BRAKE_STATUS), cmd.getElectronicParkBrakeStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_CLOUD_APP_VEHICLE_ID), cmd.getCloudAppVehicleID()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_HANDS_OFF_STEERING), cmd.getHandsOffSteering()); + assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, UnsubscribeVehicleData.KEY_WINDOW_STATUS), cmd.getWindowStatus()); assertEquals(TestValues.MATCH, JsonUtils.readBooleanFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME), cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java index 990efa920..e13fac19b 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java @@ -17,6 +17,7 @@ import com.smartdevicelink.proxy.rpc.HeadLampStatus; import com.smartdevicelink.proxy.rpc.MyKey; import com.smartdevicelink.proxy.rpc.SingleTireStatus; import com.smartdevicelink.proxy.rpc.TireStatus; +import com.smartdevicelink.proxy.rpc.WindowStatus; import com.smartdevicelink.proxy.rpc.enums.TurnSignal; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; @@ -98,6 +99,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ result.put(GetVehicleDataResponse.KEY_FUEL_RANGE, VehicleDataHelper.JSON_FUEL_RANGE); result.put(GetVehicleDataResponse.KEY_TURN_SIGNAL, VehicleDataHelper.TURN_SIGNAL); result.put(GetVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS); + result.put(GetVehicleDataResponse.KEY_WINDOW_STATUS, VehicleDataHelper.WINDOW_STATUS_LIST); result.put(GetVehicleDataResponse.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); } catch(JSONException e){ @@ -124,8 +126,10 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ JSONObject clusterModeStatusObj = new JSONObject(); JSONObject myKeyObj = new JSONObject(); JSONObject fuelRangeObj = new JSONObject(); + JSONObject windowStatusObj = new JSONObject(); JSONArray fuelRangeArrayObj = new JSONArray(); - + JSONArray windowStatusArrayObj = new JSONArray(); + try { //set up the JSONObject to represent GetVehicleDataResponse //TIRE_PRESSURE @@ -250,6 +254,11 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ fuelRangeObj.put(FuelRange.KEY_RANGE, VehicleDataHelper.FUEL_RANGE_RANGE); fuelRangeArrayObj.put(fuelRangeObj); + // WINDOW_STATUS + windowStatusObj.put(WindowStatus.KEY_LOCATION, VehicleDataHelper.LOCATION_GRID); + windowStatusObj.put(WindowStatus.KEY_STATE, VehicleDataHelper.WINDOW_STATE); + windowStatusArrayObj.put(windowStatusObj); + reference.put(GetVehicleDataResponse.KEY_SPEED, VehicleDataHelper.SPEED); reference.put(GetVehicleDataResponse.KEY_RPM, VehicleDataHelper.RPM); reference.put(GetVehicleDataResponse.KEY_EXTERNAL_TEMPERATURE, VehicleDataHelper.EXTERNAL_TEMPERATURE); @@ -279,8 +288,10 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ reference.put(GetVehicleDataResponse.KEY_FUEL_RANGE, fuelRangeArrayObj); reference.put(GetVehicleDataResponse.KEY_TURN_SIGNAL, TurnSignal.OFF); reference.put(GetVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS); + reference.put(GetVehicleDataResponse.KEY_WINDOW_STATUS, windowStatusArrayObj); reference.put(GetVehicleDataResponse.KEY_HANDS_OFF_STEERING, VehicleDataHelper.HANDS_OFF_STEERING); reference.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE); + JSONObject underTest = msg.serializeJSON(); //go inside underTest and only return the JSONObject inside the parameters key inside the response key @@ -417,6 +428,26 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ fuelRangeRefereceList, fuelRangeUnderTestList)); } + else if (key.equals(GetVehicleDataResponse.KEY_WINDOW_STATUS)) { + JSONArray windowStatusArrayObjReference = JsonUtils.readJsonArrayFromJsonObject(reference, key); + List<WindowStatus> windowStatusReferenceList = new ArrayList<>(); + for (int index = 0; index < windowStatusArrayObjReference.length(); index++) { + WindowStatus windowStatus = new WindowStatus(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)windowStatusArrayObjReference.get(index) )); + windowStatusReferenceList.add(windowStatus); + } + + JSONArray windowStatusArrayObjTest = JsonUtils.readJsonArrayFromJsonObject(underTest, key); + List<WindowStatus> windowStatusUnderTestList = new ArrayList<>(); + for (int index = 0; index < windowStatusArrayObjTest.length(); index++) { + WindowStatus windowStatus = new WindowStatus(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)windowStatusArrayObjTest.get(index) )); + windowStatusUnderTestList.add(windowStatus); + } + + assertTrue("JSON value didn't match expected value for key \"" + key + "\".", + Validator.validateWindowStatuses( + windowStatusReferenceList, + windowStatusUnderTestList)); + } else { assertEquals("JSON value didn't match expected value for key \"" + key + "\".", JsonUtils.readObjectFromJsonObject(reference, key), @@ -463,6 +494,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ assertEquals(TestValues.MATCH, VehicleDataHelper.MY_KEY, ( (GetVehicleDataResponse) msg ).getMyKey()); assertEquals(TestValues.MATCH, VehicleDataHelper.TURN_SIGNAL, ( (GetVehicleDataResponse) msg ).getTurnSignal()); assertEquals(TestValues.MATCH, VehicleDataHelper.ELECTRONIC_PARK_BRAKE_STATUS, ( (GetVehicleDataResponse) msg ).getElectronicParkBrakeStatus()); + assertEquals(TestValues.MATCH, VehicleDataHelper.WINDOW_STATUS_LIST, ( (GetVehicleDataResponse) msg ).getWindowStatus()); assertEquals(TestValues.MATCH, VehicleDataHelper.HANDS_OFF_STEERING, ( (GetVehicleDataResponse) msg ).getHandsOffSteering()); assertEquals(TestValues.MATCH, VehicleDataHelper.OEM_CUSTOM_VEHICLE_DATA_STATE, ( (GetVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); @@ -499,6 +531,7 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -587,6 +620,15 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ MyKey myKey = new MyKey(JsonRPCMarshaller.deserializeJSONObject(myKeyObj)); assertTrue(TestValues.TRUE, Validator.validateMyKey(myKey, cmd.getMyKey()) ); + JSONArray windowStatusArray = JsonUtils.readJsonArrayFromJsonObject(parameters, GetVehicleDataResponse.KEY_WINDOW_STATUS); + + List<WindowStatus> windowStatus = new ArrayList<>(); + for (int index = 0; index < windowStatusArray.length(); index++) { + WindowStatus status = new WindowStatus(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)windowStatusArray.get(index)) ); + windowStatus.add(status); + } + assertTrue(TestValues.TRUE, Validator.validateWindowStatuses(windowStatus, cmd.getWindowStatus()) ); + assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_TURN_SIGNAL), cmd.getTurnSignal().toString()); assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS), cmd.getElectronicParkBrakeStatus().toString()); assertEquals(TestValues.MATCH, JsonUtils.readStringFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME), cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java index 2277434b9..826acd3fe 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java @@ -66,6 +66,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { msg.setTurnSignal(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TURNSIGNAL.ordinal())); msg.setElectronicParkBrakeStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS.ordinal())); msg.setHandsOffSteering(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal())); + msg.setWindowStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal())); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA); return msg; @@ -118,6 +119,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { result.put(SubscribeVehicleDataResponse.KEY_MY_KEY, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_MYKEY.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_FUEL_RANGE, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELRANGE.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_TURN_SIGNAL, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TURNSIGNAL.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_WINDOW_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal()).serializeJSON()); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA.serializeJSON()); @@ -163,6 +165,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { VehicleDataResult testTurnSignal = ( (SubscribeVehicleDataResponse) msg ).getTurnSignal(); VehicleDataResult testEBrakeStatus = ( (SubscribeVehicleDataResponse) msg ).getElectronicParkBrakeStatus(); VehicleDataResult testHOffSteering = ( (SubscribeVehicleDataResponse) msg ).getHandsOffSteering(); + VehicleDataResult testWindowStatus = ( (SubscribeVehicleDataResponse) msg ).getWindowStatus(); VehicleDataResult testOEMCustomVehicleData = ( (SubscribeVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); // Valid Tests @@ -195,6 +198,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { assertTrue(TestValues.TRUE, testTurnSignal.getDataType().equals(VehicleDataType.VEHICLEDATA_TURNSIGNAL)); assertTrue(TestValues.TRUE, testEBrakeStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS)); assertTrue(TestValues.TRUE, testHOffSteering.getDataType().equals(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING)); + assertTrue(TestValues.TRUE, testWindowStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_WINDOWSTATUS)); assertTrue(TestValues.TRUE, testOEMCustomVehicleData.getOEMCustomVehicleDataType().equals(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -231,6 +235,7 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -371,6 +376,10 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { VehicleDataResult referenceHandsOffSteering = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(handsOffSteering)); assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceHandsOffSteering, cmd.getHandsOffSteering())); + JSONObject windowStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_WINDOW_STATUS); + VehicleDataResult referenceWindowStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(windowStatus)); + assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceWindowStatus, cmd.getWindowStatus())); + JSONObject oemCustomVehicleDataName = JsonUtils.readJsonObjectFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); VehicleDataResult referenceOemCustomData = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(oemCustomVehicleDataName)); assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceOemCustomData, cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME))); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java index a317fdc83..38afe9513 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java @@ -67,6 +67,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { msg.setFuelRange(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELRANGE.ordinal())); msg.setTurnSignal(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TURNSIGNAL.ordinal())); msg.setElectronicParkBrakeStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS.ordinal())); + msg.setWindowStatus(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal())); msg.setHandsOffSteering(TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal())); msg.setOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA); @@ -122,6 +123,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { result.put(SubscribeVehicleDataResponse.KEY_TURN_SIGNAL, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TURNSIGNAL.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_ELECTRONIC_PARK_BRAKE_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS.ordinal()).serializeJSON()); result.put(SubscribeVehicleDataResponse.KEY_HANDS_OFF_STEERING, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_WINDOW_STATUS, TestValues.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WINDOWSTATUS.ordinal()).serializeJSON()); result.put(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA.serializeJSON()); } catch (JSONException e) { fail(TestValues.JSON_FAIL); @@ -165,6 +167,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { VehicleDataResult testTurnSignal = ( (UnsubscribeVehicleDataResponse) msg ).getTurnSignal(); VehicleDataResult testEBrakeStatus = ( (UnsubscribeVehicleDataResponse) msg ).getElectronicParkBrakeStatus(); VehicleDataResult testHOffSteering = ( (UnsubscribeVehicleDataResponse) msg ).getHandsOffSteering(); + VehicleDataResult testWindowStatus = ( (UnsubscribeVehicleDataResponse) msg ).getWindowStatus(); VehicleDataResult testOemCustomData = ( (UnsubscribeVehicleDataResponse) msg ).getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); // Valid Tests @@ -197,6 +200,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { assertTrue(TestValues.TRUE, testTurnSignal.getDataType().equals(VehicleDataType.VEHICLEDATA_TURNSIGNAL)); assertTrue(TestValues.TRUE, testEBrakeStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_ELECTRONICPARKBRAKESTATUS)); assertTrue(TestValues.TRUE, testHOffSteering.getDataType().equals(VehicleDataType.VEHICLEDATA_HANDSOFFSTEERING)); + assertTrue(TestValues.TRUE, testWindowStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_WINDOWSTATUS)); assertTrue(TestValues.TRUE, testOemCustomData.getOEMCustomVehicleDataType().equals(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); // Invalid/Null Tests @@ -233,6 +237,7 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { assertNull(TestValues.NULL, msg.getTurnSignal()); assertNull(TestValues.NULL, msg.getElectronicParkBrakeStatus()); assertNull(TestValues.NULL, msg.getHandsOffSteering()); + assertNull(TestValues.NULL, msg.getWindowStatus()); assertNull(TestValues.NULL, msg.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME)); } @@ -373,6 +378,10 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { VehicleDataResult referenceHandsOffSteering = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(handsOffSteering)); assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceHandsOffSteering, cmd.getHandsOffSteering())); + JSONObject windowStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_WINDOW_STATUS); + VehicleDataResult referenceWindowStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(windowStatus)); + assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceWindowStatus, cmd.getWindowStatus())); + JSONObject oemCustomData = JsonUtils.readJsonObjectFromJsonObject(parameters, TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME); VehicleDataResult referenceOemCustomData = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(oemCustomData)); assertTrue(TestValues.TRUE, Validator.validateVehicleDataResult(referenceOemCustomData, cmd.getOEMCustomVehicleData(TestValues.GENERAL_OEM_CUSTOM_VEHICLE_DATA_NAME))); |