Skip to content

Commit d54f43b

Browse files
committed
prepatch: Fixed code smells
1 parent 98d39ba commit d54f43b

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/main/java/com/github/petruki/switcher/client/facade/ClientOfflineServiceFacade.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ private boolean processNumeric(final Strategy strategy, final Entry switcherInpu
267267
final double numericSecondValue = NumberUtils.createNumber(strategy.getValues()[1]).doubleValue();
268268
return numericInput >= numericFirstValue && numericFirstValue <= numericSecondValue;
269269
}
270+
break;
271+
default:
272+
throw new SwitcherInvalidOperationException(strategy.getOperation(), strategy.getStrategy());
270273
}
271274

272275
throw new SwitcherInvalidOperationException(strategy.getOperation(), strategy.getStrategy());

src/test/java/com/github/petruki/switcher/client/SwitcherOfflineTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,16 @@ public void offlineShouldReturnError_InvalidSnapshotOperationForNumeric() throws
672672
switcher.isItOn();
673673
}
674674

675+
@Test(expected = SwitcherInvalidOperationException.class)
676+
public void offlineShouldReturnError_InvalidValuesForNumericValidation() throws Exception {
677+
properties.put(SwitcherContextParam.SNAPSHOT_FILE, SNAPSHOTS_LOCAL + "/snapshot_fixture3.json");
678+
SwitcherFactory.buildContext(properties, true);
679+
680+
Switcher switcher = SwitcherFactory.getSwitcher("USECASE19");
681+
switcher.prepareEntry(new Entry(Entry.NUMERIC, "1"));
682+
switcher.isItOn();
683+
}
684+
675685
@Test(expected = SwitcherInvalidOperationException.class)
676686
public void offlineShouldReturnError_InvalidSnapshotOperationForDate() throws Exception {
677687
properties.put(SwitcherContextParam.SNAPSHOT_FILE, SNAPSHOTS_LOCAL + "/snapshot_fixture3.json");

src/test/resources/snapshot_fixture3.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,22 @@
138138
]
139139
}
140140
]
141+
},
142+
{
143+
"key": "USECASE19",
144+
"description": "It contains an invalid number of values for the given operation",
145+
"activated": true,
146+
"components": ["switcher-client"],
147+
"strategies": [
148+
{
149+
"strategy": "NUMERIC_VALIDATION",
150+
"activated": true,
151+
"operation": "BETWEEN",
152+
"values": [
153+
"1"
154+
]
155+
}
156+
]
141157
}
142158
]
143159
}

0 commit comments

Comments
 (0)