Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/master-2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build-scan:
name: SonarCloud Scan
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
Expand All @@ -35,7 +35,7 @@ jobs:
fail-fast: false
matrix:
java: ['11', '17', '21']
os: [ubuntu-latest, windows-latest]
os: [ubuntu-22.04, windows-latest]
runs-on: ${{ matrix.os }}

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build-scan:
name: SonarCloud Scan
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
Expand All @@ -35,7 +35,7 @@ jobs:
fail-fast: false
matrix:
java: ['8', '11', '17', '21']
os: [ubuntu-latest, windows-latest]
os: [ubuntu-22.04, windows-latest]
runs-on: ${{ matrix.os }}

steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
fail-fast: false
matrix:
java: ['11', '17', '21']
os: [ubuntu-latest, windows-latest]
os: [ubuntu-22.04, windows-latest]
runs-on: ${{ matrix.os }}

steps:
Expand Down Expand Up @@ -39,7 +39,7 @@ jobs:
publish:
name: Publish Release
needs: [build-test]
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
sonar-analysis:
name: SonarCloud Analysis for PR
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: Get PR details
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
required: true
default: '17'
os:
description: 'Operating System (ubuntu-20.04, ubuntu-latest, windows-latest)'
description: 'Operating System (ubuntu-22.04, ubuntu-latest, windows-latest)'
required: true
default: 'ubuntu-latest'

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<groupId>com.switcherapi</groupId>
<artifactId>switcher-client</artifactId>
<packaging>jar</packaging>
<version>2.4.0</version>
<version>2.4.1-SNAPSHOT</version>

