Skip to content

Commit bf7c814

Browse files
authored
feat: removed data attribute from snapshot (#365) (#366)
1 parent d030d08 commit bf7c814

File tree

22 files changed

+1142
-1187
lines changed

22 files changed

+1142
-1187
lines changed

pom.xml

Lines changed: 5 additions & 5 deletions
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>1.8.2-SNAPSHOT</version>
11+
<version>1.9.0-SNAPSHOT</version>
1212

1313
<name>Switcher Client</name>
1414
<description>Switcher Client SDK for working with Switcher API</description>
@@ -65,19 +65,19 @@
6565

6666
<!-- test -->
6767
<okhttp.version>5.1.0</okhttp.version>
68-
<junit-jupiter.version>5.13.4</junit-jupiter.version>
68+
<junit-jupiter.version>5.14.0</junit-jupiter.version>
6969
<junit-pioneer.version>1.9.1</junit-pioneer.version>
70-
<junit-platform-launcher.version>1.13.4</junit-platform-launcher.version>
70+
<junit-platform-launcher.version>1.14.0</junit-platform-launcher.version>
7171

7272
<!-- Plugins -->
73-
<maven-compiler-plugin.version>3.14.0</maven-compiler-plugin.version>
73+
<maven-compiler-plugin.version>3.14.1</maven-compiler-plugin.version>
7474
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
7575
<maven-javadoc-plugin.version>3.12.0</maven-javadoc-plugin.version>
7676
<maven-surefire-plugin.version>3.5.4</maven-surefire-plugin.version>
7777
<maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
7878
<sonar-maven-plugin.version>5.2.0.4988</sonar-maven-plugin.version>
7979
<jacoco-maven-plugin.version>0.8.13</jacoco-maven-plugin.version>
80-
<central-publishing-maven-plugin.version>0.8.0</central-publishing-maven-plugin.version>
80+
<central-publishing-maven-plugin.version>0.9.0</central-publishing-maven-plugin.version>
8181

8282
<!-- Sonar -->
8383
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>

snapshots/default.json

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,35 @@
11
{
2-
"data": {
3-
"domain": {
4-
"name": "Playground",
5-
"version": 1613542022439,
6-
"group": [
7-
{
8-
"name": "Release 1",
9-
"config": [
10-
{
11-
"key": "MY_SWITCHER",
12-
"strategies": [
13-
{
14-
"strategy": "VALUE_VALIDATION",
15-
"operation": "EXIST",
16-
"values": [
17-
"user_1"
18-
],
19-
"activated": false
20-
}
21-
],
22-
"components": [
23-
"switcher-playground"
24-
],
25-
"description": "My first switcher",
26-
"activated": false
27-
}
28-
],
29-
"description": "",
30-
"activated": true
31-
}
32-
],
33-
"description": "My playground",
34-
"activated": true
35-
}
2+
"domain": {
3+
"name": "Playground",
4+
"version": 1613542022439,
5+
"group": [
6+
{
7+
"name": "Release 1",
8+
"config": [
9+
{
10+
"key": "MY_SWITCHER",
11+
"strategies": [
12+
{
13+
"strategy": "VALUE_VALIDATION",
14+
"operation": "EXIST",
15+
"values": [
16+
"user_1"
17+
],
18+
"activated": false
19+
}
20+
],
21+
"components": [
22+
"switcher-playground"
23+
],
24+
"description": "My first switcher",
25+
"activated": false
26+
}
27+
],
28+
"description": "",
29+
"activated": true
30+
}
31+
],
32+
"description": "My playground",
33+
"activated": true
3634
}
3735
}

snapshots/dev1.json

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
{
2-
"data": {
3-
"domain": {
4-
"name": "Playground",
5-
"version": 1613542022439,
6-
"group": [
7-
{
8-
"name": "Release 1",
9-
"config": [
10-
{
11-
"key": "MY_SWITCHER",
12-
"strategies": [],
13-
"components": [
14-
"switcher-playground"
15-
],
16-
"description": "My first switcher",
17-
"activated": true
18-
}
19-
],
20-
"description": "",
21-
"activated": true
22-
}
23-
],
24-
"description": "My playground",
25-
"activated": true
26-
}
2+
"domain": {
3+
"name": "Playground",
4+
"version": 1613542022439,
5+
"group": [
6+
{
7+
"name": "Release 1",
8+
"config": [
9+
{
10+
"key": "MY_SWITCHER",
11+
"strategies": [],
12+
"components": [
13+
"switcher-playground"
14+
],
15+
"description": "My first switcher",
16+
"activated": true
17+
}
18+
],
19+
"description": "",
20+
"activated": true
21+
}
22+
],
23+
"description": "My playground",
24+
"activated": true
2725
}
2826
}

src/main/java/com/switcherapi/client/model/criteria/Data.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/main/java/com/switcherapi/client/model/criteria/Snapshot.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@
77
*/
88
public class Snapshot {
99

10-
private Data data;
10+
private Domain domain;
1111

1212
public Domain getDomain() {
13-
return data != null ? data.getDomain() : new Domain();
13+
return domain != null ? domain : new Domain();
1414
}
1515

16-
public Data getData() {
17-
return data;
18-
}
19-
20-
public void setData(Data data) {
21-
this.data = data;
16+
public void setDomain(Domain domain) {
17+
this.domain = domain;
2218
}
2319

2420
}

src/main/java/com/switcherapi/client/remote/ClientWSImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public Snapshot resolveSnapshot(final String token) {
111111
switcherProperties.getValue(ContextKey.COMPONENT))));
112112

113113
if (response.getStatus() == 200) {
114-
final Snapshot snapshot = response.readEntity(Snapshot.class);
114+
final Snapshot snapshot = response.readEntity(SnapshotDataResponse.class).getData();
115115
response.close();
116116

117117
return snapshot;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.switcherapi.client.remote.dto;
2+
3+
import com.switcherapi.client.model.criteria.Snapshot;
4+
5+
public class SnapshotDataResponse {
6+
7+
private Snapshot data;
8+
9+
public Snapshot getData() {
10+
return data;
11+
}
12+
13+
public void setData(Snapshot data) {
14+
this.data = data;
15+
}
16+
}

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,6 @@
5050
}
5151
]
5252
},
53-
{
54-
"name": "com.switcherapi.client.model.criteria.Data",
55-
"condition": {
56-
"typeReachable": "com.switcherapi.client.model.criteria.Snapshot"
57-
},
58-
"allDeclaredFields": true,
59-
"methods": [
60-
{
61-
"name": "<init>",
62-
"parameterTypes": []
63-
}
64-
]
65-
},
6653
{
6754
"name": "com.switcherapi.client.model.criteria.Domain",
6855
"condition": {
@@ -210,5 +197,18 @@
210197
"parameterTypes": []
211198
}
212199
]
200+
},
201+
{
202+
"name": "com.switcherapi.client.remote.dto.SnapshotDataResponse",
203+
"condition": {
204+
"typeReachable": "com.switcherapi.client.remote.ClientWSImpl"
205+
},
206+
"allDeclaredFields": true,
207+
"methods": [
208+
{
209+
"name": "<init>",
210+
"parameterTypes": []
211+
}
212+
]
213213
}
214214
]

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.switcherapi.client;
22

