Skip to content

Commit c313636

Browse files
authored
Release version 1.5.0 (#75)
2 parents 9a0e296 + a7dffbb commit c313636

File tree

5 files changed

+73
-5
lines changed

5 files changed

+73
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.5.0
2+
3+
February 16, 2017
4+
5+
- Support Android TV SDK client engine
6+
17
## 1.4.1
28

39
February 1, 2017

core-api/src/main/java/com/optimizely/ab/event/internal/payload/Event.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public class Event {
2424

2525
public enum ClientEngine {
2626
JAVA_SDK ("java-sdk"),
27-
ANDROID_SDK ("android-sdk");
27+
ANDROID_SDK ("android-sdk"),
28+
ANDROID_TV_SDK ("android-tv-sdk");
2829

2930
private final String clientEngineValue;
3031

core-api/src/test/java/com/optimizely/ab/OptimizelyBuilderTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,23 @@ public void withDefaultClientEngine() throws Exception {
130130
}
131131

132132
@Test
133-
public void withCustomClientEngine() throws Exception {
133+
public void withAndroidSDKClientEngine() throws Exception {
134134
Optimizely optimizelyClient = Optimizely.builder(validConfigJsonV2(), mockEventHandler)
135135
.withClientEngine(ClientEngine.ANDROID_SDK)
136136
.build();
137137

138138
assertThat(((EventBuilderV2)optimizelyClient.eventBuilder).clientEngine, is(ClientEngine.ANDROID_SDK));
139139
}
140140

141+
@Test
142+
public void withAndroidTVSDKClientEngine() throws Exception {
143+
Optimizely optimizelyClient = Optimizely.builder(validConfigJsonV2(), mockEventHandler)
144+
.withClientEngine(ClientEngine.ANDROID_TV_SDK)
145+
.build();
146+
147+
assertThat(((EventBuilderV2)optimizelyClient.eventBuilder).clientEngine, is(ClientEngine.ANDROID_TV_SDK));
148+
}
149+
141150
@Test
142151
public void withDefaultClientVersion() throws Exception {
143152
Optimizely optimizelyClient = Optimizely.builder(validConfigJsonV2(), mockEventHandler)

core-api/src/test/java/com/optimizely/ab/event/internal/EventBuilderV2Test.java

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public void createImpressionEventIgnoresUnknownAttributes() throws Exception {
136136
* events being sent with the overriden values.
137137
*/
138138
@Test
139-
public void createImpressionEventCustomClientEngineClientVersion() throws Exception {
139+
public void createImpressionEventAndroidClientEngineClientVersion() throws Exception {
140140
EventBuilderV2 builder = new EventBuilderV2(ClientEngine.ANDROID_SDK, "0.0.0");
141141
ProjectConfig projectConfig = ProjectConfigTestUtils.validProjectConfigV2();
142142
Experiment activatedExperiment = projectConfig.getExperiments().get(0);
@@ -153,6 +153,29 @@ public void createImpressionEventCustomClientEngineClientVersion() throws Except
153153
assertThat(impression.getClientVersion(), is("0.0.0"));
154154
}
155155

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+
156179
/**
157180
* Verify that passing a non-null session ID to
158181
* {@link EventBuilder#createImpressionEvent(ProjectConfig, Experiment, Variation, String, Map, String)} properly
@@ -370,7 +393,7 @@ public void createConversionEventExperimentStatusPrecedesForcedVariation() {
370393
* events being sent with the overriden values.
371394
*/
372395
@Test
373-
public void createConversionEventCustomClientEngineClientVersion() throws Exception {
396+
public void createConversionEventAndroidClientEngineClientVersion() throws Exception {
374397
EventBuilderV2 builder = new EventBuilderV2(ClientEngine.ANDROID_SDK, "0.0.0");
375398
ProjectConfig projectConfig = ProjectConfigTestUtils.validProjectConfigV2();
376399
Attribute attribute = projectConfig.getAttributes().get(0);
@@ -393,6 +416,35 @@ public void createConversionEventCustomClientEngineClientVersion() throws Except
393416
assertThat(conversion.getClientVersion(), is("0.0.0"));
394417
}
395418

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+
396448
/**
397449
* Verify that {@link EventBuilderV2} doesn't add experiments with a "Launched" status to the bucket map
398450
*/

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Maven version
2-
version = 1.4.1-SNAPSHOT
2+
version = 1.5.0-SNAPSHOT
33

44
# Artifact paths
55
mavenS3Bucket = optimizely-maven

0 commit comments

Comments
 (0)