Skip to content

Commit 45755d2

Browse files
authored
Fixes #360 - updated reflect-config.json reachability metadata (#361)
* Fixes #360 - updated reflect-config.json reachability metadata * test: increased shouldStartAndKillWorker delay * test: increased shouldStartAndKillWorker delay * test-ci: update maven cache * test-ci: add coverage phase for matrix * test-ci: updated matrix to use ubuntu-22.04 * test-ci: updated all matrices to use ubuntu-22.04
1 parent 1076068 commit 45755d2

File tree

13 files changed

+132
-38
lines changed

13 files changed

+132
-38
lines changed

.github/workflows/master-2.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
build-scan:
1111
name: SonarCloud Scan
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-22.04
1313

1414
steps:
1515
- uses: actions/checkout@v4
@@ -35,7 +35,7 @@ jobs:
3535
fail-fast: false
3636
matrix:
3737
java: ['11', '17', '21']
38-
os: [ubuntu-latest, windows-latest]
38+
os: [ubuntu-22.04, windows-latest]
3939
runs-on: ${{ matrix.os }}
4040

4141
steps:

.github/workflows/master.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
jobs:
1010
build-scan:
1111
name: SonarCloud Scan
12-
runs-on: ubuntu-latest
12+
runs-on: ubuntu-22.04
1313

1414
steps:
1515
- uses: actions/checkout@v4
@@ -35,7 +35,7 @@ jobs:
3535
fail-fast: false
3636
matrix:
3737
java: ['8', '11', '17', '21']
38-
os: [ubuntu-latest, windows-latest]
38+
os: [ubuntu-22.04, windows-latest]
3939
runs-on: ${{ matrix.os }}
4040

4141
steps:

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
java: ['11', '17', '21']
14-
os: [ubuntu-latest, windows-latest]
14+
os: [ubuntu-22.04, windows-latest]
1515
runs-on: ${{ matrix.os }}
1616

1717
steps:
@@ -39,7 +39,7 @@ jobs:
3939
publish:
4040
name: Publish Release
4141
needs: [build-test]
42-
runs-on: ubuntu-latest
42+
runs-on: ubuntu-22.04
4343

4444
steps:
4545
- uses: actions/checkout@v4

.github/workflows/sonar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
jobs:
1212
sonar-analysis:
1313
name: SonarCloud Analysis for PR
14-
runs-on: ubuntu-latest
14+
runs-on: ubuntu-22.04
1515

1616
steps:
1717
- name: Get PR details

.github/workflows/staging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
required: true
1010
default: '17'
1111
os:
12-
description: 'Operating System (ubuntu-20.04, ubuntu-latest, windows-latest)'
12+
description: 'Operating System (ubuntu-22.04, ubuntu-latest, windows-latest)'
1313
required: true
1414
default: 'ubuntu-latest'
1515

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<groupId>com.switcherapi</groupId>
99
<artifactId>switcher-client</artifactId>
1010
<packaging>jar</packaging>
11-
<version>2.4.0</version>
11+
<version>2.4.1-SNAPSHOT</version>
1212

1313
<name>Switcher Client</name>
1414
<description>Switcher Client SDK for working with Switcher API</description>

