From 7d19f6e0c6c5f2ddd106496cb916649e936a4703 Mon Sep 17 00:00:00 2001 From: Nong AnuchitO Date: Fri, 22 Mar 2024 21:26:17 +0700 Subject: [PATCH] update class name --- .../kampus/kbazaar/KBazaarApplicationIT.java | 42 ++++++++++--------- .../kbazaar/product/ProductServiceTest.java | 1 - 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/kbazaar/src/test/java/com/kampus/kbazaar/KBazaarApplicationIT.java b/kbazaar/src/test/java/com/kampus/kbazaar/KBazaarApplicationIT.java index c83d010..7ddb3fb 100644 --- a/kbazaar/src/test/java/com/kampus/kbazaar/KBazaarApplicationIT.java +++ b/kbazaar/src/test/java/com/kampus/kbazaar/KBazaarApplicationIT.java @@ -1,6 +1,5 @@ package com.kampus.kbazaar; -import static org.junit.jupiter.api.Assertions.assertEquals; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -27,14 +26,15 @@ @AutoConfigureMockMvc @Tag("integration-test") @TestPropertySource(locations = "classpath:application-ittest.properties") -class KBazaarApplicationTests { +class KBazaarApplicationIT { - @Autowired - private MockMvc mockMvc; + @Autowired private MockMvc mockMvc; - private final String jwtToken = "eyJhbGciOiJIUzI1NiJ9.eyJhdXRob3JpdGllcyI6WyJST0xFX1NIT1BQRVIiXSwic3ViIjoic2hvcHBlciIsImlhdCI6MTcxMTA4MTk1OSwiZXhwIjoxNzQyNjE3OTU5fQ.hwpc_6CL_ZENHurOaZEYg3tz9FVBgOYa7ILF063stxs"; + private final String jwtToken = + "eyJhbGciOiJIUzI1NiJ9.eyJhdXRob3JpdGllcyI6WyJST0xFX1NIT1BQRVIiXSwic3ViIjoic2hvcHBlciIsImlhdCI6MTcxMTA4MTk1OSwiZXhwIjoxNzQyNjE3OTU5fQ.hwpc_6CL_ZENHurOaZEYg3tz9FVBgOYa7ILF063stxs"; - static PostgreSQLContainer postgresContainer = new PostgreSQLContainer<>("postgres:12-alpine"); + static PostgreSQLContainer postgresContainer = + new PostgreSQLContainer<>("postgres:12-alpine"); @DynamicPropertySource static void postgresqlProperties(DynamicPropertyRegistry registry) { @@ -56,25 +56,27 @@ static void stopContainer() { @Test void getShopper_shouldReturnShopperList() throws Exception { - MvcResult mvcResult = mockMvc.perform( - get("/api/v1/shoppers").header("Authorization", "Bearer "+ jwtToken) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$").isArray()) - .andExpect(jsonPath("$.length()").value(Matchers.greaterThan(0))) - .andExpect(jsonPath("$[0].username").value("TechNinja")) - .andReturn(); + MvcResult mvcResult = + mockMvc.perform( + get("/api/v1/shoppers") + .header("Authorization", "Bearer " + jwtToken)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$").isArray()) + .andExpect(jsonPath("$.length()").value(Matchers.greaterThan(0))) + .andExpect(jsonPath("$[0].username").value("TechNinja")) + .andReturn(); } @Test void getShopperByName_shouldReturnShopper() throws Exception { String username = "TechNinja"; - MvcResult mvcResult = mockMvc.perform( - get("/api/v1/shoppers/" + username).header("Authorization", "Bearer "+ jwtToken) - ) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.username").value(username)) - .andReturn(); + MvcResult mvcResult = + mockMvc.perform( + get("/api/v1/shoppers/" + username) + .header("Authorization", "Bearer " + jwtToken)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.username").value(username)) + .andReturn(); } } diff --git a/kbazaar/src/test/java/com/kampus/kbazaar/product/ProductServiceTest.java b/kbazaar/src/test/java/com/kampus/kbazaar/product/ProductServiceTest.java index bf69ff4..9f5af9b 100644 --- a/kbazaar/src/test/java/com/kampus/kbazaar/product/ProductServiceTest.java +++ b/kbazaar/src/test/java/com/kampus/kbazaar/product/ProductServiceTest.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.Optional; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.mockito.InjectMocks; import org.mockito.Mock;