Skip to content

Commit 320cb2b

Browse files
author
Mike Davis
committed
Some PR feedback changes.
1 parent 0e72ee2 commit 320cb2b

File tree

3 files changed

+39
-28
lines changed

3 files changed

+39
-28
lines changed

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

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -568,21 +568,6 @@ public void activateWithUnknownExperimentKeyAndNoOpErrorHandler() throws Excepti
568568
assertNull(actualVariation);
569569
}
570570

571-
/**
572-
* Verify that {@link Optimizely#activate(String, String)} handles the case where an unknown experiment
573-
* (i.e., not in the config) is passed through and a {@link RaiseExceptionErrorHandler} is provided.
574-
* DUPE? I think this is testing RaiseExceptionErrorHandler.
575-
*/
576-
@Test
577-
public void activateWithUnknownExperimentKeyAndRaiseExceptionErrorHandler() throws Exception {
578-
thrown.expect(UnknownExperimentException.class);
579-
580-
Experiment unknownExperiment = createUnknownExperiment();
581-
582-
Optimizely optimizely = optimizelyBuilder.withErrorHandler(new RaiseExceptionErrorHandler()).build();
583-
optimizely.activate(unknownExperiment.getKey(), testUserId);
584-
}
585-
586571
/**
587572
* Verify that {@link Optimizely#activate(String, String, Map)} passes through attributes.
588573
*/
@@ -631,10 +616,9 @@ public void activateWithTypedAttributes() throws Exception {
631616
* Verify that {@link Optimizely#activate(String, String, Map<String, String>)} handles the case
632617
* where an unknown attribute (i.e., not in the config) is passed through.
633618
* <p>
634-
* In this case, the activate call should not remove the unknown attribute from the given map.
619+
* In this case, the eventual payload will NOT include the unknownAttribute
635620
*/
636621
@Test
637-
@Ignore("Kind of a silly test since the event factory strips these unknownAttributes out before sending.")
638622
@SuppressWarnings("unchecked")
639623
public void activateWithUnknownAttribute() throws Exception {
640624
Experiment activatedExperiment = validProjectConfig.getExperiments().get(0);
@@ -643,20 +627,14 @@ public void activateWithUnknownAttribute() throws Exception {
643627
Map<String, String> testUserAttributes = new HashMap<>();
644628
testUserAttributes.put("unknownAttribute", "dimValue");
645629

646-
if (datafileVersion >= 4) {
647-
testUserAttributes.put(ATTRIBUTE_HOUSE_KEY, AUDIENCE_GRYFFINDOR_VALUE);
648-
} else {
649-
testUserAttributes.put("browser_type", "chrome");
650-
}
651-
652630
logbackVerifier.expectMessage(Level.INFO, "Activating user \"userId\" in experiment \"" +
653631
activatedExperiment.getKey() + "\".");
654632

655633
Optimizely optimizely = optimizelyBuilder.withErrorHandler(new RaiseExceptionErrorHandler()).build();
656634
Variation actualVariation = optimizely.activate(activatedExperiment.getKey(), testUserId, testUserAttributes);
657635
assertThat(actualVariation, is(bucketedVariation));
658636

659-
eventHandler.expectImpression(activatedExperiment.getId(), actualVariation.getId(), testUserId, testUserAttributes);
637+
eventHandler.expectImpression(activatedExperiment.getId(), actualVariation.getId(), testUserId);
660638
}
661639

662640
/**
@@ -959,7 +937,6 @@ public void activateExperimentStatusPrecedesForcedVariation() throws Exception {
959937
* {@link EventHandler#dispatchEvent(LogEvent)} gracefully.
960938
*/
961939
@Test
962-
@Ignore("Not sure why this is broken")
963940
public void activateDispatchEventThrowsException() throws Exception {
964941
Experiment experiment = noAudienceProjectConfig.getExperiments().get(0);
965942

@@ -1288,7 +1265,6 @@ public void trackEventWithNoValidExperiments() throws Exception {
12881265
* {@link EventHandler#dispatchEvent(LogEvent)} gracefully.
12891266
*/
12901267
@Test
1291-
@Ignore("Not sure why this is failing ATM.")
12921268
public void trackDispatchEventThrowsException() throws Exception {
12931269
EventType eventType = noAudienceProjectConfig.getEventTypes().get(0);
12941270

@@ -1305,7 +1281,6 @@ public void trackDispatchEventThrowsException() throws Exception {
13051281
* dispatches events even if the event links only to launched experiments
13061282
*/
13071283
@Test
1308-
// @Ignore("Is this a bug??")
13091284
public void trackDoesNotSendEventWhenExperimentsAreLaunchedOnly() throws Exception {
13101285
EventType eventType = datafileVersion >= 4 ?
13111286
noAudienceProjectConfig.getEventNameMapping().get(EVENT_LAUNCHED_EXPERIMENT_ONLY_KEY) :
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
*
3+
* Copyright 2019 Optimizely and contributors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package com.optimizely.ab.error;
18+
19+
import com.optimizely.ab.OptimizelyRuntimeException;
20+
import org.junit.Before;
21+
import org.junit.Test;
22+
23+
public class RaiseExceptionErrorHandlerTest {
24+
25+
private RaiseExceptionErrorHandler errorHandler;
26+
27+
@Before
28+
public void setUp() throws Exception {
29+
errorHandler = new RaiseExceptionErrorHandler();
30+
}
31+
32+
@Test(expected = OptimizelyRuntimeException.class)
33+
public void handleError() {
34+
errorHandler.handleError(new OptimizelyRuntimeException());
35+
}
36+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
*
3-
* Copyright 2016-2017, 2019 Optimizely and contributors
3+
* Copyright 2016-2017 Optimizely and contributors
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)