Skip to content

Commit 3472bfd

Browse files
author
Mike Davis
committed
Remaining PR feedback.
1 parent 5f7f670 commit 3472bfd

File tree

3 files changed

+14
-30
lines changed

3 files changed

+14
-30
lines changed

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.*;
2626
import java.util.stream.Collectors;
2727

28+
import static com.optimizely.ab.config.ProjectConfig.RESERVED_ATTRIBUTE_PREFIX;
2829
import static junit.framework.TestCase.assertTrue;
2930
import static org.junit.Assert.assertEquals;
3031
import static org.junit.Assert.fail;
@@ -133,7 +134,7 @@ public void dispatchEvent(LogEvent logEvent) throws Exception {
133134
event.getKey(),
134135
visitor.getVisitorId(),
135136
visitor.getAttributes().stream()
136-
.filter(attribute -> !attribute.getKey().startsWith("$"))
137+
.filter(attribute -> !attribute.getKey().startsWith(RESERVED_ATTRIBUTE_PREFIX))
137138
.collect(Collectors.toMap(Attribute::getKey, Attribute::getValue))
138139
);
139140

@@ -145,15 +146,15 @@ public void dispatchEvent(LogEvent logEvent) throws Exception {
145146
}
146147

147148
private static class CanonicalEvent {
148-
private String experimentKey;
149-
private String variationKey;
149+
private String experimentId;
150+
private String variationId;
150151
private String eventName;
151152
private String visitorId;
152153
private Map<String, ?> attributes;
153154

154-
public CanonicalEvent(String experimentKey, String variationKey, String eventName, String visitorId, Map<String, ?> attributes) {
155-
this.experimentKey = experimentKey;
156-
this.variationKey = variationKey;
155+
public CanonicalEvent(String experimentId, String variationId, String eventName, String visitorId, Map<String, ?> attributes) {
156+
this.experimentId = experimentId;
157+
this.variationId = variationId;
157158
this.eventName = eventName;
158159
this.visitorId = visitorId;
159160
this.attributes = attributes;
@@ -164,23 +165,23 @@ public boolean equals(Object o) {
164165
if (this == o) return true;
165166
if (o == null || getClass() != o.getClass()) return false;
166167
CanonicalEvent that = (CanonicalEvent) o;
167-
return Objects.equals(experimentKey, that.experimentKey) &&
168-
Objects.equals(variationKey, that.variationKey) &&
168+
return Objects.equals(experimentId, that.experimentId) &&
169+
Objects.equals(variationId, that.variationId) &&
169170
Objects.equals(eventName, that.eventName) &&
170171
Objects.equals(visitorId, that.visitorId) &&
171172
Objects.equals(attributes, that.attributes);
172173
}
173174

174175
@Override
175176
public int hashCode() {
176-
return Objects.hash(experimentKey, variationKey, eventName, visitorId, attributes);
177+
return Objects.hash(experimentId, variationId, eventName, visitorId, attributes);
177178
}
178179

179180
@Override
180181
public String toString() {
181182
return new StringJoiner(", ", CanonicalEvent.class.getSimpleName() + "[", "]")
182-
.add("experimentKey='" + experimentKey + "'")
183-
.add("variationKey='" + variationKey + "'")
183+
.add("experimentId='" + experimentId + "'")
184+
.add("variationId='" + variationId + "'")
184185
.add("eventName='" + eventName + "'")
185186
.add("visitorId='" + visitorId + "'")
186187
.add("attributes=" + attributes)

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,25 +1263,6 @@ public void trackDoesNotSendEventWhenExperimentsAreLaunchedOnly() throws Excepti
12631263
eventHandler.expectConversion(eventType.getKey(), genericUserId);
12641264
}
12651265

1266-
/**
1267-
* Verify that {@link Optimizely#track(String, String, Map)}
1268-
* dispatches log events when the tracked event links to both launched and running experiments.
1269-
*
1270-
* TODO Is this test needed? Feels unnecessary in a post EET world.
1271-
*/
1272-
@Test
1273-
public void trackDispatchesWhenEventHasLaunchedAndRunningExperiments() throws Exception {
1274-
EventType eventType = datafileVersion >= 4 ?
1275-
noAudienceProjectConfig.getEventNameMapping().get(EVENT_BASIC_EVENT_KEY) :
1276-
noAudienceProjectConfig.getEventNameMapping().get("event_with_launched_and_running_experiments");
1277-
1278-
// The event has 1 launched experiment and 1 running experiment.
1279-
// It should send a track event with the running experiment
1280-
Optimizely optimizely = optimizelyBuilder.withConfig(noAudienceProjectConfig).build();
1281-
optimizely.track(eventType.getKey(), genericUserId);
1282-
eventHandler.expectConversion(eventType.getKey(), genericUserId);
1283-
}
1284-
12851266
/**
12861267
* Verify that an event is dispatched even if a user doesn't satisfy audience conditions for an experiment.
12871268
*/

core-api/src/test/java/com/optimizely/ab/config/PollingProjectConfigManagerTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.optimizely.ab.notification.UpdateConfigNotification;
2121
import org.junit.After;
2222
import org.junit.Before;
23+
import org.junit.Ignore;
2324
import org.junit.Test;
2425

2526
import java.util.concurrent.CountDownLatch;
@@ -102,6 +103,7 @@ public void testBlockingGetConfigWithDefault() throws Exception {
102103
}
103104

104105
@Test
106+
@Ignore("flaky")
105107
public void testBlockingGetConfigWithTimeout() throws Exception {
106108
testProjectConfigManager.start();
107109
assertNull(testProjectConfigManager.getConfig());

0 commit comments

Comments
 (0)