class UsersTemplate extends AbstractGithubTemplate implements UsersOperations {

	@Override
	public List<Email> listEmails() {
		return Arrays
				.asList(getRestOperations().getForEntity(buildUriString(USER_EMAILS_PATH), Email[].class).getBody());
	}

}

class UsersTemplateTest extends AbstractGithubTemplate {

	protected UsersTemplate usersTemplate;

	@Test
	public void getEmails() throws Exception {

		mockServer.expect(requestTo("https://api.github.com/user/emails")).andExpect(method(HttpMethod.GET))
				// .andExpect(header("Authorization", "Bearer ACCESS_TOKEN"))
				.andRespond(
						withSuccess(new ClassPathResource("listEmails.json", getClass()), MediaType.APPLICATION_JSON));

		List<Email> emailList = usersTemplate.listEmails();

		Assertions.assertThat(emailList).isNotNull();
		Assertions.assertThat(emailList.size()).isEqualTo(1);
	}

}