diff --git a/srv/src/test/java/my/bookshop/AdminServiceAddress_default_ITest.java b/srv/src/test/java/my/bookshop/AdminServiceAddress_default_ITest.java index 42b09453..db791125 100644 --- a/srv/src/test/java/my/bookshop/AdminServiceAddress_default_ITest.java +++ b/srv/src/test/java/my/bookshop/AdminServiceAddress_default_ITest.java @@ -12,7 +12,7 @@ */ @ActiveProfiles("default") @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class AdminServiceAddress_default_ITest extends AdminServiceAddressITestBase { +class AdminServiceAddress_default_ITest extends AdminServiceAddressITestBase { @Test @Override diff --git a/srv/src/test/java/my/bookshop/AdminServiceAddress_mocked_ITest.java b/srv/src/test/java/my/bookshop/AdminServiceAddress_mocked_ITest.java index d363f824..28dc7a72 100644 --- a/srv/src/test/java/my/bookshop/AdminServiceAddress_mocked_ITest.java +++ b/srv/src/test/java/my/bookshop/AdminServiceAddress_mocked_ITest.java @@ -13,7 +13,7 @@ @ActiveProfiles({"default", "mocked"}) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = "cds.remote.services.'[API_BUSINESS_PARTNER]'.destination.name=myself-AdminServiceAddressITest") -public class AdminServiceAddress_mocked_ITest extends AdminServiceAddressITestBase { +class AdminServiceAddress_mocked_ITest extends AdminServiceAddressITestBase { @Test @Override diff --git a/srv/src/test/java/my/bookshop/AdminServiceTest.java b/srv/src/test/java/my/bookshop/AdminServiceTest.java index a64dd067..b8988bb1 100644 --- a/srv/src/test/java/my/bookshop/AdminServiceTest.java +++ b/srv/src/test/java/my/bookshop/AdminServiceTest.java @@ -24,14 +24,14 @@ import cds.gen.adminservice.Orders; @SpringBootTest -public class AdminServiceTest { +class AdminServiceTest { @Autowired private AdminService.Draft adminService; @Test @WithMockUser(username = "user") - public void testUnauthorizedAccess() { + void unauthorizedAccess() { assertThrows(ServiceException.class, () -> { adminService.newDraft(Insert.into(AUTHORS).entry(Collections.emptyMap())); }); @@ -39,7 +39,7 @@ public void testUnauthorizedAccess() { @Test @WithMockUser(username = "admin") - public void testInvalidAuthorName() { + void invalidAuthorName() { assertThrows(ServiceException.class, () -> { Authors author = Authors.create(); author.setName("little Joey"); @@ -49,7 +49,7 @@ public void testInvalidAuthorName() { @Test @WithMockUser(username = "admin") - public void testValidAuthorName() { + void validAuthorName() { Authors author = Authors.create(); author.setName("Big Joey"); Result result = adminService.run(Insert.into(AUTHORS).entry(author)); @@ -58,7 +58,7 @@ public void testValidAuthorName() { @Test @WithMockUser(username = "admin") - void testCreateOrderWithoutBook() { + void createOrderWithoutBook() { Orders order = Orders.create(); order.setOrderNo("324"); order.setShippingAddressId("100"); @@ -75,7 +75,7 @@ void testCreateOrderWithoutBook() { @Test @WithMockUser(username = "admin") - void testCreateOrderWithNonExistingBook() { + void createOrderWithNonExistingBook() { Orders order = Orders.create(); order.setOrderNo("324"); order.setShippingAddressId("100"); diff --git a/srv/src/test/java/my/bookshop/CatalogServiceITest.java b/srv/src/test/java/my/bookshop/CatalogServiceITest.java index 60e3c22e..b60aba58 100644 --- a/srv/src/test/java/my/bookshop/CatalogServiceITest.java +++ b/srv/src/test/java/my/bookshop/CatalogServiceITest.java @@ -24,7 +24,7 @@ @SpringBootTest @AutoConfigureMockMvc -public class CatalogServiceITest { +class CatalogServiceITest { private static final String booksURI = "/api/browse/Books"; private static final String addReviewURI = "%s(ID=%s)/CatalogService.addReview".formatted(booksURI, "f846b0b9-01d4-4f6d-82a4-d79204f62278"); @@ -39,26 +39,26 @@ public class CatalogServiceITest { private PersistenceService db; @AfterEach - public void cleanup() { + void cleanup() { db.run(Delete.from(REVIEWS)); } @Test - public void testDiscountApplied() throws Exception { + void discountApplied() throws Exception { mockMvc.perform(get(booksURI + "?$filter=stock gt 200&top=1")) .andExpect(status().isOk()) .andExpect(jsonPath("$.value[0].title").value(containsString("11% discount"))); } @Test - public void testDiscountNotApplied() throws Exception { + void discountNotApplied() throws Exception { mockMvc.perform(get(booksURI + "?$filter=stock lt 100&top=1")) .andExpect(status().isOk()) .andExpect(jsonPath("$.value[0].title").value(not(containsString("11% discount")))); } @Test - public void testCreateReviewNotAuthenticated() throws Exception { + void createReviewNotAuthenticated() throws Exception { String payload = createTestReview().toJson(); mockMvc.perform(post(addReviewURI).contentType(MediaType.APPLICATION_JSON).content(payload)) .andExpect(status().isUnauthorized()); @@ -66,7 +66,7 @@ public void testCreateReviewNotAuthenticated() throws Exception { @Test @WithMockUser(USER_USER_STRING) - public void testCreateReviewByUser() throws Exception { + void createReviewByUser() throws Exception { String payload = createTestReview().toJson(); mockMvc.perform(post(addReviewURI).contentType(MediaType.APPLICATION_JSON).content(payload)) .andExpect(status().isOk()) @@ -75,7 +75,7 @@ public void testCreateReviewByUser() throws Exception { @Test @WithMockUser(ADMIN_USER_STRING) - public void testCreateReviewByAdmin() throws Exception { + void createReviewByAdmin() throws Exception { String payload = createTestReview().toJson(); mockMvc.perform(post(addReviewURI).contentType(MediaType.APPLICATION_JSON).content(payload)) .andExpect(status().isOk()) diff --git a/srv/src/test/java/my/bookshop/CatalogServiceTest.java b/srv/src/test/java/my/bookshop/CatalogServiceTest.java index 6660d21e..323c95fe 100644 --- a/srv/src/test/java/my/bookshop/CatalogServiceTest.java +++ b/srv/src/test/java/my/bookshop/CatalogServiceTest.java @@ -24,7 +24,7 @@ import cds.gen.catalogservice.Reviews; @SpringBootTest -public class CatalogServiceTest { +class CatalogServiceTest { @Autowired private CatalogService catalogService; @@ -33,13 +33,13 @@ public class CatalogServiceTest { private PersistenceService db; @AfterEach - public void cleanup() { + void cleanup() { db.run(Delete.from(REVIEWS)); } @Test @WithMockUser(username = "user") - public void testCreateReviewHandler() { + void createReviewHandler() { Stream bookReviews = Stream.of( createReview("f846b0b9-01d4-4f6d-82a4-d79204f62278", 1, "quite bad", "disappointing..."), createReview("aebdfc8a-0dfa-4468-bd36-48aabd65e663", 5, "great read", "just amazing...")); @@ -58,7 +58,7 @@ public void testCreateReviewHandler() { @Test @WithMockUser(username = "user") - public void testAddReviewWithInvalidRating() { + void addReviewWithInvalidRating() { Stream bookReviews = Stream.of( // lt 1 is invalid createReview("f846b0b9-01d4-4f6d-82a4-d79204f62278", 0, "quite bad", "disappointing..."), @@ -76,7 +76,7 @@ public void testAddReviewWithInvalidRating() { @Test @WithMockUser(username = "user") - public void testAddReviewForNonExistingBook() { + void addReviewForNonExistingBook() { String nonExistingBookId = "non-existing"; String exMessage1 = "You have to specify the book to review"; @@ -98,7 +98,7 @@ public void testAddReviewForNonExistingBook() { @Test @WithMockUser(username = "user") - public void testAddReviewSameBookMoreThanOnceBySameUser() { + void addReviewSameBookMoreThanOnceBySameUser() { String bookId = "4a519e61-3c3a-4bd9-ab12-d7e0c5329933"; Books_ ref = CQL.entity(BOOKS).filter(b -> b.ID().eq(bookId)); diff --git a/srv/src/test/java/my/bookshop/GenreHierarchyTest.java b/srv/src/test/java/my/bookshop/GenreHierarchyTest.java index 33a107d7..9669f07b 100644 --- a/srv/src/test/java/my/bookshop/GenreHierarchyTest.java +++ b/srv/src/test/java/my/bookshop/GenreHierarchyTest.java @@ -16,7 +16,7 @@ @SpringBootTest @AutoConfigureMockMvc -public class GenreHierarchyTest { +class GenreHierarchyTest { @Autowired private MockMvc client; @@ -25,13 +25,13 @@ public class GenreHierarchyTest { @Test @WithMockUser(username = "admin") - void testGetAll() throws Exception { + void getAll() throws Exception { client.perform(get(genresURI)).andExpect(status().isOk()); } @Test @WithMockUser(username = "admin") - void testCountAll() throws Exception { + void countAll() throws Exception { client.perform(get(genresURI + "/$count")) .andExpect(status().isOk()) .andExpect(jsonPath("$").value(269)); @@ -39,7 +39,7 @@ void testCountAll() throws Exception { @Test @WithMockUser(username = "admin") - void testStartOneLevel() throws Exception { + void startOneLevel() throws Exception { client.perform(get(genresURI + "?$select=DrillState,ID,name,DistanceFromRoot" + "&$apply=orderby(name)/" @@ -59,7 +59,7 @@ void testStartOneLevel() throws Exception { @Test @WithMockUser(username = "admin") - void testStartTwoLevels() throws Exception { + void startTwoLevels() throws Exception { client.perform(get(genresURI + "?$select=DrillState,ID,name,DistanceFromRoot" + "&$apply=orderby(name)/" @@ -80,7 +80,7 @@ void testStartTwoLevels() throws Exception { @Test @WithMockUser(username = "admin") - void testExpandNonFiction() throws Exception { + void expandNonFiction() throws Exception { client.perform(get(genresURI + "?$select=DrillState,ID,name" + "&$apply=descendants($root/GenreHierarchy,GenreHierarchy,ID,filter(ID eq 8bbf14c6-b378-4e35-9b4f-05a9c8878021),1)" @@ -93,7 +93,7 @@ void testExpandNonFiction() throws Exception { @Test @WithMockUser(username = "admin") - void testCollapseAll() throws Exception { + void collapseAll() throws Exception { client.perform(get(genresURI + "?$select=DrillState,ID,name" + "&$apply=orderby(name)/com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/GenreHierarchy,HierarchyQualifier='GenreHierarchy',NodeProperty='ID',Levels=1)" @@ -108,7 +108,7 @@ void testCollapseAll() throws Exception { @Test @WithMockUser(username = "admin") - void testExpandAllTop100() throws Exception { + void expandAllTop100() throws Exception { String url = genresURI + "?$select=DistanceFromRoot,DrillState,ID,LimitedDescendantCount,name" + "&$apply=orderby(name)/com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/GenreHierarchy,HierarchyQualifier='GenreHierarchy',NodeProperty='ID')" @@ -126,7 +126,7 @@ void testExpandAllTop100() throws Exception { @Test @WithMockUser(username = "admin") - void testSearch() throws Exception { + void search() throws Exception { client.perform(get(genresURI + "?$select=DistanceFromRoot,DrillState,ID,LimitedDescendantCount,name" + "&$apply=ancestors($root/GenreHierarchy,GenreHierarchy,ID,search(\"true\"),keep start)" @@ -154,7 +154,7 @@ void testSearch() throws Exception { @Test @WithMockUser(username = "admin") - void testFilterNotExpanded() throws Exception { + void filterNotExpanded() throws Exception { client.perform(get(genresURI + "?$select=DrillState,ID,name,DistanceFromRoot" + "&$apply=ancestors($root/GenreHierarchy,GenreHierarchy,ID,filter(name eq 'Autobiography'),keep start)/orderby(name)" @@ -168,7 +168,7 @@ void testFilterNotExpanded() throws Exception { @Test @WithMockUser(username = "admin") - void testFilterExpandLevels() throws Exception { + void filterExpandLevels() throws Exception { String expandLevelsJson = """ [{"NodeID":"8bbf14c6-b378-4e35-9b4f-05a9c8878002","Levels":1},{"NodeID":"8bbf14c6-b378-4e35-9b4f-05a9c8878031","Levels":1}]\ """; @@ -188,7 +188,7 @@ void testFilterExpandLevels() throws Exception { @Test @WithMockUser(username = "admin") - void testStartTwoLevelsOrderByDesc() throws Exception { + void startTwoLevelsOrderByDesc() throws Exception { client.perform(get(genresURI + "?$select=DrillState,ID,name,DistanceFromRoot" + "&$apply=orderby(name desc)/" diff --git a/srv/src/test/java/my/bookshop/NotesServiceITest.java b/srv/src/test/java/my/bookshop/NotesServiceITest.java index 540be4e8..9fb2fe84 100644 --- a/srv/src/test/java/my/bookshop/NotesServiceITest.java +++ b/srv/src/test/java/my/bookshop/NotesServiceITest.java @@ -11,7 +11,7 @@ @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = "cds.remote.services.'[API_BUSINESS_PARTNER]'.destination.name=myself-NotesServiceITest") @ActiveProfiles({"default", "mocked"}) -public class NotesServiceITest { +class NotesServiceITest { private static final String notesURI = "/api/notes/Notes"; private static final String addressesURI = "/api/notes/Addresses"; @@ -20,7 +20,7 @@ public class NotesServiceITest { private WebTestClient client; @Test - public void testGetNotes() throws Exception { + void getNotes() { client.get().uri(notesURI).headers(this::authenticatedCredentials).exchange() .expectStatus().isOk() .expectBody() @@ -40,7 +40,7 @@ public void testGetNotes() throws Exception { } @Test - public void testGetAddresses() throws Exception { + void getAddresses() { client.get().uri(addressesURI + "?$filter=businessPartner eq '10401010'").headers(this::authenticatedCredentials).exchange() .expectStatus().isOk() .expectBody() @@ -54,7 +54,7 @@ public void testGetAddresses() throws Exception { } @Test - public void testGetNoteWithAddress() throws Exception { + void getNoteWithAddress() { client.get().uri(notesURI + "?$expand=address").headers(this::authenticatedCredentials).exchange() .expectStatus().isOk() .expectBody() @@ -83,7 +83,7 @@ public void testGetNoteWithAddress() throws Exception { } @Test - public void testGetSuppliersWithNotes() throws Exception { + void getSuppliersWithNotes() { client.get().uri(addressesURI + "?$expand=notes($orderby=ID)&$filter=businessPartner eq '10401010'").headers(this::authenticatedCredentials).exchange() .expectStatus().isOk() .expectBody() @@ -108,7 +108,7 @@ public void testGetSuppliersWithNotes() throws Exception { } @Test - public void testGetNotesToSupplier() throws Exception { + void getNotesToSupplier() { client.get().uri(notesURI + "(ID=5efc842c-c70d-4ee2-af1d-81c7d257aff7,IsActiveEntity=true)/address").headers(this::authenticatedCredentials).exchange() .expectStatus().isOk() .expectBody() @@ -119,7 +119,7 @@ public void testGetNotesToSupplier() throws Exception { } @Test - public void testGetSupplierToNotes() throws Exception { + void getSupplierToNotes() { client.get().uri(addressesURI + "(businessPartner='10401010',ID='100')/notes").headers(this::authenticatedCredentials).exchange() .expectStatus().isOk() .expectBody() @@ -135,7 +135,7 @@ public void testGetSupplierToNotes() throws Exception { } @Test - public void testGetSupplierToSpecificNote() throws Exception { + void getSupplierToSpecificNote() { client.get().uri(addressesURI + "(businessPartner='10401010',ID='100')/notes(ID=83e2643b-aecc-47d3-9f85-a8ba14eff07d,IsActiveEntity=true)") .headers(this::authenticatedCredentials) .exchange() @@ -148,7 +148,7 @@ public void testGetSupplierToSpecificNote() throws Exception { } @Test - public void testGetNotesWithNestedExpands() throws Exception { + void getNotesWithNestedExpands() { client.get().uri(notesURI + "?$select=note&$expand=address($select=postalCode;$expand=notes($select=note))&$top=1").headers(this::authenticatedCredentials).exchange() .expectStatus().isOk() .expectBody() @@ -164,7 +164,7 @@ public void testGetNotesWithNestedExpands() throws Exception { } @Test - public void testGetAddressesWithNestedExpands() throws Exception { + void getAddressesWithNestedExpands() { client.get().uri(addressesURI + "?$select=postalCode&$expand=notes($select=note;$expand=address($select=postalCode))&$filter=businessPartner eq '1000020'") .headers(this::authenticatedCredentials) .exchange() diff --git a/srv/src/test/java/my/bookshop/RatingCalculatorTest.java b/srv/src/test/java/my/bookshop/RatingCalculatorTest.java index 816fe9b7..dea8ea05 100644 --- a/srv/src/test/java/my/bookshop/RatingCalculatorTest.java +++ b/srv/src/test/java/my/bookshop/RatingCalculatorTest.java @@ -7,12 +7,12 @@ import org.junit.jupiter.api.Test; -public class RatingCalculatorTest { +class RatingCalculatorTest { /* * Holder class for a book rating calculation test case. */ - private class RatingTestFixture { + private static class RatingTestFixture { Stream ratings; double expectedAvg; @@ -23,7 +23,7 @@ private class RatingTestFixture { } @Test - public void testGetAvgRating() { + void getAvgRating() { RatingTestFixture f1 = new RatingTestFixture(Stream.of(1.0, 2.0, 3.0, 4.0, 5.0), 3.0); RatingTestFixture f2 = new RatingTestFixture(Stream.of(1.3, 2.4, 3.5, 4.9, 5.1), 3.4); RatingTestFixture f3 = new RatingTestFixture(Stream.of(2.1, 4.0, 2.7, 3.8, 4.9), 3.5); diff --git a/srv/src/test/java/my/bookshop/handlers/CatalogServiceHandlerTest.java b/srv/src/test/java/my/bookshop/handlers/CatalogServiceHandlerTest.java index 5e97c555..a5df2c73 100644 --- a/srv/src/test/java/my/bookshop/handlers/CatalogServiceHandlerTest.java +++ b/srv/src/test/java/my/bookshop/handlers/CatalogServiceHandlerTest.java @@ -10,10 +10,10 @@ import cds.gen.catalogservice.Books; -public class CatalogServiceHandlerTest { +class CatalogServiceHandlerTest { @Test - public void testDiscountHandler() { + void discountHandler() { Books book1 = Books.create(); book1.setTitle("Book 1"); book1.setStock(10);