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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
package com.smartdevicelink.test.rpc.enums;
import com.smartdevicelink.proxy.rpc.enums.Result;
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.Result}
*/
public class ResultTests extends TestCase {
/**
* Verifies that the enum values are not null upon valid assignment.
*/
public void testValidEnums () {
String example = "SUCCESS";
Result enumSuccess = Result.valueForString(example);
example = "INVALID_DATA";
Result enumInvalidData = Result.valueForString(example);
example = "UNSUPPORTED_REQUEST";
Result enumUnsupportedRequest = Result.valueForString(example);
example = "OUT_OF_MEMORY";
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";
Result enumDuplicateName = Result.valueForString(example);
example = "TOO_MANY_APPLICATIONS";
Result enumTooManyApplications = Result.valueForString(example);
example = "APPLICATION_REGISTERED_ALREADY";
Result enumApplicationRegisteredAlready = Result.valueForString(example);
example = "UNSUPPORTED_VERSION";
Result enumUnsupportedVersion = Result.valueForString(example);
example = "WRONG_LANGUAGE";
Result enumWrongLanguage = Result.valueForString(example);
example = "APPLICATION_NOT_REGISTERED";
Result enumApplicationNotRegistered = Result.valueForString(example);
example = "IN_USE";
Result enumInUse = Result.valueForString(example);
example = "VEHICLE_DATA_NOT_ALLOWED";
Result enumVehicleDataNotAllowed = Result.valueForString(example);
example = "VEHICLE_DATA_NOT_AVAILABLE";
Result enumVehicleDataNotAvailable = Result.valueForString(example);
example = "REJECTED";
Result enumRejected = Result.valueForString(example);
example = "ABORTED";
Result enumAborted = Result.valueForString(example);
example = "IGNORED";
Result enumIgnored = Result.valueForString(example);
example = "UNSUPPORTED_RESOURCE";
Result enumUnsupportedResource = Result.valueForString(example);
example = "FILE_NOT_FOUND";
Result enumFileNotFound = Result.valueForString(example);
example = "GENERIC_ERROR";
Result enumGenericError = Result.valueForString(example);
example = "DISALLOWED";
Result enumDisallowed = Result.valueForString(example);
example = "USER_DISALLOWED";
Result enumUserDisallowed = Result.valueForString(example);
example = "TIMED_OUT";
Result enumTimedOut = Result.valueForString(example);
example = "CANCEL_ROUTE";
Result enumCancelRoute = Result.valueForString(example);
example = "TRUNCATED_DATA";
Result enumTruncatedData = Result.valueForString(example);
example = "RETRY";
Result enumRetry = Result.valueForString(example);
example = "WARNINGS";
Result enumWarnings = Result.valueForString(example);
example = "SAVED";
Result enumSaved = Result.valueForString(example);
example = "INVALID_CERT";
Result enumInvalidCert = Result.valueForString(example);
example = "EXPIRED_CERT";
Result enumExpiredCert = Result.valueForString(example);
example = "RESUME_FAILED";
Result enumResumeFailed = Result.valueForString(example);
example = "DATA_NOT_AVAILABLE";
Result enumDataNotAvailable = Result.valueForString(example);
example = "READ_ONLY";
Result enumReadOnly = Result.valueForString(example);
example = "CORRUPTED_DATA";
Result enumCorruptData = Result.valueForString(example);
example = "ENCRYPTION_NEEDED";
Result enumEncryptionRequired = Result.valueForString(example);
assertNotNull("SUCCESS returned null", enumSuccess);
assertNotNull("INVALID_DATA returned null", enumInvalidData);
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);
assertNotNull("APPLICATION_REGISTERED_ALREADY returned null", enumApplicationRegisteredAlready);
assertNotNull("UNSUPPORTED_VERSION returned null", enumUnsupportedVersion);
assertNotNull("WRONG_LANGUAGE returned null", enumWrongLanguage);
assertNotNull("APPLICATION_NOT_REGISTERED returned null", enumApplicationNotRegistered);
assertNotNull("IN_USE returned null", enumInUse);
assertNotNull("VEHICLE_DATA_NOT_ALLOWED returned null", enumVehicleDataNotAllowed);
assertNotNull("VEHICLE_DATA_NOT_AVAILABLE returned null", enumVehicleDataNotAvailable);
assertNotNull("REJECTED returned null", enumRejected);
assertNotNull("ABORTED returned null", enumAborted);
assertNotNull("IGNORED returned null", enumIgnored);
assertNotNull("UNSUPPORTED_RESOURCE returned null", enumUnsupportedResource);
assertNotNull("FILE_NOT_FOUND returned null", enumFileNotFound);
assertNotNull("GENERIC_ERROR returned null", enumGenericError);
assertNotNull("DISALLOWED returned null", enumDisallowed);
assertNotNull("USER_DISALLOWED returned null", enumUserDisallowed);
assertNotNull("TIMED_OUT returned null", enumTimedOut);
assertNotNull("CANCEL_ROUTE returned null", enumCancelRoute);
assertNotNull("TRUNCATED_DATA returned null", enumTruncatedData);
assertNotNull("RETRY returned null", enumRetry);
assertNotNull("WARNINGS returned null", enumWarnings);
assertNotNull("SAVED returned null", enumSaved);
assertNotNull("INVALID_CERT returned null", enumInvalidCert);
assertNotNull("EXPIRED_CERT returned null", enumExpiredCert);
assertNotNull("RESUME_FAILED returned null", enumResumeFailed);
assertNotNull("DATA_NOT_AVAILABLE returned null", enumDataNotAvailable);
assertNotNull("READ_ONLY returned null", enumReadOnly);
assertNotNull("CORRUPTED_DATA", enumCorruptData);
assertNotNull("ENCRYPTION_NEEDED", enumEncryptionRequired);
}
/**
* Verifies that an invalid assignment is null.
*/
public void testInvalidEnum () {
String example = "suCcesS";
try {
Result temp = Result.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 {
Result temp = Result.valueForString(example);
assertNull("Result of valueForString should be null.", temp);
}
catch (NullPointerException exception) {
fail("Null string throws NullPointerException.");
}
}
/**
* Verifies the possible enum values of Result.
*/
public void testListEnum() {
List<Result> enumValueList = Arrays.asList(Result.values());
List<Result> enumTestList = new ArrayList<Result>();
enumTestList.add(Result.SUCCESS);
enumTestList.add(Result.INVALID_DATA);
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);
enumTestList.add(Result.APPLICATION_REGISTERED_ALREADY);
enumTestList.add(Result.UNSUPPORTED_VERSION);
enumTestList.add(Result.WRONG_LANGUAGE);
enumTestList.add(Result.APPLICATION_NOT_REGISTERED);
enumTestList.add(Result.IN_USE);
enumTestList.add(Result.VEHICLE_DATA_NOT_ALLOWED);
enumTestList.add(Result.VEHICLE_DATA_NOT_AVAILABLE);
enumTestList.add(Result.REJECTED);
enumTestList.add(Result.ABORTED);
enumTestList.add(Result.IGNORED);
enumTestList.add(Result.UNSUPPORTED_RESOURCE);
enumTestList.add(Result.FILE_NOT_FOUND);
enumTestList.add(Result.GENERIC_ERROR);
enumTestList.add(Result.DISALLOWED);
enumTestList.add(Result.USER_DISALLOWED);
enumTestList.add(Result.TIMED_OUT);
enumTestList.add(Result.CANCEL_ROUTE);
enumTestList.add(Result.TRUNCATED_DATA);
enumTestList.add(Result.RETRY);
enumTestList.add(Result.WARNINGS);
enumTestList.add(Result.SAVED);
enumTestList.add(Result.INVALID_CERT);
enumTestList.add(Result.EXPIRED_CERT);
enumTestList.add(Result.RESUME_FAILED);
enumTestList.add(Result.DATA_NOT_AVAILABLE);
enumTestList.add(Result.READ_ONLY);
enumTestList.add(Result.CORRUPTED_DATA);
enumTestList.add(Result.ENCRYPTION_NEEDED);
assertTrue("Enum value list does not match enum class list",
enumValueList.containsAll(enumTestList) && enumTestList.containsAll(enumValueList));
}
}
|