Answer the question
In order to leave comments, you need to log in
Why can't tests load datasets, tables themselves are created in postgres, but here he doesn't see them?
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.orm.jpa.AutoConfigureTestEntityManager;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@SpringBootTest(classes = JmApplication.class)
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE)
@AutoConfigureTestEntityManager
@AutoConfigureMockMvc
@DBRider
@DBUnit(caseSensitiveTableNames = true, allowEmptyFields = true, schema = "stack_jm_test")
@ActiveProfiles(value = "local")
@DataSet (value ={"/controllers/UserResourseController/user_entity.yml", "/controllers/UserResourseController/role.yml"})
class JmApplicationTests {
@Autowired
MockMvc mockMvc;
@Autowired
private UserResourseController userResourseController;
@Test
void getUserDtoByidTest() throws Exception {
this.mockMvc.perform(MockMvcRequestBuilders.get("/api/user/1"))
.andExpect(status().isOk());
}
}
user_entity:
- id: 1
about: "about"
city: "Moscow"
email: "email"
full_name: "Ivan"
image_link: "https://i.pinimg.com/originals/f4/d2/96/f4d2961b652880be432fb9580891ed62.png"
is_deleted: "false"
is_enabled: "true"
last_redaction_date: "2021-08-17 15:26:13.692"
link_github: "www.gitHub.com"
link_site: "www.site.ru"
link_vk: "www.vk/user/165465"
nickname: "charick"
password: "1234"
persist_date: "2021-08-17 15:26:13.692"
role_id: 1
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question