Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Mock in Test that has JSON and it's big. How to load it from a file. Whether Mock should be in the resource directory or should it be in the test directory.


Java
@ExtendWith(MockitoExtension.class)
class HubServiceTest {

    @InjectMocks
    private HubService hubService;

    @Mock
    private ConnectHttp connectHttp;
    private Controller controller;

    @Test
    public void shouldReturnCorrectRepositories() {

        when(connectHttp.connect(Mockito.any())).thenReturn("[\n" +
                "    {\n" +
                "        \"id\": 277322841,\n" +
                "        \"node_id\": \"MDEwOlJlcG9zaXRvcnkyNzczMjI4NDE=\",\n"}]")
<pre>  List<PojoGitHub> result = hubService.getRepositories("test");

        assertThat(result).isNotNull();
    }







What I have tried:

I set it stiff in a mock
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900