Skip to content

Commit f55a318

Browse files
mnoman09mikeproeng37
authored andcommitted
Removed sorting and its unit test (#177)
1 parent 00c2312 commit f55a318

File tree

2 files changed

+1
-35
lines changed

2 files changed

+1
-35
lines changed

core-api/src/main/java/com/optimizely/ab/Optimizely.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
import com.optimizely.ab.event.internal.BuildVersionInfo;
3939
import com.optimizely.ab.event.internal.EventBuilder;
4040
import com.optimizely.ab.event.internal.payload.EventBatch.ClientEngine;
41-
import com.optimizely.ab.internal.EventTagUtils;
4241
import com.optimizely.ab.notification.NotificationCenter;
43-
import com.optimizely.ab.notification.NotificationListener;
4442
import org.slf4j.Logger;
4543
import org.slf4j.LoggerFactory;
4644

@@ -600,7 +598,7 @@ public List<String> getEnabledFeatures(@Nonnull String userId,@Nonnull Map<Strin
600598
if(isFeatureEnabled(featureKey, userId, attributes))
601599
enabledFeaturesList.add(featureKey);
602600
}
603-
Collections.sort(enabledFeaturesList);
601+
604602
return enabledFeaturesList;
605603
}
606604

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import ch.qos.logback.classic.Level;
1919
import com.google.common.collect.ImmutableMap;
20-
import com.google.common.collect.Ordering;
2120
import com.optimizely.ab.bucketing.Bucketer;
2221
import com.optimizely.ab.bucketing.DecisionService;
2322
import com.optimizely.ab.bucketing.FeatureDecision;
@@ -3393,37 +3392,6 @@ public void getEnabledFeatureWithValidUserId() throws ConfigParseException{
33933392

33943393
}
33953394

3396-
/**
3397-
* Verify {@link Optimizely#getEnabledFeatures(String, Map)} calls into
3398-
* {@link Optimizely#isFeatureEnabled(String, String, Map)} for each featureFlag
3399-
* return sorted List of FeatureFlags
3400-
* Also checks that the orignal list directly from projectConfig is unsorted
3401-
*/
3402-
@Test
3403-
public void getEnabledFeatureCheckingListIsSorted() throws ConfigParseException{
3404-
assumeTrue(datafileVersion >= Integer.parseInt(ProjectConfig.Version.V4.toString()));
3405-
3406-
Optimizely spyOptimizely = spy(Optimizely.builder(validDatafile, mockEventHandler)
3407-
.withConfig(validProjectConfig)
3408-
.build());
3409-
ArrayList<String> featureFlagsSortedList = (ArrayList<String>) spyOptimizely.getEnabledFeatures(genericUserId,
3410-
new HashMap<String, String>());
3411-
assertFalse(featureFlagsSortedList.isEmpty());
3412-
3413-
//To get Unsorted list directly from project config
3414-
List<String> unSortedFeaturesListFromProjectConfig = new ArrayList<String>();
3415-
for (FeatureFlag featureFlag : spyOptimizely.projectConfig.getFeatureFlags()){
3416-
String featureKey = featureFlag.getKey();
3417-
unSortedFeaturesListFromProjectConfig.add(featureKey);
3418-
}
3419-
3420-
//unSortedFeaturesListFromProjectConfig will retain only the elements which are also contained in featureFlagsSortedList.
3421-
unSortedFeaturesListFromProjectConfig.retainAll(featureFlagsSortedList);
3422-
assertFalse(Ordering.natural().isOrdered(unSortedFeaturesListFromProjectConfig));
3423-
3424-
assertTrue(Ordering.natural().isOrdered(featureFlagsSortedList));
3425-
}
3426-
34273395
/**
34283396
* Verify {@link Optimizely#getEnabledFeatures(String, Map)} calls into
34293397
* {@link Optimizely#isFeatureEnabled(String, String, Map)} for each featureFlag sending

0 commit comments

Comments
 (0)