Click here to Skip to main content
15,313,290 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.

class HubServiceTest {

    private HubService hubService;

    private ConnectHttp connectHttp;
    private Controller controller;

    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");


What I have tried:

I set it stiff in a mock

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