@@ -136,7 +136,7 @@ public void createImpressionEventIgnoresUnknownAttributes() throws Exception {
136
136
* events being sent with the overriden values.
137
137
*/
138
138
@ Test
139
- public void createImpressionEventCustomClientEngineClientVersion () throws Exception {
139
+ public void createImpressionEventAndroidClientEngineClientVersion () throws Exception {
140
140
EventBuilderV2 builder = new EventBuilderV2 (ClientEngine .ANDROID_SDK , "0.0.0" );
141
141
ProjectConfig projectConfig = ProjectConfigTestUtils .validProjectConfigV2 ();
142
142
Experiment activatedExperiment = projectConfig .getExperiments ().get (0 );
@@ -153,6 +153,29 @@ public void createImpressionEventCustomClientEngineClientVersion() throws Except
153
153
assertThat (impression .getClientVersion (), is ("0.0.0" ));
154
154
}
155
155
156
+ /**
157
+ * Verify that supplying {@link EventBuilderV2} with a custom Android TV client engine and client version
158
+ * results in impression events being sent with the overriden values.
159
+ */
160
+ @ Test
161
+ public void createImpressionEventAndroidTVClientEngineClientVersion () throws Exception {
162
+ String clientVersion = "0.0.0" ;
163
+ EventBuilderV2 builder = new EventBuilderV2 (ClientEngine .ANDROID_TV_SDK , clientVersion );
164
+ ProjectConfig projectConfig = ProjectConfigTestUtils .validProjectConfigV2 ();
165
+ Experiment activatedExperiment = projectConfig .getExperiments ().get (0 );
166
+ Variation bucketedVariation = activatedExperiment .getVariations ().get (0 );
167
+ Attribute attribute = projectConfig .getAttributes ().get (0 );
168
+ String userId = "userId" ;
169
+ Map <String , String > attributeMap = Collections .singletonMap (attribute .getKey (), "value" );
170
+
171
+ LogEvent impressionEvent = builder .createImpressionEvent (projectConfig , activatedExperiment , bucketedVariation ,
172
+ userId , attributeMap );
173
+ Impression impression = gson .fromJson (impressionEvent .getBody (), Impression .class );
174
+
175
+ assertThat (impression .getClientEngine (), is (ClientEngine .ANDROID_TV_SDK .getClientEngineValue ()));
176
+ assertThat (impression .getClientVersion (), is (clientVersion ));
177
+ }
178
+
156
179
/**
157
180
* Verify that passing a non-null session ID to
158
181
* {@link EventBuilder#createImpressionEvent(ProjectConfig, Experiment, Variation, String, Map, String)} properly
@@ -370,7 +393,7 @@ public void createConversionEventExperimentStatusPrecedesForcedVariation() {
370
393
* events being sent with the overriden values.
371
394
*/
372
395
@ Test
373
- public void createConversionEventCustomClientEngineClientVersion () throws Exception {
396
+ public void createConversionEventAndroidClientEngineClientVersion () throws Exception {
374
397
EventBuilderV2 builder = new EventBuilderV2 (ClientEngine .ANDROID_SDK , "0.0.0" );
375
398
ProjectConfig projectConfig = ProjectConfigTestUtils .validProjectConfigV2 ();
376
399
Attribute attribute = projectConfig .getAttributes ().get (0 );
@@ -393,6 +416,35 @@ public void createConversionEventCustomClientEngineClientVersion() throws Except
393
416
assertThat (conversion .getClientVersion (), is ("0.0.0" ));
394
417
}
395
418
419
+ /**
420
+ * Verify that supplying {@link EventBuilderV2} with a Android TV client engine and client version results in
421
+ * conversion events being sent with the overriden values.
422
+ */
423
+ @ Test
424
+ public void createConversionEventAndroidTVClientEngineClientVersion () throws Exception {
425
+ String clientVersion = "0.0.0" ;
426
+ EventBuilderV2 builder = new EventBuilderV2 (ClientEngine .ANDROID_TV_SDK , clientVersion );
427
+ ProjectConfig projectConfig = ProjectConfigTestUtils .validProjectConfigV2 ();
428
+ Attribute attribute = projectConfig .getAttributes ().get (0 );
429
+ EventType eventType = projectConfig .getEventTypes ().get (0 );
430
+ String userId = "userId" ;
431
+
432
+ Bucketer mockBucketAlgorithm = mock (Bucketer .class );
433
+ for (Experiment experiment : projectConfig .getExperiments ()) {
434
+ when (mockBucketAlgorithm .bucket (experiment , userId ))
435
+ .thenReturn (experiment .getVariations ().get (0 ));
436
+ }
437
+
438
+ Map <String , String > attributeMap = Collections .singletonMap (attribute .getKey (), "value" );
439
+ LogEvent conversionEvent = builder .createConversionEvent (projectConfig , mockBucketAlgorithm , userId ,
440
+ eventType .getId (), eventType .getKey (), attributeMap );
441
+
442
+ Conversion conversion = gson .fromJson (conversionEvent .getBody (), Conversion .class );
443
+
444
+ assertThat (conversion .getClientEngine (), is (ClientEngine .ANDROID_TV_SDK .getClientEngineValue ()));
445
+ assertThat (conversion .getClientVersion (), is (clientVersion ));
446
+ }
447
+
396
448
/**
397
449
* Verify that {@link EventBuilderV2} doesn't add experiments with a "Launched" status to the bucket map
398
450
*/
0 commit comments