Skip to content

Commit

Permalink
update class name
Browse files Browse the repository at this point in the history
  • Loading branch information
AnuchitO committed Mar 22, 2024
1 parent 7344112 commit 7d19f6e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
42 changes: 22 additions & 20 deletions kbazaar/src/test/java/com/kampus/kbazaar/KBazaarApplicationIT.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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) {
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7d19f6e

Please sign in to comment.