Skip to content

Commit 53a7734

Browse files
committed
Run JUnit5 recipe
1 parent c05d8ec commit 53a7734

9 files changed

+34
-34
lines changed

srv/src/test/java/my/bookshop/AdminServiceAddress_default_ITest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
@ActiveProfiles("default")
1414
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
15-
public class AdminServiceAddress_default_ITest extends AdminServiceAddressITestBase {
15+
class AdminServiceAddress_default_ITest extends AdminServiceAddressITestBase {
1616

1717
@Test
1818
@Override

srv/src/test/java/my/bookshop/AdminServiceAddress_mocked_ITest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
@ActiveProfiles({"default", "mocked"})
1414
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
1515
properties = "cds.remote.services.'[API_BUSINESS_PARTNER]'.destination.name=myself-AdminServiceAddressITest")
16-
public class AdminServiceAddress_mocked_ITest extends AdminServiceAddressITestBase {
16+
class AdminServiceAddress_mocked_ITest extends AdminServiceAddressITestBase {
1717

1818
@Test
1919
@Override

srv/src/test/java/my/bookshop/AdminServiceTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@
2424
import cds.gen.adminservice.Orders;
2525

2626
@SpringBootTest
27-
public class AdminServiceTest {
27+
class AdminServiceTest {
2828

2929
@Autowired
3030
private AdminService.Draft adminService;
3131

3232
@Test
3333
@WithMockUser(username = "user")
34-
public void testUnauthorizedAccess() {
34+
void testUnauthorizedAccess() {
3535
assertThrows(ServiceException.class, () -> {
3636
adminService.newDraft(Insert.into(AUTHORS).entry(Collections.emptyMap()));
3737
});
3838
}
3939

4040
@Test
4141
@WithMockUser(username = "admin")
42-
public void testInvalidAuthorName() {
42+
void testInvalidAuthorName() {
4343
assertThrows(ServiceException.class, () -> {
4444
Authors author = Authors.create();
4545
author.setName("little Joey");
@@ -49,7 +49,7 @@ public void testInvalidAuthorName() {
4949

5050
@Test
5151
@WithMockUser(username = "admin")
52-
public void testValidAuthorName() {
52+
void testValidAuthorName() {
5353
Authors author = Authors.create();
5454
author.setName("Big Joey");
5555
Result result = adminService.run(Insert.into(AUTHORS).entry(author));

srv/src/test/java/my/bookshop/CatalogServiceITest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
@SpringBootTest
2626
@AutoConfigureMockMvc
27-
public class CatalogServiceITest {
27+
class CatalogServiceITest {
2828

2929
private static final String booksURI = "/api/browse/Books";
3030
private static final String addReviewURI = "%s(ID=%s)/CatalogService.addReview".formatted(booksURI, "f846b0b9-01d4-4f6d-82a4-d79204f62278");
@@ -39,34 +39,34 @@ public class CatalogServiceITest {
3939
private PersistenceService db;
4040

4141
@AfterEach
42-
public void cleanup() {
42+
void cleanup() {
4343
db.run(Delete.from(REVIEWS));
4444
}
4545

4646
@Test
47-
public void testDiscountApplied() throws Exception {
47+
void testDiscountApplied() throws Exception {
4848
mockMvc.perform(get(booksURI + "?$filter=stock gt 200&top=1"))
4949
.andExpect(status().isOk())
5050
.andExpect(jsonPath("$.value[0].title").value(containsString("11% discount")));
5151
}
5252

5353
@Test
54-
public void testDiscountNotApplied() throws Exception {
54+
void testDiscountNotApplied() throws Exception {
5555
mockMvc.perform(get(booksURI + "?$filter=stock lt 100&top=1"))
5656
.andExpect(status().isOk())
5757
.andExpect(jsonPath("$.value[0].title").value(not(containsString("11% discount"))));
5858
}
5959

6060
@Test
61-
public void testCreateReviewNotAuthenticated() throws Exception {
61+
void testCreateReviewNotAuthenticated() throws Exception {
6262
String payload = createTestReview().toJson();
6363
mockMvc.perform(post(addReviewURI).contentType(MediaType.APPLICATION_JSON).content(payload))
6464
.andExpect(status().isUnauthorized());
6565
}
6666

6767
@Test
6868
@WithMockUser(USER_USER_STRING)
69-
public void testCreateReviewByUser() throws Exception {
69+
void testCreateReviewByUser() throws Exception {
7070
String payload = createTestReview().toJson();
7171
mockMvc.perform(post(addReviewURI).contentType(MediaType.APPLICATION_JSON).content(payload))
7272
.andExpect(status().isOk())
@@ -75,7 +75,7 @@ public void testCreateReviewByUser() throws Exception {
7575

7676
@Test
7777
@WithMockUser(ADMIN_USER_STRING)
78-
public void testCreateReviewByAdmin() throws Exception {
78+
void testCreateReviewByAdmin() throws Exception {
7979
String payload = createTestReview().toJson();
8080
mockMvc.perform(post(addReviewURI).contentType(MediaType.APPLICATION_JSON).content(payload))
8181
.andExpect(status().isOk())

srv/src/test/java/my/bookshop/CatalogServiceTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import cds.gen.catalogservice.Reviews;
2525

2626
@SpringBootTest
27-
public class CatalogServiceTest {
27+
class CatalogServiceTest {
2828

2929
@Autowired
3030
private CatalogService catalogService;
@@ -33,13 +33,13 @@ public class CatalogServiceTest {
3333
private PersistenceService db;
3434

3535
@AfterEach
36-
public void cleanup() {
36+
void cleanup() {
3737
db.run(Delete.from(REVIEWS));
3838
}
3939

4040
@Test
4141
@WithMockUser(username = "user")
42-
public void testCreateReviewHandler() {
42+
void testCreateReviewHandler() {
4343
Stream<Reviews> bookReviews = Stream.of(
4444
createReview("f846b0b9-01d4-4f6d-82a4-d79204f62278", 1, "quite bad", "disappointing..."),
4545
createReview("aebdfc8a-0dfa-4468-bd36-48aabd65e663", 5, "great read", "just amazing..."));
@@ -58,7 +58,7 @@ public void testCreateReviewHandler() {
5858

5959
@Test
6060
@WithMockUser(username = "user")
61-
public void testAddReviewWithInvalidRating() {
61+
void testAddReviewWithInvalidRating() {
6262
Stream<Reviews> bookReviews = Stream.of(
6363
// lt 1 is invalid
6464
createReview("f846b0b9-01d4-4f6d-82a4-d79204f62278", 0, "quite bad", "disappointing..."),
@@ -76,7 +76,7 @@ public void testAddReviewWithInvalidRating() {
7676

7777
@Test
7878
@WithMockUser(username = "user")
79-
public void testAddReviewForNonExistingBook() {
79+
void testAddReviewForNonExistingBook() {
8080

8181
String nonExistingBookId = "non-existing";
8282
String exMessage1 = "You have to specify the book to review";
@@ -98,7 +98,7 @@ public void testAddReviewForNonExistingBook() {
9898

9999
@Test
100100
@WithMockUser(username = "user")
101-
public void testAddReviewSameBookMoreThanOnceBySameUser() {
101+
void testAddReviewSameBookMoreThanOnceBySameUser() {
102102

103103
String bookId = "4a519e61-3c3a-4bd9-ab12-d7e0c5329933";
104104
Books_ ref = CQL.entity(BOOKS).filter(b -> b.ID().eq(bookId));

srv/src/test/java/my/bookshop/GenreHierarchyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
@SpringBootTest
1818
@AutoConfigureMockMvc
19-
public class GenreHierarchyTest {
19+
class GenreHierarchyTest {
2020

2121
@Autowired
2222
private MockMvc client;

srv/src/test/java/my/bookshop/NotesServiceITest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT,
1212
properties = "cds.remote.services.'[API_BUSINESS_PARTNER]'.destination.name=myself-NotesServiceITest")
1313
@ActiveProfiles({"default", "mocked"})
14-
public class NotesServiceITest {
14+
class NotesServiceITest {
1515

1616
private static final String notesURI = "/api/notes/Notes";
1717
private static final String addressesURI = "/api/notes/Addresses";
@@ -20,7 +20,7 @@ public class NotesServiceITest {
2020
private WebTestClient client;
2121

2222
@Test
23-
public void testGetNotes() throws Exception {
23+
void testGetNotes() throws Exception {
2424
client.get().uri(notesURI).headers(this::authenticatedCredentials).exchange()
2525
.expectStatus().isOk()
2626
.expectBody()
@@ -40,7 +40,7 @@ public void testGetNotes() throws Exception {
4040
}
4141

4242
@Test
43-
public void testGetAddresses() throws Exception {
43+
void testGetAddresses() throws Exception {
4444
client.get().uri(addressesURI + "?$filter=businessPartner eq '10401010'").headers(this::authenticatedCredentials).exchange()
4545
.expectStatus().isOk()
4646
.expectBody()
@@ -54,7 +54,7 @@ public void testGetAddresses() throws Exception {
5454
}
5555

5656
@Test
57-
public void testGetNoteWithAddress() throws Exception {
57+
void testGetNoteWithAddress() throws Exception {
5858
client.get().uri(notesURI + "?$expand=address").headers(this::authenticatedCredentials).exchange()
5959
.expectStatus().isOk()
6060
.expectBody()
@@ -83,7 +83,7 @@ public void testGetNoteWithAddress() throws Exception {
8383
}
8484

8585
@Test
86-
public void testGetSuppliersWithNotes() throws Exception {
86+
void testGetSuppliersWithNotes() throws Exception {
8787
client.get().uri(addressesURI + "?$expand=notes($orderby=ID)&$filter=businessPartner eq '10401010'").headers(this::authenticatedCredentials).exchange()
8888
.expectStatus().isOk()
8989
.expectBody()
@@ -108,7 +108,7 @@ public void testGetSuppliersWithNotes() throws Exception {
108108
}
109109

110110
@Test
111-
public void testGetNotesToSupplier() throws Exception {
111+
void testGetNotesToSupplier() throws Exception {
112112
client.get().uri(notesURI + "(ID=5efc842c-c70d-4ee2-af1d-81c7d257aff7,IsActiveEntity=true)/address").headers(this::authenticatedCredentials).exchange()
113113
.expectStatus().isOk()
114114
.expectBody()
@@ -119,7 +119,7 @@ public void testGetNotesToSupplier() throws Exception {
119119
}
120120

121121
@Test
122-
public void testGetSupplierToNotes() throws Exception {
122+
void testGetSupplierToNotes() throws Exception {
123123
client.get().uri(addressesURI + "(businessPartner='10401010',ID='100')/notes").headers(this::authenticatedCredentials).exchange()
124124
.expectStatus().isOk()
125125
.expectBody()
@@ -135,7 +135,7 @@ public void testGetSupplierToNotes() throws Exception {
135135
}
136136

137137
@Test
138-
public void testGetSupplierToSpecificNote() throws Exception {
138+
void testGetSupplierToSpecificNote() throws Exception {
139139
client.get().uri(addressesURI + "(businessPartner='10401010',ID='100')/notes(ID=83e2643b-aecc-47d3-9f85-a8ba14eff07d,IsActiveEntity=true)")
140140
.headers(this::authenticatedCredentials)
141141
.exchange()
@@ -148,7 +148,7 @@ public void testGetSupplierToSpecificNote() throws Exception {
148148
}
149149

150150
@Test
151-
public void testGetNotesWithNestedExpands() throws Exception {
151+
void testGetNotesWithNestedExpands() throws Exception {
152152
client.get().uri(notesURI + "?$select=note&$expand=address($select=postalCode;$expand=notes($select=note))&$top=1").headers(this::authenticatedCredentials).exchange()
153153
.expectStatus().isOk()
154154
.expectBody()
@@ -164,7 +164,7 @@ public void testGetNotesWithNestedExpands() throws Exception {
164164
}
165165

166166
@Test
167-
public void testGetAddressesWithNestedExpands() throws Exception {
167+
void testGetAddressesWithNestedExpands() throws Exception {
168168
client.get().uri(addressesURI + "?$select=postalCode&$expand=notes($select=note;$expand=address($select=postalCode))&$filter=businessPartner eq '1000020'")
169169
.headers(this::authenticatedCredentials)
170170
.exchange()

srv/src/test/java/my/bookshop/RatingCalculatorTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import org.junit.jupiter.api.Test;
99

10-
public class RatingCalculatorTest {
10+
class RatingCalculatorTest {
1111

1212
/*
1313
* Holder class for a book rating calculation test case.
@@ -23,7 +23,7 @@ private class RatingTestFixture {
2323
}
2424

2525
@Test
26-
public void testGetAvgRating() {
26+
void testGetAvgRating() {
2727
RatingTestFixture f1 = new RatingTestFixture(Stream.of(1.0, 2.0, 3.0, 4.0, 5.0), 3.0);
2828
RatingTestFixture f2 = new RatingTestFixture(Stream.of(1.3, 2.4, 3.5, 4.9, 5.1), 3.4);
2929
RatingTestFixture f3 = new RatingTestFixture(Stream.of(2.1, 4.0, 2.7, 3.8, 4.9), 3.5);

srv/src/test/java/my/bookshop/handlers/CatalogServiceHandlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
import cds.gen.catalogservice.Books;
1212

13-
public class CatalogServiceHandlerTest {
13+
class CatalogServiceHandlerTest {
1414

1515
@Test
16-
public void testDiscountHandler() {
16+
void testDiscountHandler() {
1717
Books book1 = Books.create();
1818
book1.setTitle("Book 1");
1919
book1.setStock(10);

0 commit comments

Comments
 (0)