<name>Switcher Client</name>
<description>Switcher Client SDK for working with Switcher API</description>
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/com/switcherapi/client/model/Entry.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,29 @@ public class Entry {
private final String strategy;

private final String input;
private Entry(final String strategy, final String input) {

public Entry(String strategy, String input) {
this.strategy = strategy;
this.input = input;
}
private Entry(final StrategyValidator strategy, final String input) {

public Entry(StrategyValidator strategy, String input) {
this(strategy.toString(), input);
}

/**
* Creates a new Entry with the given strategy and input.
*
* @param strategy Validator used to evaluate the Switcher
* @param input follow the required format documented into each strategy type
* @return new Entry
* @see StrategyValidator
*/
public static Entry build(final StrategyValidator strategy, final String input) {
public static Entry of(StrategyValidator strategy, String input) {
return new Entry(strategy, input);
}
public static Entry build(final String strategy, final String input) {

public static Entry of(String strategy, String input) {
return new Entry(strategy, input);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public SwitcherBuilder restrictRelay(boolean restrictRelay) {
*/
public SwitcherBuilder check(StrategyValidator strategy, String input) {
if (StringUtils.isNotBlank(input)) {
entry.add(Entry.build(strategy, input));
entry.add(Entry.of(strategy, input));
}

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"methods": [
{
"name": "<init>",
"parameterTypes": []
"parameterTypes": [
"java.lang.String",
"java.lang.String"
]
}
]
},
Expand All @@ -21,7 +24,9 @@
"methods": [
{
"name": "<init>",
"parameterTypes": []
"parameterTypes": [
"com.switcherapi.client.model.Entry[]"
]
}
]
},
Expand All @@ -34,7 +39,14 @@
"methods": [
{
"name": "<init>",
"parameterTypes": []
"parameterTypes": [
"java.lang.String",
"java.lang.String",
"boolean",
"com.switcherapi.client.model.criteria.StrategyConfig[]",
"java.lang.String[]",
"com.switcherapi.client.model.criteria.Relay"
]
}
]
},
Expand Down Expand Up @@ -73,7 +85,12 @@
"methods": [
{
"name": "<init>",
"parameterTypes": []
"parameterTypes": [
"java.lang.String",
"java.lang.String",
"boolean",
"com.switcherapi.client.model.criteria.Config[]"
]
}
]
},
Expand All @@ -99,7 +116,29 @@
"methods": [
{
"name": "<init>",
"parameterTypes": []
"parameterTypes": [
"java.lang.String",
"java.lang.String",
"java.lang.String",
"boolean",
"java.lang.String[]"
]
}
]
},
{
"name": "com.switcherapi.client.model.criteria.Relay",
"condition": {
"typeReachable": "com.switcherapi.client.model.criteria.Snapshot"
},
"allDeclaredFields": true,
"methods": [
{
"name": "<init>",
"parameterTypes": [
"java.lang.String",
"boolean"
]
}
]
},
Expand Down
22 changes: 11 additions & 11 deletions src/test/java/com/switcherapi/client/SwitcherLocal1Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static Stream<Arguments> dateTestArguments() {
@MethodSource("dateTestArguments")
void localShouldTest_dateValidation(String useCaseKey, String input, boolean expected) {
SwitcherRequest switcher = Switchers.getSwitcher(useCaseKey);
Entry entry = Entry.build(StrategyValidator.DATE, input);
Entry entry = Entry.of(StrategyValidator.DATE, input);

assertEquals(expected, switcher.prepareEntry(entry).isItOn());
}
Expand All @@ -130,7 +130,7 @@ void localShouldTestChained_dateValidation(String useCaseKey, String input, bool
@Test
void localShouldReturnFalse_dateValidationWrongFormat() {
SwitcherRequest switcher = Switchers.getSwitcher(Switchers.USECASE33);
Entry input = Entry.build(StrategyValidator.DATE, "2019/121/13");
Entry input = Entry.of(StrategyValidator.DATE, "2019/121/13");

switcher.prepareEntry(input);
assertThrows(SwitcherInvalidTimeFormat.class, switcher::isItOn);
Expand All @@ -157,7 +157,7 @@ static Stream<Arguments> valueTestArguments() {
@MethodSource("valueTestArguments")
void localShouldTest_valueValidation(String useCaseKey, String input, boolean expected) {
SwitcherRequest switcher = Switchers.getSwitcher(useCaseKey);
Entry entry = Entry.build(StrategyValidator.VALUE, input);
Entry entry = Entry.of(StrategyValidator.VALUE, input);

switcher.prepareEntry(entry);
assertEquals(expected, switcher.isItOn());
Expand Down Expand Up @@ -198,7 +198,7 @@ static Stream<Arguments> numericTestArguments() {
@MethodSource("numericTestArguments")
void localShouldTest_numericValidation(String useCaseKey, String input, boolean expected) {
SwitcherRequest switcher = Switchers.getSwitcher(useCaseKey);
Entry entry = Entry.build(StrategyValidator.NUMERIC, input);
Entry entry = Entry.of(StrategyValidator.NUMERIC, input);

switcher.prepareEntry(entry);
assertEquals(expected, switcher.isItOn());
Expand All @@ -215,7 +215,7 @@ void localShouldTestChained_numericValidation(String useCaseKey, String input, b
@Test
void localShouldReturnException_invalidNumericInput() {
SwitcherRequest switcher = Switchers.getSwitcher(Switchers.USECASE81);
Entry input = Entry.build(StrategyValidator.NUMERIC, "INVALID_NUMBER");
Entry input = Entry.of(StrategyValidator.NUMERIC, "INVALID_NUMBER");

switcher.prepareEntry(input);
assertThrows(SwitcherInvalidNumericFormat.class, switcher::isItOn);
Expand All @@ -239,7 +239,7 @@ static Stream<Arguments> timeTestArguments() {
@MethodSource("timeTestArguments")
void localShouldTest_timeValidation(String useCaseKey, String input, boolean expected) {
SwitcherRequest switcher = Switchers.getSwitcher(useCaseKey);
Entry entry = Entry.build(StrategyValidator.TIME, input);
Entry entry = Entry.of(StrategyValidator.TIME, input);

switcher.prepareEntry(entry);
assertEquals(expected, switcher.isItOn());
Expand All @@ -255,7 +255,7 @@ void localShouldTestChained_timeValidation(String useCaseKey, String input, bool
@Test
void localShouldReturnFalse_timeValidationWrongFormat() {
SwitcherRequest switcher = Switchers.getSwitcher(Switchers.USECASE53);
Entry input = Entry.build(StrategyValidator.TIME, "2019-12-10");
Entry input = Entry.of(StrategyValidator.TIME, "2019-12-10");

switcher.prepareEntry(input);
assertThrows(SwitcherInvalidTimeFormat.class, switcher::isItOn);
Expand All @@ -279,7 +279,7 @@ static Stream<Arguments> networkTestArguments() {
@MethodSource("networkTestArguments")
void localShouldTest_networkValidation(String useCaseKey, String input, boolean expected) {
SwitcherRequest switcher = Switchers.getSwitcher(useCaseKey);
Entry entry = Entry.build(StrategyValidator.NETWORK, input);
Entry entry = Entry.of(StrategyValidator.NETWORK, input);

switcher.prepareEntry(entry);
assertEquals(expected, switcher.isItOn());
Expand All @@ -301,7 +301,7 @@ void localShouldReturnFalse_strategyRequiresInput() {
@Test
void localShouldReturnFalse_invalidStrategyInput() {
SwitcherRequest switcher = Switchers.getSwitcher(Switchers.USECASE33);
switcher.prepareEntry(Entry.build(StrategyValidator.INVALID, "Value"));
switcher.prepareEntry(Entry.of(StrategyValidator.INVALID, "Value"));
assertFalse(switcher.isItOn());
}

Expand All @@ -328,7 +328,7 @@ static Stream<Arguments> regexTestArguments() {
@MethodSource("regexTestArguments")
void localShouldTest_regexValidation(String useCaseKey, String input, boolean expected) {
SwitcherRequest switcher = Switchers.getSwitcher(useCaseKey);
Entry entry = Entry.build(StrategyValidator.REGEX, input);
Entry entry = Entry.of(StrategyValidator.REGEX, input);

switcher.prepareEntry(entry);
assertEquals(expected, switcher.isItOn());
Expand Down Expand Up @@ -357,7 +357,7 @@ static Stream<Arguments> payloadTestArguments() {
@MethodSource("payloadTestArguments")
void localShouldTest_payloadValidation(String useCaseKey, String input, boolean expected) {
SwitcherRequest switcher = Switchers.getSwitcher(useCaseKey);
Entry entry = Entry.build(StrategyValidator.PAYLOAD, input);
Entry entry = Entry.of(StrategyValidator.PAYLOAD, input);

switcher.prepareEntry(entry);
assertEquals(expected, switcher.isItOn());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static Stream<Arguments> failTestArguments() {
void localShouldReturnError(String useCaseKey, String strategyValidator,
String input, Class<SwitcherException> error) {
SwitcherRequest switcher = Switchers.getSwitcher(useCaseKey);
switcher.prepareEntry(Entry.build(strategyValidator, input));
switcher.prepareEntry(Entry.of(strategyValidator, input));

assertThrows(error, switcher::isItOn);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/switcherapi/client/model/ModelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class ModelTest {

@Test
void testModelEntry() {
Entry entry1 = Entry.build(StrategyValidator.DATE, "2019-12-10");
Entry entry2 = Entry.build(StrategyValidator.VALUE, "Value");
Entry entry1 = Entry.of(StrategyValidator.DATE, "2019-12-10");
Entry entry2 = Entry.of(StrategyValidator.VALUE, "Value");

assertNotEquals(true, entry1.equals(entry2));
assertNotNull(entry1.toString());
Expand Down
Loading
Loading