@@ -66,35 +66,13 @@ public void constructorSDKGenerated_fail_2() {
66
66
new DeviceId ((DeviceIdType ) null , (String )null , store , mock (ModuleLog .class ), null );
67
67
}
68
68
69
- /**
70
- * Validating 'deviceIDEqualsNullSafe'
71
- * Just checking which value combinations return which values
72
- */
73
- @ Test
74
- public void deviceIDEqualsNullSafe_1 () {
75
- DeviceId did = new DeviceId (DeviceIdType .DEVELOPER_SUPPLIED , "aa" , store , mock (ModuleLog .class ), null );
76
- assertTrue (DeviceId .deviceIDEqualsNullSafe ("a" , DeviceIdType .OPEN_UDID , did ));
77
- assertTrue (DeviceId .deviceIDEqualsNullSafe ("a" , DeviceIdType .TEMPORARY_ID , did ));
78
- assertTrue (DeviceId .deviceIDEqualsNullSafe ("a" , DeviceIdType .ADVERTISING_ID , did ));
79
-
80
- did .setId (DeviceIdType .OPEN_UDID , null );
81
- assertTrue (DeviceId .deviceIDEqualsNullSafe (null , DeviceIdType .ADVERTISING_ID , did ));
82
-
83
- did .setId (DeviceIdType .OPEN_UDID , "b" );
84
- assertFalse (DeviceId .deviceIDEqualsNullSafe ("a" , DeviceIdType .DEVELOPER_SUPPLIED , did ));
85
-
86
- did .setId (DeviceIdType .OPEN_UDID , "a" );
87
- assertTrue (DeviceId .deviceIDEqualsNullSafe ("a" , DeviceIdType .DEVELOPER_SUPPLIED , did ));
88
- }
89
-
90
69
/**
91
70
* Checking temporary device ID mode is correctly recognised after init if set with "setId"
92
71
* This would make sure that temp ID mode is verified mainly with the id string value
93
72
*/
94
73
@ Test
95
74
public void temporaryIdModeEnabled_1 () {
96
75
DeviceId did = new DeviceId (DeviceIdType .DEVELOPER_SUPPLIED ,"dsd" , store , mock (ModuleLog .class ), null );
97
- did .init ();
98
76
assertFalse (did .isTemporaryIdModeEnabled ());
99
77
100
78
did .setId (DeviceIdType .OPEN_UDID , DeviceId .temporaryCountlyDeviceId );
@@ -123,12 +101,11 @@ public void temporaryIdModeEnabled_1() {
123
101
}
124
102
125
103
/**
126
- * Checking dsetting temporary device ID mode during init
104
+ * Checking setting temporary device ID mode during init
127
105
*/
128
106
@ Test
129
107
public void temporaryIdModeEnabled_2 () {
130
108
DeviceId did2 = new DeviceId (DeviceIdType .TEMPORARY_ID , DeviceId .temporaryCountlyDeviceId , store , mock (ModuleLog .class ), null );
131
- did2 .init ();
132
109
assertTrue (did2 .isTemporaryIdModeEnabled ());
133
110
134
111
//todo needs more work
@@ -140,13 +117,23 @@ public void temporaryIdModeEnabled_2() {
140
117
@ Test
141
118
public void getType () {
142
119
assertEquals (DeviceIdType .DEVELOPER_SUPPLIED , new DeviceId (DeviceIdType .DEVELOPER_SUPPLIED , "dsd" , store , mock (ModuleLog .class ), null ).getType ());
120
+ store .clear ();
121
+
143
122
assertEquals (DeviceIdType .TEMPORARY_ID , new DeviceId (DeviceIdType .TEMPORARY_ID , DeviceId .temporaryCountlyDeviceId , store , mock (ModuleLog .class ), null ).getType ());
123
+ store .clear ();
124
+
144
125
assertEquals (DeviceIdType .OPEN_UDID , new DeviceId (DeviceIdType .OPEN_UDID , null , store , mock (ModuleLog .class ), new OpenUDIDProvider () {
145
126
@ Override public String getOpenUDID () {
146
127
return "abc" ;
147
128
}
148
129
}).getType ());
149
- assertEquals (DeviceIdType .ADVERTISING_ID , new DeviceId (DeviceIdType .ADVERTISING_ID , null , store , mock (ModuleLog .class ), null ).getType ());
130
+ store .clear ();
131
+
132
+ assertEquals (DeviceIdType .OPEN_UDID , new DeviceId (DeviceIdType .ADVERTISING_ID , null , store , mock (ModuleLog .class ), new OpenUDIDProvider () {
133
+ @ Override public String getOpenUDID () {
134
+ return "123" ;
135
+ }
136
+ }).getType ());
150
137
}
151
138
152
139
/**
@@ -155,27 +142,23 @@ public void getType() {
155
142
@ Test
156
143
public void getId () {
157
144
DeviceId did1 = new DeviceId (DeviceIdType .DEVELOPER_SUPPLIED , "abc" , store , mock (ModuleLog .class ), null );
158
- did1 .init ();
159
145
assertEquals ("abc" , did1 .getCurrentId ());
160
146
161
147
store .clear ();
162
148
163
149
DeviceId did2 = new DeviceId (DeviceIdType .TEMPORARY_ID , DeviceId .temporaryCountlyDeviceId , store , mock (ModuleLog .class ), null );
164
- did2 .init ();
165
150
assertEquals (DeviceId .temporaryCountlyDeviceId , did2 .getCurrentId ());
166
151
167
152
store .clear ();
168
153
169
154
currentOpenUDIDValue = "ppp1" ;
170
155
DeviceId did3 = new DeviceId (DeviceIdType .OPEN_UDID , null , store , mock (ModuleLog .class ), openUDIDProvider );
171
- did3 .init ();
172
156
assertEquals (currentOpenUDIDValue , did3 .getCurrentId ());
173
157
174
158
store .clear ();
175
159
176
160
currentOpenUDIDValue = "openUDIDfallbackValue" ;
177
161
DeviceId did4 = new DeviceId (DeviceIdType .ADVERTISING_ID , null , store , mock (ModuleLog .class ), openUDIDProvider );
178
- did4 .init ();
179
162
assertNotNull (did4 .getCurrentId ());
180
163
assertEquals (currentOpenUDIDValue , did4 .getCurrentId ());
181
164
}
@@ -186,14 +169,13 @@ public void getId() {
186
169
@ Test
187
170
public void changeToIdDevSupplied () {
188
171
DeviceId did = new DeviceId (DeviceIdType .DEVELOPER_SUPPLIED , "abc" , store , mock (ModuleLog .class ), null );
189
- did .init ();
190
172
assertEquals ("abc" , did .getCurrentId ());
191
173
192
- did .changeToId (DeviceIdType .DEVELOPER_SUPPLIED , "123" , false );
174
+ did .changeToId (DeviceIdType .DEVELOPER_SUPPLIED , "123" );
193
175
assertEquals ("123" , did .getCurrentId ());
194
176
assertEquals (DeviceIdType .DEVELOPER_SUPPLIED , did .getType ());
195
177
196
- did .changeToId (DeviceIdType .DEVELOPER_SUPPLIED , "456" , true );
178
+ did .changeToId (DeviceIdType .DEVELOPER_SUPPLIED , "456" );
197
179
assertEquals ("456" , did .getCurrentId ());
198
180
assertEquals (DeviceIdType .DEVELOPER_SUPPLIED , did .getType ());
199
181
}
@@ -204,28 +186,27 @@ public void changeToIdDevSupplied() {
204
186
@ Test
205
187
public void changeToIdOpenUDID () {
206
188
DeviceId did = new DeviceId (DeviceIdType .DEVELOPER_SUPPLIED , "abc" , store , mock (ModuleLog .class ), openUDIDProvider );
207
- did .init ();
208
189
assertEquals ("abc" , did .getCurrentId ());
209
190
210
191
//set first value without running init, should use the provided value
211
- did .changeToId (DeviceIdType .OPEN_UDID , "123" , false );
192
+ did .changeToId (DeviceIdType .OPEN_UDID , "123" );
212
193
assertEquals ("123" , did .getCurrentId ());
213
194
assertEquals (DeviceIdType .OPEN_UDID , did .getType ());
214
195
215
196
//do a reset
216
- did .changeToId (DeviceIdType .DEVELOPER_SUPPLIED , "aaa" , true );
197
+ did .changeToId (DeviceIdType .DEVELOPER_SUPPLIED , "aaa" );
217
198
assertEquals ("aaa" , did .getCurrentId ());
218
199
assertEquals (DeviceIdType .DEVELOPER_SUPPLIED , did .getType ());
219
200
220
201
//change with init, since a value is specified, it should take precedence
221
202
currentOpenUDIDValue = "uio|" ;
222
- did .changeToId (DeviceIdType .OPEN_UDID , "456" , true );
203
+ did .changeToId (DeviceIdType .OPEN_UDID , "456" );
223
204
assertEquals ("456" , did .getCurrentId ());
224
205
assertEquals (DeviceIdType .OPEN_UDID , did .getType ());
225
206
226
207
//change with init, it should use it's own value because a null device ID is provided
227
208
currentOpenUDIDValue = "sdfh" ;
228
- did .changeToId (DeviceIdType .OPEN_UDID , null , true );
209
+ did .changeToId (DeviceIdType .OPEN_UDID , null );
229
210
assertEquals (currentOpenUDIDValue , did .getCurrentId ());
230
211
assertEquals (DeviceIdType .OPEN_UDID , did .getType ());
231
212
}
@@ -241,27 +222,22 @@ public void initWithDifferentValuesStartingDevID() {
241
222
store .clear ();
242
223
243
224
DeviceId did = new DeviceId (DeviceIdType .DEVELOPER_SUPPLIED , "abc" , store , mock (ModuleLog .class ), null );
244
- did .init ();
245
225
assertEquals ("abc" , did .getCurrentId ());
246
226
assertEquals (DeviceIdType .DEVELOPER_SUPPLIED , did .getType ());
247
227
248
228
did = new DeviceId (DeviceIdType .DEVELOPER_SUPPLIED , "123" , store , mock (ModuleLog .class ), null );
249
- did .init ();
250
229
assertEquals ("abc" , did .getCurrentId ());
251
230
assertEquals (DeviceIdType .DEVELOPER_SUPPLIED , did .getType ());
252
231
253
232
did = new DeviceId (DeviceIdType .OPEN_UDID , null , store , mock (ModuleLog .class ), null );
254
- did .init ();
255
233
assertEquals ("abc" , did .getCurrentId ());
256
234
assertEquals (DeviceIdType .DEVELOPER_SUPPLIED , did .getType ());
257
235
258
236
did = new DeviceId (DeviceIdType .ADVERTISING_ID , null , store , mock (ModuleLog .class ), null );
259
- did .init ();
260
237
assertEquals ("abc" , did .getCurrentId ());
261
238
assertEquals (DeviceIdType .DEVELOPER_SUPPLIED , did .getType ());
262
239
263
240
did = new DeviceId (DeviceIdType .TEMPORARY_ID , DeviceId .temporaryCountlyDeviceId , store , mock (ModuleLog .class ), null );
264
- did .init ();
265
241
assertEquals ("abc" , did .getCurrentId ());
266
242
assertEquals (DeviceIdType .DEVELOPER_SUPPLIED , did .getType ());
267
243
}
@@ -276,27 +252,22 @@ public void initWithDifferentValuesStartingDevID() {
276
252
public void initWithDifferentValuesStartingOpenUDID () {
277
253
currentOpenUDIDValue = "nmb" ;
278
254
DeviceId did = new DeviceId (DeviceIdType .OPEN_UDID , null , store , mock (ModuleLog .class ), openUDIDProvider );
279
- did .init ();
280
255
assertEquals (currentOpenUDIDValue , did .getCurrentId ());
281
256
assertEquals (DeviceIdType .OPEN_UDID , did .getType ());
282
257
283
258
did = new DeviceId (DeviceIdType .DEVELOPER_SUPPLIED , "123" , store , mock (ModuleLog .class ), openUDIDProvider );
284
- did .init ();
285
259
assertEquals (currentOpenUDIDValue , did .getCurrentId ());
286
260
assertEquals (DeviceIdType .OPEN_UDID , did .getType ());
287
261
288
262
did = new DeviceId (DeviceIdType .OPEN_UDID , null , store , mock (ModuleLog .class ), openUDIDProvider );
289
- did .init ();
290
263
assertEquals (currentOpenUDIDValue , did .getCurrentId ());
291
264
assertEquals (DeviceIdType .OPEN_UDID , did .getType ());
292
265
293
266
did = new DeviceId (DeviceIdType .ADVERTISING_ID , null , store , mock (ModuleLog .class ), openUDIDProvider );
294
- did .init ();
295
267
assertEquals (currentOpenUDIDValue , did .getCurrentId ());
296
268
assertEquals (DeviceIdType .OPEN_UDID , did .getType ());
297
269
298
270
did = new DeviceId (DeviceIdType .TEMPORARY_ID , DeviceId .temporaryCountlyDeviceId , store , mock (ModuleLog .class ), openUDIDProvider );
299
- did .init ();
300
271
assertEquals (currentOpenUDIDValue , did .getCurrentId ());
301
272
assertEquals (DeviceIdType .OPEN_UDID , did .getType ());
302
273
}
@@ -312,14 +283,12 @@ public void reinitOpenUDID_differentValue() {
312
283
313
284
//init the first time and openUDID returns one value
314
285
DeviceId did = new DeviceId (DeviceIdType .OPEN_UDID , null , store , mock (ModuleLog .class ), openUDIDProvider );
315
- did .init ();
316
286
assertEquals (currentOpenUDIDValue , did .getCurrentId ());
317
287
assertEquals (DeviceIdType .OPEN_UDID , did .getType ());
318
288
319
289
//init the second time and openUDID returns a different value
320
290
currentOpenUDIDValue = "zxc" ;
321
291
did = new DeviceId (DeviceIdType .OPEN_UDID , null , store , mock (ModuleLog .class ), openUDIDProvider );
322
- did .init ();
323
292
assertEquals (initialValue , did .getCurrentId ());
324
293
assertEquals (DeviceIdType .OPEN_UDID , did .getType ());
325
294
}
0 commit comments