diff options
author | Mikayla Ray <mikayla@livioconnect.com> | 2015-05-26 16:40:34 -0400 |
---|---|---|
committer | Mikayla Ray <mikayla@livioconnect.com> | 2015-05-26 16:40:34 -0400 |
commit | d6b893d1204ba6790ee525e6fbe8b1bb36cb7676 (patch) | |
tree | ca1ebf821a2bf7c7df95022158f4401e049b0d8b | |
parent | ac5e53d208b15eb4f78d58786ac2771f10d72625 (diff) | |
download | sdl_android-d6b893d1204ba6790ee525e6fbe8b1bb36cb7676.tar.gz |
Updated and documented all RPC response unit tests.
44 files changed, 1815 insertions, 2172 deletions
diff --git a/sdl_android_tests/src/com/smartdevicelink/test/Test.java b/sdl_android_tests/src/com/smartdevicelink/test/Test.java index 8fbd08ccd..2b6fe90aa 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/Test.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/Test.java @@ -11,36 +11,60 @@ import org.json.JSONObject; import android.util.Log; import com.smartdevicelink.proxy.TTSChunkFactory; +import com.smartdevicelink.proxy.rpc.AudioPassThruCapabilities; +import com.smartdevicelink.proxy.rpc.ButtonCapabilities; import com.smartdevicelink.proxy.rpc.Choice; +import com.smartdevicelink.proxy.rpc.DIDResult; import com.smartdevicelink.proxy.rpc.DeviceInfo; +import com.smartdevicelink.proxy.rpc.DisplayCapabilities; import com.smartdevicelink.proxy.rpc.Image; +import com.smartdevicelink.proxy.rpc.ImageField; +import com.smartdevicelink.proxy.rpc.ImageResolution; import com.smartdevicelink.proxy.rpc.KeyboardProperties; import com.smartdevicelink.proxy.rpc.MenuParams; +import com.smartdevicelink.proxy.rpc.PresetBankCapabilities; +import com.smartdevicelink.proxy.rpc.ScreenParams; import com.smartdevicelink.proxy.rpc.SdlMsgVersion; import com.smartdevicelink.proxy.rpc.SoftButton; +import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities; import com.smartdevicelink.proxy.rpc.StartTime; import com.smartdevicelink.proxy.rpc.TTSChunk; +import com.smartdevicelink.proxy.rpc.TextField; +import com.smartdevicelink.proxy.rpc.TouchEventCapabilities; import com.smartdevicelink.proxy.rpc.Turn; +import com.smartdevicelink.proxy.rpc.VehicleDataResult; +import com.smartdevicelink.proxy.rpc.VehicleType; import com.smartdevicelink.proxy.rpc.VrHelpItem; import com.smartdevicelink.proxy.rpc.enums.AppHMIType; import com.smartdevicelink.proxy.rpc.enums.AudioType; import com.smartdevicelink.proxy.rpc.enums.BitsPerSample; import com.smartdevicelink.proxy.rpc.enums.ButtonName; +import com.smartdevicelink.proxy.rpc.enums.CharacterSet; +import com.smartdevicelink.proxy.rpc.enums.DisplayType; import com.smartdevicelink.proxy.rpc.enums.FileType; import com.smartdevicelink.proxy.rpc.enums.GlobalProperty; +import com.smartdevicelink.proxy.rpc.enums.HmiZoneCapabilities; +import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; import com.smartdevicelink.proxy.rpc.enums.ImageType; import com.smartdevicelink.proxy.rpc.enums.InteractionMode; import com.smartdevicelink.proxy.rpc.enums.KeyboardLayout; import com.smartdevicelink.proxy.rpc.enums.KeypressMode; import com.smartdevicelink.proxy.rpc.enums.Language; import com.smartdevicelink.proxy.rpc.enums.LayoutMode; +import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat; +import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech; import com.smartdevicelink.proxy.rpc.enums.RequestType; import com.smartdevicelink.proxy.rpc.enums.SamplingRate; import com.smartdevicelink.proxy.rpc.enums.SoftButtonType; import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities; import com.smartdevicelink.proxy.rpc.enums.SystemAction; import com.smartdevicelink.proxy.rpc.enums.TextAlignment; +import com.smartdevicelink.proxy.rpc.enums.TextFieldName; +import com.smartdevicelink.proxy.rpc.enums.TriggerSource; import com.smartdevicelink.proxy.rpc.enums.UpdateMode; +import com.smartdevicelink.proxy.rpc.enums.VehicleDataResultCode; +import com.smartdevicelink.proxy.rpc.enums.VehicleDataType; +import com.smartdevicelink.proxy.rpc.enums.VrCapabilities; public class Test { @@ -54,52 +78,114 @@ public class Test { public static final String JSON_FAIL = "Json testing failed."; // Rpc Test Values - public static final int GENERAL_INT = 100; - public static final float GENERAL_FLOAT = 100f; - public static final Image GENERAL_IMAGE = new Image(); - public static final String GENERAL_STRING = "test"; - public static final Double GENERAL_DOUBLE = 10.01; - public static final boolean GENERAL_BOOLEAN = true; - public static final FileType GENERAL_FILETYPE = FileType.BINARY; - public static final Language GENERAL_LANGUAGE = Language.EN_US; - public static final AudioType GENERAL_AUDIOTYPE = AudioType.PCM; - public static final StartTime GENERAL_STARTTIME = new StartTime(); - public static final DeviceInfo GENERAL_DEVICEINFO = new DeviceInfo(); - public static final LayoutMode GENERAL_LAYOUTMODE = LayoutMode.LIST_ONLY; - public static final MenuParams GENERAL_MENUPARAMS = new MenuParams(); - public static final ButtonName GENERAL_BUTTONNAME = ButtonName.OK; - public static final UpdateMode GENERAL_UPDATEMODE = UpdateMode.RESUME; - public static final RequestType GENERAL_REQUESTTYPE = RequestType.AUTH_REQUEST; - public static final SamplingRate GENERAL_SAMPLINGRATE = SamplingRate._8KHZ; - public static final BitsPerSample GENERAL_BITSPERSAMPLE = BitsPerSample._8_BIT; - public static final TextAlignment GENERAL_TEXTALIGNMENT = TextAlignment.CENTERED; - public static final SdlMsgVersion GENERAL_SDLMSGVERSION = new SdlMsgVersion(); - public static final InteractionMode GENERAL_INTERACTIONMODE = InteractionMode.BOTH; - public static final KeyboardProperties GENERAL_KEYBOARDPROPERTIES = new KeyboardProperties(); + public static final int GENERAL_INT = 100; + public static final float GENERAL_FLOAT = 100f; + public static final Image GENERAL_IMAGE = new Image(); + public static final String GENERAL_STRING = "test"; + public static final Double GENERAL_DOUBLE = 10.01; + public static final boolean GENERAL_BOOLEAN = true; + public static final FileType GENERAL_FILETYPE = FileType.BINARY; + public static final Language GENERAL_LANGUAGE = Language.EN_US; + public static final AudioType GENERAL_AUDIOTYPE = AudioType.PCM; + public static final StartTime GENERAL_STARTTIME = new StartTime(); + public static final DeviceInfo GENERAL_DEVICEINFO = new DeviceInfo(); + public static final LayoutMode GENERAL_LAYOUTMODE = LayoutMode.LIST_ONLY; + public static final MenuParams GENERAL_MENUPARAMS = new MenuParams(); + public static final ButtonName GENERAL_BUTTONNAME = ButtonName.OK; + public static final UpdateMode GENERAL_UPDATEMODE = UpdateMode.RESUME; + public static final VehicleType GENERAL_VEHICLETYPE = new VehicleType(); + public static final RequestType GENERAL_REQUESTTYPE = RequestType.AUTH_REQUEST; + public static final SamplingRate GENERAL_SAMPLINGRATE = SamplingRate._8KHZ; + public static final ScreenParams GENERAL_SCREENPARAMS = new ScreenParams(); + public static final TriggerSource GENERAL_TRIGGERSOURCE = TriggerSource.TS_VR; + public static final BitsPerSample GENERAL_BITSPERSAMPLE = BitsPerSample._8_BIT; + public static final TextAlignment GENERAL_TEXTALIGNMENT = TextAlignment.CENTERED; + public static final SdlMsgVersion GENERAL_SDLMSGVERSION = new SdlMsgVersion(); + public static final InteractionMode GENERAL_INTERACTIONMODE = InteractionMode.BOTH; + public static final KeyboardProperties GENERAL_KEYBOARDPROPERTIES = new KeyboardProperties(); + public static final DisplayCapabilities GENERAL_DISPLAYCAPABILITIES = new DisplayCapabilities(); + public static final PresetBankCapabilities GENERAL_PRESETBANKCAPABILITIES = new PresetBankCapabilities(); - public static final List<Turn> GENERAL_TURN_LIST = new ArrayList<Turn>(); - public static final List<Choice> GENERAL_CHOICE_LIST = new ArrayList<Choice>(); - public static final List<String> GENERAL_STRING_LIST = Arrays.asList(new String[] { "a", "b"}); - public static final List<Integer> GENERAL_INTEGER_LIST = Arrays.asList(new Integer[]{ -1, -2}); - public static final List<TTSChunk> GENERAL_TTSCHUNK_LIST = new ArrayList<TTSChunk>(); - public static final List<AppHMIType> GENERAL_APPHMITYPE_LIST = new ArrayList<AppHMIType>(); - public static final List<VrHelpItem> GENERAL_VRHELPITEM_LIST = new ArrayList<VrHelpItem>(); - public static final List<SoftButton> GENERAL_SOFTBUTTON_LIST = new ArrayList<SoftButton>(); - public static final List<GlobalProperty> GENERAL_GLOBALPROPERTY_LIST = new ArrayList<GlobalProperty>(); + public static final List<Turn> GENERAL_TURN_LIST = new ArrayList<Turn>(); + public static final List<Choice> GENERAL_CHOICE_LIST = new ArrayList<Choice>(); + public static final List<String> GENERAL_STRING_LIST = Arrays.asList(new String[] { "a", "b"}); + public static final List<Integer> GENERAL_INTEGER_LIST = Arrays.asList(new Integer[]{ -1, -2}); + public static final List<TTSChunk> GENERAL_TTSCHUNK_LIST = new ArrayList<TTSChunk>(); + public static final List<TextField> GENERAL_TEXTFIELD_LIST = new ArrayList<TextField>(); + public static final List<DIDResult> GENERAL_DIDRESULT_LIST = new ArrayList<DIDResult>(); + public static final List<AppHMIType> GENERAL_APPHMITYPE_LIST = new ArrayList<AppHMIType>(); + public static final List<VrHelpItem> GENERAL_VRHELPITEM_LIST = new ArrayList<VrHelpItem>(); + public static final List<SoftButton> GENERAL_SOFTBUTTON_LIST = new ArrayList<SoftButton>(); + public static final List<ImageField> GENERAL_IMAGEFIELD_LIST = new ArrayList<ImageField>(); + public static final List<GlobalProperty> GENERAL_GLOBALPROPERTY_LIST = new ArrayList<GlobalProperty>(); + public static final List<VrCapabilities> GENERAL_VRCAPABILITIES_LIST = new ArrayList<VrCapabilities>(); + public static final List<MediaClockFormat> GENERAL_MEDIACLOCKFORMAT_LIST = new ArrayList<MediaClockFormat>(); + public static final List<VehicleDataResult> GENERAL_VEHICLEDATARESULT_LIST = new ArrayList<VehicleDataResult>(); + public static final List<PrerecordedSpeech> GENERAL_PRERECORDEDSPEECH_LIST = new ArrayList<PrerecordedSpeech>(); + public static final List<SpeechCapabilities> GENERAL_SPEECHCAPABILITIES_LIST = new ArrayList<SpeechCapabilities>(); + public static final List<ButtonCapabilities> GENERAL_BUTTONCAPABILITIES_LIST = new ArrayList<ButtonCapabilities>(); + public static final List<HmiZoneCapabilities> GENERAL_HMIZONECAPABILITIES_LIST = new ArrayList<HmiZoneCapabilities>(); + public static final List<SoftButtonCapabilities> GENERAL_SOFTBUTTONCAPABILITIES_LIST = new ArrayList<SoftButtonCapabilities>(); + public static final List<AudioPassThruCapabilities> GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST = new ArrayList<AudioPassThruCapabilities>(); - public static final JSONArray JSON_TURNS = new JSONArray(); - public static final JSONArray JSON_CHOICES = new JSONArray(); - public static final JSONArray JSON_TTSCHUNKS = new JSONArray(); - public static final JSONArray JSON_VRHELPITEMS = new JSONArray(); - public static final JSONArray JSON_SOFTBUTTONS = new JSONArray(); - public static final JSONObject JSON_IMAGE = new JSONObject(); - public static final JSONObject JSON_STARTTIME = new JSONObject(); - public static final JSONObject JSON_MENUPARAMS = new JSONObject(); - public static final JSONObject JSON_DEVICEINFO = new JSONObject(); - public static final JSONObject JSON_SDLMSGVERSION = new JSONObject(); - public static final JSONObject JSON_KEYBOARDPROPERTIES = new JSONObject(); + public static final JSONArray JSON_TURNS = new JSONArray(); + public static final JSONArray JSON_CHOICES = new JSONArray(); + public static final JSONArray JSON_TTSCHUNKS = new JSONArray(); + public static final JSONArray JSON_DIDRESULTS = new JSONArray(); + public static final JSONArray JSON_TEXTFIELDS = new JSONArray(); + public static final JSONArray JSON_VRHELPITEMS = new JSONArray(); + public static final JSONArray JSON_SOFTBUTTONS = new JSONArray(); + public static final JSONArray JSON_IMAGEFIELDS = new JSONArray(); + public static final JSONArray JSON_BUTTONCAPABILITIES = new JSONArray(); + public static final JSONArray JSON_SOFTBUTTONCAPABILITIES = new JSONArray(); + public static final JSONArray JSON_AUDIOPASSTHRUCAPABILITIES = new JSONArray(); + + public static final JSONObject JSON_IMAGE = new JSONObject(); + public static final JSONObject JSON_STARTTIME = new JSONObject(); + public static final JSONObject JSON_MENUPARAMS = new JSONObject(); + public static final JSONObject JSON_DEVICEINFO = new JSONObject(); + public static final JSONObject JSON_SCREENPARAMS = new JSONObject(); + public static final JSONObject JSON_SDLMSGVERSION = new JSONObject(); + public static final JSONObject JSON_KEYBOARDPROPERTIES = new JSONObject(); + public static final JSONObject JSON_DISPLAYCAPABILITIES = new JSONObject(); + public static final JSONObject JSON_PRESETBANKCAPABILITIES = new JSONObject(); static { + // TextField List Setup + TextField item = new TextField(); + item.setName(TextFieldName.ETA); + item.setRows(GENERAL_INT); + item.setWidth(GENERAL_INT); + item.setCharacterSet(CharacterSet.CID1SET); + GENERAL_TEXTFIELD_LIST.add(item); + + // ImageField List Setup + ImageResolution imageResolution = new ImageResolution(); + imageResolution.setResolutionHeight(GENERAL_INT); + imageResolution.setResolutionWidth(GENERAL_INT); + + List<FileType> fileTypes = new ArrayList<FileType>(); + fileTypes.add(GENERAL_FILETYPE); + + ImageField imageField = new ImageField(); + imageField.setImageResolution(imageResolution); + imageField.setName(ImageFieldName.graphic); + imageField.setImageTypeSupported(fileTypes); + GENERAL_IMAGEFIELD_LIST.add(imageField); + + // ScreenParams Setup + TouchEventCapabilities touchEC = new TouchEventCapabilities(); + touchEC.setDoublePressAvailable(GENERAL_BOOLEAN); + touchEC.setMultiTouchAvailable(GENERAL_BOOLEAN); + touchEC.setPressAvailable(GENERAL_BOOLEAN); + + GENERAL_SCREENPARAMS.setImageResolution(imageResolution); + GENERAL_SCREENPARAMS.setTouchEventAvailable(touchEC); + + // MediaClockFormat List Setup + GENERAL_MEDIACLOCKFORMAT_LIST.add(MediaClockFormat.CLOCK1); + GENERAL_MEDIACLOCKFORMAT_LIST.add(MediaClockFormat.CLOCK2); + // Image Setup GENERAL_IMAGE.setValue(GENERAL_STRING); GENERAL_IMAGE.setImageType(ImageType.STATIC); @@ -178,7 +264,79 @@ public class Test { // GlobalProperty List Setup GENERAL_GLOBALPROPERTY_LIST.add(GlobalProperty.HELPPROMPT); GENERAL_GLOBALPROPERTY_LIST.add(GlobalProperty.MENUICON); + + // VehicleDataResult List Setup + for (VehicleDataType data : VehicleDataType.values()) { + VehicleDataResult result = new VehicleDataResult(); + result.setResultCode(VehicleDataResultCode.SUCCESS); + result.setDataType(data); + GENERAL_VEHICLEDATARESULT_LIST.add(result); + } + + // DidResult List Setup + DIDResult testResult = new DIDResult(); + testResult.setData(GENERAL_STRING); + testResult.setDidLocation(GENERAL_INT); + testResult.setResultCode(VehicleDataResultCode.SUCCESS); + GENERAL_DIDRESULT_LIST.add(testResult); + + // DisplayCapabilities Setup + GENERAL_DISPLAYCAPABILITIES.setDisplayType(DisplayType.TYPE2); + GENERAL_DISPLAYCAPABILITIES.setGraphicSupported(GENERAL_BOOLEAN); + GENERAL_DISPLAYCAPABILITIES.setImageFields(GENERAL_IMAGEFIELD_LIST); + GENERAL_DISPLAYCAPABILITIES.setMediaClockFormats(GENERAL_MEDIACLOCKFORMAT_LIST); + GENERAL_DISPLAYCAPABILITIES.setNumCustomPresetsAvailable(GENERAL_INT); + GENERAL_DISPLAYCAPABILITIES.setScreenParams(GENERAL_SCREENPARAMS); + GENERAL_DISPLAYCAPABILITIES.setTemplatesAvailable(GENERAL_STRING_LIST); + GENERAL_DISPLAYCAPABILITIES.setTextFields(GENERAL_TEXTFIELD_LIST); + // PresetBankCapabilities Setup + GENERAL_PRESETBANKCAPABILITIES.setOnScreenPresetsAvailable(GENERAL_BOOLEAN); + + // ButtonCapabilities List Setup + ButtonCapabilities testButton = new ButtonCapabilities(); + testButton.setLongPressAvailable(GENERAL_BOOLEAN); + testButton.setShortPressAvailable(GENERAL_BOOLEAN); + testButton.setUpDownAvailable(GENERAL_BOOLEAN); + testButton.setName(ButtonName.OK); + GENERAL_BUTTONCAPABILITIES_LIST.add(testButton); + + // SoftButtonCapabilities List Setup + SoftButtonCapabilities testSoftButton = new SoftButtonCapabilities(); + testSoftButton.setLongPressAvailable(GENERAL_BOOLEAN); + testSoftButton.setShortPressAvailable(GENERAL_BOOLEAN); + testSoftButton.setUpDownAvailable(GENERAL_BOOLEAN); + testSoftButton.setImageSupported(GENERAL_BOOLEAN); + GENERAL_SOFTBUTTONCAPABILITIES_LIST.add(testSoftButton); + + // VehicleType Setup + GENERAL_VEHICLETYPE.setMake(GENERAL_STRING); + GENERAL_VEHICLETYPE.setModel(GENERAL_STRING); + GENERAL_VEHICLETYPE.setModelYear(GENERAL_STRING); + GENERAL_VEHICLETYPE.setTrim(GENERAL_STRING); + + // AudioPassThruCapabilities List Setup + AudioPassThruCapabilities testAptc = new AudioPassThruCapabilities(); + testAptc.setAudioType(GENERAL_AUDIOTYPE); + testAptc.setBitsPerSample(GENERAL_BITSPERSAMPLE); + testAptc.setSamplingRate(GENERAL_SAMPLINGRATE); + GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST.add(testAptc); + + // PrerecordedSpeech List Setup + GENERAL_PRERECORDEDSPEECH_LIST.add(PrerecordedSpeech.HELP_JINGLE); + GENERAL_PRERECORDEDSPEECH_LIST.add(PrerecordedSpeech.INITIAL_JINGLE); + + // HmiZoneCapabilities List Setup + GENERAL_HMIZONECAPABILITIES_LIST.add(HmiZoneCapabilities.BACK); + GENERAL_HMIZONECAPABILITIES_LIST.add(HmiZoneCapabilities.FRONT); + + // SpeechCapabilities List Setup + GENERAL_SPEECHCAPABILITIES_LIST.add(SpeechCapabilities.SILENCE); + GENERAL_SPEECHCAPABILITIES_LIST.add(SpeechCapabilities.TEXT); + + // VrCapabilities List Setup + GENERAL_VRCAPABILITIES_LIST.add(VrCapabilities.TEXT); + try { // Json Image Setup JSON_IMAGE.put(Image.KEY_IMAGE_TYPE, ImageType.STATIC); @@ -251,7 +409,79 @@ public class Test { // Json SdlMessageVersion Setup JSON_SDLMSGVERSION.put(SdlMsgVersion.KEY_MAJOR_VERSION, GENERAL_INT); - JSON_SDLMSGVERSION.put(SdlMsgVersion.KEY_MINOR_VERSION, GENERAL_INT); + JSON_SDLMSGVERSION.put(SdlMsgVersion.KEY_MINOR_VERSION, GENERAL_INT); + + // Json DidResult List Setup + JSONObject jsonResult = new JSONObject(); + jsonResult.put(DIDResult.KEY_DATA, GENERAL_STRING); + jsonResult.put(DIDResult.KEY_DID_LOCATION, GENERAL_INT); + jsonResult.put(DIDResult.KEY_RESULT_CODE, VehicleDataResultCode.SUCCESS); + JSON_DIDRESULTS.put(jsonResult); + + // Json PresetBankCapabilities Setup + JSON_PRESETBANKCAPABILITIES.put(PresetBankCapabilities.KEY_ON_SCREEN_PRESETS_AVAILABLE, GENERAL_BOOLEAN); + + // Json ButtonCapabilities List Setup + JSONObject jsonButton = new JSONObject(); + jsonButton.put(ButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, GENERAL_BOOLEAN); + jsonButton.put(ButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, GENERAL_BOOLEAN); + jsonButton.put(ButtonCapabilities.KEY_UP_DOWN_AVAILABLE, GENERAL_BOOLEAN); + jsonButton.put(ButtonCapabilities.KEY_NAME, GENERAL_STRING); + JSON_BUTTONCAPABILITIES.put(jsonButton); + + // Json SoftButtonCapabilities List Setup + jsonButton = new JSONObject(); + jsonButton.put(SoftButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, GENERAL_BOOLEAN); + jsonButton.put(SoftButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, GENERAL_BOOLEAN); + jsonButton.put(SoftButtonCapabilities.KEY_UP_DOWN_AVAILABLE, GENERAL_BOOLEAN); + jsonButton.put(SoftButtonCapabilities.KEY_IMAGE_SUPPORTED, GENERAL_BOOLEAN); + JSON_SOFTBUTTONCAPABILITIES.put(jsonButton); + + // Json AudioPassThruCapabilities List Setup + jsonButton = new JSONObject(); + jsonButton.put(AudioPassThruCapabilities.KEY_AUDIO_TYPE, GENERAL_AUDIOTYPE); + jsonButton.put(AudioPassThruCapabilities.KEY_BITS_PER_SAMPLE, GENERAL_BITSPERSAMPLE); + jsonButton.put(AudioPassThruCapabilities.KEY_SAMPLING_RATE, GENERAL_SAMPLINGRATE); + JSON_AUDIOPASSTHRUCAPABILITIES.put(jsonButton); + + // Json TextField List Setup + JSONObject jsonItem = new JSONObject(); + jsonItem.put(TextField.KEY_CHARACTER_SET, CharacterSet.CID1SET); + jsonItem.put(TextField.KEY_NAME, TextFieldName.ETA); + jsonItem.put(TextField.KEY_ROWS, GENERAL_INT); + jsonItem.put(TextField.KEY_WIDTH, GENERAL_INT); + JSON_TEXTFIELDS.put(jsonItem); + + // Json ImageField List Setup + JSONObject jsonImageResolution = new JSONObject(); + jsonImageResolution.put(ImageResolution.KEY_RESOLUTION_HEIGHT, GENERAL_INT); + jsonImageResolution.put(ImageResolution.KEY_RESOLUTION_WIDTH, GENERAL_INT); + + jsonItem = new JSONObject(); + jsonItem.put(ImageField.KEY_IMAGE_RESOLUTION, jsonImageResolution); + jsonItem.put(ImageField.KEY_IMAGE_TYPE_SUPPORTED, JsonUtils.createJsonArray(fileTypes)); + jsonItem.put(ImageField.KEY_NAME, ImageFieldName.graphic); + JSON_IMAGEFIELDS.put(jsonItem); + + // Json ScreenParams Setup + JSONObject jsonTEC = new JSONObject(); + jsonTEC.put(TouchEventCapabilities.KEY_DOUBLE_PRESS_AVAILABLE, GENERAL_BOOLEAN); + jsonTEC.put(TouchEventCapabilities.KEY_MULTI_TOUCH_AVAILABLE, GENERAL_BOOLEAN); + jsonTEC.put(TouchEventCapabilities.KEY_PRESS_AVAILABLE, GENERAL_BOOLEAN); + + JSON_SCREENPARAMS.put(ScreenParams.KEY_RESOLUTION, jsonImageResolution); + JSON_SCREENPARAMS.put(ScreenParams.KEY_TOUCH_EVENT_AVAILABLE, jsonTEC); + + // Json DisplayCapabilities Setup + JSON_DISPLAYCAPABILITIES.put(DisplayCapabilities.KEY_DISPLAY_TYPE, GENERAL_STRING); + JSON_DISPLAYCAPABILITIES.put(DisplayCapabilities.KEY_GRAPHIC_SUPPORTED, GENERAL_BOOLEAN); + JSON_DISPLAYCAPABILITIES.put(DisplayCapabilities.KEY_IMAGE_FIELDS, JSON_IMAGEFIELDS); + JSON_DISPLAYCAPABILITIES.put(DisplayCapabilities.KEY_MEDIA_CLOCK_FORMATS, JsonUtils.createJsonArray(GENERAL_MEDIACLOCKFORMAT_LIST)); + JSON_DISPLAYCAPABILITIES.put(DisplayCapabilities.KEY_NUM_CUSTOM_PRESETS_AVAILABLE, GENERAL_INT); + JSON_DISPLAYCAPABILITIES.put(DisplayCapabilities.KEY_SCREEN_PARAMS, JSON_SCREENPARAMS); + JSON_DISPLAYCAPABILITIES.put(DisplayCapabilities.KEY_TEMPLATES_AVAILABLE, JsonUtils.createJsonArray(GENERAL_STRING_LIST)); + JSON_DISPLAYCAPABILITIES.put(DisplayCapabilities.KEY_TEXT_FIELDS, JSON_TEXTFIELDS); + } catch (JSONException e) { Log.e("Test", "Static Json Construction Failed.", e); } diff --git a/sdl_android_tests/src/com/smartdevicelink/test/VehicleDataHelper.java b/sdl_android_tests/src/com/smartdevicelink/test/VehicleDataHelper.java index ebdbb452f..ef19542fa 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/VehicleDataHelper.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/VehicleDataHelper.java @@ -35,7 +35,6 @@ import com.smartdevicelink.proxy.rpc.enums.VehicleDataStatus; import com.smartdevicelink.proxy.rpc.enums.WarningLightStatus; import com.smartdevicelink.proxy.rpc.enums.WiperStatus; -@SuppressWarnings("deprecation") public class VehicleDataHelper{ //top level variables for OnVehicleData public static final double SPEED = 35.6; @@ -304,7 +303,7 @@ public class VehicleDataHelper{ VEHICLE_DATA.setEngineTorque(ENGINE_TORQUE); VEHICLE_DATA.setOdometer(ODOMETER); VEHICLE_DATA.setGps(GPS); - VEHICLE_DATA.setFuelLevel_State(FUEL_LEVEL_STATE); + VEHICLE_DATA.setFuelLevelState(FUEL_LEVEL_STATE); VEHICLE_DATA.setInstantFuelConsumption(INSTANT_FUEL_CONSUMPTION); VEHICLE_DATA.setBeltStatus(BELT_STATUS); VEHICLE_DATA.setBodyInformation(BODY_INFORMATION); @@ -331,7 +330,7 @@ public class VehicleDataHelper{ VEHICLE_DATA_RESPONSE.setEngineTorque(ENGINE_TORQUE); VEHICLE_DATA_RESPONSE.setOdometer(ODOMETER); VEHICLE_DATA_RESPONSE.setGps(GPS); - VEHICLE_DATA_RESPONSE.setFuelLevel_State(FUEL_LEVEL_STATE); + VEHICLE_DATA_RESPONSE.setFuelLevelState(FUEL_LEVEL_STATE); VEHICLE_DATA_RESPONSE.setInstantFuelConsumption(INSTANT_FUEL_CONSUMPTION); VEHICLE_DATA_RESPONSE.setBeltStatus(BELT_STATUS); VEHICLE_DATA_RESPONSE.setBodyInformation(BODY_INFORMATION); diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/requests/AddCommandTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/requests/AddCommandTests.java index 44c8489a7..66553b1ed 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/requests/AddCommandTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/requests/AddCommandTests.java @@ -65,8 +65,7 @@ public class AddCommandTests extends BaseRpcTests{ /** * Tests the expected values of the RPC message. */ - public void testRpcValues () { - + public void testRpcValues () { // Test Values int testCmdId = ( (AddCommand) msg ).getCmdID(); Image testImage = ( (AddCommand) msg ).getCmdIcon(); @@ -131,8 +130,7 @@ public class AddCommandTests extends BaseRpcTests{ Image referenceCmdIcon = new Image(JsonRPCMarshaller.deserializeJSONObject(cmdIcon)); assertTrue(Test.TRUE, Validator.validateImage(referenceCmdIcon, cmd.getCmdIcon())); - } - catch (JSONException e) { + } catch (JSONException e) { e.printStackTrace(); } } diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/requests/SpeakTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/requests/SpeakTests.java index 77cf03ae3..9cf828b5c 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/requests/SpeakTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/requests/SpeakTests.java @@ -11,36 +11,24 @@ import org.json.JSONObject; import com.smartdevicelink.marshal.JsonRPCMarshaller; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCMessage; -import com.smartdevicelink.proxy.TTSChunkFactory; import com.smartdevicelink.proxy.rpc.Speak; import com.smartdevicelink.proxy.rpc.TTSChunk; -import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.Validator; import com.smartdevicelink.test.json.rpc.JsonFileReader; public class SpeakTests extends BaseRpcTests { - - private List<TTSChunk> ttsChunks; @Override protected RPCMessage createMessage() { Speak msg = new Speak(); - - createCustomObjects(); - msg.setTtsChunks(ttsChunks); + msg.setTtsChunks(Test.GENERAL_TTSCHUNK_LIST); return msg; } - - private void createCustomObjects () { - ttsChunks = new ArrayList<TTSChunk>(2); - - ttsChunks.add(TTSChunkFactory.createChunk(SpeechCapabilities.TEXT, "Welcome to the jungle")); - ttsChunks.add(TTSChunkFactory.createChunk(SpeechCapabilities.TEXT, "Say a command")); - } @Override protected String getMessageType() { @@ -55,57 +43,51 @@ public class SpeakTests extends BaseRpcTests { @Override protected JSONObject getExpectedParameters(int sdlVersion) { JSONObject result = new JSONObject(); - JSONArray ttsChunk = new JSONArray(); - try { - JSONObject chunk = new JSONObject(); - chunk.put(TTSChunk.KEY_TEXT, "Welcome to the jungle"); - chunk.put(TTSChunk.KEY_TYPE, SpeechCapabilities.TEXT); - ttsChunk.put(chunk); - - chunk = new JSONObject(); - chunk.put(TTSChunk.KEY_TEXT, "Say a command"); - chunk.put(TTSChunk.KEY_TYPE, SpeechCapabilities.TEXT); - ttsChunk.put(chunk); - - result.put(Speak.KEY_TTS_CHUNKS, ttsChunk); - + try { + result.put(Speak.KEY_TTS_CHUNKS, Test.JSON_TTSCHUNKS); } catch (JSONException e) { - /* do nothing */ + fail(Test.JSON_FAIL); } return result; } - public void testTtsChunks() { + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values List<TTSChunk> copy = ( (Speak) msg ).getTtsChunks(); - assertTrue("Input value didn't match expected value.", Validator.validateTtsChunks(ttsChunks, copy)); - } - - public void testNull() { + // Valid Tests + assertTrue(Test.TRUE, Validator.validateTtsChunks(Test.GENERAL_TTSCHUNK_LIST, copy)); + + // Invalid/Null Tests Speak msg = new Speak(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull("Tts chunks wasn't set, but getter method returned an object.", msg.getTtsChunks()); + assertNull(Test.MATCH, msg.getTtsChunks()); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); Speak cmd = new Speak(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); @@ -115,13 +97,9 @@ public class SpeakTests extends BaseRpcTests { TTSChunk chunk = new TTSChunk(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)ttsChunkArray.get(index)) ); ttsChunkList.add(chunk); } - assertTrue("TTSChunk list doesn't match input TTSChunk list", Validator.validateTtsChunks(ttsChunkList, cmd.getTtsChunks())); - - } - catch (JSONException e) { + assertTrue(Test.TRUE, Validator.validateTtsChunks(ttsChunkList, cmd.getTtsChunks())); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java index 7bd43996d..61b498b29 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/requests/UnsubscribeVehicleDataTests.java @@ -102,8 +102,7 @@ public class UnsubscribeVehicleDataTests extends BaseRpcTests { /** * Tests the expected values of the RPC message. */ - public void testRpcValues(){ - + public void testRpcValues(){ // Valid Tests assertTrue(Test.TRUE,( (UnsubscribeVehicleData) msg ).getSpeed()); assertTrue(Test.TRUE,( (UnsubscribeVehicleData) msg ).getRpm()); diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AddCommandResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AddCommandResponseTests.java index fc9788236..9ac064355 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AddCommandResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AddCommandResponseTests.java @@ -12,8 +12,13 @@ import com.smartdevicelink.proxy.rpc.AddCommand; import com.smartdevicelink.proxy.rpc.AddCommandResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.AddCommandResponse} + */ public class AddCommandResponseTests extends BaseRpcTests{ @Override @@ -36,31 +41,35 @@ public class AddCommandResponseTests extends BaseRpcTests{ return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests AddCommandResponse msg = new AddCommandResponse(); - assertNotNull("Null object creation failed.", msg); + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); AddCommand cmd = new AddCommand(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AddSubmenuResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AddSubmenuResponseTests.java index 99e66688b..07291a957 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AddSubmenuResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AddSubmenuResponseTests.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.AddSubMenuResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.AddSubmenuResponse} + */ public class AddSubmenuResponseTests extends BaseRpcTests{ @Override @@ -35,32 +40,35 @@ public class AddSubmenuResponseTests extends BaseRpcTests{ return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests AddSubMenuResponse msg = new AddSubMenuResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); AddSubMenuResponse cmd = new AddSubMenuResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - - } - -} + } + } +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AlertManeuverResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AlertManeuverResponseTests.java index aed634ebd..f5618eb16 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AlertManeuverResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AlertManeuverResponseTests.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.AlertManeuverResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.AlertManeuverResponse} + */ public class AlertManeuverResponseTests extends BaseRpcTests { @Override @@ -35,32 +40,35 @@ public class AlertManeuverResponseTests extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests AlertManeuverResponse msg = new AlertManeuverResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); AlertManeuverResponse cmd = new AlertManeuverResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AlertResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AlertResponseTests.java index d9f46c21b..c84d54fdd 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AlertResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/AlertResponseTests.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.AlertResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.AlertResponse} + */ public class AlertResponseTests extends BaseRpcTests{ private static final int TRY_AGAIN_TIME = 400; @@ -41,48 +46,52 @@ public class AlertResponseTests extends BaseRpcTests{ try{ result.put(AlertResponse.KEY_TRY_AGAIN_TIME, TRY_AGAIN_TIME); }catch(JSONException e){ - /* do nothing */ + fail(Test.JSON_FAIL); } return result; } - public void testTryAgainTime(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values int tryAgainTime = ( (AlertResponse) msg ).getTryAgainTime(); - assertEquals("Try again time didn't match expected time.", TRY_AGAIN_TIME, tryAgainTime); - } - - public void testNull(){ + + // Valid Tests + assertEquals(Test.MATCH, TRY_AGAIN_TIME, tryAgainTime); + + // Invalid/Null Tests AlertResponse msg = new AlertResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull("Try again time wasn't set, but getter method returned an object.", msg.getTryAgainTime()); + assertNull(Test.NULL, msg.getTryAgainTime()); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); AlertResponse cmd = new AlertResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); - assertEquals("Try again time doesn't match input time", JsonUtils.readIntegerFromJsonObject(parameters, AlertResponse.KEY_TRY_AGAIN_TIME), cmd.getTryAgainTime()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, AlertResponse.KEY_TRY_AGAIN_TIME), cmd.getTryAgainTime()); - } - catch (JSONException e) { + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ChangeRegistrationResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ChangeRegistrationResponseTests.java index 08bbddc94..16b7d7b5c 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ChangeRegistrationResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ChangeRegistrationResponseTests.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.ChangeRegistrationResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.ChangeRegistrationResponse} + */ public class ChangeRegistrationResponseTests extends BaseRpcTests{ @Override @@ -35,32 +40,36 @@ public class ChangeRegistrationResponseTests extends BaseRpcTests{ return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests ChangeRegistrationResponse msg = new ChangeRegistrationResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); ChangeRegistrationResponse cmd = new ChangeRegistrationResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + } catch (JSONException e) { e.printStackTrace(); - } - + } } -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/CreateInteractionChoiceSetResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/CreateInteractionChoiceSetResponseTests.java index 1c0369863..7c814e07d 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/CreateInteractionChoiceSetResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/CreateInteractionChoiceSetResponseTests.java @@ -6,7 +6,12 @@ import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.CreateInteractionChoiceSetResponse; import com.smartdevicelink.test.BaseRpcTests; +import com.smartdevicelink.test.Test; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.CreateInteractionChoiceSetResponse} + */ public class CreateInteractionChoiceSetResponseTests extends BaseRpcTests{ @Override @@ -29,11 +34,14 @@ public class CreateInteractionChoiceSetResponseTests extends BaseRpcTests{ return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests CreateInteractionChoiceSetResponse msg = new CreateInteractionChoiceSetResponse(); - assertNotNull("Null object creation failed.", msg); + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteCommandResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteCommandResponseTests.java index c2917e4f9..417483f78 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteCommandResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteCommandResponseTests.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.DeleteCommandResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.DeleteCommandResponse} + */ public class DeleteCommandResponseTests extends BaseRpcTests{ @Override @@ -35,31 +40,35 @@ public class DeleteCommandResponseTests extends BaseRpcTests{ return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests DeleteCommandResponse msg = new DeleteCommandResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); DeleteCommandResponse cmd = new DeleteCommandResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteFileResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteFileResponseTests.java index 14e2f7752..7d7928717 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteFileResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteFileResponseTests.java @@ -11,17 +11,20 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.DeleteFileResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.DeleteFileResponse} + */ public class DeleteFileResponseTests extends BaseRpcTests{ - private static final int SPACE_AVAILABLE = 58534924; - @Override protected RPCMessage createMessage(){ DeleteFileResponse msg = new DeleteFileResponse(); - msg.setSpaceAvailable(SPACE_AVAILABLE); + msg.setSpaceAvailable(Test.GENERAL_INT); return msg; } @@ -41,51 +44,54 @@ public class DeleteFileResponseTests extends BaseRpcTests{ JSONObject result = new JSONObject(); try{ - result.put(DeleteFileResponse.KEY_SPACE_AVAILABLE, SPACE_AVAILABLE); + result.put(DeleteFileResponse.KEY_SPACE_AVAILABLE, Test.GENERAL_INT); }catch(JSONException e){ - /* do nothing */ + fail(Test.JSON_FAIL); } return result; } - public void testSpaceAvailable(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values int spaceAvailable = ( (DeleteFileResponse) msg ).getSpaceAvailable(); - assertEquals("Space available didn't match input space available.", SPACE_AVAILABLE, spaceAvailable); - } - - public void testNull(){ + + // Valid Tests + assertEquals(Test.MATCH, Test.GENERAL_INT, spaceAvailable); + + // Invalid/Null Tests DeleteFileResponse msg = new DeleteFileResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull("Space available wasn't set, but getter method returned an object.", msg.getSpaceAvailable()); + assertNull(Test.NULL, msg.getSpaceAvailable()); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); DeleteFileResponse cmd = new DeleteFileResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); - assertEquals("Space available doesn't match input space available", JsonUtils.readIntegerFromJsonObject(parameters, DeleteFileResponse.KEY_SPACE_AVAILABLE), cmd.getSpaceAvailable()); - - } - catch (JSONException e) { + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, DeleteFileResponse.KEY_SPACE_AVAILABLE), cmd.getSpaceAvailable()); + } catch (JSONException e) { e.printStackTrace(); - } - - } - -} + } + } +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteInteractionChoiceSetResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteInteractionChoiceSetResponseTests.java index 3dffd6e93..32d085c76 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteInteractionChoiceSetResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteInteractionChoiceSetResponseTests.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.DeleteInteractionChoiceSetResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.DeleteInteractionChoiceSetResponse} + */ public class DeleteInteractionChoiceSetResponseTests extends BaseRpcTests{ @Override @@ -35,33 +40,35 @@ public class DeleteInteractionChoiceSetResponseTests extends BaseRpcTests{ return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests DeleteInteractionChoiceSetResponse msg = new DeleteInteractionChoiceSetResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); DeleteInteractionChoiceSetResponse cmd = new DeleteInteractionChoiceSetResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); - - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + assertNotNull(Test.NOT_NULL, body); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteSubMenuResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteSubMenuResponseTests.java index c61a73043..ab5c8d405 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteSubMenuResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DeleteSubMenuResponseTests.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.DeleteSubMenuResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.DeleteSubMenuResponse} + */ public class DeleteSubMenuResponseTests extends BaseRpcTests{ @Override @@ -35,32 +40,35 @@ public class DeleteSubMenuResponseTests extends BaseRpcTests{ return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests DeleteSubMenuResponse msg = new DeleteSubMenuResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); DeleteSubMenuResponse cmd = new DeleteSubMenuResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DiagnosticMessageResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DiagnosticMessageResponseTests.java index 4cc9d8594..f71582fae 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DiagnosticMessageResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/DiagnosticMessageResponseTests.java @@ -1,6 +1,5 @@ package com.smartdevicelink.test.rpc.responses; -import java.util.Arrays; import java.util.Hashtable; import java.util.List; @@ -13,19 +12,21 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.DiagnosticMessageResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.Validator; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.DiagnosticMessageResponse} + */ public class DiagnosticMessageResponseTests extends BaseRpcTests{ - private final List<Integer> MESSAGE_DATA_RESULT = Arrays.asList(new Integer[] { 1, 1, 3, 5, 8, 13, 21, 34, - 55, 89 }); - @Override protected RPCMessage createMessage(){ DiagnosticMessageResponse msg = new DiagnosticMessageResponse(); - msg.setMessageDataResult(MESSAGE_DATA_RESULT); + msg.setMessageDataResult(Test.GENERAL_INTEGER_LIST); return msg; } @@ -46,59 +47,64 @@ public class DiagnosticMessageResponseTests extends BaseRpcTests{ try{ result.put(DiagnosticMessageResponse.KEY_MESSAGE_DATA_RESULT, - JsonUtils.createJsonArray(MESSAGE_DATA_RESULT)); + JsonUtils.createJsonArray(Test.GENERAL_INTEGER_LIST)); }catch(JSONException e){ - /* do nothing */ + fail(Test.JSON_FAIL); } return result; } - public void testMessageData(){ + + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values List<Integer> cmdId = ( (DiagnosticMessageResponse) msg ).getMessageDataResult(); - assertEquals("Array size didn't match expected size.", MESSAGE_DATA_RESULT.size(), cmdId.size()); + // Valid Tests + assertEquals(Test.MATCH, Test.GENERAL_INTEGER_LIST.size(), cmdId.size()); - for(int i = 0; i < MESSAGE_DATA_RESULT.size(); i++){ - assertEquals("Message data didn't match input message data.", MESSAGE_DATA_RESULT.get(i), cmdId.get(i)); + for(int i = 0; i < Test.GENERAL_INTEGER_LIST.size(); i++){ + assertEquals(Test.MATCH, Test.GENERAL_INTEGER_LIST.get(i), cmdId.get(i)); } - } - - public void testNull(){ + + // Invalid/Null Tests DiagnosticMessageResponse msg = new DiagnosticMessageResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull("Message data wasn't set, but getter method returned an object.", msg.getMessageDataResult()); + assertNull(Test.NULL, msg.getMessageDataResult()); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); DiagnosticMessageResponse cmd = new DiagnosticMessageResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); List<Integer> dataResultList = JsonUtils.readIntegerListFromJsonObject(parameters, DiagnosticMessageResponse.KEY_MESSAGE_DATA_RESULT); List<Integer> testResultList = cmd.getMessageDataResult(); - assertEquals("Data result list length not same as reference list length", dataResultList.size(), testResultList.size()); - assertTrue("Data result list doesn't match input data result", Validator.validateIntegerList(dataResultList, testResultList)); - } - catch (JSONException e) { + assertEquals(Test.MATCH, dataResultList.size(), testResultList.size()); + assertTrue(Test.TRUE, Validator.validateIntegerList(dataResultList, testResultList)); + } catch (JSONException e) { e.printStackTrace(); - } - + } } -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/EndAudioPassThruResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/EndAudioPassThruResponseTests.java index 346c89444..6ece8473a 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/EndAudioPassThruResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/EndAudioPassThruResponseTests.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.EndAudioPassThruResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.EndAudioPassThruResponse} + */ public class EndAudioPassThruResponseTests extends BaseRpcTests{ @Override @@ -35,30 +40,35 @@ public class EndAudioPassThruResponseTests extends BaseRpcTests{ return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests EndAudioPassThruResponse msg = new EndAudioPassThruResponse(); - assertNotNull("Null object creation failed.", msg); + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); EndAudioPassThruResponse cmd = new EndAudioPassThruResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/GenericResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/GenericResponseTests.java index 651e8ea3b..79b22a0f3 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/GenericResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/GenericResponseTests.java @@ -6,7 +6,12 @@ import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.GenericResponse; import com.smartdevicelink.test.BaseRpcTests; +import com.smartdevicelink.test.Test; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.GenericResponse} + */ public class GenericResponseTests extends BaseRpcTests{ @Override @@ -29,10 +34,13 @@ public class GenericResponseTests extends BaseRpcTests{ return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests GenericResponse msg = new GenericResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/GetDTCsResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/GetDTCsResponseTests.java index 745d4a8ac..ef8a2a70c 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/GetDTCsResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/GetDTCsResponseTests.java @@ -1,6 +1,5 @@ package com.smartdevicelink.test.rpc.responses; -import java.util.Arrays; import java.util.Hashtable; import java.util.List; @@ -13,19 +12,21 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.GetDTCsResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.Validator; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.GetDTCsResponse} + */ public class GetDTCsResponseTests extends BaseRpcTests{ - - private final List<String> DTC_LIST = Arrays.asList(new String[] { "0x1FED: Tire Pressure Low", - "0x84F2: Passenger Window Open Circuit Fault" }); - + @Override protected RPCMessage createMessage(){ GetDTCsResponse msg = new GetDTCsResponse(); - msg.setDtc(DTC_LIST); + msg.setDtc(Test.GENERAL_STRING_LIST); return msg; } @@ -45,60 +46,63 @@ public class GetDTCsResponseTests extends BaseRpcTests{ JSONObject result = new JSONObject(); try{ - result.put(GetDTCsResponse.KEY_DTC, JsonUtils.createJsonArray(DTC_LIST)); + result.put(GetDTCsResponse.KEY_DTC, JsonUtils.createJsonArray(Test.GENERAL_STRING_LIST)); }catch(JSONException e){ - /* do nothing */ + fail(Test.JSON_FAIL); } return result; } - public void testDtcList(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values List<String> cmdId = ( (GetDTCsResponse) msg ).getDtc(); - assertEquals("DTC list size didn't match expected size.", DTC_LIST.size(), cmdId.size()); + // Valid Tests + assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST.size(), cmdId.size()); - for(int i = 0; i < DTC_LIST.size(); i++){ - assertEquals("DTC value at index " + i + " didn't match expected value.", DTC_LIST.get(i), cmdId.get(i)); + for(int i = 0; i < Test.GENERAL_STRING_LIST.size(); i++){ + assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST.get(i), cmdId.get(i)); } - } - - public void testNull(){ + + // Invalid/Null Tests GetDTCsResponse msg = new GetDTCsResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull("DTC list wasn't set, but getter method returned an object.", msg.getDtc()); + assertNull(Test.NULL, msg.getDtc()); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); GetDTCsResponse cmd = new GetDTCsResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); List<String> dtcList = JsonUtils.readStringListFromJsonObject(parameters, GetDTCsResponse.KEY_DTC); List<String> testDtcList = cmd.getDtc(); - assertEquals("DTC list length not same as reference DTC list", dtcList.size(), testDtcList.size()); - assertTrue("DTC list doesn't match input DTC list", Validator.validateStringList(dtcList, testDtcList)); + assertEquals(Test.MATCH, dtcList.size(), testDtcList.size()); + assertTrue(Test.TRUE, Validator.validateStringList(dtcList, testDtcList)); - } - catch (JSONException e) { + } catch (JSONException e) { e.printStackTrace(); - } - - } - -} + } + } +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java index 6471629be..32f37c793 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/GetVehicleDataResponseTests.java @@ -17,22 +17,24 @@ import com.smartdevicelink.proxy.rpc.DeviceStatus; import com.smartdevicelink.proxy.rpc.ECallInfo; import com.smartdevicelink.proxy.rpc.EmergencyEvent; import com.smartdevicelink.proxy.rpc.GPSData; +import com.smartdevicelink.proxy.rpc.GetVehicleData; import com.smartdevicelink.proxy.rpc.GetVehicleDataResponse; 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.enums.ComponentVolumeStatus; -import com.smartdevicelink.proxy.rpc.enums.PRNDL; -import com.smartdevicelink.proxy.rpc.enums.VehicleDataEventStatus; -import com.smartdevicelink.proxy.rpc.enums.WiperStatus; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.Validator; import com.smartdevicelink.test.VehicleDataHelper; import com.smartdevicelink.test.json.rpc.JsonFileReader; -@SuppressWarnings("deprecation") + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.GetVehicleDataResponse} + */ public class GetVehicleDataResponseTests extends BaseRpcTests{ @Override @@ -80,139 +82,13 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ result.put(GetVehicleDataResponse.KEY_EMERGENCY_EVENT, VehicleDataHelper.EMERGENCY_EVENT.serializeJSON()); result.put(GetVehicleDataResponse.KEY_CLUSTER_MODE_STATUS, VehicleDataHelper.CLUSTER_MODE_STATUS.serializeJSON()); result.put(GetVehicleDataResponse.KEY_MY_KEY, VehicleDataHelper.MY_KEY.serializeJSON()); - - }catch(JSONException e){ - //do nothing + } catch(JSONException e){ + fail(Test.JSON_FAIL); } return result; } - public void testSpeed() { - Double copy = ( (GetVehicleDataResponse) msg).getSpeed(); - assertEquals("Speed does not match input speed", VehicleDataHelper.SPEED, copy); - } - - public void testRpm() { - int copy = ( (GetVehicleDataResponse) msg).getRpm(); - assertEquals("RPM does not match input RPM", VehicleDataHelper.RPM, copy); - } - - public void testExternalTemperature() { - Double copy = ( (GetVehicleDataResponse) msg).getExternalTemperature(); - assertEquals("External temperature does not match input external temperature", VehicleDataHelper.EXTERNAL_TEMPERATURE, copy); - } - - public void testFuelLevel() { - Double copy = ( (GetVehicleDataResponse) msg).getFuelLevel(); - assertEquals("Fuel level does not match input fuel level", VehicleDataHelper.FUEL_LEVEL, copy); - } - - public void testVin() { - String copy = ( (GetVehicleDataResponse) msg).getVin(); - assertEquals("VIN does not match input VIN", VehicleDataHelper.VIN, copy); - } - - public void testPRNDL() { - PRNDL copy = ( (GetVehicleDataResponse) msg).getPrndl(); - assertEquals("PRNDL does not match input PRNDL", VehicleDataHelper.PRNDL_FINAL, copy); - } - - public void testTirePressure() { - TireStatus copy = ( (GetVehicleDataResponse) msg).getTirePressure(); - assertTrue("Tire pressure does not match input tire pressure", Validator.validateTireStatus(VehicleDataHelper.TIRE_PRESSURE, copy)); - } - - public void testEngineTorque() { - Double copy = ( (GetVehicleDataResponse) msg).getEngineTorque(); - assertEquals("Engine torque does not match input engine torque", VehicleDataHelper.ENGINE_TORQUE, copy); - } - - public void testOdometer() { - int copy = ( (GetVehicleDataResponse) msg).getOdometer(); - assertEquals("Odometer does not match input odometer", VehicleDataHelper.ODOMETER, copy); - } - - public void testGps() { - GPSData copy = ( (GetVehicleDataResponse) msg).getGps(); - assertTrue("GPS does not match input GPS", Validator.validateGpsData(VehicleDataHelper.GPS, copy)); - } - - public void testFuelLevel_State() { - ComponentVolumeStatus copy = ( (GetVehicleDataResponse) msg).getFuelLevel_State(); - assertEquals("Fuel level does not match input fuel level", VehicleDataHelper.FUEL_LEVEL_STATE, copy); - } - - public void testInstantFuelConsumption() { - Double copy = ( (GetVehicleDataResponse) msg).getInstantFuelConsumption(); - assertEquals("Instant fuel consumption does not match input instant fuel consumption", VehicleDataHelper.INSTANT_FUEL_CONSUMPTION, copy); - } - - public void testBeltStatus() { - BeltStatus copy = ( (GetVehicleDataResponse) msg).getBeltStatus(); - assertTrue("Belt status does not match input belt status", Validator.validateBeltStatus(VehicleDataHelper.BELT_STATUS, copy)); - } - - public void testBodyInformation() { - BodyInformation copy = ( (GetVehicleDataResponse) msg).getBodyInformation(); - assertTrue("Body information does not match input body information", Validator.validateBodyInformation(VehicleDataHelper.BODY_INFORMATION, copy)); - } - - public void testDeviceStatus() { - DeviceStatus copy = ( (GetVehicleDataResponse) msg).getDeviceStatus(); - assertTrue("Device status does not match input device status", Validator.validateDeviceStatus(VehicleDataHelper.DEVICE_STATUS, copy)); - } - - public void testDriverBraking() { - VehicleDataEventStatus copy = ( (GetVehicleDataResponse) msg).getDriverBraking(); - assertEquals("Driver braking does not match input driver braking", VehicleDataHelper.DRIVER_BRAKING, copy); - } - - public void testWiperStatus() { - WiperStatus copy = ( (GetVehicleDataResponse) msg).getWiperStatus(); - assertEquals("Wiper status does not match input wiper status", VehicleDataHelper.WIPER_STATUS, copy); - } - - public void testHeadLampStatus() { - HeadLampStatus copy = ( (GetVehicleDataResponse) msg).getHeadLampStatus(); - assertTrue("Head lamp status does not match input head lamp status", Validator.validateHeadLampStatus(VehicleDataHelper.HEAD_LAMP_STATUS, copy)); - } - - public void testAccPedalPosition() { - Double copy = ( (GetVehicleDataResponse) msg).getAccPedalPosition(); - assertEquals("Acc pedal position does not match input acc pedal position", VehicleDataHelper.ACC_PEDAL_POSITION, copy); - } - - public void testSteeringWheelAngle() { - Double copy = ( (GetVehicleDataResponse) msg).getSteeringWheelAngle(); - assertEquals("Steering wheel angle does not match input steering wheel angle", VehicleDataHelper.STEERING_WHEEL_ANGLE, copy); - } - - public void testECallInfo() { - ECallInfo copy = ( (GetVehicleDataResponse) msg).getECallInfo(); - assertTrue("Emergency call info does not match input emergency call info", Validator.validateECallInfo(VehicleDataHelper.E_CALL_INFO, copy)); - } - - public void testAirbagStatus() { - AirbagStatus copy = ( (GetVehicleDataResponse) msg).getAirbagStatus(); - assertTrue("Airbag status does not match input airbag status", Validator.validateAirbagStatus(VehicleDataHelper.AIRBAG_STATUS, copy)); - } - - public void testEmergencyEvent() { - EmergencyEvent copy = ( (GetVehicleDataResponse) msg).getEmergencyEvent(); - assertTrue("Emergency event does not match input emergency event", Validator.validateEmergencyEvent(VehicleDataHelper.EMERGENCY_EVENT, copy)); - } - - public void testClusterModeStatus() { - ClusterModeStatus copy = ( (GetVehicleDataResponse) msg).getClusterModeStatus(); - assertTrue("Cluster mode status does not match cluster mode status", Validator.validateClusterModeStatus(VehicleDataHelper.CLUSTER_MODE_STATUS, copy)); - } - - public void testMyKey() { - MyKey copy = ( (GetVehicleDataResponse) msg).getMyKey(); - assertTrue("My key does not match my key", Validator.validateMyKey(VehicleDataHelper.MY_KEY, copy)); - } - public void testJson() { JSONObject reference = new JSONObject(); @@ -494,140 +370,155 @@ public class GetVehicleDataResponseTests extends BaseRpcTests{ } } catch (JSONException e) { - /* do nothing */ + fail(Test.JSON_FAIL); } } - public void testNull(){ - GetVehicleDataResponse msg = new GetVehicleDataResponse(); - assertNotNull("Null object creation failed.", msg); - - testNullBase(msg); - - assertNull("Speed wasn't set, but getter method returned an object.", msg.getSpeed()); - assertNull("RPM wasn't set, but getter method returned an object.", msg.getRpm()); - assertNull("External temperature wasn't set, but getter method returned an object.", msg.getExternalTemperature()); - assertNull("Fuel level wasn't set, but getter method returned an object.", msg.getFuelLevel()); - assertNull("VIN wasn't set, but getter method returned an object.", msg.getVin()); - assertNull("PRNDL wasn't set, but getter method returned an object.", msg.getPrndl()); - assertNull("Tire pressure wasn't set, but getter method returned an object.", msg.getTirePressure()); - assertNull("Engine torque wasn't set, but getter method returned an object.", msg.getEngineTorque()); - assertNull("Odometer wasn't set, but getter method returned an object.", msg.getOdometer()); - assertNull("GPS wasn't set, but getter method returned an object.", msg.getGps()); - assertNull("Fuel level state wasn't set, but getter method returned an object.", msg.getFuelLevel_State()); - assertNull("Instant fuel consumption wasn't set, but getter method returned an object.", msg.getInstantFuelConsumption()); - assertNull("Belt status wasn't set, but getter method returned an object.", msg.getBeltStatus()); - assertNull("Body information wasn't set, but getter method returned an object.", msg.getBodyInformation()); - assertNull("Device status wasn't set, but getter method returned an object.", msg.getDeviceStatus()); - assertNull("Driver braking wasn't set, but getter method returned an object.", msg.getDriverBraking()); - assertNull("Wiper status wasn't set, but getter method returned an object.", msg.getWiperStatus()); - assertNull("Head lamp status wasn't set, but getter method returned an object.", msg.getHeadLampStatus()); - assertNull("Acceleration pedal position wasn't set, but getter method returned an object.", msg.getAccPedalPosition()); - assertNull("Steering wheel angle wasn't set, but getter method returned an object.", msg.getSteeringWheelAngle()); - assertNull("Emergency call info wasn't set, but getter method returned an object.", msg.getECallInfo()); - assertNull("Airbag status wasn't set, but getter method returned an object.", msg.getAirbagStatus()); - assertNull("Emergency event wasn't set, but getter method returned an object.", msg.getEmergencyEvent()); - assertNull("Cluster mode status wasn't set, but getter method returned an object.", msg.getClusterModeStatus()); - assertNull("My key wasn't set, but getter method returned an object.", msg.getMyKey()); + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues(){ + // Valid Tests + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getSpeed()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getRpm()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getExternalTemperature()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getFuelLevel()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getPrndl()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getTirePressure()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getEngineTorque()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getOdometer()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getGps()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getFuelLevelState()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getInstantFuelConsumption()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getBeltStatus()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getBodyInformation()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getDeviceStatus()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getDriverBraking()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getWiperStatus()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getHeadLampStatus()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getAccPedalPosition()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getSteeringWheelAngle()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getECallInfo()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getAirbagStatus()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getEmergencyEvent()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getClusterModeStatus()); + assertTrue(Test.TRUE,( (GetVehicleData) msg ).getMyKey()); + + // Invalid/Null Tests + GetVehicleData msg = new GetVehicleData(); + assertNotNull(Test.NOT_NULL, msg); + testNullBase(msg); + + assertNull(Test.NULL, msg.getAccPedalPosition()); + assertNull(Test.NULL, msg.getAirbagStatus()); + assertNull(Test.NULL, msg.getBeltStatus()); + assertNull(Test.NULL, msg.getDriverBraking()); + assertNull(Test.NULL, msg.getFuelLevel()); + assertNull(Test.NULL, msg.getTirePressure()); + assertNull(Test.NULL, msg.getWiperStatus()); + assertNull(Test.NULL, msg.getGps()); + assertNull(Test.NULL, msg.getSpeed()); + assertNull(Test.NULL, msg.getRpm()); + assertNull(Test.NULL, msg.getFuelLevelState()); + assertNull(Test.NULL, msg.getInstantFuelConsumption()); + assertNull(Test.NULL, msg.getExternalTemperature()); + assertNull(Test.NULL, msg.getPrndl()); + assertNull(Test.NULL, msg.getOdometer()); + assertNull(Test.NULL, msg.getBodyInformation()); + assertNull(Test.NULL, msg.getDeviceStatus()); + assertNull(Test.NULL, msg.getHeadLampStatus()); + assertNull(Test.NULL, msg.getEngineTorque()); + assertNull(Test.NULL, msg.getSteeringWheelAngle()); + assertNull(Test.NULL, msg.getECallInfo()); + assertNull(Test.NULL, msg.getEmergencyEvent()); + assertNull(Test.NULL, msg.getClusterModeStatus()); + assertNull(Test.NULL, msg.getMyKey()); } + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); GetVehicleDataResponse cmd = new GetVehicleDataResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); - assertEquals("Speed doesn't match input speed", - JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_SPEED), cmd.getSpeed()); - assertEquals("Rpm doesn't match input rpm", - JsonUtils.readIntegerFromJsonObject(parameters, GetVehicleDataResponse.KEY_RPM), cmd.getRpm()); - assertEquals("External temperature doesn't match input temperature", - JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_EXTERNAL_TEMPERATURE), cmd.getExternalTemperature()); - assertEquals("Fuel level doesn't match input level", - JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_FUEL_LEVEL), cmd.getFuelLevel()); - assertEquals("VIN doesn't match input VIN", - JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_VIN), cmd.getVin()); - assertEquals("PRNDL doesn't match input PRDNL", - JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_PRNDL), cmd.getPrndl().toString()); + assertEquals(Test.MATCH, JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_SPEED), cmd.getSpeed()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, GetVehicleDataResponse.KEY_RPM), cmd.getRpm()); + assertEquals(Test.MATCH, JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_EXTERNAL_TEMPERATURE), cmd.getExternalTemperature()); + assertEquals(Test.MATCH, JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_FUEL_LEVEL), cmd.getFuelLevel()); + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_VIN), cmd.getVin()); + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_PRNDL), cmd.getPrndl().toString()); JSONObject tireStatusObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_TIRE_PRESSURE); TireStatus tireStatus = new TireStatus(JsonRPCMarshaller.deserializeJSONObject(tireStatusObj)); - assertTrue("Tire pressure doesn't match input pressure", Validator.validateTireStatus(tireStatus, cmd.getTirePressure()) ); + assertTrue(Test.TRUE, Validator.validateTireStatus(tireStatus, cmd.getTirePressure()) ); - assertEquals("Engine torque doesn't match input torque", - JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_ENGINE_TORQUE), cmd.getEngineTorque()); - assertEquals("Odometer doesn't match input odometer", - JsonUtils.readIntegerFromJsonObject(parameters, GetVehicleDataResponse.KEY_ODOMETER), cmd.getOdometer()); + assertEquals(Test.MATCH, JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_ENGINE_TORQUE), cmd.getEngineTorque()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, GetVehicleDataResponse.KEY_ODOMETER), cmd.getOdometer()); JSONObject gpsDataObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_GPS); GPSData gpsData = new GPSData(JsonRPCMarshaller.deserializeJSONObject(gpsDataObj)); - assertTrue("GPS doesn't match input GPS", Validator.validateGpsData(gpsData, cmd.getGps()) ); + assertTrue(Test.TRUE, Validator.validateGpsData(gpsData, cmd.getGps()) ); - assertEquals("Fuel level state doesn't match input state", - JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_FUEL_LEVEL_STATE), cmd.getFuelLevel_State().toString()); - assertEquals("Instant fuel consumption doesn't match input consumption", - JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_INSTANT_FUEL_CONSUMPTION), cmd.getInstantFuelConsumption()); + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_FUEL_LEVEL_STATE), cmd.getFuelLevelState().toString()); + assertEquals(Test.MATCH, JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_INSTANT_FUEL_CONSUMPTION), cmd.getInstantFuelConsumption()); JSONObject beltStatusObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_BELT_STATUS); BeltStatus beltStatus = new BeltStatus(JsonRPCMarshaller.deserializeJSONObject(beltStatusObj)); - assertTrue("Belt status doesn't match input status", Validator.validateBeltStatus(beltStatus, cmd.getBeltStatus()) ); + assertTrue(Test.TRUE, Validator.validateBeltStatus(beltStatus, cmd.getBeltStatus()) ); JSONObject bodyInformationObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_BODY_INFORMATION); BodyInformation bodyInformation = new BodyInformation(JsonRPCMarshaller.deserializeJSONObject(bodyInformationObj)); - assertTrue("Body information doesn't match input information", Validator.validateBodyInformation(bodyInformation, cmd.getBodyInformation()) ); + assertTrue(Test.TRUE, Validator.validateBodyInformation(bodyInformation, cmd.getBodyInformation()) ); JSONObject deviceStatusObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_DEVICE_STATUS); DeviceStatus deviceStatus = new DeviceStatus(JsonRPCMarshaller.deserializeJSONObject(deviceStatusObj)); - assertTrue("Device status doesn't match input status", Validator.validateDeviceStatus(deviceStatus, cmd.getDeviceStatus()) ); + assertTrue(Test.TRUE, Validator.validateDeviceStatus(deviceStatus, cmd.getDeviceStatus()) ); - assertEquals("Driver braking doesn't match input braking", - JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_DRIVER_BRAKING), cmd.getDriverBraking().toString()); - assertEquals("Wiper status doesn't match input status", - JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_WIPER_STATUS), cmd.getWiperStatus().toString()); + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_DRIVER_BRAKING), cmd.getDriverBraking().toString()); + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, GetVehicleDataResponse.KEY_WIPER_STATUS), cmd.getWiperStatus().toString()); JSONObject headLampStatusObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_HEAD_LAMP_STATUS); HeadLampStatus headLampStatus = new HeadLampStatus(JsonRPCMarshaller.deserializeJSONObject(headLampStatusObj)); - assertTrue("Head lamp status doesn't match input status", Validator.validateHeadLampStatus(headLampStatus, cmd.getHeadLampStatus()) ); + assertTrue(Test.TRUE, Validator.validateHeadLampStatus(headLampStatus, cmd.getHeadLampStatus()) ); - assertEquals("Acceleration pedal position doesn't match input position", - JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_ACC_PEDAL_POSITION), cmd.getAccPedalPosition()); - assertEquals("Steering wheel angle doesn't match input angle", - JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_STEERING_WHEEL_ANGLE), cmd.getSteeringWheelAngle()); + assertEquals(Test.MATCH, JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_ACC_PEDAL_POSITION), cmd.getAccPedalPosition()); + assertEquals(Test.MATCH, JsonUtils.readDoubleFromJsonObject(parameters, GetVehicleDataResponse.KEY_STEERING_WHEEL_ANGLE), cmd.getSteeringWheelAngle()); JSONObject eCallInfoObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_E_CALL_INFO); ECallInfo eCallInfo = new ECallInfo(JsonRPCMarshaller.deserializeJSONObject(eCallInfoObj)); - assertTrue("Emergency call info doesn't match input info", Validator.validateECallInfo(eCallInfo, cmd.getECallInfo()) ); + assertTrue(Test.TRUE, Validator.validateECallInfo(eCallInfo, cmd.getECallInfo()) ); JSONObject airbagStatusObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_AIRBAG_STATUS); AirbagStatus airbagStatus = new AirbagStatus(JsonRPCMarshaller.deserializeJSONObject(airbagStatusObj)); - assertTrue("Airbag status doesn't match input status", Validator.validateAirbagStatus(airbagStatus, cmd.getAirbagStatus()) ); + assertTrue(Test.TRUE, Validator.validateAirbagStatus(airbagStatus, cmd.getAirbagStatus()) ); JSONObject emergencyEventObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_EMERGENCY_EVENT); EmergencyEvent emergencyEvent = new EmergencyEvent(JsonRPCMarshaller.deserializeJSONObject(emergencyEventObj)); - assertTrue("Emergency event doesn't match input event", Validator.validateEmergencyEvent(emergencyEvent, cmd.getEmergencyEvent()) ); + assertTrue(Test.TRUE, Validator.validateEmergencyEvent(emergencyEvent, cmd.getEmergencyEvent()) ); JSONObject clusterModeStatusObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_CLUSTER_MODE_STATUS); ClusterModeStatus clusterModeStatus = new ClusterModeStatus(JsonRPCMarshaller.deserializeJSONObject(clusterModeStatusObj)); - assertTrue("Cluster mode status doesn't match input status", Validator.validateClusterModeStatus(clusterModeStatus, cmd.getClusterModeStatus()) ); + assertTrue(Test.TRUE, Validator.validateClusterModeStatus(clusterModeStatus, cmd.getClusterModeStatus()) ); JSONObject myKeyObj = JsonUtils.readJsonObjectFromJsonObject(parameters, GetVehicleDataResponse.KEY_MY_KEY); MyKey myKey = new MyKey(JsonRPCMarshaller.deserializeJSONObject(myKeyObj)); - assertTrue("My key doesn't match input key", Validator.validateMyKey(myKey, cmd.getMyKey()) ); - } - catch (JSONException e) { + assertTrue(Test.TRUE, Validator.validateMyKey(myKey, cmd.getMyKey()) ); + } catch (JSONException e) { e.printStackTrace(); - } - - } - -} + } + } +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ListFilesResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ListFilesResponseTests.java index 4e7ce5dfd..032ba064d 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ListFilesResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ListFilesResponseTests.java @@ -1,6 +1,5 @@ package com.smartdevicelink.test.rpc.responses; -import java.util.Arrays; import java.util.Hashtable; import java.util.List; @@ -13,21 +12,22 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.ListFilesResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.Validator; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.ListFilesResponse} + */ public class ListFilesResponseTests extends BaseRpcTests{ - private final List<String> FILENAMES = Arrays.asList(new String[] { "turn_left.png", "turn_right.png", - "proceed.png", "ding.mp3" }); - private static final int SPACE_AVAILABLE = 684355; - @Override protected RPCMessage createMessage(){ ListFilesResponse msg = new ListFilesResponse(); - msg.setFilenames(FILENAMES); - msg.setSpaceAvailable(SPACE_AVAILABLE); + msg.setFilenames(Test.GENERAL_STRING_LIST); + msg.setSpaceAvailable(Test.GENERAL_INT); return msg; } @@ -47,65 +47,64 @@ public class ListFilesResponseTests extends BaseRpcTests{ JSONObject result = new JSONObject(); try{ - result.put(ListFilesResponse.KEY_FILENAMES, JsonUtils.createJsonArray(FILENAMES)); - result.put(ListFilesResponse.KEY_SPACE_AVAILABLE, SPACE_AVAILABLE); + result.put(ListFilesResponse.KEY_FILENAMES, JsonUtils.createJsonArray(Test.GENERAL_STRING_LIST)); + result.put(ListFilesResponse.KEY_SPACE_AVAILABLE, Test.GENERAL_INT); }catch(JSONException e){ - /* do nothing */ + fail(Test.JSON_FAIL); } return result; } - public void testFilenames(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values List<String> filenames = ( (ListFilesResponse) msg ).getFilenames(); - assertEquals("Filenames size didn't match expected size.", FILENAMES.size(), filenames.size()); - assertTrue("Filenames didn't match input filenames.", Validator.validateStringList(FILENAMES, filenames)); - } - - public void testSpaceAvailable(){ int spaceAvailable = ( (ListFilesResponse) msg ).getSpaceAvailable(); - assertEquals("Space available didn't match expected space available.", SPACE_AVAILABLE, spaceAvailable); - } - - public void testNull(){ + + // Valid Tests + assertEquals(Test.MATCH, Test.GENERAL_STRING_LIST.size(), filenames.size()); + assertTrue(Test.TRUE, Validator.validateStringList(Test.GENERAL_STRING_LIST, filenames)); + assertEquals(Test.MATCH, Test.GENERAL_INT, spaceAvailable); + + // Invalid/Null Tests ListFilesResponse msg = new ListFilesResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull("Filenames wasn't set, but getter method returned an object.", msg.getFilenames()); - assertNull("Space available wasn't set, but getter method returned an object.", msg.getSpaceAvailable()); + assertNull(Test.NULL, msg.getFilenames()); + assertNull(Test.NULL, msg.getSpaceAvailable()); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); ListFilesResponse cmd = new ListFilesResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); List<String> fileNamesList = JsonUtils.readStringListFromJsonObject(parameters, ListFilesResponse.KEY_FILENAMES); List<String> testNamesList = cmd.getFilenames(); - assertEquals("File name list length not same as reference file name list", fileNamesList.size(), testNamesList.size()); - assertTrue("File name list doesn't match input file name list", Validator.validateStringList(fileNamesList, testNamesList)); - assertEquals("Space available doesn't match input space available", - JsonUtils.readIntegerFromJsonObject(parameters, ListFilesResponse.KEY_SPACE_AVAILABLE), cmd.getSpaceAvailable()); - - } - catch (JSONException e) { + assertEquals(Test.MATCH, fileNamesList.size(), testNamesList.size()); + assertTrue(Test.TRUE, Validator.validateStringList(fileNamesList, testNamesList)); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, ListFilesResponse.KEY_SPACE_AVAILABLE), cmd.getSpaceAvailable()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/PerformAudioPassThruResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/PerformAudioPassThruResponseTest.java index 96b0b3816..4b909ee22 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/PerformAudioPassThruResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/PerformAudioPassThruResponseTest.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.PerformAudioPassThruResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.PerformAudioPassThruResponse} + */ public class PerformAudioPassThruResponseTest extends BaseRpcTests { @Override @@ -34,33 +39,36 @@ public class PerformAudioPassThruResponseTest extends BaseRpcTests { protected JSONObject getExpectedParameters(int sdlVersion){ return new JSONObject(); } - - public void testNull(){ + + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests PerformAudioPassThruResponse msg = new PerformAudioPassThruResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); PerformAudioPassThruResponse cmd = new PerformAudioPassThruResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java index da7ccedc7..527d43f38 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/PerformInteractionResponseTest.java @@ -12,21 +12,22 @@ import com.smartdevicelink.proxy.rpc.PerformInteractionResponse; import com.smartdevicelink.proxy.rpc.enums.TriggerSource; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.PerformInteractionResponse} + */ public class PerformInteractionResponseTest extends BaseRpcTests { - - private static final Integer CHOICE_ID = -1; - private static final TriggerSource TRIGGER_SOURCE = TriggerSource.TS_VR; - private static final String MANUAL_TEXT_ENTRY = "manualTextEntry"; @Override protected RPCMessage createMessage() { PerformInteractionResponse msg = new PerformInteractionResponse(); - msg.setChoiceID(CHOICE_ID); - msg.setTriggerSource(TRIGGER_SOURCE); - msg.setManualTextEntry(MANUAL_TEXT_ENTRY); + msg.setChoiceID(Test.GENERAL_INT); + msg.setTriggerSource(Test.GENERAL_TRIGGERSOURCE); + msg.setManualTextEntry(Test.GENERAL_STRING); return msg; } @@ -46,74 +47,64 @@ public class PerformInteractionResponseTest extends BaseRpcTests { JSONObject result = new JSONObject(); try { - result.put(PerformInteractionResponse.KEY_CHOICE_ID, CHOICE_ID); - result.put(PerformInteractionResponse.KEY_TRIGGER_SOURCE, TRIGGER_SOURCE); - result.put(PerformInteractionResponse.KEY_MANUAL_TEXT_ENTRY, MANUAL_TEXT_ENTRY); - + result.put(PerformInteractionResponse.KEY_CHOICE_ID, Test.GENERAL_INT); + result.put(PerformInteractionResponse.KEY_TRIGGER_SOURCE, Test.GENERAL_TRIGGERSOURCE); + result.put(PerformInteractionResponse.KEY_MANUAL_TEXT_ENTRY, Test.GENERAL_STRING); } catch (JSONException e) { - /* do nothing */ + fail(Test.JSON_FAIL); } return result; } - public void testChoiceId() { - Integer copy = ( (PerformInteractionResponse) msg).getChoiceID(); - + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values + Integer testId = ( (PerformInteractionResponse) msg).getChoiceID(); + TriggerSource testSource = ( (PerformInteractionResponse) msg).getTriggerSource(); + String testText = ( (PerformInteractionResponse) msg).getManualTextEntry(); - assertEquals("Choice id didn't match input data.", CHOICE_ID, copy); - } + // Valid Tests + assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, testId); + assertEquals(Test.MATCH, Test.GENERAL_TRIGGERSOURCE, testSource); + assertEquals(Test.MATCH, Test.GENERAL_STRING, testText); - public void testTriggerSource () { - TriggerSource copy = ( (PerformInteractionResponse) msg).getTriggerSource(); - - assertEquals("Trigger source didn't match input data.", TRIGGER_SOURCE, copy); - } - - public void testManualTextEntry () { - String copy = ( (PerformInteractionResponse) msg).getManualTextEntry(); - - assertEquals("Manual text entry didn't match input data.", MANUAL_TEXT_ENTRY, copy); - } - - public void testNull() { + // Invalid/Null Tests PerformInteractionResponse msg = new PerformInteractionResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull("Choice id wasn't set, but getter method returned an object.", msg.getChoiceID()); - assertNull("Trigger source wasn't set, but getter method returned an object.", msg.getTriggerSource()); - assertNull("Manual text entry wasn't set, but getter method returned an object.", msg.getManualTextEntry()); + assertNull(Test.NULL, msg.getChoiceID()); + assertNull(Test.NULL, msg.getTriggerSource()); + assertNull(Test.NULL, msg.getManualTextEntry()); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); PerformInteractionResponse cmd = new PerformInteractionResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); - assertEquals("Manual text entry doesn't match input text entry", - JsonUtils.readStringFromJsonObject(parameters, PerformInteractionResponse.KEY_MANUAL_TEXT_ENTRY), cmd.getManualTextEntry()); - assertEquals("Trigger source doesn't match input trigger source", - JsonUtils.readStringFromJsonObject(parameters, PerformInteractionResponse.KEY_TRIGGER_SOURCE), cmd.getTriggerSource().toString()); - assertEquals("Choice ID doesn't match input ID", - JsonUtils.readIntegerFromJsonObject(parameters, PerformInteractionResponse.KEY_CHOICE_ID), cmd.getChoiceID()); - } - catch (JSONException e) { + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, PerformInteractionResponse.KEY_MANUAL_TEXT_ENTRY), cmd.getManualTextEntry()); + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, PerformInteractionResponse.KEY_TRIGGER_SOURCE), cmd.getTriggerSource().toString()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, PerformInteractionResponse.KEY_CHOICE_ID), cmd.getChoiceID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/PutFileResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/PutFileResponseTest.java index 8fed6a353..d226796db 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/PutFileResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/PutFileResponseTest.java @@ -11,17 +11,20 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.PutFileResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.PutFileResponse} + */ public class PutFileResponseTest extends BaseRpcTests { - - private static final Integer SPACE_AVAILABLE = -1; @Override protected RPCMessage createMessage() { PutFileResponse msg = new PutFileResponse(); - msg.setSpaceAvailable(SPACE_AVAILABLE); + msg.setSpaceAvailable(Test.GENERAL_INT); return msg; } @@ -41,54 +44,54 @@ public class PutFileResponseTest extends BaseRpcTests { JSONObject result = new JSONObject(); try { - result.put(PutFileResponse.KEY_SPACE_AVAILABLE, SPACE_AVAILABLE); - + result.put(PutFileResponse.KEY_SPACE_AVAILABLE, Test.GENERAL_INT); } catch (JSONException e) { - /* do nothing */ + fail(Test.JSON_FAIL); } return result; } - public void testSpaceAvailable() { - Integer copy = ( (PutFileResponse) msg ).getSpaceAvailable(); + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values + Integer testSpace = ( (PutFileResponse) msg ).getSpaceAvailable(); - assertEquals("Data didn't match input data.", SPACE_AVAILABLE, copy); - } - - public void testNull() { + // Valid Tests + assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, testSpace); + + // Invalid/Null Tests PutFileResponse msg = new PutFileResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull("Space available wasn't set, but getter method returned an object.", msg.getSpaceAvailable()); + assertNull(Test.NULL, msg.getSpaceAvailable()); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); PutFileResponse cmd = new PutFileResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); - assertEquals("Space available doesn't match input space available", - JsonUtils.readIntegerFromJsonObject(parameters, PutFileResponse.KEY_SPACE_AVAILABLE), cmd.getSpaceAvailable()); - - } - catch (JSONException e) { + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, PutFileResponse.KEY_SPACE_AVAILABLE), cmd.getSpaceAvailable()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ReadDIDResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ReadDIDResponseTest.java index 4933f4378..295dc4598 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ReadDIDResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ReadDIDResponseTest.java @@ -13,40 +13,26 @@ import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.DIDResult; import com.smartdevicelink.proxy.rpc.ReadDIDResponse; -import com.smartdevicelink.proxy.rpc.enums.VehicleDataResultCode; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.Validator; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.ReadDIDResponse} + */ public class ReadDIDResponseTest extends BaseRpcTests { - - private List<DIDResult> didResults; @Override protected RPCMessage createMessage() { ReadDIDResponse msg = new ReadDIDResponse(); - - createCustomObjects(); - msg.setDidResult(didResults); + msg.setDidResult(Test.GENERAL_DIDRESULT_LIST); return msg; } - - public void createCustomObjects () { - didResults = new ArrayList<DIDResult>(2); - - DIDResult item1 = new DIDResult(); - item1.setData("data"); - item1.setResultCode(VehicleDataResultCode.SUCCESS); - - DIDResult item2 = new DIDResult(); - item2.setData("info"); - item2.setResultCode(VehicleDataResultCode.IGNORED); - didResults.add(item1); - didResults.add(item2); - } @Override protected String getMessageType() { @@ -60,59 +46,52 @@ public class ReadDIDResponseTest extends BaseRpcTests { @Override protected JSONObject getExpectedParameters(int sdlVersion) { - JSONObject result = new JSONObject(), - didResult = new JSONObject(); - JSONArray didResults = new JSONArray(); + JSONObject result = new JSONObject(); - try { - didResult.put(DIDResult.KEY_DATA, "data"); - didResult.put(DIDResult.KEY_RESULT_CODE, VehicleDataResultCode.SUCCESS); - didResults.put(didResult); - - didResult = new JSONObject(); - didResult.put(DIDResult.KEY_DATA, "info"); - didResult.put(DIDResult.KEY_RESULT_CODE, VehicleDataResultCode.IGNORED); - didResults.put(didResult); - - result.put(ReadDIDResponse.KEY_DID_RESULT, didResults); - + try { + result.put(ReadDIDResponse.KEY_DID_RESULT, Test.JSON_DIDRESULTS); } catch (JSONException e) { - /* do nothing */ + fail(Test.JSON_FAIL); } return result; } - public void testDidResults() { - List<DIDResult> copy = ( (ReadDIDResponse) msg ).getDidResult(); + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values + List<DIDResult> testResults = ( (ReadDIDResponse) msg ).getDidResult(); - assertNotNull("Did results were null.", copy); - assertTrue("Did results didn't match input data.", Validator.validateDIDResults(didResults, copy)); - } - - public void testNull() { + // Valid Tests + assertTrue("Did results didn't match input data.", Validator.validateDIDResults(Test.GENERAL_DIDRESULT_LIST, testResults)); + + // Invalid/Null Tests ReadDIDResponse msg = new ReadDIDResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull("Did response wasn't set, but getter method returned an object.", msg.getDidResult()); + assertNull(Test.NULL, msg.getDidResult()); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); ReadDIDResponse cmd = new ReadDIDResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); @@ -122,13 +101,9 @@ public class ReadDIDResponseTest extends BaseRpcTests { DIDResult chunk = new DIDResult(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)didResultArray.get(index)) ); didResultList.add(chunk); } - assertTrue("TTSChunk list doesn't match input TTSChunk list", Validator.validateDIDResults(didResultList, cmd.getDidResult())); - - } - catch (JSONException e) { + assertTrue(Test.MATCH, Validator.validateDIDResults(didResultList, cmd.getDidResult())); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/RegisterAppInterfaceResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/RegisterAppInterfaceResponseTest.java index 47089ba4b..9418cf707 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/RegisterAppInterfaceResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/RegisterAppInterfaceResponseTest.java @@ -1,7 +1,6 @@ package com.smartdevicelink.test.rpc.responses; import java.util.ArrayList; -import java.util.Arrays; import java.util.Hashtable; import java.util.List; @@ -15,214 +14,50 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.AudioPassThruCapabilities; import com.smartdevicelink.proxy.rpc.ButtonCapabilities; import com.smartdevicelink.proxy.rpc.DisplayCapabilities; -import com.smartdevicelink.proxy.rpc.ImageField; -import com.smartdevicelink.proxy.rpc.ImageResolution; import com.smartdevicelink.proxy.rpc.PresetBankCapabilities; import com.smartdevicelink.proxy.rpc.RegisterAppInterfaceResponse; -import com.smartdevicelink.proxy.rpc.ScreenParams; import com.smartdevicelink.proxy.rpc.SdlMsgVersion; import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities; -import com.smartdevicelink.proxy.rpc.TextField; -import com.smartdevicelink.proxy.rpc.TouchEventCapabilities; import com.smartdevicelink.proxy.rpc.VehicleType; -import com.smartdevicelink.proxy.rpc.enums.AudioType; -import com.smartdevicelink.proxy.rpc.enums.BitsPerSample; -import com.smartdevicelink.proxy.rpc.enums.ButtonName; -import com.smartdevicelink.proxy.rpc.enums.CharacterSet; -import com.smartdevicelink.proxy.rpc.enums.DisplayType; -import com.smartdevicelink.proxy.rpc.enums.FileType; import com.smartdevicelink.proxy.rpc.enums.HmiZoneCapabilities; -import com.smartdevicelink.proxy.rpc.enums.ImageFieldName; import com.smartdevicelink.proxy.rpc.enums.Language; -import com.smartdevicelink.proxy.rpc.enums.MediaClockFormat; import com.smartdevicelink.proxy.rpc.enums.PrerecordedSpeech; -import com.smartdevicelink.proxy.rpc.enums.SamplingRate; import com.smartdevicelink.proxy.rpc.enums.SpeechCapabilities; -import com.smartdevicelink.proxy.rpc.enums.TextFieldName; import com.smartdevicelink.proxy.rpc.enums.VrCapabilities; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.Validator; import com.smartdevicelink.test.json.rpc.JsonFileReader; -@SuppressWarnings("deprecation") +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.RegisterAppInterfaceResponse} + */ public class RegisterAppInterfaceResponseTest extends BaseRpcTests { - private final List<PrerecordedSpeech> PRERECORDED_SPEECH = - Arrays.asList(new PrerecordedSpeech[]{ PrerecordedSpeech.POSITIVE_JINGLE, PrerecordedSpeech.NEGATIVE_JINGLE }); - private final List<HmiZoneCapabilities> HMI_ZONE_CAPABILITIES = - Arrays.asList(new HmiZoneCapabilities[]{ HmiZoneCapabilities.BACK, HmiZoneCapabilities.FRONT }); - private final List<SpeechCapabilities> SPEECH_CAPABILITIES = - Arrays.asList(new SpeechCapabilities[]{ SpeechCapabilities.SILENCE, SpeechCapabilities.TEXT }); - private final List<VrCapabilities> VR_CAPABILITIES = - Arrays.asList(new VrCapabilities[]{ VrCapabilities.Text }); - - private DisplayCapabilities displayCapabilities; - private List<ButtonCapabilities> buttonCapabilities; - private List<SoftButtonCapabilities> softButtonCapabilities; - private List<AudioPassThruCapabilities> audioPassThruCapabilities; - - private static final PresetBankCapabilities PRESET_BANK_CAPABILITIES = new PresetBankCapabilities(); - private static final VehicleType VEHICLE_TYPE = new VehicleType(); - private static final SdlMsgVersion SDL_MSG_VERSION = new SdlMsgVersion(); - - private static final Language LANGUAGE = Language.EN_US; - private static final Language HMI_LANGUAGE = Language.EN_US; - - private static final List<Integer> SUPPORTED_DIAG_MODES = Arrays.asList(new Integer[]{ 0,1 }); - - // Variables for displayCapabilities - private ScreenParams screenParams; - private List<String> temps = Arrays.asList(new String[]{"a","b"}); - private List<ImageField> imageList; - private List<TextField> textFields; - private List<MediaClockFormat> mediaClockFormatList; - @Override protected RPCMessage createMessage() { RegisterAppInterfaceResponse msg = new RegisterAppInterfaceResponse(); - createCustomObjects(); - - msg.setSdlMsgVersion(SDL_MSG_VERSION); - msg.setLanguage(LANGUAGE); - msg.setHmiDisplayLanguage(HMI_LANGUAGE); - msg.setDisplayCapabilities(displayCapabilities); - msg.setPresetBankCapabilities(PRESET_BANK_CAPABILITIES); - msg.setVehicleType(VEHICLE_TYPE); - msg.setButtonCapabilities(buttonCapabilities); - msg.setSoftButtonCapabilities(softButtonCapabilities); - msg.setAudioPassThruCapabilities(audioPassThruCapabilities); - msg.setHmiZoneCapabilities(HMI_ZONE_CAPABILITIES); - msg.setSpeechCapabilities(SPEECH_CAPABILITIES); - msg.setVrCapabilities(VR_CAPABILITIES); - msg.setPrerecordedSpeech(PRERECORDED_SPEECH); - msg.setSupportedDiagModes(SUPPORTED_DIAG_MODES); + msg.setSdlMsgVersion(Test.GENERAL_SDLMSGVERSION); + msg.setLanguage(Test.GENERAL_LANGUAGE); + msg.setHmiDisplayLanguage(Test.GENERAL_LANGUAGE); + msg.setDisplayCapabilities(Test.GENERAL_DISPLAYCAPABILITIES); + msg.setPresetBankCapabilities(Test.GENERAL_PRESETBANKCAPABILITIES); + msg.setVehicleType(Test.GENERAL_VEHICLETYPE); + msg.setButtonCapabilities(Test.GENERAL_BUTTONCAPABILITIES_LIST); + msg.setSoftButtonCapabilities(Test.GENERAL_SOFTBUTTONCAPABILITIES_LIST); + msg.setAudioPassThruCapabilities(Test.GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST); + msg.setHmiZoneCapabilities(Test.GENERAL_HMIZONECAPABILITIES_LIST); + msg.setSpeechCapabilities(Test.GENERAL_SPEECHCAPABILITIES_LIST); + msg.setVrCapabilities(Test.GENERAL_VRCAPABILITIES_LIST); + msg.setPrerecordedSpeech(Test.GENERAL_PRERECORDEDSPEECH_LIST); + msg.setSupportedDiagModes(Test.GENERAL_INTEGER_LIST); return msg; } - private void createCustomObjects () { - screenParams = new ScreenParams(); - displayCapabilities = new DisplayCapabilities(); - imageList = new ArrayList<ImageField>(2); - textFields = new ArrayList<TextField>(2); - buttonCapabilities = new ArrayList<ButtonCapabilities>(2); - mediaClockFormatList = new ArrayList<MediaClockFormat>(2); - softButtonCapabilities = new ArrayList<SoftButtonCapabilities>(2); - audioPassThruCapabilities = new ArrayList<AudioPassThruCapabilities>(2); - - ImageResolution resolution = new ImageResolution(); - resolution.setResolutionHeight(10); - resolution.setResolutionWidth(10); - - ImageField image = new ImageField(); - image.setName(ImageFieldName.appIcon); - image.setImageResolution(resolution); - - List<FileType> fileListBinary = new ArrayList<FileType>(); - fileListBinary.add(FileType.BINARY); - image.setImageTypeSupported(fileListBinary); - imageList.add(image); - - resolution = new ImageResolution(); - resolution.setResolutionHeight(50); - resolution.setResolutionWidth(50); - - image = new ImageField(); - image.setName(ImageFieldName.graphic); - image.setImageResolution(resolution); - - List<FileType> fileListJPEG = new ArrayList<FileType>(); - fileListJPEG.add(FileType.GRAPHIC_JPEG); - image.setImageTypeSupported(fileListJPEG); - imageList.add(image); - - mediaClockFormatList.add(MediaClockFormat.CLOCK1); - mediaClockFormatList.add(MediaClockFormat.CLOCK2); - - TouchEventCapabilities touch = new TouchEventCapabilities(); - touch.setPressAvailable(true); - touch.setDoublePressAvailable(true); - touch.setMultiTouchAvailable(false); - - screenParams.setImageResolution(resolution); - screenParams.setTouchEventAvailable(touch); - - TextField text = new TextField(); - text.setName(TextFieldName.ETA); - text.setRows(5); - text.setWidth(5); - text.setCharacterSet(CharacterSet.TYPE5SET); - textFields.add(text); - - text = new TextField(); - text.setName(TextFieldName.ETA); - text.setRows(10); - text.setWidth(10); - text.setCharacterSet(CharacterSet.TYPE2SET); - textFields.add(text); - - displayCapabilities.setDisplayType(DisplayType.CID); - displayCapabilities.setGraphicSupported(true); - displayCapabilities.setImageFields(imageList); - displayCapabilities.setMediaClockFormats(mediaClockFormatList); - displayCapabilities.setNumCustomPresetsAvailable(1); - displayCapabilities.setScreenParams(screenParams); - displayCapabilities.setTemplatesAvailable(temps); - displayCapabilities.setTextFields(textFields); - - ButtonCapabilities button1 = new ButtonCapabilities(); - button1.setName(ButtonName.OK); - button1.setShortPressAvailable(true); - button1.setLongPressAvailable(true); - button1.setUpDownAvailable(false); - buttonCapabilities.add(button1); - - button1 = new ButtonCapabilities(); - button1.setName(ButtonName.CUSTOM_BUTTON); - button1.setShortPressAvailable(false); - button1.setLongPressAvailable(false); - button1.setUpDownAvailable(false); - buttonCapabilities.add(button1); - - SoftButtonCapabilities button2 = new SoftButtonCapabilities(); - button2.setImageSupported(false); - button2.setLongPressAvailable(true); - button2.setShortPressAvailable(true); - button2.setUpDownAvailable(true); - softButtonCapabilities.add(button2); - - button2 = new SoftButtonCapabilities(); - button2.setImageSupported(true); - button2.setLongPressAvailable(false); - button2.setShortPressAvailable(false); - button2.setUpDownAvailable(false); - softButtonCapabilities.add(button2); - - AudioPassThruCapabilities audio = new AudioPassThruCapabilities(); - audio.setAudioType(AudioType.PCM); - audio.setSamplingRate(SamplingRate._8KHZ); - audio.setBitsPerSample(BitsPerSample._8_BIT); - audioPassThruCapabilities.add(audio); - - audio = new AudioPassThruCapabilities(); - audio.setAudioType(AudioType.PCM); - audio.setSamplingRate(SamplingRate._16KHZ); - audio.setBitsPerSample(BitsPerSample._16_BIT); - audioPassThruCapabilities.add(audio); - - PRESET_BANK_CAPABILITIES.setOnScreenPresetsAvailable(true); - - VEHICLE_TYPE.setMake("make"); - VEHICLE_TYPE.setModel("model"); - VEHICLE_TYPE.setModelYear("year"); - VEHICLE_TYPE.setTrim("trim"); - - SDL_MSG_VERSION.setMajorVersion(0); - SDL_MSG_VERSION.setMinorVersion(1); - } - @Override protected String getMessageType() { return RPCMessage.KEY_RESPONSE; @@ -236,290 +71,121 @@ public class RegisterAppInterfaceResponseTest extends BaseRpcTests { @Override protected JSONObject getExpectedParameters(int sdlVersion) { - JSONObject result = new JSONObject(), - audioPass = new JSONObject(), - softButton = new JSONObject(), - button = new JSONObject(), - display = new JSONObject(), - image = new JSONObject(), - resolution = new JSONObject(), - screen = new JSONObject(), - touch = new JSONObject(), - field = new JSONObject(); - JSONArray fields = new JSONArray(), - images = new JSONArray(), - buttons = new JSONArray(), - softButtons = new JSONArray(), - audioPasses = new JSONArray(); + JSONObject result = new JSONObject(); try { - audioPass.put(AudioPassThruCapabilities.KEY_AUDIO_TYPE, AudioType.PCM); - audioPass.put(AudioPassThruCapabilities.KEY_SAMPLING_RATE, SamplingRate._8KHZ); - audioPass.put(AudioPassThruCapabilities.KEY_BITS_PER_SAMPLE, BitsPerSample._8_BIT); - audioPasses.put(audioPass); - - audioPass = new JSONObject(); - audioPass.put(AudioPassThruCapabilities.KEY_AUDIO_TYPE, AudioType.PCM); - audioPass.put(AudioPassThruCapabilities.KEY_SAMPLING_RATE, SamplingRate._16KHZ); - audioPass.put(AudioPassThruCapabilities.KEY_BITS_PER_SAMPLE, BitsPerSample._16_BIT); - audioPasses.put(audioPass); - - softButton.put(SoftButtonCapabilities.KEY_IMAGE_SUPPORTED, false); - softButton.put(SoftButtonCapabilities.KEY_UP_DOWN_AVAILABLE, true); - softButton.put(SoftButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, true); - softButton.put(SoftButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, true); - softButtons.put(softButton); - - softButton = new JSONObject(); - softButton.put(SoftButtonCapabilities.KEY_IMAGE_SUPPORTED, true); - softButton.put(SoftButtonCapabilities.KEY_UP_DOWN_AVAILABLE, false); - softButton.put(SoftButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, false); - softButton.put(SoftButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, false); - softButtons.put(softButton); - - button.put(ButtonCapabilities.KEY_NAME, ButtonName.OK); - button.put(ButtonCapabilities.KEY_UP_DOWN_AVAILABLE, false); - button.put(ButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, true); - button.put(ButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, true); - buttons.put(button); - - button = new JSONObject(); - button.put(ButtonCapabilities.KEY_NAME, ButtonName.CUSTOM_BUTTON); - button.put(ButtonCapabilities.KEY_UP_DOWN_AVAILABLE, false); - button.put(ButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, false); - button.put(ButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, false); - buttons.put(button); - - button = new JSONObject(); - button.put(ButtonCapabilities.KEY_NAME, ButtonName.CUSTOM_BUTTON); - button.put(ButtonCapabilities.KEY_UP_DOWN_AVAILABLE, true); - button.put(ButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, false); - button.put(ButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, false); - - resolution.put(ImageResolution.KEY_RESOLUTION_HEIGHT, 10); - resolution.put(ImageResolution.KEY_RESOLUTION_WIDTH, 10); - //TODO: correct value to put in? ImageFieldName.appIcon.name() - image.put(ImageField.KEY_NAME, ImageFieldName.appIcon); - image.put(ImageField.KEY_IMAGE_RESOLUTION, resolution); - JSONArray imageTypes = new JSONArray(); - imageTypes.put(FileType.BINARY); - image.put(ImageField.KEY_IMAGE_TYPE_SUPPORTED, imageTypes); - images.put(image); - - resolution = new JSONObject(); - resolution.put(ImageResolution.KEY_RESOLUTION_HEIGHT, 50); - resolution.put(ImageResolution.KEY_RESOLUTION_WIDTH, 50); - //TODO: correct value to put in? ImageFieldName.graphic.name() - image = new JSONObject(); - image.put(ImageField.KEY_NAME, ImageFieldName.graphic); - image.put(ImageField.KEY_IMAGE_RESOLUTION, resolution); - imageTypes = new JSONArray(); - imageTypes.put(FileType.GRAPHIC_JPEG); - image.put(ImageField.KEY_IMAGE_TYPE_SUPPORTED, imageTypes); - images.put(image); - - touch.put(TouchEventCapabilities.KEY_PRESS_AVAILABLE, true); - touch.put(TouchEventCapabilities.KEY_MULTI_TOUCH_AVAILABLE, false); - touch.put(TouchEventCapabilities.KEY_DOUBLE_PRESS_AVAILABLE, true); - - screen.put(ScreenParams.KEY_RESOLUTION, resolution); - screen.put(ScreenParams.KEY_TOUCH_EVENT_AVAILABLE, touch); - - field.put(TextField.KEY_NAME, TextFieldName.ETA); - field.put(TextField.KEY_WIDTH, 5); - field.put(TextField.KEY_ROWS, 5); - field.put(TextField.KEY_CHARACTER_SET, CharacterSet.TYPE5SET); - fields.put(field); - - field = new JSONObject(); - field.put(TextField.KEY_NAME, TextFieldName.ETA); - field.put(TextField.KEY_WIDTH, 10); - field.put(TextField.KEY_ROWS, 10); - field.put(TextField.KEY_CHARACTER_SET, CharacterSet.TYPE2SET); - fields.put(field); - - display.put(DisplayCapabilities.KEY_DISPLAY_TYPE, DisplayType.CID); - display.put(DisplayCapabilities.KEY_GRAPHIC_SUPPORTED, true); - display.put(DisplayCapabilities.KEY_IMAGE_FIELDS, images); - display.put(DisplayCapabilities.KEY_MEDIA_CLOCK_FORMATS, JsonUtils.createJsonArrayOfJsonNames(mediaClockFormatList, SDL_VERSION_UNDER_TEST)); - display.put(DisplayCapabilities.KEY_NUM_CUSTOM_PRESETS_AVAILABLE, 1); - display.put(DisplayCapabilities.KEY_SCREEN_PARAMS, screen); - display.put(DisplayCapabilities.KEY_TEMPLATES_AVAILABLE, JsonUtils.createJsonArray(temps)); - display.put(DisplayCapabilities.KEY_TEXT_FIELDS, fields); - - result.put(RegisterAppInterfaceResponse.KEY_LANGUAGE, LANGUAGE); - result.put(RegisterAppInterfaceResponse.KEY_HMI_DISPLAY_LANGUAGE, HMI_LANGUAGE); - - result.put(RegisterAppInterfaceResponse.KEY_SUPPORTED_DIAG_MODES, JsonUtils.createJsonArray(SUPPORTED_DIAG_MODES)); - - result.put(RegisterAppInterfaceResponse.KEY_SDL_MSG_VERSION, SDL_MSG_VERSION.serializeJSON()); - result.put(RegisterAppInterfaceResponse.KEY_VEHICLE_TYPE, VEHICLE_TYPE.serializeJSON()); - result.put(RegisterAppInterfaceResponse.KEY_PRESET_BANK_CAPABILITIES, PRESET_BANK_CAPABILITIES.serializeJSON()); - - result.put(RegisterAppInterfaceResponse.KEY_DISPLAY_CAPABILITIES, display); - result.put(RegisterAppInterfaceResponse.KEY_BUTTON_CAPABILITIES, buttons); - result.put(RegisterAppInterfaceResponse.KEY_SOFT_BUTTON_CAPABILITIES, softButtons); - result.put(RegisterAppInterfaceResponse.KEY_AUDIO_PASS_THRU_CAPABILITIES, audioPasses); - - result.put(RegisterAppInterfaceResponse.KEY_SPEECH_CAPABILITIES, - JsonUtils.createJsonArrayOfJsonNames(SPEECH_CAPABILITIES, SDL_VERSION_UNDER_TEST)); - result.put(RegisterAppInterfaceResponse.KEY_VR_CAPABILITIES, - JsonUtils.createJsonArrayOfJsonNames(VR_CAPABILITIES, SDL_VERSION_UNDER_TEST)); - result.put(RegisterAppInterfaceResponse.KEY_HMI_ZONE_CAPABILITIES, - JsonUtils.createJsonArrayOfJsonNames(HMI_ZONE_CAPABILITIES, SDL_VERSION_UNDER_TEST)); - result.put(RegisterAppInterfaceResponse.KEY_PRERECORDED_SPEECH, - JsonUtils.createJsonArrayOfJsonNames(PRERECORDED_SPEECH, SDL_VERSION_UNDER_TEST)); - + result.put(RegisterAppInterfaceResponse.KEY_LANGUAGE, Test.GENERAL_LANGUAGE); + result.put(RegisterAppInterfaceResponse.KEY_HMI_DISPLAY_LANGUAGE, Test.GENERAL_LANGUAGE); + result.put(RegisterAppInterfaceResponse.KEY_SUPPORTED_DIAG_MODES, JsonUtils.createJsonArray(Test.GENERAL_INTEGER_LIST)); + result.put(RegisterAppInterfaceResponse.KEY_SDL_MSG_VERSION, Test.JSON_SDLMSGVERSION); + result.put(RegisterAppInterfaceResponse.KEY_VEHICLE_TYPE, Test.GENERAL_VEHICLETYPE); + result.put(RegisterAppInterfaceResponse.KEY_PRESET_BANK_CAPABILITIES, Test.JSON_PRESETBANKCAPABILITIES); + result.put(RegisterAppInterfaceResponse.KEY_DISPLAY_CAPABILITIES, Test.JSON_DISPLAYCAPABILITIES); + result.put(RegisterAppInterfaceResponse.KEY_BUTTON_CAPABILITIES, Test.JSON_BUTTONCAPABILITIES); + result.put(RegisterAppInterfaceResponse.KEY_SOFT_BUTTON_CAPABILITIES, Test.JSON_SOFTBUTTONCAPABILITIES); + result.put(RegisterAppInterfaceResponse.KEY_AUDIO_PASS_THRU_CAPABILITIES, Test.GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST); + result.put(RegisterAppInterfaceResponse.KEY_SPEECH_CAPABILITIES, JsonUtils.createJsonArray(Test.GENERAL_SPEECHCAPABILITIES_LIST)); + result.put(RegisterAppInterfaceResponse.KEY_VR_CAPABILITIES, JsonUtils.createJsonArray(Test.GENERAL_VRCAPABILITIES_LIST)); + result.put(RegisterAppInterfaceResponse.KEY_HMI_ZONE_CAPABILITIES, JsonUtils.createJsonArray(Test.GENERAL_HMIZONECAPABILITIES_LIST)); + result.put(RegisterAppInterfaceResponse.KEY_PRERECORDED_SPEECH, JsonUtils.createJsonArray(Test.GENERAL_PRERECORDEDSPEECH_LIST)); } catch (JSONException e) { - /* do nothing */ + fail(Test.JSON_FAIL); } return result; } - public void testSdlMsgVersion () { - SdlMsgVersion copy = ( (RegisterAppInterfaceResponse) msg ).getSdlMsgVersion(); - - assertTrue("Data didn't match input data.", Validator.validateSdlMsgVersion(SDL_MSG_VERSION, copy)); - } - - public void testLanguage () { - Language copy = ( (RegisterAppInterfaceResponse) msg ).getLanguage(); - - assertEquals("Data didn't match input data.", LANGUAGE, copy); - } - - public void testHmiLanguage () { - Language copy = ( (RegisterAppInterfaceResponse) msg ).getHmiDisplayLanguage(); - - assertEquals("Data didn't match input data.", HMI_LANGUAGE, copy); - } - - public void testDisplayCapabilities () { - DisplayCapabilities copy = ( (RegisterAppInterfaceResponse) msg ).getDisplayCapabilities(); - - assertNotNull("Display capabilities prompt were null.", copy); - assertTrue("Data didn't match input data.", Validator.validateDisplayCapabilities(displayCapabilities, copy)); - } - - public void testPresetBankCapabilities () { - PresetBankCapabilities copy = ( (RegisterAppInterfaceResponse) msg ).getPresetBankCapabilities(); - - assertTrue("Data didn't match input data.", Validator.validatePresetBankCapabilities(PRESET_BANK_CAPABILITIES, copy)); - } - - public void testVehicleType () { - VehicleType copy = ( (RegisterAppInterfaceResponse) msg ).getVehicleType(); - - assertTrue("Data didn't match input data.", Validator.validateVehicleType(VEHICLE_TYPE, copy)); - } - - public void testButtonCapabilities () { - List<ButtonCapabilities> copy = ( (RegisterAppInterfaceResponse) msg ).getButtonCapabilities(); - - assertNotNull("Button capabilties were null.", copy); - assertTrue("Button capabilities didn't match input.", Validator.validateButtonCapabilities(buttonCapabilities, copy)); - } - - public void testSoftButtonCapabilities () { - List<SoftButtonCapabilities> copy = ( (RegisterAppInterfaceResponse) msg ).getSoftButtonCapabilities(); - - assertNotNull("Soft button capabilties were null.", copy); - assertTrue("Soft button capabilities didn't match input.", Validator.validateSoftButtonCapabilities(softButtonCapabilities, copy)); - } - - public void testAudioPassThruCapabilities () { - List<AudioPassThruCapabilities> copy = ( (RegisterAppInterfaceResponse) msg ).getAudioPassThruCapabilities(); - - assertNotNull("Audio pass thru capabilties were null.", copy); - assertTrue("Audio pass thru capabilities didn't match input.", Validator.validateAudioPassThruCapabilities(audioPassThruCapabilities, copy)); - - } - - public void testHmiZoneCapabilities () { - List<HmiZoneCapabilities> copy = ( (RegisterAppInterfaceResponse) msg ).getHmiZoneCapabilities(); - - assertEquals("Data didn't match input data.", HMI_ZONE_CAPABILITIES, copy); - } - - public void testSpeechCapabilities () { - List<SpeechCapabilities> copy = ( (RegisterAppInterfaceResponse) msg ).getSpeechCapabilities(); - - assertEquals("Data didn't match input data.", SPEECH_CAPABILITIES, copy); - } - - public void testVrCapabilities () { - List<VrCapabilities> copy = ( (RegisterAppInterfaceResponse) msg ).getVrCapabilities(); - - assertEquals("Data didn't match input data.", VR_CAPABILITIES, copy); - } - - public void testPrerecordedSpeech () { - List<PrerecordedSpeech> copy = ( (RegisterAppInterfaceResponse) msg ).getPrerecordedSpeech(); - - assertEquals("Data didn't match input data.", PRERECORDED_SPEECH, copy); - } - - public void testSupportedDiagModes () { - List<Integer> copy = ( (RegisterAppInterfaceResponse) msg ).getSupportedDiagModes(); - - assertEquals("Data didn't match input data.", SUPPORTED_DIAG_MODES, copy); - } - - public void testNull() { + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values + List<Integer> testSupportedDiagModes = ( (RegisterAppInterfaceResponse) msg ).getSupportedDiagModes(); + List<PrerecordedSpeech> testPrerecordedSpeech = ( (RegisterAppInterfaceResponse) msg ).getPrerecordedSpeech(); + List<VrCapabilities> testVrCapabilities = ( (RegisterAppInterfaceResponse) msg ).getVrCapabilities(); + List<SpeechCapabilities> testSpeechCapabilities = ( (RegisterAppInterfaceResponse) msg ).getSpeechCapabilities(); + List<HmiZoneCapabilities> testHmiZoneCapabilities = ( (RegisterAppInterfaceResponse) msg ).getHmiZoneCapabilities(); + List<SoftButtonCapabilities> testSoftButtonCapabilities = ( (RegisterAppInterfaceResponse) msg ).getSoftButtonCapabilities(); + List<ButtonCapabilities> testButtonCapabilities = ( (RegisterAppInterfaceResponse) msg ).getButtonCapabilities(); + VehicleType testVehicleType = ( (RegisterAppInterfaceResponse) msg ).getVehicleType(); + PresetBankCapabilities testPbc = ( (RegisterAppInterfaceResponse) msg ).getPresetBankCapabilities(); + DisplayCapabilities testDc = ( (RegisterAppInterfaceResponse) msg ).getDisplayCapabilities(); + Language testHmiLang = ( (RegisterAppInterfaceResponse) msg ).getHmiDisplayLanguage(); + Language testLang = ( (RegisterAppInterfaceResponse) msg ).getLanguage(); + SdlMsgVersion testMsgVersion = ( (RegisterAppInterfaceResponse) msg ).getSdlMsgVersion(); + List<AudioPassThruCapabilities> testAptc = ( (RegisterAppInterfaceResponse) msg ).getAudioPassThruCapabilities(); + + // Valid Tests + assertEquals(Test.MATCH, Test.GENERAL_INTEGER_LIST, testSupportedDiagModes); + assertEquals(Test.MATCH, Test.GENERAL_PRERECORDEDSPEECH_LIST, testPrerecordedSpeech); + assertEquals(Test.MATCH, Test.GENERAL_VRCAPABILITIES_LIST, testVrCapabilities); + assertEquals(Test.MATCH, Test.GENERAL_SPEECHCAPABILITIES_LIST, testSpeechCapabilities); + assertEquals(Test.MATCH, Test.GENERAL_HMIZONECAPABILITIES_LIST, testHmiZoneCapabilities); + assertTrue(Test.TRUE, Validator.validateSoftButtonCapabilities(Test.GENERAL_SOFTBUTTONCAPABILITIES_LIST, testSoftButtonCapabilities)); + assertTrue(Test.TRUE, Validator.validateButtonCapabilities(Test.GENERAL_BUTTONCAPABILITIES_LIST, testButtonCapabilities)); + assertTrue(Test.TRUE, Validator.validateVehicleType(Test.GENERAL_VEHICLETYPE, testVehicleType)); + assertTrue(Test.TRUE, Validator.validatePresetBankCapabilities(Test.GENERAL_PRESETBANKCAPABILITIES, testPbc)); + assertTrue(Test.TRUE, Validator.validateDisplayCapabilities(Test.GENERAL_DISPLAYCAPABILITIES, testDc)); + assertEquals(Test.MATCH, Test.GENERAL_LANGUAGE, testHmiLang); + assertEquals(Test.MATCH, Test.GENERAL_LANGUAGE, testLang); + assertTrue(Test.TRUE, Validator.validateSdlMsgVersion(Test.GENERAL_SDLMSGVERSION, testMsgVersion)); + assertTrue(Test.TRUE, Validator.validateAudioPassThruCapabilities(Test.GENERAL_AUDIOPASSTHRUCAPABILITIES_LIST, testAptc)); + + // Invalid/Null Tests RegisterAppInterfaceResponse msg = new RegisterAppInterfaceResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull("Sdl message version wasn't set, but getter method returned an object.", msg.getSdlMsgVersion()); - assertNull("Language wasn't set, but getter method returned an object.", msg.getLanguage()); - assertNull("Hmi language wasn't set, but getter method returned an object.", msg.getHmiDisplayLanguage()); - assertNull("Display capabilities wasn't set, but getter method returned an object.", msg.getDisplayCapabilities()); - assertNull("Preset bank capabilities wasn't set, but getter method returned an object.", msg.getPresetBankCapabilities()); - assertNull("Vehicle type wasn't set, but getter method returned an object.", msg.getVehicleType()); - assertNull("Button capabilities wasn't set, but getter method returned an object.", msg.getButtonCapabilities()); - assertNull("Soft button capabilities wasn't set, but getter method returned an object.", msg.getSoftButtonCapabilities()); - assertNull("Audio pass thru capabilities wasn't set, but getter method returned an object.", msg.getAudioPassThruCapabilities()); - assertNull("Hmi zone capabilities wasn't set, but getter method returned an object.", msg.getHmiZoneCapabilities()); - assertNull("Speech capabilities wasn't set, but getter method returned an object.", msg.getSpeechCapabilities()); - assertNull("Vr capabilities wasn't set, but getter method returned an object.", msg.getVrCapabilities()); - assertNull("Prerecorded speech wasn't set, but getter method returned an object.", msg.getPrerecordedSpeech()); - assertNull("Supported diag modes wasn't set, but getter method returned an object.", msg.getSupportedDiagModes()); - } - - //TODO: what to do about getProxyVersionInfo? + assertNull(Test.NULL, msg.getSdlMsgVersion()); + assertNull(Test.NULL, msg.getLanguage()); + assertNull(Test.NULL, msg.getHmiDisplayLanguage()); + assertNull(Test.NULL, msg.getDisplayCapabilities()); + assertNull(Test.NULL, msg.getPresetBankCapabilities()); + assertNull(Test.NULL, msg.getVehicleType()); + assertNull(Test.NULL, msg.getButtonCapabilities()); + assertNull(Test.NULL, msg.getSoftButtonCapabilities()); + assertNull(Test.NULL, msg.getAudioPassThruCapabilities()); + assertNull(Test.NULL, msg.getHmiZoneCapabilities()); + assertNull(Test.NULL, msg.getSpeechCapabilities()); + assertNull(Test.NULL, msg.getVrCapabilities()); + assertNull(Test.NULL, msg.getPrerecordedSpeech()); + assertNull(Test.NULL, msg.getSupportedDiagModes()); + } + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); RegisterAppInterfaceResponse cmd = new RegisterAppInterfaceResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); JSONObject vehicleTypeObj = JsonUtils.readJsonObjectFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_VEHICLE_TYPE); VehicleType vehicleType = new VehicleType(JsonRPCMarshaller.deserializeJSONObject(vehicleTypeObj)); - assertTrue("Vehicle type doesn't match input vehicle type", Validator.validateVehicleType(vehicleType, cmd.getVehicleType())); + assertTrue(Test.TRUE, Validator.validateVehicleType(vehicleType, cmd.getVehicleType())); JSONArray speechCapabilitiesArray = JsonUtils.readJsonArrayFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_SPEECH_CAPABILITIES); for (int index = 0; index < speechCapabilitiesArray.length(); index++) { SpeechCapabilities speechCapability = SpeechCapabilities.valueForString( speechCapabilitiesArray.get(index).toString() ); - assertEquals("Speech capabilities item doesn't match input capabilities item", speechCapability, cmd.getSpeechCapabilities().get(index)); + assertEquals(Test.MATCH, speechCapability, cmd.getSpeechCapabilities().get(index)); } JSONArray vrCapabilitiesArray = JsonUtils.readJsonArrayFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_VR_CAPABILITIES); for (int index = 0; index < vrCapabilitiesArray.length(); index++) { VrCapabilities vrCapability = VrCapabilities.valueForString( vrCapabilitiesArray.get(index).toString() ); - assertEquals("VR capabilities item doesn't match input capabilities item", vrCapability, cmd.getVrCapabilities().get(index)); + assertEquals(Test.MATCH, vrCapability, cmd.getVrCapabilities().get(index)); } JSONArray audioPassThruCapabilitiesArray = JsonUtils.readJsonArrayFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_AUDIO_PASS_THRU_CAPABILITIES); @@ -529,32 +195,29 @@ public class RegisterAppInterfaceResponseTest extends BaseRpcTests { new AudioPassThruCapabilities(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)audioPassThruCapabilitiesArray.get(index) )); audioPassThruCapabilitiesList.add(audioPassThruCapability); } - assertTrue("Audio pass-through capabilities list doesn't match input capabilities list", - Validator.validateAudioPassThruCapabilities(audioPassThruCapabilitiesList, cmd.getAudioPassThruCapabilities() )); + assertTrue(Test.TRUE, Validator.validateAudioPassThruCapabilities(audioPassThruCapabilitiesList, cmd.getAudioPassThruCapabilities() )); JSONArray hmiZoneCapabilitiesArray = JsonUtils.readJsonArrayFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_HMI_ZONE_CAPABILITIES); for (int index = 0; index < hmiZoneCapabilitiesArray.length(); index++) { HmiZoneCapabilities hmiZoneCapability = HmiZoneCapabilities.valueForString( hmiZoneCapabilitiesArray.get(index).toString() ); - assertEquals("HMI zone capabilities item doesn't match input capabilities item", hmiZoneCapability, cmd.getHmiZoneCapabilities().get(index)); + assertEquals(Test.MATCH, hmiZoneCapability, cmd.getHmiZoneCapabilities().get(index)); } JSONArray prerecordedSpeechArray = JsonUtils.readJsonArrayFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_PRERECORDED_SPEECH); for (int index = 0; index < prerecordedSpeechArray.length(); index++) { PrerecordedSpeech prerecordedSpeech = PrerecordedSpeech.valueForString( prerecordedSpeechArray.get(index).toString() ); - assertEquals("Pre-recorded speech item doesn't match input speech item", prerecordedSpeech, cmd.getPrerecordedSpeech().get(index)); + assertEquals(Test.MATCH, prerecordedSpeech, cmd.getPrerecordedSpeech().get(index)); } List<Integer> supportedDiagnosticModesList = JsonUtils.readIntegerListFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_SUPPORTED_DIAG_MODES); List<Integer> testDiagnosticModesList = cmd.getSupportedDiagModes(); - assertEquals("Supported diagnostic modes list length not same as reference modes list length", supportedDiagnosticModesList.size(), testDiagnosticModesList.size()); - assertTrue("Supported diagnostic modes list doesn't match input modes list", Validator.validateIntegerList(supportedDiagnosticModesList, testDiagnosticModesList)); + assertEquals(Test.MATCH, supportedDiagnosticModesList.size(), testDiagnosticModesList.size()); + assertTrue(Test.TRUE, Validator.validateIntegerList(supportedDiagnosticModesList, testDiagnosticModesList)); JSONObject sdlMsgVersionObj = JsonUtils.readJsonObjectFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_SDL_MSG_VERSION); SdlMsgVersion sdlMsgVersion = new SdlMsgVersion(JsonRPCMarshaller.deserializeJSONObject(sdlMsgVersionObj)); - assertTrue("SDL message version doesn't match input version", Validator.validateSdlMsgVersion(sdlMsgVersion, cmd.getSdlMsgVersion()) ); - - assertEquals("Language doesn't match input language", - JsonUtils.readStringFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_LANGUAGE), cmd.getLanguage().toString()); + assertTrue(Test.TRUE, Validator.validateSdlMsgVersion(sdlMsgVersion, cmd.getSdlMsgVersion()) ); + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_LANGUAGE), cmd.getLanguage().toString()); JSONArray buttonCapabilitiesArray = JsonUtils.readJsonArrayFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_BUTTON_CAPABILITIES); List<ButtonCapabilities> buttonCapabilitiesList = new ArrayList<ButtonCapabilities>(); @@ -562,15 +225,12 @@ public class RegisterAppInterfaceResponseTest extends BaseRpcTests { ButtonCapabilities buttonCapability = new ButtonCapabilities(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)buttonCapabilitiesArray.get(index) )); buttonCapabilitiesList.add(buttonCapability); } - assertTrue("Button capabilities list doesn't match input capabilities list", - Validator.validateButtonCapabilities(buttonCapabilitiesList, cmd.getButtonCapabilities() )); + assertTrue(Test.TRUE, Validator.validateButtonCapabilities(buttonCapabilitiesList, cmd.getButtonCapabilities() )); JSONObject displayCapabilitiesObj = JsonUtils.readJsonObjectFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_DISPLAY_CAPABILITIES); DisplayCapabilities displayCapabilities = new DisplayCapabilities(JsonRPCMarshaller.deserializeJSONObject(displayCapabilitiesObj)); - assertTrue("Display capabilities doesn't match input capabilities", Validator.validateDisplayCapabilities(displayCapabilities, cmd.getDisplayCapabilities()) ); - - assertEquals("HMI Language doesn't match input language", - JsonUtils.readStringFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_HMI_DISPLAY_LANGUAGE), cmd.getHmiDisplayLanguage().toString()); + assertTrue(Test.TRUE, Validator.validateDisplayCapabilities(displayCapabilities, cmd.getDisplayCapabilities()) ); + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_HMI_DISPLAY_LANGUAGE), cmd.getHmiDisplayLanguage().toString()); JSONArray softButtonCapabilitiesArray = JsonUtils.readJsonArrayFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_SOFT_BUTTON_CAPABILITIES); List<SoftButtonCapabilities> softButtonCapabilitiesList = new ArrayList<SoftButtonCapabilities>(); @@ -579,19 +239,13 @@ public class RegisterAppInterfaceResponseTest extends BaseRpcTests { new SoftButtonCapabilities(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)softButtonCapabilitiesArray.get(index) )); softButtonCapabilitiesList.add(softButtonCapability); } - assertTrue("Soft button capabilities list doesn't match input capabilities list", - Validator.validateSoftButtonCapabilities(softButtonCapabilitiesList, cmd.getSoftButtonCapabilities() )); + assertTrue(Test.TRUE, Validator.validateSoftButtonCapabilities(softButtonCapabilitiesList, cmd.getSoftButtonCapabilities() )); JSONObject presetBankCapabilitiesObj = JsonUtils.readJsonObjectFromJsonObject(parameters, RegisterAppInterfaceResponse.KEY_PRESET_BANK_CAPABILITIES); PresetBankCapabilities presetBankCapabilities = new PresetBankCapabilities(JsonRPCMarshaller.deserializeJSONObject(presetBankCapabilitiesObj)); - assertTrue("Preset bank capabilities doesn't match input capabilities", Validator.validatePresetBankCapabilities(presetBankCapabilities, cmd.getPresetBankCapabilities()) ); - - - - } - catch (JSONException e) { + assertTrue(Test.TRUE, Validator.validatePresetBankCapabilities(presetBankCapabilities, cmd.getPresetBankCapabilities()) ); + } catch (JSONException e) { e.printStackTrace(); - } - + } } -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java index 132587e04..1779de62b 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ResetGlobalPropertiesResponseTest.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.ResetGlobalPropertiesResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.ResetGlobalPropertiesResponse} + */ public class ResetGlobalPropertiesResponseTest extends BaseRpcTests { @Override @@ -35,33 +40,36 @@ public class ResetGlobalPropertiesResponseTest extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests ResetGlobalPropertiesResponse msg = new ResetGlobalPropertiesResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NULL, msg); testNullBase(msg); } + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); ResetGlobalPropertiesResponse cmd = new ResetGlobalPropertiesResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + } catch (JSONException e) { e.printStackTrace(); - } - - } - -} + } + } +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ScrollableMessageResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ScrollableMessageResponseTest.java index b2b810000..c51aceb2f 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ScrollableMessageResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ScrollableMessageResponseTest.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.ScrollableMessageResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.ScrollableMessageResponse} + */ public class ScrollableMessageResponseTest extends BaseRpcTests { @Override @@ -35,32 +40,35 @@ public class ScrollableMessageResponseTest extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests ScrollableMessageResponse msg = new ScrollableMessageResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); ScrollableMessageResponse cmd = new ScrollableMessageResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SendLocationResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SendLocationResponseTests.java index 120ffaeb3..00c9d3851 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SendLocationResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SendLocationResponseTests.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.SendLocationResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.SendLocaitonResponse} + */ public class SendLocationResponseTests extends BaseRpcTests { @Override @@ -36,31 +41,34 @@ public class SendLocationResponseTests extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests SendLocationResponse msg = new SendLocationResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); SendLocationResponse cmd = new SendLocationResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetAppIconResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetAppIconResponseTest.java index 8e13a543d..805a3308e 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetAppIconResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetAppIconResponseTest.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.SetAppIconResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.SetAppIconResponse} + */ public class SetAppIconResponseTest extends BaseRpcTests { @Override @@ -35,32 +40,35 @@ public class SetAppIconResponseTest extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests SetAppIconResponse msg = new SetAppIconResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); SetAppIconResponse cmd = new SetAppIconResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetDisplayLayoutResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetDisplayLayoutResponseTest.java index 9c5d35672..b05852cb9 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetDisplayLayoutResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetDisplayLayoutResponseTest.java @@ -16,54 +16,29 @@ import com.smartdevicelink.proxy.rpc.DisplayCapabilities; import com.smartdevicelink.proxy.rpc.PresetBankCapabilities; import com.smartdevicelink.proxy.rpc.SetDisplayLayoutResponse; import com.smartdevicelink.proxy.rpc.SoftButtonCapabilities; -import com.smartdevicelink.proxy.rpc.enums.DisplayType; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.Validator; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.SetDisplayLayoutResponse} + */ public class SetDisplayLayoutResponseTest extends BaseRpcTests { - private DisplayCapabilities DISPLAY_CAPABILITIES = new DisplayCapabilities(); - private static final PresetBankCapabilities PRESET_BANK_CAPABILITIES = new PresetBankCapabilities(); - private final List<ButtonCapabilities> BUTTON_CAPABILITIES_LIST = new ArrayList<ButtonCapabilities>(); - private final List<SoftButtonCapabilities> SOFT_BUTTON_CAPABILITIES_LIST = new ArrayList<SoftButtonCapabilities>(); - private static final Boolean BUTTON_CAPABILITIES_TRUE = true; - private static final Boolean BUTTON_CAPABILITIES_FALSE = false; - private static final Boolean SOFT_BUTTON_CAPABILITIES_TRUE = true; - private static final Boolean SOFT_BUTTON_CAPABILITIES_FALSE = false; - @Override protected RPCMessage createMessage() { SetDisplayLayoutResponse msg = new SetDisplayLayoutResponse(); - createCustomObjects(); - msg.setDisplayCapabilities(DISPLAY_CAPABILITIES); - msg.setPresetBankCapabilities(PRESET_BANK_CAPABILITIES); - msg.setButtonCapabilities(BUTTON_CAPABILITIES_LIST); - msg.setSoftButtonCapabilities(SOFT_BUTTON_CAPABILITIES_LIST); + msg.setDisplayCapabilities(Test.GENERAL_DISPLAYCAPABILITIES); + msg.setPresetBankCapabilities(Test.GENERAL_PRESETBANKCAPABILITIES); + msg.setButtonCapabilities(Test.GENERAL_BUTTONCAPABILITIES_LIST); + msg.setSoftButtonCapabilities(Test.GENERAL_SOFTBUTTONCAPABILITIES_LIST); return msg; } - - private void createCustomObjects () { - ButtonCapabilities buttonCapabailities = new ButtonCapabilities(); - buttonCapabailities.setUpDownAvailable(BUTTON_CAPABILITIES_TRUE); - buttonCapabailities.setLongPressAvailable(BUTTON_CAPABILITIES_TRUE); - buttonCapabailities.setShortPressAvailable(BUTTON_CAPABILITIES_FALSE); - BUTTON_CAPABILITIES_LIST.add(buttonCapabailities); - - SoftButtonCapabilities softButtonCapabilities = new SoftButtonCapabilities(); - softButtonCapabilities.setImageSupported(SOFT_BUTTON_CAPABILITIES_FALSE); - softButtonCapabilities.setUpDownAvailable(SOFT_BUTTON_CAPABILITIES_TRUE); - softButtonCapabilities.setLongPressAvailable(SOFT_BUTTON_CAPABILITIES_FALSE); - softButtonCapabilities.setShortPressAvailable(SOFT_BUTTON_CAPABILITIES_TRUE); - SOFT_BUTTON_CAPABILITIES_LIST.add(softButtonCapabilities); - - DISPLAY_CAPABILITIES.setDisplayType(DisplayType.TYPE2); - DISPLAY_CAPABILITIES.setGraphicSupported(true); - PRESET_BANK_CAPABILITIES.setOnScreenPresetsAvailable(true); - } @Override protected String getMessageType() { @@ -78,98 +53,69 @@ public class SetDisplayLayoutResponseTest extends BaseRpcTests { @Override protected JSONObject getExpectedParameters(int sdlVersion) { JSONObject result = new JSONObject(); - JSONObject presetBank = new JSONObject(); - try { - presetBank.put(PresetBankCapabilities.KEY_ON_SCREEN_PRESETS_AVAILABLE, PRESET_BANK_CAPABILITIES.onScreenPresetsAvailable()); - - result.put(SetDisplayLayoutResponse.KEY_DISPLAY_CAPABILITIES, DISPLAY_CAPABILITIES.serializeJSON()); - result.put(SetDisplayLayoutResponse.KEY_PRESET_BANK_CAPABILITIES, presetBank); - - JSONObject buttonCapabilitiesObj = new JSONObject(); - JSONArray buttonCapabilitiesArray = new JSONArray(); - buttonCapabilitiesObj.put(ButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, true); - buttonCapabilitiesObj.put(ButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, false); - buttonCapabilitiesObj.put(ButtonCapabilities.KEY_UP_DOWN_AVAILABLE, true); - buttonCapabilitiesArray.put(buttonCapabilitiesObj); - - result.put(SetDisplayLayoutResponse.KEY_BUTTON_CAPABILITIES, buttonCapabilitiesArray); - - JSONObject softButtonCapabilitiesObj = new JSONObject(); - JSONArray softButtonCapabilitiesArray = new JSONArray(); - softButtonCapabilitiesObj.put(SoftButtonCapabilities.KEY_UP_DOWN_AVAILABLE, true); - softButtonCapabilitiesObj.put(SoftButtonCapabilities.KEY_SHORT_PRESS_AVAILABLE, true); - softButtonCapabilitiesObj.put(SoftButtonCapabilities.KEY_LONG_PRESS_AVAILABLE, false); - softButtonCapabilitiesObj.put(SoftButtonCapabilities.KEY_IMAGE_SUPPORTED, false); - softButtonCapabilitiesArray.put(softButtonCapabilitiesObj); - - result.put(SetDisplayLayoutResponse.KEY_SOFT_BUTTON_CAPABILITIES, softButtonCapabilitiesArray); - + try { + result.put(SetDisplayLayoutResponse.KEY_DISPLAY_CAPABILITIES, Test.GENERAL_DISPLAYCAPABILITIES.serializeJSON()); + result.put(SetDisplayLayoutResponse.KEY_PRESET_BANK_CAPABILITIES, Test.JSON_PRESETBANKCAPABILITIES); + result.put(SetDisplayLayoutResponse.KEY_BUTTON_CAPABILITIES, Test.JSON_BUTTONCAPABILITIES); + result.put(SetDisplayLayoutResponse.KEY_SOFT_BUTTON_CAPABILITIES, Test.JSON_SOFTBUTTONCAPABILITIES); } catch (JSONException e) { - /* do nothing */ + fail(Test.JSON_FAIL); } return result; } - public void testDisplayCapabilities() { - DisplayCapabilities copy = ( (SetDisplayLayoutResponse) msg ).getDisplayCapabilities(); + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values + DisplayCapabilities testDisplay = ( (SetDisplayLayoutResponse) msg ).getDisplayCapabilities(); + PresetBankCapabilities testPbc = ( (SetDisplayLayoutResponse) msg ).getPresetBankCapabilities(); + List<ButtonCapabilities> testBc = ( (SetDisplayLayoutResponse) msg ).getButtonCapabilities(); + List<SoftButtonCapabilities> testSbc = ( (SetDisplayLayoutResponse) msg ).getSoftButtonCapabilities(); - assertTrue("Input value didn't match expected value.", Validator.validateDisplayCapabilities(DISPLAY_CAPABILITIES, copy)); - } - - public void testPresetBankCapabilities() { - PresetBankCapabilities copy = ( (SetDisplayLayoutResponse) msg ).getPresetBankCapabilities(); - - assertTrue("Input value didn't match expected value.", Validator.validatePresetBankCapabilities(PRESET_BANK_CAPABILITIES, copy)); - } - - public void testButtonCapabilities () { - List<ButtonCapabilities> copy = ( (SetDisplayLayoutResponse) msg ).getButtonCapabilities(); - - assertEquals("List size didn't match expected size.", BUTTON_CAPABILITIES_LIST.size(), copy.size()); - - for (int i = 0; i < BUTTON_CAPABILITIES_LIST.size(); i++) { - assertEquals("Input value didn't match expected value.", BUTTON_CAPABILITIES_LIST.get(i), copy.get(i)); + // Valid Tests + assertTrue(Test.TRUE, Validator.validateDisplayCapabilities(Test.GENERAL_DISPLAYCAPABILITIES, testDisplay)); + assertTrue(Test.TRUE, Validator.validatePresetBankCapabilities(Test.GENERAL_PRESETBANKCAPABILITIES, testPbc)); + assertEquals(Test.MATCH, Test.GENERAL_BUTTONCAPABILITIES_LIST.size(), testBc.size()); + assertEquals(Test.MATCH, Test.GENERAL_SOFTBUTTONCAPABILITIES_LIST.size(), testSbc.size()); + for (int i = 0; i < Test.GENERAL_BUTTONCAPABILITIES_LIST.size(); i++) { + assertEquals(Test.MATCH, Test.GENERAL_BUTTONCAPABILITIES_LIST.get(i), testBc.get(i)); } - } - - public void testSoftButtonCapabilities () { - List<SoftButtonCapabilities> copy = ( (SetDisplayLayoutResponse) msg ).getSoftButtonCapabilities(); - - assertEquals("List size didn't match expected size.", SOFT_BUTTON_CAPABILITIES_LIST.size(), copy.size()); - - for (int i = 0; i < SOFT_BUTTON_CAPABILITIES_LIST.size(); i++) { - assertEquals("Input value didn't match expected value.", SOFT_BUTTON_CAPABILITIES_LIST.get(i), copy.get(i)); + for (int i = 0; i < Test.GENERAL_SOFTBUTTONCAPABILITIES_LIST.size(); i++) { + assertEquals(Test.MATCH, Test.GENERAL_SOFTBUTTONCAPABILITIES_LIST.get(i), testSbc.get(i)); } - } - - public void testNull() { + + // Invalid/Null Tests SetDisplayLayoutResponse msg = new SetDisplayLayoutResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull("Display capabilities wasn't set, but getter method returned an object.", msg.getDisplayCapabilities()); - assertNull("Preset bank capabilities wasn't set, but getter method returned an object.", msg.getPresetBankCapabilities()); - assertNull("Button capabilities wasn't set, but getter method returned an object.", msg.getButtonCapabilities()); - assertNull("Soft button capabilities wasn't set, but getter method returned an object.", msg.getSoftButtonCapabilities()); + assertNull(Test.NULL, msg.getDisplayCapabilities()); + assertNull(Test.NULL, msg.getPresetBankCapabilities()); + assertNull(Test.NULL, msg.getButtonCapabilities()); + assertNull(Test.NULL, msg.getSoftButtonCapabilities()); } + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); SetDisplayLayoutResponse cmd = new SetDisplayLayoutResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); @@ -179,12 +125,11 @@ public class SetDisplayLayoutResponseTest extends BaseRpcTests { ButtonCapabilities buttonCapability = new ButtonCapabilities(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)buttonCapabilitiesArray.get(index) )); buttonCapabilitiesList.add(buttonCapability); } - assertTrue("Button capabilities list doesn't match input capabilities list", - Validator.validateButtonCapabilities(buttonCapabilitiesList, cmd.getButtonCapabilities() )); + assertTrue(Test.TRUE, Validator.validateButtonCapabilities(buttonCapabilitiesList, cmd.getButtonCapabilities() )); JSONObject displayCapabilitiesObj = JsonUtils.readJsonObjectFromJsonObject(parameters, SetDisplayLayoutResponse.KEY_DISPLAY_CAPABILITIES); DisplayCapabilities displayCapabilities = new DisplayCapabilities(JsonRPCMarshaller.deserializeJSONObject(displayCapabilitiesObj)); - assertTrue("Display capabilities doesn't match input capabilities", Validator.validateDisplayCapabilities(displayCapabilities, cmd.getDisplayCapabilities()) ); + assertTrue(Test.TRUE, Validator.validateDisplayCapabilities(displayCapabilities, cmd.getDisplayCapabilities()) ); JSONArray softButtonCapabilitiesArray = JsonUtils.readJsonArrayFromJsonObject(parameters, SetDisplayLayoutResponse.KEY_SOFT_BUTTON_CAPABILITIES); List<SoftButtonCapabilities> softButtonCapabilitiesList = new ArrayList<SoftButtonCapabilities>(); @@ -193,17 +138,13 @@ public class SetDisplayLayoutResponseTest extends BaseRpcTests { new SoftButtonCapabilities(JsonRPCMarshaller.deserializeJSONObject( (JSONObject)softButtonCapabilitiesArray.get(index) )); softButtonCapabilitiesList.add(softButtonCapability); } - assertTrue("Soft button capabilities list doesn't match input capabilities list", - Validator.validateSoftButtonCapabilities(softButtonCapabilitiesList, cmd.getSoftButtonCapabilities() )); + assertTrue(Test.TRUE, Validator.validateSoftButtonCapabilities(softButtonCapabilitiesList, cmd.getSoftButtonCapabilities() )); JSONObject presetBankCapabilitiesObj = JsonUtils.readJsonObjectFromJsonObject(parameters, SetDisplayLayoutResponse.KEY_PRESET_BANK_CAPABILITIES); PresetBankCapabilities presetBankCapabilities = new PresetBankCapabilities(JsonRPCMarshaller.deserializeJSONObject(presetBankCapabilitiesObj)); - assertTrue("Preset bank capabilities doesn't match input capabilities", Validator.validatePresetBankCapabilities(presetBankCapabilities, cmd.getPresetBankCapabilities()) ); - } - catch (JSONException e) { + assertTrue(Test.TRUE, Validator.validatePresetBankCapabilities(presetBankCapabilities, cmd.getPresetBankCapabilities()) ); + } catch (JSONException e) { e.printStackTrace(); - } - - } - -} + } + } +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetGlobalPropertiesResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetGlobalPropertiesResponseTest.java index 50e022036..6129e79ea 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetGlobalPropertiesResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetGlobalPropertiesResponseTest.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.SetGlobalPropertiesResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.SetGlobalPropertiesResponse} + */ public class SetGlobalPropertiesResponseTest extends BaseRpcTests { @Override @@ -35,32 +40,35 @@ public class SetGlobalPropertiesResponseTest extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests SetGlobalPropertiesResponse msg = new SetGlobalPropertiesResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); SetGlobalPropertiesResponse cmd = new SetGlobalPropertiesResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - - } - -} + } + } +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetMediaClockTimerResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetMediaClockTimerResponseTest.java index 37c611e94..9f9675ef5 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetMediaClockTimerResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SetMediaClockTimerResponseTest.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.SetMediaClockTimerResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.SetMediaClockTimerResponse} + */ public class SetMediaClockTimerResponseTest extends BaseRpcTests { @Override @@ -35,32 +40,35 @@ public class SetMediaClockTimerResponseTest extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests SetMediaClockTimerResponse msg = new SetMediaClockTimerResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); SetMediaClockTimerResponse cmd = new SetMediaClockTimerResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ShowConstantTbtResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ShowConstantTbtResponseTests.java index 9869663b4..f55d8b42a 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ShowConstantTbtResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ShowConstantTbtResponseTests.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.ShowConstantTbtResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.ShowConstantTbtResponse} + */ public class ShowConstantTbtResponseTests extends BaseRpcTests { @Override @@ -36,29 +41,34 @@ public class ShowConstantTbtResponseTests extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests ShowConstantTbtResponse msg = new ShowConstantTbtResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); ShowConstantTbtResponse cmd = new ShowConstantTbtResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } + } } }
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java index e07d05828..6ab23603e 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/ShowResponseTest.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.ShowResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.ShowResponse} + */ public class ShowResponseTest extends BaseRpcTests { @Override @@ -35,32 +40,35 @@ public class ShowResponseTest extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests ShowResponse msg = new ShowResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); ShowResponse cmd = new ShowResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SliderResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SliderResponseTest.java index 196443d5d..508243808 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SliderResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SliderResponseTest.java @@ -11,17 +11,20 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.SliderResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.SliderResponse} + */ public class SliderResponseTest extends BaseRpcTests { - - private static final Integer POSITION = 0; @Override protected RPCMessage createMessage() { SliderResponse msg = new SliderResponse(); - msg.setSliderPosition(POSITION); + msg.setSliderPosition(Test.GENERAL_INT); return msg; } @@ -41,10 +44,10 @@ public class SliderResponseTest extends BaseRpcTests { JSONObject result = new JSONObject(); try { - result.put(SliderResponse.KEY_SLIDER_POSITION, POSITION); + result.put(SliderResponse.KEY_SLIDER_POSITION, Test.GENERAL_INT); } catch (JSONException e) { - /* do nothing */ + fail(Test.JSON_FAIL); } return result; @@ -52,42 +55,40 @@ public class SliderResponseTest extends BaseRpcTests { public void testPosition() { Integer copy = ( (SliderResponse) msg ).getSliderPosition(); - assertEquals("Data didn't match input data.", POSITION, copy); + assertEquals(Test.MATCH, (Integer) Test.GENERAL_INT, copy); } public void testNull() { SliderResponse msg = new SliderResponse(); - assertNotNull("Null object creation failed.", msg); + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); - assertNull("Position wasn't set, but getter method returned an object.", msg.getSliderPosition()); + assertNull(Test.NULL, msg.getSliderPosition()); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); SliderResponse cmd = new SliderResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); - assertEquals("Slider position doesn't match input position", - JsonUtils.readIntegerFromJsonObject(parameters, SliderResponse.KEY_SLIDER_POSITION), cmd.getSliderPosition()); - - } - catch (JSONException e) { + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(parameters, SliderResponse.KEY_SLIDER_POSITION), cmd.getSliderPosition()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SpeakResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SpeakResponseTest.java index ba8367201..8c23edd13 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SpeakResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SpeakResponseTest.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.SpeakResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.SpeakResponse} + */ public class SpeakResponseTest extends BaseRpcTests { @Override @@ -35,32 +40,35 @@ public class SpeakResponseTest extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests SpeakResponse msg = new SpeakResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); SpeakResponse cmd = new SpeakResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SubscribeButtonResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SubscribeButtonResponseTest.java index e236e124d..413886081 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SubscribeButtonResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SubscribeButtonResponseTest.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.SubscribeButtonResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.SubscribeButtonResponse} + */ public class SubscribeButtonResponseTest extends BaseRpcTests { @Override @@ -35,32 +40,35 @@ public class SubscribeButtonResponseTest extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests SubscribeButtonResponse msg = new SubscribeButtonResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); SubscribeButtonResponse cmd = new SubscribeButtonResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java index cf76651f8..51d6015fe 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SubscribeVehicleDataResponseTest.java @@ -10,76 +10,49 @@ import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.SubscribeVehicleDataResponse; import com.smartdevicelink.proxy.rpc.VehicleDataResult; -import com.smartdevicelink.proxy.rpc.enums.VehicleDataResultCode; import com.smartdevicelink.proxy.rpc.enums.VehicleDataType; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.Validator; import com.smartdevicelink.test.json.rpc.JsonFileReader; -@SuppressWarnings("deprecation") +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.SubscribeVehicleDataResponse} + */ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { - //TODO: the corresponding library class does not include variables for the vehicle data type VEHICLEDATA_BATTVOLTAGE. intentional? - public static final VehicleDataResult KEY_SPEED = new VehicleDataResult(); - public static final VehicleDataResult KEY_RPM = new VehicleDataResult(); - public static final VehicleDataResult KEY_EXTERNAL_TEMPERATURE = new VehicleDataResult(); - public static final VehicleDataResult KEY_FUEL_LEVEL = new VehicleDataResult(); - public static final VehicleDataResult KEY_PRNDL = new VehicleDataResult(); - public static final VehicleDataResult KEY_TIRE_PRESSURE = new VehicleDataResult(); - public static final VehicleDataResult KEY_ENGINE_TORQUE = new VehicleDataResult(); - public static final VehicleDataResult KEY_ODOMETER = new VehicleDataResult(); - public static final VehicleDataResult KEY_GPS = new VehicleDataResult(); - public static final VehicleDataResult KEY_FUEL_LEVEL_STATE = new VehicleDataResult(); - public static final VehicleDataResult KEY_INSTANT_FUEL_CONSUMPTION = new VehicleDataResult(); - public static final VehicleDataResult KEY_BELT_STATUS = new VehicleDataResult(); - public static final VehicleDataResult KEY_BODY_INFORMATION = new VehicleDataResult(); - public static final VehicleDataResult KEY_DEVICE_STATUS = new VehicleDataResult(); - public static final VehicleDataResult KEY_DRIVER_BRAKING = new VehicleDataResult(); - public static final VehicleDataResult KEY_WIPER_STATUS = new VehicleDataResult(); - public static final VehicleDataResult KEY_HEAD_LAMP_STATUS = new VehicleDataResult(); - public static final VehicleDataResult KEY_ACC_PEDAL_POSITION = new VehicleDataResult(); - public static final VehicleDataResult KEY_STEERING_WHEEL_ANGLE = new VehicleDataResult(); - public static final VehicleDataResult KEY_E_CALL_INFO = new VehicleDataResult(); - public static final VehicleDataResult KEY_AIRBAG_STATUS = new VehicleDataResult(); - public static final VehicleDataResult KEY_EMERGENCY_EVENT = new VehicleDataResult(); - public static final VehicleDataResult KEY_CLUSTER_MODE_STATUS = new VehicleDataResult(); - public static final VehicleDataResult KEY_MY_KEY = new VehicleDataResult(); - - //this method makes setting up the VehicleDataResult objects easier. assumes VehicleDataResultCode.SUCCESS for all result codes - private VehicleDataResult populateResultObject (VehicleDataResult data, VehicleDataType type) { - data.setDataType(type); - data.setResultCode(VehicleDataResultCode.SUCCESS); - return data; - } + // TODO : Test different result codes. + @Override protected RPCMessage createMessage() { SubscribeVehicleDataResponse msg = new SubscribeVehicleDataResponse(); - msg.setSpeed( populateResultObject(KEY_SPEED, VehicleDataType.VEHICLEDATA_SPEED) ); - msg.setRpm( populateResultObject(KEY_RPM, VehicleDataType.VEHICLEDATA_RPM) ); - msg.setExternalTemperature( populateResultObject(KEY_EXTERNAL_TEMPERATURE, VehicleDataType.VEHICLEDATA_EXTERNTEMP) ); - msg.setFuelLevel( populateResultObject(KEY_FUEL_LEVEL, VehicleDataType.VEHICLEDATA_FUELLEVEL) ); - msg.setPrndl( populateResultObject(KEY_PRNDL, VehicleDataType.VEHICLEDATA_PRNDL) ); - msg.setTirePressure( populateResultObject(KEY_TIRE_PRESSURE, VehicleDataType.VEHICLEDATA_TIREPRESSURE) ); - msg.setEngineTorque( populateResultObject(KEY_ENGINE_TORQUE, VehicleDataType.VEHICLEDATA_ENGINETORQUE) ); - msg.setOdometer( populateResultObject(KEY_ODOMETER, VehicleDataType.VEHICLEDATA_ODOMETER) ); - msg.setGps( populateResultObject(KEY_GPS, VehicleDataType.VEHICLEDATA_GPS) ); - msg.setFuelLevel_State( populateResultObject(KEY_FUEL_LEVEL_STATE, VehicleDataType.VEHICLEDATA_FUELLEVEL_STATE) ); - msg.setInstantFuelConsumption( populateResultObject(KEY_INSTANT_FUEL_CONSUMPTION, VehicleDataType.VEHICLEDATA_FUELCONSUMPTION) ); - msg.setBeltStatus( populateResultObject(KEY_BELT_STATUS, VehicleDataType.VEHICLEDATA_BELTSTATUS) ); - msg.setBodyInformation( populateResultObject(KEY_BODY_INFORMATION, VehicleDataType.VEHICLEDATA_BODYINFO) ); - msg.setDeviceStatus( populateResultObject(KEY_DEVICE_STATUS, VehicleDataType.VEHICLEDATA_DEVICESTATUS) ); - msg.setDriverBraking( populateResultObject(KEY_DRIVER_BRAKING, VehicleDataType.VEHICLEDATA_BRAKING) ); - msg.setWiperStatus( populateResultObject(KEY_WIPER_STATUS, VehicleDataType.VEHICLEDATA_WIPERSTATUS) ); - msg.setHeadLampStatus( populateResultObject(KEY_HEAD_LAMP_STATUS, VehicleDataType.VEHICLEDATA_HEADLAMPSTATUS) ); - msg.setAccPedalPosition( populateResultObject(KEY_ACC_PEDAL_POSITION, VehicleDataType.VEHICLEDATA_ACCPEDAL) ); - msg.setSteeringWheelAngle( populateResultObject(KEY_STEERING_WHEEL_ANGLE, VehicleDataType.VEHICLEDATA_STEERINGWHEEL) ); - msg.setECallInfo( populateResultObject(KEY_E_CALL_INFO, VehicleDataType.VEHICLEDATA_ECALLINFO) ); - msg.setAirbagStatus( populateResultObject(KEY_AIRBAG_STATUS, VehicleDataType.VEHICLEDATA_AIRBAGSTATUS) ); - msg.setEmergencyEvent( populateResultObject(KEY_EMERGENCY_EVENT, VehicleDataType.VEHICLEDATA_EMERGENCYEVENT) ); - msg.setClusterModeStatus( populateResultObject(KEY_CLUSTER_MODE_STATUS, VehicleDataType.VEHICLEDATA_CLUSTERMODESTATUS) ); - msg.setMyKey( populateResultObject(KEY_MY_KEY, VehicleDataType.VEHICLEDATA_MYKEY) ); + msg.setSpeed(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_SPEED.ordinal())); + msg.setRpm(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_RPM.ordinal())); + msg.setExternalTemperature(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_EXTERNTEMP.ordinal())); + msg.setFuelLevel(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELLEVEL.ordinal())); + msg.setPrndl(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_PRNDL.ordinal())); + msg.setTirePressure(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TIREPRESSURE.ordinal())); + msg.setEngineTorque(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ENGINETORQUE.ordinal())); + msg.setOdometer(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ODOMETER.ordinal())); + msg.setGps(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_GPS.ordinal())); + msg.setFuelLevelState(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELLEVEL_STATE.ordinal())); + msg.setInstantFuelConsumption(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELCONSUMPTION.ordinal())); + msg.setBeltStatus(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_BELTSTATUS.ordinal())); + msg.setBodyInformation(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_BODYINFO.ordinal())); + msg.setDeviceStatus(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_DEVICESTATUS.ordinal())); + msg.setDriverBraking(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_BRAKING.ordinal())); + msg.setWiperStatus(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WIPERSTATUS.ordinal())); + msg.setHeadLampStatus(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HEADLAMPSTATUS.ordinal())); + msg.setAccPedalPosition(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ACCPEDAL.ordinal())); + msg.setSteeringWheelAngle(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_STEERINGWHEEL.ordinal())); + msg.setECallInfo(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ECALLINFO.ordinal())); + msg.setAirbagStatus(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_AIRBAGSTATUS.ordinal())); + msg.setEmergencyEvent(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_EMERGENCYEVENT.ordinal())); + msg.setClusterModeStatus(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_CLUSTERMODESTATUS.ordinal())); + msg.setMyKey(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_MYKEY.ordinal())); return msg; } @@ -97,346 +70,248 @@ public class SubscribeVehicleDataResponseTest extends BaseRpcTests { @Override protected JSONObject getExpectedParameters(int sdlVersion) { JSONObject result = new JSONObject(); - //TODO: correct? + try { - result.put(SubscribeVehicleDataResponse.KEY_SPEED, KEY_SPEED.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_RPM, KEY_RPM.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_EXTERNAL_TEMPERATURE, KEY_EXTERNAL_TEMPERATURE.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_FUEL_LEVEL, KEY_FUEL_LEVEL.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_PRNDL, KEY_PRNDL.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_TIRE_PRESSURE, KEY_TIRE_PRESSURE.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_ENGINE_TORQUE, KEY_ENGINE_TORQUE.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_ODOMETER, KEY_ODOMETER.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_GPS, KEY_GPS.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_FUEL_LEVEL_STATE, KEY_FUEL_LEVEL_STATE.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_INSTANT_FUEL_CONSUMPTION, KEY_INSTANT_FUEL_CONSUMPTION.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_BELT_STATUS, KEY_BELT_STATUS.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_BODY_INFORMATION, KEY_BODY_INFORMATION.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_DEVICE_STATUS, KEY_DEVICE_STATUS.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_DRIVER_BRAKING, KEY_DRIVER_BRAKING.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_WIPER_STATUS, KEY_WIPER_STATUS.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_HEAD_LAMP_STATUS, KEY_HEAD_LAMP_STATUS.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_ACC_PEDAL_POSITION, KEY_ACC_PEDAL_POSITION.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_STEERING_WHEEL_ANGLE, KEY_STEERING_WHEEL_ANGLE.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_E_CALL_INFO, KEY_E_CALL_INFO.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_AIRBAG_STATUS, KEY_AIRBAG_STATUS.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_EMERGENCY_EVENT, KEY_EMERGENCY_EVENT.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_CLUSTER_MODE_STATUS, KEY_CLUSTER_MODE_STATUS.serializeJSON()); - result.put(SubscribeVehicleDataResponse.KEY_MY_KEY, KEY_MY_KEY.serializeJSON()); + + // Note: If the key values stored in SubscribeVehicleDataResponse + // were to be in a list then this could be easily looped through + // instead of individually set. + + result.put(SubscribeVehicleDataResponse.KEY_SPEED, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_SPEED.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_RPM, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_RPM.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_EXTERNAL_TEMPERATURE, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_EXTERNTEMP.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_FUEL_LEVEL, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELLEVEL.ordinal())); + result.put(SubscribeVehicleDataResponse.KEY_PRNDL, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_PRNDL.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_TIRE_PRESSURE, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TIREPRESSURE.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_ENGINE_TORQUE, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ENGINETORQUE.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_ODOMETER, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ODOMETER.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_GPS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_GPS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_FUEL_LEVEL_STATE, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELLEVEL_STATE.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_INSTANT_FUEL_CONSUMPTION, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELCONSUMPTION.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_BELT_STATUS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_BELTSTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_BODY_INFORMATION, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_BODYINFO.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_DEVICE_STATUS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_DEVICESTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_DRIVER_BRAKING, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_BRAKING.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_WIPER_STATUS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WIPERSTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_HEAD_LAMP_STATUS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HEADLAMPSTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_ACC_PEDAL_POSITION, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ACCPEDAL.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_STEERING_WHEEL_ANGLE, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_STEERINGWHEEL.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_E_CALL_INFO, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ECALLINFO.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_AIRBAG_STATUS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_AIRBAGSTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_EMERGENCY_EVENT, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_EMERGENCYEVENT.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_CLUSTER_MODE_STATUS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_CLUSTERMODESTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_MY_KEY, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_MYKEY.ordinal()).serializeJSON()); } catch (JSONException e) { - // do nothing + fail(Test.JSON_FAIL); } return result; } - - /* The VehicleDataResult class contains the following retrievable variables: - * (VehicleDataType) dataType Enum value being tested - * (VehicleDataResultCode) resultCode Enum value being ignored - * - * Should we test the result code as follows? Are we to assume success? - * - * assertTrue("Result code didn't match expected value.", data.getResultCode().equals(VehicleDataResultCode.SUCCESS)); - */ - public void testGps(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getGps(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_GPS)); - } - - public void testOdometer(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getOdometer(); + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Test Values + VehicleDataResult testGps = ( (SubscribeVehicleDataResponse) msg ).getGps(); + VehicleDataResult testOdometer = ( (SubscribeVehicleDataResponse) msg ).getOdometer(); + VehicleDataResult testTirePressure = ( (SubscribeVehicleDataResponse) msg ).getTirePressure(); + VehicleDataResult testBeltStatus = ( (SubscribeVehicleDataResponse) msg ).getBeltStatus(); + VehicleDataResult testBodyInfo = ( (SubscribeVehicleDataResponse) msg ).getBodyInformation(); + VehicleDataResult testDeviceStatus = ( (SubscribeVehicleDataResponse) msg ).getDeviceStatus(); + VehicleDataResult testHeadLampStatus = ( (SubscribeVehicleDataResponse) msg ).getHeadLampStatus(); + VehicleDataResult testECallInfo = ( (SubscribeVehicleDataResponse) msg ).getECallInfo(); + VehicleDataResult testAirbagStatus = ( (SubscribeVehicleDataResponse) msg ).getAirbagStatus(); + VehicleDataResult testEmergencyEvent = ( (SubscribeVehicleDataResponse) msg ).getEmergencyEvent(); + VehicleDataResult testClusterMode = ( (SubscribeVehicleDataResponse) msg ).getClusterModeStatus(); + VehicleDataResult testMyKey = ( (SubscribeVehicleDataResponse) msg ).getMyKey(); + VehicleDataResult testSpeed = ( (SubscribeVehicleDataResponse) msg ).getSpeed(); + VehicleDataResult testRpm = ( (SubscribeVehicleDataResponse) msg ).getRpm(); + VehicleDataResult testFuelLevel = ( (SubscribeVehicleDataResponse) msg ).getFuelLevel(); + VehicleDataResult testConsumption = ( (SubscribeVehicleDataResponse) msg ).getInstantFuelConsumption(); + VehicleDataResult testExternalTemp = ( (SubscribeVehicleDataResponse) msg ).getExternalTemperature(); + VehicleDataResult testEngineTorque = ( (SubscribeVehicleDataResponse) msg ).getEngineTorque(); + VehicleDataResult testAccPedal = ( (SubscribeVehicleDataResponse) msg ).getAccPedalPosition(); + VehicleDataResult testSteeringWheel = ( (SubscribeVehicleDataResponse) msg ).getSteeringWheelAngle(); + VehicleDataResult testFuelLevelState = ( (SubscribeVehicleDataResponse) msg ).getFuelLevelState(); + VehicleDataResult testPrndl = ( (SubscribeVehicleDataResponse) msg ).getPrndl(); + VehicleDataResult testBraking = ( (SubscribeVehicleDataResponse) msg ).getDriverBraking(); + VehicleDataResult testWiperStatus = ( (SubscribeVehicleDataResponse) msg ).getWiperStatus(); - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_ODOMETER)); - } - - public void testTireStatus(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getTirePressure(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_TIREPRESSURE)); - } - - public void testBeltStatus(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getBeltStatus(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_BELTSTATUS)); - } - - public void testBodyInformation(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getBodyInformation(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_BODYINFO)); - } - - public void testDeviceStatus(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getDeviceStatus(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_DEVICESTATUS)); - } - - public void testHeadLampStatus(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getHeadLampStatus(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_HEADLAMPSTATUS)); - } - - public void testECallInfo(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getECallInfo(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_ECALLINFO)); - } - - public void testAirbagStatus(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getAirbagStatus(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_AIRBAGSTATUS)); - } - - public void testEmergencyEvent(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getEmergencyEvent(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_EMERGENCYEVENT)); - } - - public void testClusterModeStatus(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getClusterModeStatus(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_CLUSTERMODESTATUS)); - } - - public void testMyKey(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getMyKey(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_MYKEY)); - } - - public void testSpeed(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getSpeed(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_SPEED)); - } - - public void testRpm(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getRpm(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_RPM)); - } - - public void testFuelLevel(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getFuelLevel(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELLEVEL)); - } - - public void testInstantFuelConsumption(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getInstantFuelConsumption(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELCONSUMPTION)); - } - - public void testExternalTemperature(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getExternalTemperature(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_EXTERNTEMP)); - } - - public void testEngineTorque(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getEngineTorque(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_ENGINETORQUE)); - } - - public void testAccPedalPosition(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getAccPedalPosition(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_ACCPEDAL)); - } - - public void testSteeringWheelAngle(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getSteeringWheelAngle(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_STEERINGWHEEL)); - } - - public void testFuelLevelState(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getFuelLevel_State(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELLEVEL_STATE)); - } - - public void testPRNDL(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getPrndl(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_PRNDL)); - } - - public void testDriverBraking(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getDriverBraking(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_BRAKING)); - } - - public void testWiperStatus(){ - VehicleDataResult data = ( (SubscribeVehicleDataResponse) msg ).getWiperStatus(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_WIPERSTATUS)); - } - - public void testNull(){ + // Valid Tests + assertTrue(Test.TRUE, testGps.getDataType().equals(VehicleDataType.VEHICLEDATA_GPS)); + assertTrue(Test.TRUE, testOdometer.getDataType().equals(VehicleDataType.VEHICLEDATA_ODOMETER)); + assertTrue(Test.TRUE, testTirePressure.getDataType().equals(VehicleDataType.VEHICLEDATA_TIREPRESSURE)); + assertTrue(Test.TRUE, testBeltStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_BELTSTATUS)); + assertTrue(Test.TRUE, testBodyInfo.getDataType().equals(VehicleDataType.VEHICLEDATA_BODYINFO)); + assertTrue(Test.TRUE, testDeviceStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_DEVICESTATUS)); + assertTrue(Test.TRUE, testHeadLampStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_HEADLAMPSTATUS)); + assertTrue(Test.TRUE, testECallInfo.getDataType().equals(VehicleDataType.VEHICLEDATA_ECALLINFO)); + assertTrue(Test.TRUE, testAirbagStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_AIRBAGSTATUS)); + assertTrue(Test.TRUE, testEmergencyEvent.getDataType().equals(VehicleDataType.VEHICLEDATA_EMERGENCYEVENT)); + assertTrue(Test.TRUE, testClusterMode.getDataType().equals(VehicleDataType.VEHICLEDATA_CLUSTERMODESTATUS)); + assertTrue(Test.TRUE, testMyKey.getDataType().equals(VehicleDataType.VEHICLEDATA_MYKEY)); + assertTrue(Test.TRUE, testSpeed.getDataType().equals(VehicleDataType.VEHICLEDATA_SPEED)); + assertTrue(Test.TRUE, testRpm.getDataType().equals(VehicleDataType.VEHICLEDATA_RPM)); + assertTrue(Test.TRUE, testFuelLevel.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELLEVEL)); + assertTrue(Test.TRUE, testConsumption.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELCONSUMPTION)); + assertTrue(Test.TRUE, testExternalTemp.getDataType().equals(VehicleDataType.VEHICLEDATA_EXTERNTEMP)); + assertTrue(Test.TRUE, testEngineTorque.getDataType().equals(VehicleDataType.VEHICLEDATA_ENGINETORQUE)); + assertTrue(Test.TRUE, testAccPedal.getDataType().equals(VehicleDataType.VEHICLEDATA_ACCPEDAL)); + assertTrue(Test.TRUE, testSteeringWheel.getDataType().equals(VehicleDataType.VEHICLEDATA_STEERINGWHEEL)); + assertTrue(Test.TRUE, testFuelLevelState.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELLEVEL_STATE)); + assertTrue(Test.TRUE, testPrndl.getDataType().equals(VehicleDataType.VEHICLEDATA_PRNDL)); + assertTrue(Test.TRUE, testBraking.getDataType().equals(VehicleDataType.VEHICLEDATA_BRAKING)); + assertTrue(Test.TRUE, testWiperStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_WIPERSTATUS)); + + // Invalid/Null Tests SubscribeVehicleDataResponse msg = new SubscribeVehicleDataResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull("Null object creation failed.", msg); testNullBase(msg); - assertNull("Accel pedal vehicle data wasn't set, but getter method returned an object.", msg.getAccPedalPosition()); - assertNull("Airbag vehicle data wasn't set, but getter method returned an object.", msg.getAirbagStatus()); - assertNull("Belt vehicle data wasn't set, but getter method returned an object.", msg.getBeltStatus()); - assertNull("Driver braking vehicle data wasn't set, but getter method returned an object.", msg.getDriverBraking()); - assertNull("Fuel level vehicle data wasn't set, but getter method returned an object.", msg.getFuelLevel()); - assertNull("Tire pressure vehicle data wasn't set, but getter method returned an object.", msg.getTirePressure()); - assertNull("Wiper vehicle data wasn't set, but getter method returned an object.", msg.getWiperStatus()); - assertNull("Gps data wasn't set, but getter method returned an object.", msg.getGps()); - assertNull("Speed data wasn't set, but getter method returned an object.", msg.getSpeed()); - assertNull("Rpm data wasn't set, but getter method returned an object.", msg.getRpm()); - assertNull("Fuel level state data wasn't set, but getter method returned an object.", msg.getFuelLevel_State()); - assertNull("Fuel consumption data wasn't set, but getter method returned an object.", msg.getInstantFuelConsumption()); - assertNull("External temperature data wasn't set, but getter method returned an object.", msg.getExternalTemperature()); - assertNull("PRNDL data wasn't set, but getter method returned an object.", msg.getPrndl()); - assertNull("Odometer data wasn't set, but getter method returned an object.", msg.getOdometer()); - assertNull("Body information data wasn't set, but getter method returned an object.", msg.getBodyInformation()); - assertNull("Device status data wasn't set, but getter method returned an object.", msg.getDeviceStatus()); - assertNull("Head lamp status data wasn't set, but getter method returned an object.", msg.getHeadLampStatus()); - assertNull("Engine torque data wasn't set, but getter method returned an object.", msg.getEngineTorque()); - assertNull("Steering wheel angle data wasn't set, but getter method returned an object.", msg.getSteeringWheelAngle()); - assertNull("ECall info data wasn't set, but getter method returned an object.", msg.getECallInfo()); - assertNull("Emergency event data wasn't set, but getter method returned an object.", msg.getEmergencyEvent()); - assertNull("Cluster mode data wasn't set, but getter method returned an object.", msg.getClusterModeStatus()); - assertNull("My key data wasn't set, but getter method returned an object.", msg.getMyKey()); + + assertNull(Test.NULL, msg.getAccPedalPosition()); + assertNull(Test.NULL, msg.getAirbagStatus()); + assertNull(Test.NULL, msg.getBeltStatus()); + assertNull(Test.NULL, msg.getDriverBraking()); + assertNull(Test.NULL, msg.getFuelLevel()); + assertNull(Test.NULL, msg.getTirePressure()); + assertNull(Test.NULL, msg.getWiperStatus()); + assertNull(Test.NULL, msg.getGps()); + assertNull(Test.NULL, msg.getSpeed()); + assertNull(Test.NULL, msg.getRpm()); + assertNull(Test.NULL, msg.getFuelLevelState()); + assertNull(Test.NULL, msg.getInstantFuelConsumption()); + assertNull(Test.NULL, msg.getExternalTemperature()); + assertNull(Test.NULL, msg.getPrndl()); + assertNull(Test.NULL, msg.getOdometer()); + assertNull(Test.NULL, msg.getBodyInformation()); + assertNull(Test.NULL, msg.getDeviceStatus()); + assertNull(Test.NULL, msg.getHeadLampStatus()); + assertNull(Test.NULL, msg.getEngineTorque()); + assertNull(Test.NULL, msg.getSteeringWheelAngle()); + assertNull(Test.NULL, msg.getECallInfo()); + assertNull(Test.NULL, msg.getEmergencyEvent()); + assertNull(Test.NULL, msg.getClusterModeStatus()); + assertNull(Test.NULL, msg.getMyKey()); } + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); SubscribeVehicleDataResponse cmd = new SubscribeVehicleDataResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); JSONObject speed = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_SPEED); VehicleDataResult referenceSpeed = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(speed)); - assertTrue("Speed doesn't match expected speed", Validator.validateVehicleDataResult(referenceSpeed, cmd.getSpeed())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceSpeed, cmd.getSpeed())); JSONObject rpm = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_RPM); VehicleDataResult referenceRpm = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(rpm)); - assertTrue("RPM doesn't match expected RPM", Validator.validateVehicleDataResult(referenceRpm, cmd.getRpm())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceRpm, cmd.getRpm())); JSONObject fuelLevel = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_FUEL_LEVEL); VehicleDataResult referenceFuelLevel = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(fuelLevel)); - assertTrue("Fuel level doesn't match expected level", Validator.validateVehicleDataResult(referenceFuelLevel, cmd.getFuelLevel())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceFuelLevel, cmd.getFuelLevel())); JSONObject externalTemperature = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_EXTERNAL_TEMPERATURE); VehicleDataResult referenceExternalTemperature = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(externalTemperature)); - assertTrue("External temperature doesn't match expected temperature", - Validator.validateVehicleDataResult(referenceExternalTemperature, cmd.getExternalTemperature())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceExternalTemperature, cmd.getExternalTemperature())); JSONObject prndl = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_PRNDL); VehicleDataResult referencePrndl = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(prndl)); - assertTrue("PRNDL doesn't match expected PRNDL", Validator.validateVehicleDataResult(referencePrndl, cmd.getPrndl())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referencePrndl, cmd.getPrndl())); JSONObject tirePressure = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_TIRE_PRESSURE); VehicleDataResult referenceTirePressure = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(tirePressure)); - assertTrue("Tire pressure doesn't match expected pressure", Validator.validateVehicleDataResult(referenceTirePressure, cmd.getTirePressure())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceTirePressure, cmd.getTirePressure())); JSONObject engineTorque = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_ENGINE_TORQUE); VehicleDataResult referenceEngineTorque = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(engineTorque)); - assertTrue("Engine torque doesn't match expected torque", Validator.validateVehicleDataResult(referenceEngineTorque, cmd.getEngineTorque())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceEngineTorque, cmd.getEngineTorque())); JSONObject odometer = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_ODOMETER); VehicleDataResult referenceOdometer = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(odometer)); - assertTrue("Odometer doesn't match expected odometer", Validator.validateVehicleDataResult(referenceOdometer, cmd.getOdometer())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceOdometer, cmd.getOdometer())); JSONObject gps = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_GPS); VehicleDataResult referenceGps = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(gps)); - assertTrue("GPS doesn't match expected GPS", Validator.validateVehicleDataResult(referenceGps, cmd.getGps())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceGps, cmd.getGps())); JSONObject fuelLevelState = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_FUEL_LEVEL_STATE); VehicleDataResult referenceFuelLevelState = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(fuelLevelState)); - assertTrue("Fuel level state doesn't match expected state", Validator.validateVehicleDataResult(referenceFuelLevelState, cmd.getFuelLevel_State())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceFuelLevelState, cmd.getFuelLevelState())); JSONObject fuelConsumption = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_INSTANT_FUEL_CONSUMPTION); VehicleDataResult referenceFuelConsumption = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(fuelConsumption)); - assertTrue("Fuel consumption doesn't match expected consumption", - Validator.validateVehicleDataResult(referenceFuelConsumption, cmd.getInstantFuelConsumption())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceFuelConsumption, cmd.getInstantFuelConsumption())); JSONObject beltStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_BELT_STATUS); VehicleDataResult referenceBeltStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(beltStatus)); - assertTrue("Belt status doesn't match expected status", Validator.validateVehicleDataResult(referenceBeltStatus, cmd.getBeltStatus())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceBeltStatus, cmd.getBeltStatus())); JSONObject bodyInformation = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_BODY_INFORMATION); VehicleDataResult referenceBodyInformation = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(bodyInformation)); - assertTrue("Body information doesn't match expected information", - Validator.validateVehicleDataResult(referenceBodyInformation, cmd.getBodyInformation())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceBodyInformation, cmd.getBodyInformation())); JSONObject deviceStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_DEVICE_STATUS); VehicleDataResult referenceDeviceStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(deviceStatus)); - assertTrue("Device status doesn't match expected status", Validator.validateVehicleDataResult(referenceDeviceStatus, cmd.getDeviceStatus())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceDeviceStatus, cmd.getDeviceStatus())); JSONObject driverBraking = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_DRIVER_BRAKING); VehicleDataResult referenceDriverBraking = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(driverBraking)); - assertTrue("Driver braking doesn't match expected braking", Validator.validateVehicleDataResult(referenceDriverBraking, cmd.getDriverBraking())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceDriverBraking, cmd.getDriverBraking())); JSONObject wiperStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_WIPER_STATUS); VehicleDataResult referenceWiperStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(wiperStatus)); - assertTrue("Wiper status doesn't match expected status", Validator.validateVehicleDataResult(referenceWiperStatus, cmd.getWiperStatus())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceWiperStatus, cmd.getWiperStatus())); JSONObject headLampStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_HEAD_LAMP_STATUS); VehicleDataResult referenceHeadLampStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(headLampStatus)); - assertTrue("Head lamp status doesn't match expected status", Validator.validateVehicleDataResult(referenceHeadLampStatus, cmd.getHeadLampStatus())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceHeadLampStatus, cmd.getHeadLampStatus())); JSONObject accPedalPosition = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_ACC_PEDAL_POSITION); VehicleDataResult referenceAccPedalPosition = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(accPedalPosition)); - assertTrue("Acc pedal position doesn't match expected position", - Validator.validateVehicleDataResult(referenceAccPedalPosition, cmd.getAccPedalPosition())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceAccPedalPosition, cmd.getAccPedalPosition())); JSONObject steeringWheelAngle = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_STEERING_WHEEL_ANGLE); VehicleDataResult referenceSteeringWheelAngle = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(steeringWheelAngle)); - assertTrue("Steering wheel angle doesn't match expected angle", - Validator.validateVehicleDataResult(referenceSteeringWheelAngle, cmd.getSteeringWheelAngle())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceSteeringWheelAngle, cmd.getSteeringWheelAngle())); JSONObject eCallInfo = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_E_CALL_INFO); VehicleDataResult referenceECallInfo = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(eCallInfo)); - assertTrue("Emergency call info doesn't match expected info", Validator.validateVehicleDataResult(referenceECallInfo, cmd.getECallInfo())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceECallInfo, cmd.getECallInfo())); JSONObject airbagStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_AIRBAG_STATUS); VehicleDataResult referenceAirbagStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(airbagStatus)); - assertTrue("Airbag status doesn't match expected status", Validator.validateVehicleDataResult(referenceAirbagStatus, cmd.getAirbagStatus())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceAirbagStatus, cmd.getAirbagStatus())); JSONObject emergencyEvent = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_EMERGENCY_EVENT); VehicleDataResult referenceEmergencyEvent = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(emergencyEvent)); - assertTrue("Emergency event doesn't match expected event", Validator.validateVehicleDataResult(referenceEmergencyEvent, cmd.getEmergencyEvent())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceEmergencyEvent, cmd.getEmergencyEvent())); JSONObject clusterModeStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_CLUSTER_MODE_STATUS); VehicleDataResult referenceClusterModeStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(clusterModeStatus)); - assertTrue("Cluster mode status doesn't match expected status", - Validator.validateVehicleDataResult(referenceClusterModeStatus, cmd.getClusterModeStatus())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceClusterModeStatus, cmd.getClusterModeStatus())); JSONObject myKey = JsonUtils.readJsonObjectFromJsonObject(parameters, SubscribeVehicleDataResponse.KEY_MY_KEY); VehicleDataResult referenceMyKey = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(myKey)); - assertTrue("My key doesn't match expected key", Validator.validateVehicleDataResult(referenceMyKey, cmd.getMyKey())); - } - catch (JSONException e) { + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceMyKey, cmd.getMyKey())); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SystemRequestResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SystemRequestResponseTest.java index ac68ed78b..55cb416f4 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SystemRequestResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/SystemRequestResponseTest.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.SystemRequestResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.SystemRequestResponse} + */ public class SystemRequestResponseTest extends BaseRpcTests { @Override @@ -35,32 +40,35 @@ public class SystemRequestResponseTest extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests SystemRequestResponse msg = new SystemRequestResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); SystemRequestResponse cmd = new SystemRequestResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UnregisterAppInterfaceResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UnregisterAppInterfaceResponseTest.java index b844046cb..249f4fdd1 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UnregisterAppInterfaceResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UnregisterAppInterfaceResponseTest.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.UnregisterAppInterfaceResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.UnregisterAppInterfaceResponse} + */ public class UnregisterAppInterfaceResponseTest extends BaseRpcTests { @Override @@ -35,32 +40,35 @@ public class UnregisterAppInterfaceResponseTest extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests UnregisterAppInterfaceResponse msg = new UnregisterAppInterfaceResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); UnregisterAppInterfaceResponse cmd = new UnregisterAppInterfaceResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UnsubscribeButtonResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UnsubscribeButtonResponseTest.java index 181e2d99e..f3780656c 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UnsubscribeButtonResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UnsubscribeButtonResponseTest.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.UnsubscribeButtonResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.UnsubscribeButtonResponse} + */ public class UnsubscribeButtonResponseTest extends BaseRpcTests { @Override @@ -35,32 +40,35 @@ public class UnsubscribeButtonResponseTest extends BaseRpcTests { return new JSONObject(); } - public void testNull(){ + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests UnsubscribeButtonResponse msg = new UnsubscribeButtonResponse(); - assertNotNull("Null object creation failed.", msg); - + assertNotNull(Test.NOT_NULL, msg); testNullBase(msg); } - + + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); UnsubscribeButtonResponse cmd = new UnsubscribeButtonResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - } - catch (JSONException e) { + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { e.printStackTrace(); - } - - } - -} + } + } +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java index 95e162c95..6f0f53393 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UnsubscribeVehicleDataResponseTest.java @@ -9,79 +9,53 @@ import org.json.JSONObject; import com.smartdevicelink.marshal.JsonRPCMarshaller; import com.smartdevicelink.protocol.enums.FunctionID; import com.smartdevicelink.proxy.RPCMessage; +import com.smartdevicelink.proxy.rpc.SubscribeVehicleDataResponse; import com.smartdevicelink.proxy.rpc.UnsubscribeVehicleDataResponse; import com.smartdevicelink.proxy.rpc.VehicleDataResult; -import com.smartdevicelink.proxy.rpc.enums.VehicleDataResultCode; import com.smartdevicelink.proxy.rpc.enums.VehicleDataType; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.Validator; import com.smartdevicelink.test.json.rpc.JsonFileReader; -@SuppressWarnings("deprecation") +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.UnsubscribeVehicleDataResponse} + */ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { - //TODO: the corresponding library class does not include variables for the vehicle data type VEHICLEDATA_BATTVOLTAGE. intentional? - public static final VehicleDataResult KEY_SPEED = new VehicleDataResult(); - public static final VehicleDataResult KEY_RPM = new VehicleDataResult(); - public static final VehicleDataResult KEY_EXTERNAL_TEMPERATURE = new VehicleDataResult(); - public static final VehicleDataResult KEY_FUEL_LEVEL = new VehicleDataResult(); - public static final VehicleDataResult KEY_PRNDL = new VehicleDataResult(); - public static final VehicleDataResult KEY_TIRE_PRESSURE = new VehicleDataResult(); - public static final VehicleDataResult KEY_ENGINE_TORQUE = new VehicleDataResult(); - public static final VehicleDataResult KEY_ODOMETER = new VehicleDataResult(); - public static final VehicleDataResult KEY_GPS = new VehicleDataResult(); - public static final VehicleDataResult KEY_FUEL_LEVEL_STATE = new VehicleDataResult(); - public static final VehicleDataResult KEY_INSTANT_FUEL_CONSUMPTION = new VehicleDataResult(); - public static final VehicleDataResult KEY_BELT_STATUS = new VehicleDataResult(); - public static final VehicleDataResult KEY_BODY_INFORMATION = new VehicleDataResult(); - public static final VehicleDataResult KEY_DEVICE_STATUS = new VehicleDataResult(); - public static final VehicleDataResult KEY_DRIVER_BRAKING = new VehicleDataResult(); - public static final VehicleDataResult KEY_WIPER_STATUS = new VehicleDataResult(); - public static final VehicleDataResult KEY_HEAD_LAMP_STATUS = new VehicleDataResult(); - public static final VehicleDataResult KEY_ACC_PEDAL_POSITION = new VehicleDataResult(); - public static final VehicleDataResult KEY_STEERING_WHEEL_ANGLE = new VehicleDataResult(); - public static final VehicleDataResult KEY_E_CALL_INFO = new VehicleDataResult(); - public static final VehicleDataResult KEY_AIRBAG_STATUS = new VehicleDataResult(); - public static final VehicleDataResult KEY_EMERGENCY_EVENT = new VehicleDataResult(); - public static final VehicleDataResult KEY_CLUSTER_MODE_STATUS = new VehicleDataResult(); - public static final VehicleDataResult KEY_MY_KEY = new VehicleDataResult(); - - //this method makes setting up the VehicleDataResult objects easier. assumes VehicleDataResultCode.SUCCESS for all result codes - private VehicleDataResult populateResultObject (VehicleDataResult data, VehicleDataType type) { - data.setDataType(type); - data.setResultCode(VehicleDataResultCode.SUCCESS); - return data; - } + + // TODO : Test different result codes. @Override protected RPCMessage createMessage() { UnsubscribeVehicleDataResponse msg = new UnsubscribeVehicleDataResponse(); - msg.setSpeed( populateResultObject(KEY_SPEED, VehicleDataType.VEHICLEDATA_SPEED) ); - msg.setRpm( populateResultObject(KEY_RPM, VehicleDataType.VEHICLEDATA_RPM) ); - msg.setExternalTemperature( populateResultObject(KEY_EXTERNAL_TEMPERATURE, VehicleDataType.VEHICLEDATA_EXTERNTEMP) ); - msg.setFuelLevel( populateResultObject(KEY_FUEL_LEVEL, VehicleDataType.VEHICLEDATA_FUELLEVEL) ); - msg.setPrndl( populateResultObject(KEY_PRNDL, VehicleDataType.VEHICLEDATA_PRNDL) ); - msg.setTirePressure( populateResultObject(KEY_TIRE_PRESSURE, VehicleDataType.VEHICLEDATA_TIREPRESSURE) ); - msg.setEngineTorque( populateResultObject(KEY_ENGINE_TORQUE, VehicleDataType.VEHICLEDATA_ENGINETORQUE) ); - msg.setOdometer( populateResultObject(KEY_ODOMETER, VehicleDataType.VEHICLEDATA_ODOMETER) ); - msg.setGps( populateResultObject(KEY_GPS, VehicleDataType.VEHICLEDATA_GPS) ); - msg.setFuelLevel_State( populateResultObject(KEY_FUEL_LEVEL_STATE, VehicleDataType.VEHICLEDATA_FUELLEVEL_STATE) ); - msg.setInstantFuelConsumption( populateResultObject(KEY_INSTANT_FUEL_CONSUMPTION, VehicleDataType.VEHICLEDATA_FUELCONSUMPTION) ); - msg.setBeltStatus( populateResultObject(KEY_BELT_STATUS, VehicleDataType.VEHICLEDATA_BELTSTATUS) ); - msg.setBodyInformation( populateResultObject(KEY_BODY_INFORMATION, VehicleDataType.VEHICLEDATA_BODYINFO) ); - msg.setDeviceStatus( populateResultObject(KEY_DEVICE_STATUS, VehicleDataType.VEHICLEDATA_DEVICESTATUS) ); - msg.setDriverBraking( populateResultObject(KEY_DRIVER_BRAKING, VehicleDataType.VEHICLEDATA_BRAKING) ); - msg.setWiperStatus( populateResultObject(KEY_WIPER_STATUS, VehicleDataType.VEHICLEDATA_WIPERSTATUS) ); - msg.setHeadLampStatus( populateResultObject(KEY_HEAD_LAMP_STATUS, VehicleDataType.VEHICLEDATA_HEADLAMPSTATUS) ); - msg.setAccPedalPosition( populateResultObject(KEY_ACC_PEDAL_POSITION, VehicleDataType.VEHICLEDATA_ACCPEDAL) ); - msg.setSteeringWheelAngle( populateResultObject(KEY_STEERING_WHEEL_ANGLE, VehicleDataType.VEHICLEDATA_STEERINGWHEEL) ); - msg.setECallInfo( populateResultObject(KEY_E_CALL_INFO, VehicleDataType.VEHICLEDATA_ECALLINFO) ); - msg.setAirbagStatus( populateResultObject(KEY_AIRBAG_STATUS, VehicleDataType.VEHICLEDATA_AIRBAGSTATUS) ); - msg.setEmergencyEvent( populateResultObject(KEY_EMERGENCY_EVENT, VehicleDataType.VEHICLEDATA_EMERGENCYEVENT) ); - msg.setClusterModeStatus( populateResultObject(KEY_CLUSTER_MODE_STATUS, VehicleDataType.VEHICLEDATA_CLUSTERMODESTATUS) ); - msg.setMyKey( populateResultObject(KEY_MY_KEY, VehicleDataType.VEHICLEDATA_MYKEY) ); - + msg.setSpeed(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_SPEED.ordinal())); + msg.setRpm(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_RPM.ordinal())); + msg.setExternalTemperature(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_EXTERNTEMP.ordinal())); + msg.setFuelLevel(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELLEVEL.ordinal())); + msg.setPrndl(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_PRNDL.ordinal())); + msg.setTirePressure(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TIREPRESSURE.ordinal())); + msg.setEngineTorque(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ENGINETORQUE.ordinal())); + msg.setOdometer(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ODOMETER.ordinal())); + msg.setGps(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_GPS.ordinal())); + msg.setFuelLevelState(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELLEVEL_STATE.ordinal())); + msg.setInstantFuelConsumption(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELCONSUMPTION.ordinal())); + msg.setBeltStatus(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_BELTSTATUS.ordinal())); + msg.setBodyInformation(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_BODYINFO.ordinal())); + msg.setDeviceStatus(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_DEVICESTATUS.ordinal())); + msg.setDriverBraking(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_BRAKING.ordinal())); + msg.setWiperStatus(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WIPERSTATUS.ordinal())); + msg.setHeadLampStatus(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HEADLAMPSTATUS.ordinal())); + msg.setAccPedalPosition(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ACCPEDAL.ordinal())); + msg.setSteeringWheelAngle(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_STEERINGWHEEL.ordinal())); + msg.setECallInfo(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ECALLINFO.ordinal())); + msg.setAirbagStatus(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_AIRBAGSTATUS.ordinal())); + msg.setEmergencyEvent(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_EMERGENCYEVENT.ordinal())); + msg.setClusterModeStatus(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_CLUSTERMODESTATUS.ordinal())); + msg.setMyKey(Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_MYKEY.ordinal())); + return msg; } @@ -98,346 +72,248 @@ public class UnsubscribeVehicleDataResponseTest extends BaseRpcTests { @Override protected JSONObject getExpectedParameters(int sdlVersion) { JSONObject result = new JSONObject(); - //TODO: correct? + try { - result.put(UnsubscribeVehicleDataResponse.KEY_SPEED, KEY_SPEED.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_RPM, KEY_RPM.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_EXTERNAL_TEMPERATURE, KEY_EXTERNAL_TEMPERATURE.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_FUEL_LEVEL, KEY_FUEL_LEVEL.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_PRNDL, KEY_PRNDL.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_TIRE_PRESSURE, KEY_TIRE_PRESSURE.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_ENGINE_TORQUE, KEY_ENGINE_TORQUE.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_ODOMETER, KEY_ODOMETER.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_GPS, KEY_GPS.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_FUEL_LEVEL_STATE, KEY_FUEL_LEVEL_STATE.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_INSTANT_FUEL_CONSUMPTION, KEY_INSTANT_FUEL_CONSUMPTION.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_BELT_STATUS, KEY_BELT_STATUS.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_BODY_INFORMATION, KEY_BODY_INFORMATION.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_DEVICE_STATUS, KEY_DEVICE_STATUS.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_DRIVER_BRAKING, KEY_DRIVER_BRAKING.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_WIPER_STATUS, KEY_WIPER_STATUS.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_HEAD_LAMP_STATUS, KEY_HEAD_LAMP_STATUS.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_ACC_PEDAL_POSITION, KEY_ACC_PEDAL_POSITION.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_STEERING_WHEEL_ANGLE, KEY_STEERING_WHEEL_ANGLE.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_E_CALL_INFO, KEY_E_CALL_INFO.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_AIRBAG_STATUS, KEY_AIRBAG_STATUS.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_EMERGENCY_EVENT, KEY_EMERGENCY_EVENT.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_CLUSTER_MODE_STATUS, KEY_CLUSTER_MODE_STATUS.serializeJSON()); - result.put(UnsubscribeVehicleDataResponse.KEY_MY_KEY, KEY_MY_KEY.serializeJSON()); + + // Note: If the key values stored in SubscribeVehicleDataResponse + // were to be in a list then this could be easily looped through + // instead of individually set. + + result.put(SubscribeVehicleDataResponse.KEY_SPEED, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_SPEED.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_RPM, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_RPM.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_EXTERNAL_TEMPERATURE, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_EXTERNTEMP.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_FUEL_LEVEL, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELLEVEL.ordinal())); + result.put(SubscribeVehicleDataResponse.KEY_PRNDL, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_PRNDL.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_TIRE_PRESSURE, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_TIREPRESSURE.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_ENGINE_TORQUE, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ENGINETORQUE.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_ODOMETER, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ODOMETER.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_GPS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_GPS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_FUEL_LEVEL_STATE, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELLEVEL_STATE.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_INSTANT_FUEL_CONSUMPTION, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_FUELCONSUMPTION.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_BELT_STATUS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_BELTSTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_BODY_INFORMATION, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_BODYINFO.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_DEVICE_STATUS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_DEVICESTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_DRIVER_BRAKING, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_BRAKING.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_WIPER_STATUS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_WIPERSTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_HEAD_LAMP_STATUS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_HEADLAMPSTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_ACC_PEDAL_POSITION, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ACCPEDAL.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_STEERING_WHEEL_ANGLE, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_STEERINGWHEEL.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_E_CALL_INFO, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_ECALLINFO.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_AIRBAG_STATUS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_AIRBAGSTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_EMERGENCY_EVENT, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_EMERGENCYEVENT.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_CLUSTER_MODE_STATUS, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_CLUSTERMODESTATUS.ordinal()).serializeJSON()); + result.put(SubscribeVehicleDataResponse.KEY_MY_KEY, Test.GENERAL_VEHICLEDATARESULT_LIST.get(VehicleDataType.VEHICLEDATA_MYKEY.ordinal()).serializeJSON()); } catch (JSONException e) { - // do nothing + fail(Test.JSON_FAIL); } return result; } - /* The VehicleDataResult class contains the following retrievable variables: - * (VehicleDataType) dataType Enum value being tested - * (VehicleDataResultCode) resultCode Enum value being ignored - * - * Should we test the result code as follows? Are we to assume success? - * - * assertTrue("Result code didn't match expected value.", data.getResultCode().equals(VehicleDataResultCode.SUCCESS)); + /** + * Tests the expected values of the RPC message. */ - - public void testGps(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getGps(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_GPS)); - } - - public void testOdometer(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getOdometer(); + public void testRpcValues () { + // Test Values + VehicleDataResult testGps = ( (UnsubscribeVehicleDataResponse) msg ).getGps(); + VehicleDataResult testOdometer = ( (UnsubscribeVehicleDataResponse) msg ).getOdometer(); + VehicleDataResult testTirePressure = ( (UnsubscribeVehicleDataResponse) msg ).getTirePressure(); + VehicleDataResult testBeltStatus = ( (UnsubscribeVehicleDataResponse) msg ).getBeltStatus(); + VehicleDataResult testBodyInfo = ( (UnsubscribeVehicleDataResponse) msg ).getBodyInformation(); + VehicleDataResult testDeviceStatus = ( (UnsubscribeVehicleDataResponse) msg ).getDeviceStatus(); + VehicleDataResult testHeadLampStatus = ( (UnsubscribeVehicleDataResponse) msg ).getHeadLampStatus(); + VehicleDataResult testECallInfo = ( (UnsubscribeVehicleDataResponse) msg ).getECallInfo(); + VehicleDataResult testAirbagStatus = ( (UnsubscribeVehicleDataResponse) msg ).getAirbagStatus(); + VehicleDataResult testEmergencyEvent = ( (UnsubscribeVehicleDataResponse) msg ).getEmergencyEvent(); + VehicleDataResult testClusterMode = ( (UnsubscribeVehicleDataResponse) msg ).getClusterModeStatus(); + VehicleDataResult testMyKey = ( (UnsubscribeVehicleDataResponse) msg ).getMyKey(); + VehicleDataResult testSpeed = ( (UnsubscribeVehicleDataResponse) msg ).getSpeed(); + VehicleDataResult testRpm = ( (UnsubscribeVehicleDataResponse) msg ).getRpm(); + VehicleDataResult testFuelLevel = ( (UnsubscribeVehicleDataResponse) msg ).getFuelLevel(); + VehicleDataResult testConsumption = ( (UnsubscribeVehicleDataResponse) msg ).getInstantFuelConsumption(); + VehicleDataResult testExternalTemp = ( (UnsubscribeVehicleDataResponse) msg ).getExternalTemperature(); + VehicleDataResult testEngineTorque = ( (UnsubscribeVehicleDataResponse) msg ).getEngineTorque(); + VehicleDataResult testAccPedal = ( (UnsubscribeVehicleDataResponse) msg ).getAccPedalPosition(); + VehicleDataResult testSteeringWheel = ( (UnsubscribeVehicleDataResponse) msg ).getSteeringWheelAngle(); + VehicleDataResult testFuelLevelState = ( (UnsubscribeVehicleDataResponse) msg ).getFuelLevelState(); + VehicleDataResult testPrndl = ( (UnsubscribeVehicleDataResponse) msg ).getPrndl(); + VehicleDataResult testBraking = ( (UnsubscribeVehicleDataResponse) msg ).getDriverBraking(); + VehicleDataResult testWiperStatus = ( (UnsubscribeVehicleDataResponse) msg ).getWiperStatus(); - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_ODOMETER)); - } - - public void testTireStatus(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getTirePressure(); + // Valid Tests + assertTrue(Test.TRUE, testGps.getDataType().equals(VehicleDataType.VEHICLEDATA_GPS)); + assertTrue(Test.TRUE, testOdometer.getDataType().equals(VehicleDataType.VEHICLEDATA_ODOMETER)); + assertTrue(Test.TRUE, testTirePressure.getDataType().equals(VehicleDataType.VEHICLEDATA_TIREPRESSURE)); + assertTrue(Test.TRUE, testBeltStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_BELTSTATUS)); + assertTrue(Test.TRUE, testBodyInfo.getDataType().equals(VehicleDataType.VEHICLEDATA_BODYINFO)); + assertTrue(Test.TRUE, testDeviceStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_DEVICESTATUS)); + assertTrue(Test.TRUE, testHeadLampStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_HEADLAMPSTATUS)); + assertTrue(Test.TRUE, testECallInfo.getDataType().equals(VehicleDataType.VEHICLEDATA_ECALLINFO)); + assertTrue(Test.TRUE, testAirbagStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_AIRBAGSTATUS)); + assertTrue(Test.TRUE, testEmergencyEvent.getDataType().equals(VehicleDataType.VEHICLEDATA_EMERGENCYEVENT)); + assertTrue(Test.TRUE, testClusterMode.getDataType().equals(VehicleDataType.VEHICLEDATA_CLUSTERMODESTATUS)); + assertTrue(Test.TRUE, testMyKey.getDataType().equals(VehicleDataType.VEHICLEDATA_MYKEY)); + assertTrue(Test.TRUE, testSpeed.getDataType().equals(VehicleDataType.VEHICLEDATA_SPEED)); + assertTrue(Test.TRUE, testRpm.getDataType().equals(VehicleDataType.VEHICLEDATA_RPM)); + assertTrue(Test.TRUE, testFuelLevel.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELLEVEL)); + assertTrue(Test.TRUE, testConsumption.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELCONSUMPTION)); + assertTrue(Test.TRUE, testExternalTemp.getDataType().equals(VehicleDataType.VEHICLEDATA_EXTERNTEMP)); + assertTrue(Test.TRUE, testEngineTorque.getDataType().equals(VehicleDataType.VEHICLEDATA_ENGINETORQUE)); + assertTrue(Test.TRUE, testAccPedal.getDataType().equals(VehicleDataType.VEHICLEDATA_ACCPEDAL)); + assertTrue(Test.TRUE, testSteeringWheel.getDataType().equals(VehicleDataType.VEHICLEDATA_STEERINGWHEEL)); + assertTrue(Test.TRUE, testFuelLevelState.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELLEVEL_STATE)); + assertTrue(Test.TRUE, testPrndl.getDataType().equals(VehicleDataType.VEHICLEDATA_PRNDL)); + assertTrue(Test.TRUE, testBraking.getDataType().equals(VehicleDataType.VEHICLEDATA_BRAKING)); + assertTrue(Test.TRUE, testWiperStatus.getDataType().equals(VehicleDataType.VEHICLEDATA_WIPERSTATUS)); + + // Invalid/Null Tests + UnsubscribeVehicleDataResponse msg = new UnsubscribeVehicleDataResponse(); + assertNotNull("Null object creation failed.", msg); + testNullBase(msg); - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_TIREPRESSURE)); - } - - public void testBeltStatus(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getBeltStatus(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_BELTSTATUS)); + assertNull(Test.NULL, msg.getAccPedalPosition()); + assertNull(Test.NULL, msg.getAirbagStatus()); + assertNull(Test.NULL, msg.getBeltStatus()); + assertNull(Test.NULL, msg.getDriverBraking()); + assertNull(Test.NULL, msg.getFuelLevel()); + assertNull(Test.NULL, msg.getTirePressure()); + assertNull(Test.NULL, msg.getWiperStatus()); + assertNull(Test.NULL, msg.getGps()); + assertNull(Test.NULL, msg.getSpeed()); + assertNull(Test.NULL, msg.getRpm()); + assertNull(Test.NULL, msg.getFuelLevelState()); + assertNull(Test.NULL, msg.getInstantFuelConsumption()); + assertNull(Test.NULL, msg.getExternalTemperature()); + assertNull(Test.NULL, msg.getPrndl()); + assertNull(Test.NULL, msg.getOdometer()); + assertNull(Test.NULL, msg.getBodyInformation()); + assertNull(Test.NULL, msg.getDeviceStatus()); + assertNull(Test.NULL, msg.getHeadLampStatus()); + assertNull(Test.NULL, msg.getEngineTorque()); + assertNull(Test.NULL, msg.getSteeringWheelAngle()); + assertNull(Test.NULL, msg.getECallInfo()); + assertNull(Test.NULL, msg.getEmergencyEvent()); + assertNull(Test.NULL, msg.getClusterModeStatus()); + assertNull(Test.NULL, msg.getMyKey()); } - public void testBodyInformation(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getBodyInformation(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_BODYINFO)); - } - - public void testDeviceStatus(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getDeviceStatus(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_DEVICESTATUS)); - } - - public void testHeadLampStatus(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getHeadLampStatus(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_HEADLAMPSTATUS)); - } - - public void testECallInfo(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getECallInfo(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_ECALLINFO)); - } - - public void testAirbagStatus(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getAirbagStatus(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_AIRBAGSTATUS)); - } - - public void testEmergencyEvent(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getEmergencyEvent(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_EMERGENCYEVENT)); - } - - public void testClusterModeStatus(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getClusterModeStatus(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_CLUSTERMODESTATUS)); - } - - public void testMyKey(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getMyKey(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_MYKEY)); - } - - public void testSpeed(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getSpeed(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_SPEED)); - } - - public void testRpm(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getRpm(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_RPM)); - } - - public void testFuelLevel(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getFuelLevel(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELLEVEL)); - } - - public void testInstantFuelConsumption(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getInstantFuelConsumption(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELCONSUMPTION)); - } - - public void testExternalTemperature(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getExternalTemperature(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_EXTERNTEMP)); - } - - public void testEngineTorque(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getEngineTorque(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_ENGINETORQUE)); - } - - public void testAccPedalPosition(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getAccPedalPosition(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_ACCPEDAL)); - } - - public void testSteeringWheelAngle(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getSteeringWheelAngle(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_STEERINGWHEEL)); - } - - public void testFuelLevelState(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getFuelLevel_State(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_FUELLEVEL_STATE)); - } - - public void testPRNDL(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getPrndl(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_PRNDL)); - } - - public void testDriverBraking(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getDriverBraking(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_BRAKING)); - } - - public void testWiperStatus(){ - VehicleDataResult data = ( (UnsubscribeVehicleDataResponse) msg ).getWiperStatus(); - - assertTrue("Returned data was not of expected type.", data.getDataType().equals(VehicleDataType.VEHICLEDATA_WIPERSTATUS)); - } - - public void testNull() { - UnsubscribeVehicleDataResponse msg = new UnsubscribeVehicleDataResponse(); - assertNotNull("Null object creation failed.", msg); - - testNullBase(msg); - assertNull("Accel pedal vehicle data wasn't set, but getter method returned an object.", msg.getAccPedalPosition()); - assertNull("Airbag vehicle data wasn't set, but getter method returned an object.", msg.getAirbagStatus()); - assertNull("Belt vehicle data wasn't set, but getter method returned an object.", msg.getBeltStatus()); - assertNull("Driver braking vehicle data wasn't set, but getter method returned an object.", msg.getDriverBraking()); - assertNull("Fuel level vehicle data wasn't set, but getter method returned an object.", msg.getFuelLevel()); - assertNull("Tire pressure vehicle data wasn't set, but getter method returned an object.", msg.getTirePressure()); - assertNull("Wiper vehicle data wasn't set, but getter method returned an object.", msg.getWiperStatus()); - assertNull("Gps data wasn't set, but getter method returned an object.", msg.getGps()); - assertNull("Speed data wasn't set, but getter method returned an object.", msg.getSpeed()); - assertNull("Rpm data wasn't set, but getter method returned an object.", msg.getRpm()); - assertNull("Fuel level state data wasn't set, but getter method returned an object.", msg.getFuelLevel_State()); - assertNull("Fuel consumption data wasn't set, but getter method returned an object.", msg.getInstantFuelConsumption()); - assertNull("External temperature data wasn't set, but getter method returned an object.", msg.getExternalTemperature()); - assertNull("PRNDL data wasn't set, but getter method returned an object.", msg.getPrndl()); - assertNull("Odometer data wasn't set, but getter method returned an object.", msg.getOdometer()); - assertNull("Body information data wasn't set, but getter method returned an object.", msg.getBodyInformation()); - assertNull("Device status data wasn't set, but getter method returned an object.", msg.getDeviceStatus()); - assertNull("Head lamp status data wasn't set, but getter method returned an object.", msg.getHeadLampStatus()); - assertNull("Engine torque data wasn't set, but getter method returned an object.", msg.getEngineTorque()); - assertNull("Steering wheel angle data wasn't set, but getter method returned an object.", msg.getSteeringWheelAngle()); - assertNull("ECall info data wasn't set, but getter method returned an object.", msg.getECallInfo()); - assertNull("Emergency event data wasn't set, but getter method returned an object.", msg.getEmergencyEvent()); - assertNull("Cluster mode data wasn't set, but getter method returned an object.", msg.getClusterModeStatus()); - assertNull("My key data wasn't set, but getter method returned an object.", msg.getMyKey()); - } - + /** + * Tests a valid JSON construction of this RPC message. + */ public void testJsonConstructor () { JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); + assertNotNull(Test.NOT_NULL, commandJson); try { Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); UnsubscribeVehicleDataResponse cmd = new UnsubscribeVehicleDataResponse(hash); JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); + assertNotNull(Test.NOT_NULL, body); - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); JSONObject parameters = JsonUtils.readJsonObjectFromJsonObject(body, RPCMessage.KEY_PARAMETERS); JSONObject speed = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_SPEED); VehicleDataResult referenceSpeed = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(speed)); - assertTrue("Speed doesn't match expected speed", Validator.validateVehicleDataResult(referenceSpeed, cmd.getSpeed())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceSpeed, cmd.getSpeed())); JSONObject rpm = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_RPM); VehicleDataResult referenceRpm = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(rpm)); - assertTrue("RPM doesn't match expected RPM", Validator.validateVehicleDataResult(referenceRpm, cmd.getRpm())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceRpm, cmd.getRpm())); JSONObject fuelLevel = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_FUEL_LEVEL); VehicleDataResult referenceFuelLevel = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(fuelLevel)); - assertTrue("Fuel level doesn't match expected level", Validator.validateVehicleDataResult(referenceFuelLevel, cmd.getFuelLevel())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceFuelLevel, cmd.getFuelLevel())); JSONObject externalTemperature = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_EXTERNAL_TEMPERATURE); VehicleDataResult referenceExternalTemperature = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(externalTemperature)); - assertTrue("External temperature doesn't match expected temperature", - Validator.validateVehicleDataResult(referenceExternalTemperature, cmd.getExternalTemperature())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceExternalTemperature, cmd.getExternalTemperature())); JSONObject prndl = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_PRNDL); VehicleDataResult referencePrndl = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(prndl)); - assertTrue("PRNDL doesn't match expected PRNDL", Validator.validateVehicleDataResult(referencePrndl, cmd.getPrndl())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referencePrndl, cmd.getPrndl())); JSONObject tirePressure = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_TIRE_PRESSURE); VehicleDataResult referenceTirePressure = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(tirePressure)); - assertTrue("Tire pressure doesn't match expected pressure", Validator.validateVehicleDataResult(referenceTirePressure, cmd.getTirePressure())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceTirePressure, cmd.getTirePressure())); JSONObject engineTorque = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_ENGINE_TORQUE); VehicleDataResult referenceEngineTorque = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(engineTorque)); - assertTrue("Engine torque doesn't match expected torque", Validator.validateVehicleDataResult(referenceEngineTorque, cmd.getEngineTorque())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceEngineTorque, cmd.getEngineTorque())); JSONObject odometer = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_ODOMETER); VehicleDataResult referenceOdometer = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(odometer)); - assertTrue("Odometer doesn't match expected odometer", Validator.validateVehicleDataResult(referenceOdometer, cmd.getOdometer())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceOdometer, cmd.getOdometer())); JSONObject gps = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_GPS); VehicleDataResult referenceGps = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(gps)); - assertTrue("GPS doesn't match expected GPS", Validator.validateVehicleDataResult(referenceGps, cmd.getGps())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceGps, cmd.getGps())); JSONObject fuelLevelState = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_FUEL_LEVEL_STATE); VehicleDataResult referenceFuelLevelState = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(fuelLevelState)); - assertTrue("Fuel level state doesn't match expected state", Validator.validateVehicleDataResult(referenceFuelLevelState, cmd.getFuelLevel_State())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceFuelLevelState, cmd.getFuelLevelState())); JSONObject fuelConsumption = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_INSTANT_FUEL_CONSUMPTION); VehicleDataResult referenceFuelConsumption = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(fuelConsumption)); - assertTrue("Fuel consumption doesn't match expected consumption", - Validator.validateVehicleDataResult(referenceFuelConsumption, cmd.getInstantFuelConsumption())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceFuelConsumption, cmd.getInstantFuelConsumption())); JSONObject beltStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_BELT_STATUS); VehicleDataResult referenceBeltStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(beltStatus)); - assertTrue("Belt status doesn't match expected status", Validator.validateVehicleDataResult(referenceBeltStatus, cmd.getBeltStatus())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceBeltStatus, cmd.getBeltStatus())); JSONObject bodyInformation = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_BODY_INFORMATION); VehicleDataResult referenceBodyInformation = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(bodyInformation)); - assertTrue("Body information doesn't match expected information", - Validator.validateVehicleDataResult(referenceBodyInformation, cmd.getBodyInformation())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceBodyInformation, cmd.getBodyInformation())); JSONObject deviceStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_DEVICE_STATUS); VehicleDataResult referenceDeviceStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(deviceStatus)); - assertTrue("Device status doesn't match expected status", Validator.validateVehicleDataResult(referenceDeviceStatus, cmd.getDeviceStatus())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceDeviceStatus, cmd.getDeviceStatus())); JSONObject driverBraking = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_DRIVER_BRAKING); VehicleDataResult referenceDriverBraking = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(driverBraking)); - assertTrue("Driver braking doesn't match expected braking", Validator.validateVehicleDataResult(referenceDriverBraking, cmd.getDriverBraking())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceDriverBraking, cmd.getDriverBraking())); JSONObject wiperStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_WIPER_STATUS); VehicleDataResult referenceWiperStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(wiperStatus)); - assertTrue("Wiper status doesn't match expected status", Validator.validateVehicleDataResult(referenceWiperStatus, cmd.getWiperStatus())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceWiperStatus, cmd.getWiperStatus())); JSONObject headLampStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_HEAD_LAMP_STATUS); VehicleDataResult referenceHeadLampStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(headLampStatus)); - assertTrue("Head lamp status doesn't match expected status", Validator.validateVehicleDataResult(referenceHeadLampStatus, cmd.getHeadLampStatus())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceHeadLampStatus, cmd.getHeadLampStatus())); JSONObject accPedalPosition = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_ACC_PEDAL_POSITION); VehicleDataResult referenceAccPedalPosition = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(accPedalPosition)); - assertTrue("Acc pedal position doesn't match expected position", - Validator.validateVehicleDataResult(referenceAccPedalPosition, cmd.getAccPedalPosition())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceAccPedalPosition, cmd.getAccPedalPosition())); JSONObject steeringWheelAngle = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_STEERING_WHEEL_ANGLE); VehicleDataResult referenceSteeringWheelAngle = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(steeringWheelAngle)); - assertTrue("Steering wheel angle doesn't match expected angle", - Validator.validateVehicleDataResult(referenceSteeringWheelAngle, cmd.getSteeringWheelAngle())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceSteeringWheelAngle, cmd.getSteeringWheelAngle())); JSONObject eCallInfo = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_E_CALL_INFO); VehicleDataResult referenceECallInfo = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(eCallInfo)); - assertTrue("Emergency call info doesn't match expected info", Validator.validateVehicleDataResult(referenceECallInfo, cmd.getECallInfo())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceECallInfo, cmd.getECallInfo())); JSONObject airbagStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_AIRBAG_STATUS); VehicleDataResult referenceAirbagStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(airbagStatus)); - assertTrue("Airbag status doesn't match expected status", Validator.validateVehicleDataResult(referenceAirbagStatus, cmd.getAirbagStatus())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceAirbagStatus, cmd.getAirbagStatus())); JSONObject emergencyEvent = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_EMERGENCY_EVENT); VehicleDataResult referenceEmergencyEvent = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(emergencyEvent)); - assertTrue("Emergency event doesn't match expected event", Validator.validateVehicleDataResult(referenceEmergencyEvent, cmd.getEmergencyEvent())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceEmergencyEvent, cmd.getEmergencyEvent())); JSONObject clusterModeStatus = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_CLUSTER_MODE_STATUS); VehicleDataResult referenceClusterModeStatus = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(clusterModeStatus)); - assertTrue("Cluster mode status doesn't match expected status", - Validator.validateVehicleDataResult(referenceClusterModeStatus, cmd.getClusterModeStatus())); + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceClusterModeStatus, cmd.getClusterModeStatus())); JSONObject myKey = JsonUtils.readJsonObjectFromJsonObject(parameters, UnsubscribeVehicleDataResponse.KEY_MY_KEY); VehicleDataResult referenceMyKey = new VehicleDataResult(JsonRPCMarshaller.deserializeJSONObject(myKey)); - assertTrue("My key doesn't match expected key", Validator.validateVehicleDataResult(referenceMyKey, cmd.getMyKey())); - } - catch (JSONException e) { + assertTrue(Test.TRUE, Validator.validateVehicleDataResult(referenceMyKey, cmd.getMyKey())); + } catch (JSONException e) { e.printStackTrace(); - } - + } } - -} +}
\ No newline at end of file diff --git a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UpdateTurnListResponseTests.java b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UpdateTurnListResponseTests.java index b9fe65889..c08247bca 100644 --- a/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UpdateTurnListResponseTests.java +++ b/sdl_android_tests/src/com/smartdevicelink/test/rpc/responses/UpdateTurnListResponseTests.java @@ -11,8 +11,13 @@ import com.smartdevicelink.proxy.RPCMessage; import com.smartdevicelink.proxy.rpc.UpdateTurnListResponse; import com.smartdevicelink.test.BaseRpcTests; import com.smartdevicelink.test.JsonUtils; +import com.smartdevicelink.test.Test; import com.smartdevicelink.test.json.rpc.JsonFileReader; +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.rpc.UpdateTurnListResponse} + */ public class UpdateTurnListResponseTests extends BaseRpcTests { @Override @@ -35,29 +40,34 @@ public class UpdateTurnListResponseTests extends BaseRpcTests { return new JSONObject(); } - public void testNull() { + /** + * Tests the expected values of the RPC message. + */ + public void testRpcValues () { + // Invalid/Null Tests UpdateTurnListResponse msg = new UpdateTurnListResponse(); - assertNotNull("Null object creation failed.", msg); - - testNullBase(msg); + assertNotNull(Test.NOT_NULL, msg); + testNullBase(msg); } + /** + * Tests the expected values of the RPC message. + */ public void testJsonConstructor () { - JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); - assertNotNull("Command object is null", commandJson); - - try { - Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); - UpdateTurnListResponse cmd = new UpdateTurnListResponse(hash); - JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); - assertNotNull("Command type doesn't match expected message type", body); - - // test everything in the body - assertEquals("Command name doesn't match input name", JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); - assertEquals("Correlation ID doesn't match input ID", JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); - - } catch (JSONException e) { - e.printStackTrace(); - } + JSONObject commandJson = JsonFileReader.readId(getCommandType(), getMessageType()); + assertNotNull(Test.NOT_NULL, commandJson); + + try { + Hashtable<String, Object> hash = JsonRPCMarshaller.deserializeJSONObject(commandJson); + UpdateTurnListResponse cmd = new UpdateTurnListResponse(hash); + JSONObject body = JsonUtils.readJsonObjectFromJsonObject(commandJson, getMessageType()); + assertNotNull(Test.NOT_NULL, body); + + // Test everything in the json body. + assertEquals(Test.MATCH, JsonUtils.readStringFromJsonObject(body, RPCMessage.KEY_FUNCTION_NAME), cmd.getFunctionName()); + assertEquals(Test.MATCH, JsonUtils.readIntegerFromJsonObject(body, RPCMessage.KEY_CORRELATION_ID), cmd.getCorrelationID()); + } catch (JSONException e) { + e.printStackTrace(); + } } }
\ No newline at end of file |