|
|
@ -0,0 +1,47 @@ |
|
|
|
|
|
package com.example.urbanbazaar.controller; |
|
|
|
|
|
|
|
|
|
|
|
import static org.hamcrest.collection.IsCollectionWithSize.hasSize; |
|
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; |
|
|
|
|
|
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Before; |
|
|
|
|
|
import org.junit.FixMethodOrder; |
|
|
|
|
|
import org.junit.Test; |
|
|
|
|
|
import org.junit.runner.RunWith; |
|
|
|
|
|
import org.junit.runners.MethodSorters; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
|
import org.springframework.boot.test.context.SpringBootTest; |
|
|
|
|
|
import org.springframework.http.MediaType; |
|
|
|
|
|
import org.springframework.test.context.ContextConfiguration; |
|
|
|
|
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
|
|
|
|
|
import org.springframework.test.web.servlet.MockMvc; |
|
|
|
|
|
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; |
|
|
|
|
|
import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
|
|
|
|
|
import org.springframework.web.context.WebApplicationContext; |
|
|
|
|
|
|
|
|
|
|
|
import com.example.urbanbazaar.UbUserServiceProxyApplication; |
|
|
|
|
|
|
|
|
|
|
|
@RunWith(SpringJUnit4ClassRunner.class) |
|
|
|
|
|
@ContextConfiguration(classes = UbUserServiceProxyApplication.class) |
|
|
|
|
|
@SpringBootTest |
|
|
|
|
|
@FixMethodOrder(MethodSorters.NAME_ASCENDING) |
|
|
|
|
|
public class MemberControllerTest { |
|
|
|
|
|
private MockMvc mockMvc; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private WebApplicationContext wac; |
|
|
|
|
|
|
|
|
|
|
|
@Before |
|
|
|
|
|
public void setUp() { |
|
|
|
|
|
this.mockMvc = MockMvcBuilders.webAppContextSetup(wac).build(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
public void shouldFetchAllMembers() throws Exception { |
|
|
|
|
|
this.mockMvc.perform(MockMvcRequestBuilders.get("/users/showAllMembers") |
|
|
|
|
|
.accept(MediaType.APPLICATION_JSON)) |
|
|
|
|
|
.andDo(print()) |
|
|
|
|
|
.andExpect(jsonPath("$", hasSize(4))) |
|
|
|
|
|
.andReturn(); |
|
|
|
|
|
} |
|
|
|
|
|
} |