-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
o.mohkamkar
committed
Apr 13, 2024
1 parent
ccb4f1a
commit 8748113
Showing
1 changed file
with
37 additions
and
1 deletion.
There are no files selected for viewing
38 changes: 37 additions & 1 deletion
38
iam-api/src/test/java/com/omidmk/iamapi/IAMApiApplicationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,49 @@ | ||
package com.omidmk.iamapi; | ||
|
||
import com.omidmk.iamapi.service.CustomerService; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.boot.test.web.server.LocalServerPort; | ||
import org.springframework.test.web.servlet.MockMvc; | ||
|
||
@SpringBootTest | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; | ||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@AutoConfigureMockMvc | ||
class IAMApiApplicationTests { | ||
|
||
@MockBean | ||
private CustomerService customerService; | ||
|
||
@LocalServerPort | ||
private int port; | ||
|
||
@Autowired | ||
private TestRestTemplate restTemplate; | ||
|
||
@Autowired | ||
private MockMvc mockMvc; | ||
|
||
@Test | ||
void contextLoads() { | ||
assertThat(this.restTemplate.getForObject("http://localhost:" + port + "/", String.class)).contains("Hello, World"); | ||
// assertThat(customerService).isNotNull(); | ||
// Assertions.assertNull(customerService.findUserByEmail("[email protected]").orElse(null)); | ||
} | ||
|
||
@Test | ||
void shouldReturnDefaultMessage() throws Exception { | ||
this.mockMvc.perform(get("/v1/plans/beginner")).andDo(print()).andExpect(status().is4xxClientError()) | ||
.andExpect(content().string(containsString(""))); | ||
} | ||
|
||
} |