Skip to content

Commit

Permalink
Remove duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
gthea committed Sep 7, 2023
1 parent a0b9a08 commit 67fcd9d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,7 @@ public Map<String, String> getTreatmentsByFlagSet(@NonNull String flagSet, @Null
} catch (Exception exception) {
Logger.e(exception);

Map<String, String> result = new HashMap<>();
Set<String> namesByFlagSets = mSplitsStorage.getNamesByFlagSets(Collections.singletonList(flagSet));
for (String featureFlagName : namesByFlagSets) {
result.put(featureFlagName, Treatments.CONTROL);
}

return result;
return buildExceptionResult(Collections.singletonList(flagSet));
}
}

Expand All @@ -166,13 +160,7 @@ public Map<String, String> getTreatmentsByFlagSets(@NonNull List<String> flagSet
} catch (Exception exception) {
Logger.e(exception);

Map<String, String> result = new HashMap<>();
Set<String> namesByFlagSets = mSplitsStorage.getNamesByFlagSets(flagSets);
for (String featureFlagName : namesByFlagSets) {
result.put(featureFlagName, Treatments.CONTROL);
}

return result;
return buildExceptionResult(flagSets);
}
}

Expand All @@ -183,13 +171,7 @@ public Map<String, SplitResult> getTreatmentsWithConfigByFlagSet(@NonNull String
} catch (Exception exception) {
Logger.e(exception);

Map<String, SplitResult> result = new HashMap<>();
Set<String> namesByFlagSets = mSplitsStorage.getNamesByFlagSets(Collections.singletonList(flagSet));
for (String featureFlagName : namesByFlagSets) {
result.put(featureFlagName, new SplitResult(Treatments.CONTROL));
}

return result;
return buildExceptionResultWithConfig(Collections.singletonList(flagSet));
}
}

Expand All @@ -200,13 +182,7 @@ public Map<String, SplitResult> getTreatmentsWithConfigByFlagSets(@NonNull List<
} catch (Exception exception) {
Logger.e(exception);

Map<String, SplitResult> result = new HashMap<>();
Set<String> namesByFlagSets = mSplitsStorage.getNamesByFlagSets(flagSets);
for (String featureFlagName : namesByFlagSets) {
result.put(featureFlagName, new SplitResult(Treatments.CONTROL));
}

return result;
return buildExceptionResultWithConfig(flagSets);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -72,7 +73,7 @@ public void setUp() throws Exception {
splitClientConfig,
"api_key",
"test_database_name",
SplitFilter.bySet(Arrays.asList("set_1", "set_2"))
Collections.singletonList(SplitFilter.bySet(Arrays.asList("set_1", "set_2")))
);
}

Expand Down

0 comments on commit 67fcd9d

Please sign in to comment.