Created
April 13, 2020 13:29
-
-
Save pradeepwebonise/854e5c67e6f01be3795065fb75b8cc97 to your computer and use it in GitHub Desktop.
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
import org.junit.Before; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.mockito.InjectMocks; | |
import org.mockito.Mock; | |
import org.mockito.MockitoAnnotations; | |
import org.springframework.http.MediaType; | |
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | |
import org.springframework.test.web.servlet.MockMvc; | |
import org.springframework.test.web.servlet.setup.MockMvcBuilders; | |
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | |
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | |
@RunWith(SpringJUnit4ClassRunner.class) | |
public class TestControllerTest { | |
private static final String SEARCH_KEY = "aa"; | |
@Mock | |
private TestService trackService; | |
@InjectMocks | |
private TestController testController; | |
private MockMvc mockMvc; | |
@Before | |
public void setUp() { | |
MockitoAnnotations.initMocks(this); | |
mockMvc = MockMvcBuilders.standaloneSetup(trackController).build(); | |
} | |
@Test | |
public void testGetTracks() throws Exception { | |
mockMvc.perform(get("/tracks") | |
.param("searchKey", SEARCH_KEY) | |
.contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment