class GitHubApiController {

    @GetMapping("user/{screenName}")
    public ResponseEntity<User> discoverUserByScreenName(@PathVariable("screenName")  String screenName) {
        return Optional.of(ResponseEntity.ok(gitHubService.discoverUserByScreenName(screenName)))
                .or(new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
    }

}

class GitHubApiControllerTest {

    @LocalServerPort
    private int port;
    @Autowired
    private TestRestTemplate restTemplate;

    @Test
    public void testDiscoverUserByScreenName() throws Exception {

        ResponseEntity<User> user1 = restTemplate.getForEntity("http://localhost:" + port + "/v1/user/bingohuang", User.class);
        assertEquals(HttpStatus.OK, user1.getStatusCode());

        ResponseEntity<User> user2 = restTemplate.getForEntity("http://localhost:" + port + "/v1/user/163yun", User.class);
        assertEquals(HttpStatus.OK, user2.getStatusCode());

        ResponseEntity<User> user3 = restTemplate.getForEntity("http://localhost:" + port + "/v1/user/huangqingbing", User.class);
        assertEquals(HttpStatus.OK, user3.getStatusCode());
    }

}