Skip to content

Commit b61b73e

Browse files
author
Josh Deffibaugh
committed
Remove unneeded public api and fixes doc warnings
1 parent c629c49 commit b61b73e

File tree

2 files changed

+46
-116
lines changed

2 files changed

+46
-116
lines changed

android-sdk/src/main/java/com/optimizely/ab/android/sdk/AndroidOptimizely.java

Lines changed: 46 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.optimizely.ab.android.sdk;
1718

1819
import android.app.Activity;
@@ -21,13 +22,10 @@
2122

2223
import com.optimizely.ab.Optimizely;
2324
import com.optimizely.ab.UnknownEventTypeException;
24-
import com.optimizely.ab.UnknownExperimentException;
2525
import com.optimizely.ab.config.Experiment;
26-
import com.optimizely.ab.config.ProjectConfig;
2726
import com.optimizely.ab.config.Variation;
2827

2928
import org.slf4j.Logger;
30-
import org.slf4j.LoggerFactory;
3129

3230
import java.util.Map;
3331

@@ -52,10 +50,14 @@ public class AndroidOptimizely {
5250
}
5351

5452
/**
53+
* Activate an experiment for a user
5554
* @see Optimizely#activate(String, String)
55+
* @param experimentKey the experiment key
56+
* @param userId the user id
57+
* @return the {@link Variation} the user bucketed into
5658
*/
5759
public @Nullable Variation activate(@NonNull String experimentKey,
58-
@NonNull String userId) throws UnknownExperimentException {
60+
@NonNull String userId) {
5961
if (optimizely != null) {
6062
return optimizely.activate(experimentKey, userId);
6163
} else {
@@ -66,11 +68,17 @@ public class AndroidOptimizely {
6668
}
6769

6870
/**
69-
* @see Optimizely#activate(String, String, Map)
71+
* Activate an experiment for a user
72+
* @see Optimizely#activate(String, String)
73+
* @param experimentKey the experiment key
74+
* @param userId the user id
75+
* @param attributes a map of attributes about the user
76+
* @return the {@link Variation} the user bucketed into
7077
*/
78+
@SuppressWarnings("WeakerAccess")
7179
public @Nullable Variation activate(@NonNull String experimentKey,
7280
@NonNull String userId,
73-
@NonNull Map<String, String> attributes) throws UnknownExperimentException {
81+
@NonNull Map<String, String> attributes) {
7482
if (optimizely != null) {
7583
return optimizely.activate(experimentKey, userId, attributes);
7684
} else {
@@ -81,37 +89,12 @@ public class AndroidOptimizely {
8189
}
8290

8391
/**
84-
* @see Optimizely#activate(Experiment, String)
85-
*/
86-
public @Nullable Variation activate(@NonNull Experiment experiment,
87-
@NonNull String userId) {
88-
if (optimizely != null) {
89-
return optimizely.activate(experiment, userId);
90-
} else {
91-
logger.warn("Optimizely is not initialized, can't activate experiment {} for user {}",
92-
experiment.getKey(), userId);
93-
return null;
94-
}
95-
}
96-
97-
public @Nullable Variation activate(@NonNull Experiment experiment,
98-
@NonNull String userId,
99-
@NonNull Map<String, String> attributes) {
100-
if (optimizely != null) {
101-
return optimizely.activate(experiment, userId, attributes);
102-
} else {
103-
logger.warn("Optimizely is not initialized, can't activate experiment {} for user {} " +
104-
"with attributes", experiment.getKey(), userId);
105-
return null;
106-
}
107-
}
108-
109-
110-
/**
111-
* @see Optimizely#track(String, String)
92+
* Track an event for a user
93+
* @param eventName the name of the event
94+
* @param userId the user id
11295
*/
11396
public void track(@NonNull String eventName,
114-
@NonNull String userId) throws UnknownEventTypeException {
97+
@NonNull String userId) {
11598
if (optimizely != null) {
11699
optimizely.track(eventName, userId);
117100
} else {
@@ -120,7 +103,10 @@ public void track(@NonNull String eventName,
120103
}
121104

122105
/**
123-
* @see Optimizely#track(String, String, Map)
106+
* Track an event for a user
107+
* @param eventName the name of the event
108+
* @param userId the user id
109+
* @param attributes a map of attributes about the user
124110
*/
125111
public void track(@NonNull String eventName,
126112
@NonNull String userId,
@@ -134,7 +120,10 @@ public void track(@NonNull String eventName,
134120
}
135121

136122
/**
137-
* @see Optimizely#track(String, String, long)
123+
* Track an event for a user
124+
* @param eventName the name of the event
125+
* @param userId the user id
126+
* @param eventValue a value to tie to the event
138127
*/
139128
public void track(@NonNull String eventName,
140129
@NonNull String userId,
@@ -148,12 +137,17 @@ public void track(@NonNull String eventName,
148137
}
149138

150139
/**
151-
* @see Optimizely#track(String, String, Map, long)
140+
* Track an event for a user with attributes and a value
141+
* @see Optimizely#track(String, String, Map, Long)
142+
* @param eventName the String name of the event
143+
* @param userId the String user id
144+
* @param attributes the attributes of the event
145+
* @param eventValue the value of the event
152146
*/
153147
public void track(@NonNull String eventName,
154148
@NonNull String userId,
155149
@NonNull Map<String, String> attributes,
156-
long eventValue) throws UnknownEventTypeException {
150+
long eventValue) {
157151
if (optimizely != null) {
158152
optimizely.track(eventName, userId, attributes, eventValue);
159153
} else {
@@ -162,26 +156,16 @@ public void track(@NonNull String eventName,
162156
}
163157
}
164158

165-
166159
/**
160+
* Get the variation the user is bucketed into
167161
* @see Optimizely#getVariation(Experiment, String)
162+
* @param experimentKey a String experiment key
163+
* @param userId a String user id
164+
* @return a variation for the provided experiment key and user id
168165
*/
169-
public @Nullable Variation getVariation(@NonNull Experiment experiment,
170-
@NonNull String userId) throws UnknownExperimentException {
171-
if (optimizely != null) {
172-
return optimizely.getVariation(experiment, userId);
173-
} else {
174-
logger.warn("Optimizely is not initialized, could not get variation for experiment {} " +
175-
"for user {}", experiment.getKey(), userId);
176-
return null;
177-
}
178-
}
179-
180-
/**
181-
* @see Optimizely#getVariation(String, String)
182-
*/
166+
@SuppressWarnings("WeakerAccess")
183167
public @Nullable Variation getVariation(@NonNull String experimentKey,
184-
@NonNull String userId) throws UnknownExperimentException{
168+
@NonNull String userId) {
185169
if (optimizely != null) {
186170
return optimizely.getVariation(experimentKey, userId);
187171
} else {
@@ -192,8 +176,14 @@ public void track(@NonNull String eventName,
192176
}
193177

194178
/**
195-
* @see Optimizely#getVariation(String, String, Map)
179+
* Get the variation the user is bucketed into
180+
* @see Optimizely#getVariation(Experiment, String)
181+
* @param experimentKey a String experiment key
182+
* @param userId a String userId
183+
* @param attributes a map of attributes
184+
* @return the variation for the provided experiment key, user id, and attributes
196185
*/
186+
@SuppressWarnings("WeakerAccess")
197187
public @Nullable Variation getVariation(@NonNull String experimentKey,
198188
@NonNull String userId,
199189
@NonNull Map<String, String> attributes) {

android-sdk/src/test/java/com/optimizely/ab/android/sdk/AndroidOptimizelyTest.java

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.optimizely.ab.android.sdk;
1818

1919
import com.optimizely.ab.Optimizely;
20-
import com.optimizely.ab.config.Experiment;
2120

2221
import org.junit.Test;
2322
import org.junit.runner.RunWith;
@@ -27,9 +26,7 @@
2726

2827
import java.util.HashMap;
2928

30-
import static org.mockito.Mockito.mock;
3129
import static org.mockito.Mockito.verify;
32-
import static org.mockito.Mockito.when;
3330

3431
/**
3532
* Tests for {@link AndroidOptimizely}
@@ -71,44 +68,6 @@ public void testBadActivation2() {
7168
"for user {} with attributes", "1", "1");
7269
}
7370

74-
@Test
75-
public void testGoodActivation3() {
76-
AndroidOptimizely androidOptimizely = new AndroidOptimizely(optimizely, logger);
77-
final Experiment experiment = mock(Experiment.class);
78-
when(experiment.getKey()).thenReturn("1");
79-
androidOptimizely.activate(experiment, "1");
80-
verify(optimizely).activate(experiment, "1");
81-
}
82-
83-
@Test
84-
public void testBadActivation3() {
85-
AndroidOptimizely androidOptimizely = new AndroidOptimizely(null, logger);
86-
final Experiment experiment = mock(Experiment.class);
87-
when(experiment.getKey()).thenReturn("1");
88-
androidOptimizely.activate(experiment, "1");
89-
verify(logger).warn("Optimizely is not initialized, can't activate experiment {} " +
90-
"for user {}", "1", "1");
91-
}
92-
93-
@Test
94-
public void testGoodActivation4() {
95-
AndroidOptimizely androidOptimizely = new AndroidOptimizely(optimizely, logger);
96-
final Experiment experiment = mock(Experiment.class);
97-
when(experiment.getKey()).thenReturn("1");
98-
final HashMap<String, String> attributes = new HashMap<>();
99-
androidOptimizely.activate(experiment, "1", attributes);
100-
verify(optimizely).activate(experiment, "1", attributes);
101-
}
102-
103-
@Test
104-
public void testBadActivation4() {
105-
AndroidOptimizely androidOptimizely = new AndroidOptimizely(null, logger);
106-
final Experiment experiment = mock(Experiment.class);
107-
when(experiment.getKey()).thenReturn("1");
108-
androidOptimizely.activate(experiment, "1", new HashMap<String, String>());
109-
verify(logger).warn("Optimizely is not initialized, can't activate experiment {} " +
110-
"for user {} with attributes", "1", "1");
111-
}
11271

11372
@Test
11473
public void testGoodTrack1() {
@@ -188,25 +147,6 @@ public void testBadGetVariation1() {
188147
"for user {}", "1", "1");
189148
}
190149

191-
@Test
192-
public void testGoodGetVariation2() {
193-
AndroidOptimizely androidOptimizely = new AndroidOptimizely(optimizely, logger);
194-
Experiment experiment = mock(Experiment.class);
195-
when(experiment.getKey()).thenReturn("1");
196-
androidOptimizely.getVariation(experiment, "1");
197-
verify(optimizely).getVariation(experiment, "1");
198-
}
199-
200-
@Test
201-
public void testBadGetVariation2() {
202-
AndroidOptimizely androidOptimizely = new AndroidOptimizely(null, logger);
203-
Experiment experiment = mock(Experiment.class);
204-
when(experiment.getKey()).thenReturn("1");
205-
androidOptimizely.getVariation(experiment, "1");
206-
verify(logger).warn("Optimizely is not initialized, could not get variation for experiment {} " +
207-
"for user {}", experiment.getKey(), "1");
208-
}
209-
210150
@Test
211151
public void testGoodGetVariation3() {
212152
AndroidOptimizely androidOptimizely = new AndroidOptimizely(optimizely, logger);

0 commit comments

Comments
 (0)