use of com.nixmash.blog.jpa.dto.GitHubDTO in project nixmash-blog by mintster.
the class GithubJobUI method getDummyStats.
public GitHubDTO getDummyStats() {
GitHubDTO gitHubDTO = new GitHubDTO();
gitHubDTO.setStars(251);
gitHubDTO.setForks(87);
gitHubDTO.setSubscribers(45);
gitHubDTO.setFollowers(87);
return gitHubDTO;
}
use of com.nixmash.blog.jpa.dto.GitHubDTO in project nixmash-blog by mintster.
the class GitHubTests method getGitHubProjectStatsInClassObject.
@Test
public void getGitHubProjectStatsInClassObject() throws Exception {
GitHubDTO gitHubDTO = restTemplate.getForObject(gitHubRepoUrl, GitHubDTO.class);
assertThat(gitHubDTO.getSubscribers(), greaterThan(-1));
HttpEntity<String> stringUserEntity = restTemplate.getForEntity(gitHubUserUrl, String.class);
ObjectMapper mapper = new ObjectMapper();
ObjectNode node = mapper.readValue(stringUserEntity.getBody(), ObjectNode.class);
gitHubDTO.setFollowers(node.get("followers").intValue());
assertThat(gitHubDTO.getFollowers(), greaterThan(-1));
}
use of com.nixmash.blog.jpa.dto.GitHubDTO in project nixmash-blog by mintster.
the class WebUI method getGitHubStats.
public GitHubDTO getGitHubStats() {
String gitHubRepoUrl = environment.getProperty("github.repo.url");
String gitHubUserUrl = environment.getProperty("github.user.url");
// Load Repository JSON elements into GitHubDTO Object
GitHubDTO gitHubDTO = new GitHubDTO();
RestTemplate restTemplate = new RestTemplate();
try {
gitHubDTO = restTemplate.getForObject(gitHubRepoUrl, GitHubDTO.class);
} catch (RestClientException e) {
gitHubDTO.setIsEmpty(true);
return gitHubDTO;
}
// Load User Followers count from GitHub User JSON Endpoint and add to GitHubDTO
HttpEntity<String> stringUserEntity = restTemplate.getForEntity(gitHubUserUrl, String.class);
ObjectMapper mapper = new ObjectMapper();
try {
ObjectNode node = mapper.readValue(stringUserEntity.getBody(), ObjectNode.class);
gitHubDTO.setFollowers(node.get("followers").intValue());
} catch (IOException e) {
logger.error("Error adding follower count from GitHub API to GitHubDTO object");
}
return gitHubDTO;
}
use of com.nixmash.blog.jpa.dto.GitHubDTO in project nixmash-blog by mintster.
the class GithubJobUI method getGitHubStats.
public GitHubDTO getGitHubStats() {
String gitHubRepoUrl = environment.getProperty("github.job.repo.url");
String gitHubUserUrl = environment.getProperty("github.job.user.url");
// Load Repository JSON elements into GitHubDTO Object
GitHubDTO gitHubDTO = new GitHubDTO();
RestTemplate restTemplate = new RestTemplate();
try {
gitHubDTO = restTemplate.getForObject(gitHubRepoUrl, GitHubDTO.class);
} catch (RestClientException e) {
gitHubDTO.setIsEmpty(true);
return gitHubDTO;
}
// Load User Followers count from GitHub User JSON Endpoint and add to GitHubDTO
HttpEntity<String> stringUserEntity = restTemplate.getForEntity(gitHubUserUrl, String.class);
ObjectMapper mapper = new ObjectMapper();
try {
ObjectNode node = mapper.readValue(stringUserEntity.getBody(), ObjectNode.class);
gitHubDTO.setFollowers(node.get("followers").intValue());
} catch (IOException e) {
logger.error("Error adding follower count from GitHub API to GitHubDTO object");
}
return gitHubDTO;
}
Aggregations