Skip to content

Commit 1f4d2f2

Browse files
committed
Fixes SwitcherTest when input not provided for evaluation (#316)
1 parent 5a193d1 commit 1f4d2f2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/main/java/com/github/switcherapi/client/model/response/CriteriaResponse.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ public class CriteriaResponse {
3030
protected Map<String, List<String>> entryWhen;
3131

3232
public CriteriaResponse() {
33+
entryWhen = new HashMap<>();
3334
}
3435

3536
public CriteriaResponse(final boolean result, final String reason, final Switcher switcher) {
37+
this();
3638
this.result = result;
3739
this.reason = reason;
3840
this.switcherKey = switcher.getSwitcherKey();
@@ -55,7 +57,7 @@ public CriteriaResponse buildFromSwitcher(Switcher switcher) {
5557
}
5658

5759
private boolean isEntryMatching(Entry inputEntry) {
58-
return entryWhen.containsKey(inputEntry.getStrategy()) &&
60+
return entryWhen.isEmpty() || entryWhen.containsKey(inputEntry.getStrategy()) &&
5961
entryWhen.get(inputEntry.getStrategy()).contains(inputEntry.getInput());
6062
}
6163

@@ -117,10 +119,6 @@ public CriteriaResponse when(StrategyValidator strategy, String input) {
117119
}
118120

119121
public CriteriaResponse when(StrategyValidator strategy, List<String> inputs) {
120-
if (entryWhen == null) {
121-
entryWhen = new HashMap<>();
122-
}
123-
124122
entryWhen.put(strategy.toString(), inputs);
125123
return this;
126124
}

0 commit comments

Comments
 (0)