@@ -0,0 +1,2471 @@
+package cane.brothers.spring;%0A%0Aimport static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.http.MediaType;%0Aimport org.springframework.test.context.ContextConfiguration;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;%0Aimport org.springframework.test.context.web.WebAppConfiguration;%0Aimport org.springframework.test.web.servlet.MockMvc;%0Aimport org.springframework.test.web.servlet.setup.MockMvcBuilders;%0Aimport org.springframework.web.context.WebApplicationContext;%0A%0Aimport cane.brothers.spring.model.Item;%0Aimport cane.brothers.spring.repo.ItemRepository;%0A%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@ContextConfiguration(classes = BootApplication.class)%0A@WebAppConfiguration%0Apublic class ItemRepoMockMvcIT %7B%0A%0A%09public static final MediaType APPLICATION_JSON_UTF8 = new MediaType(MediaType.APPLICATION_JSON.getType(),%0A%09%09%09%22hal+json%22);%0A%0A%09private MockMvc mockMvc;%0A%09%0A%09@Autowired%0A%09ItemRepository repository;%0A%09%0A%09Item testItem;%0A%0A%09@Autowired%0A%09private WebApplicationContext webApplicationContext;%0A%0A%09@Before%0A%09public void setUp() %7B%0A%09%09// %D0%B8%D0%BD%D0%B8%D1%86%D0%B8%D0%B0%D0%BB%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D1%8F %D0%BF%D1%80%D0%BE%D1%85%D0%BE%D0%B4%D0%B8%D1%82 %D0%BA%D0%B0%D0%B6%D0%B4%D1%8B%D0%B9 %D1%80%D0%B0%D0%B7 %D0%BF%D0%B5%D1%80%D0%B5%D0%B4 @Test%0A%09%09testItem = new Item(%22test%22, %22test item%22);%0A%09%09%0A        repository.deleteAll();%0A        testItem = repository.save(testItem);%0A%0A%09%09mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();%0A%09%7D%0A%0A%09@Test%0A%09public void canFindAll_ShouldReturnItems() throws Exception %7B%0A%09%09mockMvc.perform(get(%22/items%22))%0A%09%09%09.andExpect(status().isOk())%0A%09%09%09.andExpect(content().contentType(APPLICATION_JSON_UTF8));%0A%09%09%09//.andExpect(jsonPath(%22$._embedded.items.length()%22).value(1));%0A%09%09%09//.andDo(print());%0A%09%7D%0A%09%0A%09@Test%0A    public void canFindOne_ShouldReturnItem() throws Exception %7B%0A%09%09//not working%0A%09%09mockMvc.perform(get(%22/items/%7Bid%7D%22, testItem.getId()))%0A        %09%09.andExpect(status().isOk())%0A        %09%09.andExpect(jsonPath(%22$.name%22).value(%22test%22));%0A    %7D%0A%09%0A%09@Test%0A    public void canNotFindOne_ShouldReturnItem() throws Exception %7B%0A        mockMvc.perform(get(%22/items/1000%22))%0A        %09%09.andExpect(status().isNotFound());%0A    %7D%0A%7D%0A

add MockMvc IT