33
import com.switcherapi.Switchers;
4-
import com.switcherapi.client.model.criteria.Data;
54
import com.switcherapi.client.model.criteria.Domain;
65
import com.switcherapi.client.model.criteria.Snapshot;
76
import com.switcherapi.client.utils.SnapshotLoader;
@@ -60,9 +59,7 @@ void restoreStubs() {
6059

6160
static void generateFixture(String environment) {
6261
final Snapshot mockedSnapshot = new Snapshot();
63-
final Data data = new Data();
64-
data.setDomain(DOMAIN_OUTDATED);
65-
mockedSnapshot.setData(data);
62+
mockedSnapshot.setDomain(DOMAIN_OUTDATED);
6663

6764
SnapshotLoader.saveSnapshot(mockedSnapshot, SNAPSHOTS_LOCAL, environment);
6865
}

src/test/java/com/switcherapi/client/model/ModelTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@ void testCriteriaPackage() {
7575
assertSame("Name", domain.getName());
7676
assertEquals(10000000000L, domain.getVersion());
7777
assertSame(groups, domain.getGroup());
78-
79-
final Data data = new Data();
80-
data.setDomain(domain);
81-
82-
final Snapshot snapshot = new Snapshot();
83-
snapshot.setData(data);
84-
85-
assertSame(data, snapshot.getData());
8678
}
8779

8880
}

0 commit comments

Comments
 (0)