blob: 21823e4bdce4a2ebdf7acee60f62f9c6e600adff (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
package com.smartdevicelink.test.rpc.enums;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import junit.framework.TestCase;
import com.smartdevicelink.proxy.rpc.enums.EmergencyEventType;
/**
* This is a unit test class for the SmartDeviceLink library project class :
* {@link com.smartdevicelink.rpc.enums.EmergencyEventType}
*/
public class EmergencyEventTypeTests extends TestCase {
/**
* Verifies that the enum values are not null upon valid assignment.
*/
public void testValidEnums () {
String example = "NO_EVENT";
EmergencyEventType enumEventType = EmergencyEventType.valueForString(example);
example = "FRONTAL";
EmergencyEventType enumFrontal = EmergencyEventType.valueForString(example);
example = "SIDE";
EmergencyEventType enumSide = EmergencyEventType.valueForString(example);
example = "REAR";
EmergencyEventType enumRear = EmergencyEventType.valueForString(example);
example = "ROLLOVER";
EmergencyEventType enumRollover = EmergencyEventType.valueForString(example);
example = "NOT_SUPPORTED";
EmergencyEventType enumNotSupported = EmergencyEventType.valueForString(example);
example = "FAULT";
EmergencyEventType enumFault = EmergencyEventType.valueForString(example);
assertNotNull("NO_EVENT returned null", enumEventType);
assertNotNull("FRONTAL returned null", enumFrontal);
assertNotNull("SIDE returned null", enumSide);
assertNotNull("REAR returned null", enumRear);
assertNotNull("ROLLOVER returned null", enumRollover);
assertNotNull("NOT_SUPPORTED returned null", enumNotSupported);
assertNotNull("FAULT returned null", enumFault);
}
/**
* Verifies that an invalid assignment is null.
*/
public void testInvalidEnum () {
String example = "nO_EvenT";
try {
EmergencyEventType temp = EmergencyEventType.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 {
EmergencyEventType temp = EmergencyEventType.valueForString(example);
assertNull("Result of valueForString should be null.", temp);
}
catch (NullPointerException exception) {
fail("Null string throws NullPointerException.");
}
}
/**
* Verifies the possible enum values of EmergencyEvent.
*/
public void testListEnum() {
List<EmergencyEventType> enumValueList = Arrays.asList(EmergencyEventType.values());
List<EmergencyEventType> enumTestList = new ArrayList<EmergencyEventType>();
enumTestList.add(EmergencyEventType.NO_EVENT);
enumTestList.add(EmergencyEventType.FRONTAL);
enumTestList.add(EmergencyEventType.SIDE);
enumTestList.add(EmergencyEventType.REAR);
enumTestList.add(EmergencyEventType.ROLLOVER);
enumTestList.add(EmergencyEventType.NOT_SUPPORTED);
enumTestList.add(EmergencyEventType.FAULT);
assertTrue("Enum value list does not match enum class list",
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
}
}
|