diff options
author | Julian Kast <Julian.kast@livio.io> | 2020-03-03 13:22:42 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-03 13:22:42 -0500 |
commit | 5349b84f326b531129caa4e098bd51baa6534ebf (patch) | |
tree | 4050e0ebc65e945da97e43aa4b7e2ec1e32de203 /android/sdl_android | |
parent | 9b43ce1a26d49260fc1a2ac6b9665103e9aeaf0b (diff) | |
parent | 191a781b456d443870773fb5776d69f1e1abcf16 (diff) | |
download | sdl_android-5349b84f326b531129caa4e098bd51baa6534ebf.tar.gz |
Merge pull request #1294 from smartdevicelink/feature/add_missing_enums
Add missing enums
Diffstat (limited to 'android/sdl_android')
8 files changed, 549 insertions, 0 deletions
diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/RpcConverterTest.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/RpcConverterTest.java index 22e2cba2f..34b3f71aa 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/RpcConverterTest.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/managers/lifecycle/RpcConverterTest.java @@ -25,6 +25,7 @@ public class RpcConverterTest extends AndroidTestCase2 { FunctionID[] functionIDs = FunctionID.values(); for(FunctionID functionID : functionIDs) { switch (functionID){ + case RESERVED: case SYNC_P_DATA: case ON_SYNC_P_DATA: case ENCODED_SYNC_P_DATA: @@ -54,6 +55,7 @@ public class RpcConverterTest extends AndroidTestCase2 { rpcClassName.append(RPC_PACKAGE); switch (functionID) { + case RESERVED: case SYNC_P_DATA: case ON_SYNC_P_DATA: case ENCODED_SYNC_P_DATA: @@ -91,6 +93,7 @@ public class RpcConverterTest extends AndroidTestCase2 { for(FunctionID functionID : functionIDs){ switch (functionID){ + case RESERVED: case SYNC_P_DATA: case ON_SYNC_P_DATA: case ENCODED_SYNC_P_DATA: diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppInterfaceUnregisteredReasonTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppInterfaceUnregisteredReasonTests.java index cdc7375df..cc59924d4 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppInterfaceUnregisteredReasonTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/AppInterfaceUnregisteredReasonTests.java @@ -42,6 +42,8 @@ public class AppInterfaceUnregisteredReasonTests extends TestCase { AppInterfaceUnregisteredReason enumAppAuthorized = AppInterfaceUnregisteredReason.valueForString(example); example = "PROTOCOL_VIOLATION"; AppInterfaceUnregisteredReason enumProtocolViolation = AppInterfaceUnregisteredReason.valueForString(example); + example = "UNSUPPORTED_HMI_RESOURCE"; + AppInterfaceUnregisteredReason enumUnsupportedHMIResource = AppInterfaceUnregisteredReason.valueForString(example); assertNotNull("USER_EXIT returned null", enumUserExit); assertNotNull("IGNITION_OFF returned null", enumIgnitionOff); @@ -55,6 +57,7 @@ public class AppInterfaceUnregisteredReasonTests extends TestCase { assertNotNull("FACTORY_DEFAULTS returned null", enumFactoryDefaults); assertNotNull("APP_UNAUTHORIZED returned null", enumAppAuthorized); assertNotNull("PROTOCOL_VIOLATION returned null", enumProtocolViolation); + assertNotNull("UNSUPPORTED_HMI_RESOURCE returned null", enumUnsupportedHMIResource); } /** @@ -104,6 +107,7 @@ public class AppInterfaceUnregisteredReasonTests extends TestCase { enumTestList.add(AppInterfaceUnregisteredReason.FACTORY_DEFAULTS); enumTestList.add(AppInterfaceUnregisteredReason.APP_UNAUTHORIZED); enumTestList.add(AppInterfaceUnregisteredReason.PROTOCOL_VIOLATION); + enumTestList.add(AppInterfaceUnregisteredReason.UNSUPPORTED_HMI_RESOURCE); assertTrue("Enum value list does not match enum class list", enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MaintenanceModeStatusTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MaintenanceModeStatusTests.java new file mode 100644 index 000000000..9254cd2b2 --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MaintenanceModeStatusTests.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2020 Livio, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Livio Inc. nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package com.smartdevicelink.test.rpc.enums; + +import com.smartdevicelink.proxy.rpc.enums.MaintenanceModeStatus; + +import junit.framework.TestCase; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.proxy.rpc.enums.MaintenanceModeStatus} + */ +public class MaintenanceModeStatusTests extends TestCase { + + /** + * Verifies that the enum values are not null upon valid assignment. + */ + public void testValidEnums () { + String example = "NORMAL"; + MaintenanceModeStatus enumNormal = MaintenanceModeStatus.valueForString(example); + example = "NEAR"; + MaintenanceModeStatus enumNear = MaintenanceModeStatus.valueForString(example); + example = "ACTIVE"; + MaintenanceModeStatus enumActive = MaintenanceModeStatus.valueForString(example); + example = "FEATURE_NOT_PRESENT"; + MaintenanceModeStatus enumFeatureNotPResent = MaintenanceModeStatus.valueForString(example); + + assertNotNull("NORMAL returned null", enumNormal); + assertNotNull("NEAR returned null", enumNear); + assertNotNull("ACTIVE returned null", enumActive); + assertNotNull("FEATURE_NOT_PRESENT returned null", enumFeatureNotPResent); + } + + /** + * Verifies that an invalid assignment is null. + */ + public void testInvalidEnum () { + String example = "normAL"; + try { + MaintenanceModeStatus temp = MaintenanceModeStatus.valueForString(example); + assertNull("Result of valueForString should be null.", temp); + } + catch (IllegalArgumentException exception) { + fail("Invalid enum throws IllegalArgumentException."); + } + } + + /** + * Verifies that a null assignment is invalid. + */ + public void testNullEnum () { + String example = null; + try { + MaintenanceModeStatus temp = MaintenanceModeStatus.valueForString(example); + assertNull("Result of valueForString should be null.", temp); + } + catch (NullPointerException exception) { + fail("Null string throws NullPointerException."); + } + } + + /** + * Verifies the possible enum values of MaintenanceModeStatus. + */ + public void testListEnum() { + List<MaintenanceModeStatus> enumValueList = Arrays.asList(MaintenanceModeStatus.values()); + + List<MaintenanceModeStatus> enumTestList = new ArrayList<>(); + enumTestList.add(MaintenanceModeStatus.NORMAL); + enumTestList.add(MaintenanceModeStatus.NEAR); + enumTestList.add(MaintenanceModeStatus.ACTIVE); + enumTestList.add(MaintenanceModeStatus.FEATURE_NOT_PRESENT); + + assertTrue("Enum value list does not match enum class list", + enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); + } +}
\ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MessageTypeTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MessageTypeTests.java new file mode 100644 index 000000000..354948cdf --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/MessageTypeTests.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2020 Livio, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Livio Inc. nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package com.smartdevicelink.test.rpc.enums; + +import com.smartdevicelink.proxy.rpc.enums.MessageType; + +import junit.framework.TestCase; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.proxy.rpc.enums.MessageType} + */ +public class MessageTypeTests extends TestCase { + + /** + * Verifies that the enum values are not null upon valid assignment. + */ + public void testValidEnums() { + int example = 0; + MessageType enumRequest = MessageType.valueForInt(example); + example = 1; + MessageType enumResponse = MessageType.valueForInt(example); + example = 2; + MessageType enumNotification = MessageType.valueForInt(example); + + assertNotNull("REQUEST returned null", enumRequest); + assertNotNull("RESPONSE returned null", enumResponse); + assertNotNull("NOTIFICATION returned null", enumNotification); + + } + + /** + * Verifies that an invalid assignment is null. + */ + public void testInvalidEnum() { + int example = 3; + try { + MessageType temp = MessageType.valueForInt(example); + assertNull("Result of valueForString should be null.", temp); + } catch (IllegalArgumentException exception) { + fail("Invalid enum throws IllegalArgumentException."); + } + } + + + /** + * Verifies the possible enum values of MessageType. + */ + public void testListEnum() { + List<MessageType> enumValueList = Arrays.asList(MessageType.values()); + + List<MessageType> enumTestList = new ArrayList<>(); + enumTestList.add(MessageType.REQUEST); + enumTestList.add(MessageType.RESPONSE); + enumTestList.add(MessageType.NOTIFICATION); + + assertTrue("Enum value list does not match enum class list", + enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); + } +}
\ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/PermissionStatusTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/PermissionStatusTests.java new file mode 100644 index 000000000..2a11db43f --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/PermissionStatusTests.java @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2020 Livio, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Livio Inc. nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package com.smartdevicelink.test.rpc.enums; + +import com.smartdevicelink.proxy.rpc.enums.PermissionStatus; + +import junit.framework.TestCase; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.proxy.rpc.enums.PermissionStatus} + */ +public class PermissionStatusTests extends TestCase { + + /** + * Verifies that the enum values are not null upon valid assignment. + */ + public void testValidEnums () { + String example = "ALLOWED"; + PermissionStatus enumAllowed = PermissionStatus.valueForString(example); + example = "DISALLOWED"; + PermissionStatus enumDisallowed = PermissionStatus.valueForString(example); + example = "USER_DISALLOWED"; + PermissionStatus enumUserDisallowed = PermissionStatus.valueForString(example); + example = "USER_CONSENT_PENDING"; + PermissionStatus enumUserConsentPending = PermissionStatus.valueForString(example); + + assertNotNull("ALLOWED returned null", enumAllowed); + assertNotNull("DISALLOWED returned null", enumDisallowed); + assertNotNull("USER_DISALLOWED returned null", enumUserDisallowed); + assertNotNull("USER_CONSENT_PENDING returned null", enumUserConsentPending); + } + + /** + * Verifies that an invalid assignment is null. + */ + public void testInvalidEnum () { + String example = "DISALLOwed"; + try { + PermissionStatus temp = PermissionStatus.valueForString(example); + assertNull("Result of valueForString should be null.", temp); + } + catch (IllegalArgumentException exception) { + fail("Invalid enum throws IllegalArgumentException."); + } + } + + /** + * Verifies that a null assignment is invalid. + */ + public void testNullEnum () { + String example = null; + try { + PermissionStatus temp = PermissionStatus.valueForString(example); + assertNull("Result of valueForString should be null.", temp); + } + catch (NullPointerException exception) { + fail("Null string throws NullPointerException."); + } + } + + /** + * Verifies the possible enum values of PermissionStatus. + */ + public void testListEnum() { + List<PermissionStatus> enumValueList = Arrays.asList(PermissionStatus.values()); + + List<PermissionStatus> enumTestList = new ArrayList<>(); + enumTestList.add(PermissionStatus.ALLOWED); + enumTestList.add(PermissionStatus.DISALLOWED); + enumTestList.add(PermissionStatus.USER_DISALLOWED); + enumTestList.add(PermissionStatus.USER_CONSENT_PENDING); + + assertTrue("Enum value list does not match enum class list", + enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); + } +}
\ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java index f3b374b4c..8bfec0490 100644 --- a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/ResultTests.java @@ -28,6 +28,8 @@ public class ResultTests extends TestCase { Result enumOutOfMemory = Result.valueForString(example); example = "TOO_MANY_PENDING_REQUESTS"; Result enumTooManyPendingRequests = Result.valueForString(example); + example = "CHAR_LIMIT_EXCEEDED"; + Result enumCharLimitExceeded = Result.valueForString(example); example = "INVALID_ID"; Result enumInvalidId = Result.valueForString(example); example = "DUPLICATE_NAME"; @@ -96,6 +98,7 @@ public class ResultTests extends TestCase { assertNotNull("UNSUPPORTED_REQUEST returned null", enumUnsupportedRequest); assertNotNull("OUT_OF_MEMORY returned null", enumOutOfMemory); assertNotNull("TOO_MANY_PENDING_REQUESTS returned null", enumTooManyPendingRequests); + assertNotNull("CHAR_LIMIT_EXCEEDED returned null", enumCharLimitExceeded); assertNotNull("INVALID_ID returned null", enumInvalidId); assertNotNull("DUPLICATE_NAME returned null", enumDuplicateName); assertNotNull("TOO_MANY_APPLICATIONS returned null", enumTooManyApplications); @@ -169,6 +172,7 @@ public class ResultTests extends TestCase { enumTestList.add(Result.UNSUPPORTED_REQUEST); enumTestList.add(Result.OUT_OF_MEMORY); enumTestList.add(Result.TOO_MANY_PENDING_REQUESTS); + enumTestList.add(Result.CHAR_LIMIT_EXCEEDED); enumTestList.add(Result.INVALID_ID); enumTestList.add(Result.DUPLICATE_NAME); enumTestList.add(Result.TOO_MANY_APPLICATIONS); diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TimerModeTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TimerModeTests.java new file mode 100644 index 000000000..892159a0d --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/TimerModeTests.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2020 Livio, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Livio Inc. nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package com.smartdevicelink.test.rpc.enums; + +import com.smartdevicelink.proxy.rpc.enums.TimerMode; + +import junit.framework.TestCase; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.proxy.rpc.enums.TimerMode} + */ +public class TimerModeTests extends TestCase { + + /** + * Verifies that the enum values are not null upon valid assignment. + */ + public void testValidEnums () { + String example = "UP"; + TimerMode enumUp = TimerMode.valueForString(example); + example = "DOWN"; + TimerMode enumDown = TimerMode.valueForString(example); + example = "NONE"; + TimerMode enumNone = TimerMode.valueForString(example); + + assertNotNull("UP returned null", enumUp); + assertNotNull("DOWN returned null", enumDown); + assertNotNull("NONE returned null", enumNone); + } + + /** + * Verifies that an invalid assignment is null. + */ + public void testInvalidEnum () { + String example = "NonE"; + try { + TimerMode temp = TimerMode.valueForString(example); + assertNull("Result of valueForString should be null.", temp); + } + catch (IllegalArgumentException exception) { + fail("Invalid enum throws IllegalArgumentException."); + } + } + + /** + * Verifies that a null assignment is invalid. + */ + public void testNullEnum () { + String example = null; + try { + TimerMode temp = TimerMode.valueForString(example); + assertNull("Result of valueForString should be null.", temp); + } + catch (NullPointerException exception) { + fail("Null string throws NullPointerException."); + } + } + + /** + * Verifies the possible enum values of TimerMode. + */ + public void testListEnum() { + List<TimerMode> enumValueList = Arrays.asList(TimerMode.values()); + + List<TimerMode> enumTestList = new ArrayList<>(); + enumTestList.add(TimerMode.UP); + enumTestList.add(TimerMode.DOWN); + enumTestList.add(TimerMode.NONE); + + assertTrue("Enum value list does not match enum class list", + enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); + } +}
\ No newline at end of file diff --git a/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataActiveStatusTests.java b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataActiveStatusTests.java new file mode 100644 index 000000000..b6ba15a7a --- /dev/null +++ b/android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/enums/VehicleDataActiveStatusTests.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2020 Livio, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Livio Inc. nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package com.smartdevicelink.test.rpc.enums; + +import com.smartdevicelink.proxy.rpc.enums.VehicleDataActiveStatus; + +import junit.framework.TestCase; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * This is a unit test class for the SmartDeviceLink library project class : + * {@link com.smartdevicelink.proxy.rpc.enums.VehicleDataActiveStatus} + */ +public class VehicleDataActiveStatusTests extends TestCase { + + /** + * Verifies that the enum values are not null upon valid assignment. + */ + public void testValidEnums () { + String example = "INACTIVE_NOT_CONFIRMED"; + VehicleDataActiveStatus enumInactiveNotConfirmed = VehicleDataActiveStatus.valueForString(example); + example = "INACTIVE_CONFIRMED"; + VehicleDataActiveStatus enumInactiveConfirmed = VehicleDataActiveStatus.valueForString(example); + example = "ACTIVE_NOT_CONFIRMED"; + VehicleDataActiveStatus enumActiveNotConfirmed = VehicleDataActiveStatus.valueForString(example); + example = "ACTIVE_CONFIRMED"; + VehicleDataActiveStatus enumActiveConfirmed = VehicleDataActiveStatus.valueForString(example); + example = "FAULT"; + VehicleDataActiveStatus enumFault = VehicleDataActiveStatus.valueForString(example); + + assertNotNull("INACTIVE_NOT_CONFIRMED returned null", enumInactiveNotConfirmed); + assertNotNull("INACTIVE_CONFIRMED returned null", enumInactiveConfirmed); + assertNotNull("ACTIVE_NOT_CONFIRMED returned null", enumActiveNotConfirmed); + assertNotNull("ACTIVE_CONFIRMED returned null", enumActiveConfirmed); + assertNotNull("FAULT returned null", enumFault); + } + + /** + * Verifies that an invalid assignment is null. + */ + public void testInvalidEnum () { + String example = "FauLt"; + try { + VehicleDataActiveStatus temp = VehicleDataActiveStatus.valueForString(example); + assertNull("Result of valueForString should be null.", temp); + } + catch (IllegalArgumentException exception) { + fail("Invalid enum throws IllegalArgumentException."); + } + } + + /** + * Verifies that a null assignment is invalid. + */ + public void testNullEnum () { + String example = null; + try { + VehicleDataActiveStatus temp = VehicleDataActiveStatus.valueForString(example); + assertNull("Result of valueForString should be null.", temp); + } + catch (NullPointerException exception) { + fail("Null string throws NullPointerException."); + } + } + + /** + * Verifies the possible enum values of VehicleDataActiveStatus. + */ + public void testListEnum() { + List<VehicleDataActiveStatus> enumValueList = Arrays.asList(VehicleDataActiveStatus.values()); + + List<VehicleDataActiveStatus> enumTestList = new ArrayList<>(); + enumTestList.add(VehicleDataActiveStatus.INACTIVE_NOT_CONFIRMED); + enumTestList.add(VehicleDataActiveStatus.INACTIVE_CONFIRMED); + enumTestList.add(VehicleDataActiveStatus.ACTIVE_NOT_CONFIRMED); + enumTestList.add(VehicleDataActiveStatus.ACTIVE_CONFIRMED); + enumTestList.add(VehicleDataActiveStatus.FAULT); + + assertTrue("Enum value list does not match enum class list", + enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList)); + } +}
\ No newline at end of file |