blob: 20946252c8c6b6adc1177aeca735d234e912ac07 (
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
|
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.ComponentVolumeStatus;
/**
* This is a unit test class for the SmartDeviceLink library project class :
* {@link com.smartdevicelink.rpc.enums.ComponentVolumeStatus}
*/
public class ComponentVolumeStatusTests extends TestCase {
/**
* Verifies that the enum values are not null upon valid assignment.
*/
public void testValidEnums () {
String example = "UNKNOWN";
ComponentVolumeStatus enumUnknown = ComponentVolumeStatus.valueForString(example);
example = "NORMAL";
ComponentVolumeStatus enumNormal = ComponentVolumeStatus.valueForString(example);
example = "LOW";
ComponentVolumeStatus enumLow = ComponentVolumeStatus.valueForString(example);
example = "FAULT";
ComponentVolumeStatus enumFault = ComponentVolumeStatus.valueForString(example);
example = "ALERT";
ComponentVolumeStatus enumAlert = ComponentVolumeStatus.valueForString(example);
example = "NOT_SUPPORTED";
ComponentVolumeStatus enumNotSupported = ComponentVolumeStatus.valueForString(example);
assertNotNull("UNKNOWN returned null", enumUnknown);
assertNotNull("NORMAL returned null", enumNormal);
assertNotNull("LOW returned null", enumLow);
assertNotNull("FAULT returned null", enumFault);
assertNotNull("ALERT returned null", enumAlert);
assertNotNull("NOT_SUPPORTED returned null", enumNotSupported);
}
/**
* Verifies that an invalid assignment is null.
*/
public void testInvalidEnum () {
String example = "unKNowN";
try {
ComponentVolumeStatus temp = ComponentVolumeStatus.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 {
ComponentVolumeStatus temp = ComponentVolumeStatus.valueForString(example);
assertNull("Result of valueForString should be null.", temp);
}
catch (NullPointerException exception) {
fail("Null string throws NullPointerException.");
}
}
/**
* Verifies the possible enum values of ComponentVolumeStatus.
*/
public void testListEnum() {
List<ComponentVolumeStatus> enumValueList = Arrays.asList(ComponentVolumeStatus.values());
List<ComponentVolumeStatus> enumTestList = new ArrayList<ComponentVolumeStatus>();
enumTestList.add(ComponentVolumeStatus.UNKNOWN);
enumTestList.add(ComponentVolumeStatus.NORMAL);
enumTestList.add(ComponentVolumeStatus.LOW);
enumTestList.add(ComponentVolumeStatus.FAULT);
enumTestList.add(ComponentVolumeStatus.ALERT);
enumTestList.add(ComponentVolumeStatus.NOT_SUPPORTED);
assertTrue("Enum value list does not match enum class list",
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
}
}
|