src/main/java/com/switcherapi/client/model/Entry.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,29 @@ public class Entry {
1111
private final String strategy;
1212

1313
private final String input;
14-
15-
private Entry(final String strategy, final String input) {
14+
15+
public Entry(String strategy, String input) {
1616
this.strategy = strategy;
1717
this.input = input;
1818
}
19-
20-
private Entry(final StrategyValidator strategy, final String input) {
19+
20+
public Entry(StrategyValidator strategy, String input) {
2121
this(strategy.toString(), input);
2222
}
2323

2424
/**
25+
* Creates a new Entry with the given strategy and input.
26+
*
2527
* @param strategy Validator used to evaluate the Switcher
2628
* @param input follow the required format documented into each strategy type
2729
* @return new Entry
2830
* @see StrategyValidator
2931
*/
30-
public static Entry build(final StrategyValidator strategy, final String input) {
32+
public static Entry of(StrategyValidator strategy, String input) {
3133
return new Entry(strategy, input);
3234
}
33-
34-
public static Entry build(final String strategy, final String input) {
35+
36+
public static Entry of(String strategy, String input) {
3537
return new Entry(strategy, input);
3638
}
3739

src/main/java/com/switcherapi/client/model/SwitcherBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public SwitcherBuilder restrictRelay(boolean restrictRelay) {
9595
*/
9696
public SwitcherBuilder check(StrategyValidator strategy, String input) {
9797
if (StringUtils.isNotBlank(input)) {
98-
entry.add(Entry.build(strategy, input));
98+
entry.add(Entry.of(strategy, input));
9999
}
100100

101101
return this;

src/main/resources/META-INF/native-image/com.switcherapi/switcher-client/reflect-config.json

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
"methods": [
99
{
1010
"name": "<init>",
11-
"parameterTypes": []
11+
"parameterTypes": [
12+
"java.lang.String",
13+
"java.lang.String"
14+
]
1215
}
1316
]
1417
},
@@ -21,7 +24,9 @@
2124
"methods": [
2225
{
2326
"name": "<init>",
24-
"parameterTypes": []
27+
"parameterTypes": [
28+
"com.switcherapi.client.model.Entry[]"
29+
]
2530
}
2631
]
2732
},
@@ -34,7 +39,14 @@
3439
"methods": [
3540
{
3641
"name": "<init>",
37-
"parameterTypes": []
42+
"parameterTypes": [
43+
"java.lang.String",
44+
"java.lang.String",
45+
"boolean",
46+
"com.switcherapi.client.model.criteria.StrategyConfig[]",
47+
"java.lang.String[]",
48+
"com.switcherapi.client.model.criteria.Relay"
49+
]
3850
}
3951
]
4052
},
@@ -73,7 +85,12 @@
7385
"methods": [
7486
{
7587
"name": "<init>",
76-
"parameterTypes": []
88+
"parameterTypes": [
89+
"java.lang.String",
90+
"java.lang.String",
91+
"boolean",
92+
"com.switcherapi.client.model.criteria.Config[]"
93+
]
7794
}
7895
]
7996
},
@@ -99,7 +116,29 @@
99116
"methods": [
100117
{
101118
"name": "<init>",
102-
"parameterTypes": []
119+
"parameterTypes": [
120+
"java.lang.String",
121+
"java.lang.String",
122+
"java.lang.String",
123+
"boolean",
124+
"java.lang.String[]"
125+
]
126+
}
127+
]
128+
},
129+
{
130+
"name": "com.switcherapi.client.model.criteria.Relay",
131+
"condition": {
132+
"typeReachable": "com.switcherapi.client.model.criteria.Snapshot"
133+
},
134+
"allDeclaredFields": true,
135+
"methods": [
136+
{
137+
"name": "<init>",
138+
"parameterTypes": [
139+
"java.lang.String",
140+
"boolean"
141+
]
103142
}
104143
]
105144
},

src/test/java/com/switcherapi/client/SwitcherLocal1Test.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static Stream<Arguments> dateTestArguments() {
115115
@MethodSource("dateTestArguments")
116116
void localShouldTest_dateValidation(String useCaseKey, String input, boolean expected) {
117117
SwitcherRequest switcher = Switchers.getSwitcher(useCaseKey);
118-
Entry entry = Entry.build(StrategyValidator.DATE, input);
118+
Entry entry = Entry.of(StrategyValidator.DATE, input);
119119

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

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

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

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

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

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

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

284284
switcher.prepareEntry(entry);
285285
assertEquals(expected, switcher.isItOn());
@@ -301,7 +301,7 @@ void localShouldReturnFalse_strategyRequiresInput() {
301301
@Test
302302
void localShouldReturnFalse_invalidStrategyInput() {
303303
SwitcherRequest switcher = Switchers.getSwitcher(Switchers.USECASE33);
304-
switcher.prepareEntry(Entry.build(StrategyValidator.INVALID, "Value"));
304+
switcher.prepareEntry(Entry.of(StrategyValidator.INVALID, "Value"));
305305
assertFalse(switcher.isItOn());
306306
}
307307

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

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

362362
switcher.prepareEntry(entry);
363363
assertEquals(expected, switcher.isItOn());

0 commit comments

Comments
 (0)