@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = RANDOM_PORT)
@ActiveProfiles(value = "local")
@AutoConfigureMockMvc
@WithUserDetails(value = "jaddap2", userDetailsServiceBeanName = "customDbUserDetailsService")
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class PersonIntegrationTest
{
@Autowired
private WebApplicationContext context;
@Autowired
private MockMvc mockMvc;
@BeforeAll
public void setup()
{
mockMvc = MockMvcBuilders
.webAppContextSetup(context)
.apply(springSecurity())
.build();
}
@Test
@WithUserDetails(value = "jaddap2", userDetailsServiceBeanName = "customDbUserDetailsService")
void findPatientById() throws Exception
{
MvcResult mvcResult = this.mockMvc.perform(get("/api/v1/person/find/1")).andDo(print()).andExpect(status().isOk()).andReturn();
assertNotNull(mvcResult);
}
}
Last active
December 22, 2021 23:35
-
-
Save pavankjadda/c10e9f341b6c15576cb3b56e3ec415e1 to your computer and use it in GitHub Desktop.
Spring Boot Integration Test
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment