Skip to content

Commit 15726b1

Browse files
committed
chore: uso di text block per i json
1 parent a3f269f commit 15726b1

File tree

3 files changed

+81
-52
lines changed

3 files changed

+81
-52
lines changed

01_driver_implicit/src/test/java/io/doubleloop/driverimplicit/UserControllerTest.java

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ class UserControllerTest {
2323

2424
@Test
2525
void registerValidUser() throws Exception {
26-
final var json = "{" +
27-
"\"email\": \"[email protected]\"," +
28-
"\"password\": \"123456\"" +
29-
"}";
26+
final var json = """
27+
{
28+
"email": "[email protected]",
29+
"password": "123456"
30+
}
31+
""";
3032

3133
mockMvc.perform(post("/api/users/")
3234
.content(json)
@@ -37,12 +39,14 @@ void registerValidUser() throws Exception {
3739

3840
@Test
3941
void registerValidBusinessUser() throws Exception {
40-
final var json = "{" +
41-
"\"email\": \"[email protected]\"," +
42-
"\"password\": \"123456\"," +
43-
"\"isBusiness\": true," +
44-
"\"PIVA\": \"0123\"" +
45-
"}";
42+
final var json = """
43+
{
44+
"email": "[email protected]",
45+
"password": "123456",
46+
"isBusiness": true,
47+
"PIVA": "0123"
48+
}
49+
""";
4650

4751
mockMvc.perform(post("/api/users/")
4852
.content(json)
@@ -53,10 +57,12 @@ void registerValidBusinessUser() throws Exception {
5357

5458
@Test
5559
void registerUserEmptyEmail() throws Exception {
56-
final var json = "{" +
57-
"\"email\": \"\"," +
58-
"\"password\": \"123456\"" +
59-
"}";
60+
final var json = """
61+
{
62+
"email": "",
63+
"password": "123456"
64+
}
65+
""";
6066

6167
mockMvc.perform(post("/api/users/")
6268
.content(json)
@@ -66,10 +72,12 @@ void registerUserEmptyEmail() throws Exception {
6672

6773
@Test
6874
void registerUserEmptyPassword() throws Exception {
69-
final var json = "{" +
70-
"\"email\": \"[email protected]\"," +
71-
"\"password\": \"\"" +
72-
"}";
75+
final var json = """
76+
{
77+
"email": "[email protected]",
78+
"password": ""
79+
}
80+
""";
7381

7482
mockMvc.perform(post("/api/users/")
7583
.content(json)
@@ -79,12 +87,14 @@ void registerUserEmptyPassword() throws Exception {
7987

8088
@Test
8189
void registerBusinessUserEmptyPIVA() throws Exception {
82-
final var json = "{" +
83-
"\"email\": \"[email protected]\"," +
84-
"\"password\": \"123456\"," +
85-
"\"isBusiness\": true," +
86-
"\"PIVA\": \"\"" +
87-
"}";
90+
final var json = """
91+
{
92+
"email": "[email protected]",
93+
"password": "123456",
94+
"isBusiness": true,
95+
"PIVA": ""
96+
}
97+
""";
8898

8999
mockMvc.perform(post("/api/users/")
90100
.content(json)
@@ -94,10 +104,14 @@ void registerBusinessUserEmptyPIVA() throws Exception {
94104

95105
@Test
96106
void registerDuplicatedEmail() throws Exception {
97-
final var json = "{" +
98-
"\"email\": \"[email protected]\"," +
99-
"\"password\": \"123456\"" +
100-
"}";
107+
final var json = """
108+
{
109+
"email": "[email protected]",
110+
"password": "123456",
111+
"isBusiness": true,
112+
"PIVA": "0123"
113+
}
114+
""";
101115

102116
mockMvc.perform(post("/api/users/")
103117
.content(json)
@@ -108,12 +122,14 @@ void registerDuplicatedEmail() throws Exception {
108122

109123
@Test
110124
void registerUnregisteredPIVA() throws Exception {
111-
final var json = "{" +
112-
"\"email\": \"[email protected]\"," +
113-
"\"password\": \"123456\"," +
114-
"\"isBusiness\": true," +
115-
"\"PIVA\": \"0000\"" +
116-
"}";
125+
final var json = """
126+
{
127+
"email": "[email protected]",
128+
"password": "123456",
129+
"isBusiness": true,
130+
"PIVA": "0000"
131+
}
132+
""";
117133

118134
mockMvc.perform(post("/api/users/")
119135
.content(json)

02_driver_explicit/src/test/java/io/doubleloop/driverexplicit/UserControllerTest.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ void setUp() {
3939

4040
@Test
4141
void registerValidUser() throws Exception {
42-
final var json = "{" +
43-
"\"email\": \"[email protected]\"," +
44-
"\"password\": \"123456\"" +
45-
"}";
42+
final var json = """
43+
{
44+
"email": "[email protected]",
45+
"password": "123456"
46+
}
47+
""";
4648

4749
mockMvc.perform(post("/api/users/")
4850
.content(json)
@@ -53,10 +55,12 @@ void registerValidUser() throws Exception {
5355

5456
@Test
5557
void registerUserEmptyEmail() throws Exception {
56-
final var json = "{" +
57-
"\"email\": \"\"," +
58-
"\"password\": \"123456\"" +
59-
"}";
58+
final var json = """
59+
{
60+
"email": "",
61+
"password": "123456"
62+
}
63+
""";
6064

6165
mockMvc.perform(post("/api/users/")
6266
.content(json)
@@ -66,10 +70,12 @@ void registerUserEmptyEmail() throws Exception {
6670

6771
@Test
6872
void registerUserEmptyPassword() throws Exception {
69-
final var json = "{" +
70-
"\"email\": \"[email protected]\"," +
71-
"\"password\": \"\"" +
72-
"}";
73+
final var json = """
74+
{
75+
"email": "[email protected]",
76+
"password": ""
77+
}
78+
""";
7379

7480
mockMvc.perform(post("/api/users/")
7581
.content(json)
@@ -81,10 +87,12 @@ void registerUserEmptyPassword() throws Exception {
8187
void registerDuplicatedEmail() throws Exception {
8288
userRepository.save(new User("[email protected]", "123456"));
8389

84-
final var json = "{" +
85-
"\"email\": \"[email protected]\"," +
86-
"\"password\": \"123456\"" +
87-
"}";
90+
final var json = """
91+
{
92+
"email": "[email protected]",
93+
"password": "123456"
94+
}
95+
""";
8896

8997
mockMvc.perform(post("/api/users/")
9098
.content(json)

04_driven_pull/src/test/java/io/doubleloop/drivenpull/DailyBalanceControllerTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ void dailyUserBalance() throws Exception {
3131

3232
mockMvc.perform(get("/api/balance/daily/123"))
3333
.andExpect(status().isOk())
34-
.andExpect(content().string("{\"userId\":\"123\",\"date\":\"2024-11-15\",\"balance\":100.0}"))
35-
;
34+
.andExpect(content().string("""
35+
{
36+
"userId":"123",
37+
"date":"2024-11-15",
38+
"balance":100.0
39+
}
40+
"""));
3641
}
3742
}

0 commit comments

Comments
 (0)