Search in sources :

Example 1 with GithubServerFetchHandler

use of com.hp.octane.integrations.services.pullrequestsandbranches.github.GithubServerFetchHandler in project octane-ci-java-sdk by MicroFocus.

the class FetchHandlerTests method githubServerTest.

@Test
public void githubServerTest() {
    GithubServerFetchHandler handler = new GithubServerFetchHandler(new NoCredentialsStrategy());
    String result = handler.getRepoApiPath("https://github.houston.softwaregrp.net/MQM/mqm.git");
    Assert.assertEquals("getRepoApiPath for https failed", "https://github.houston.softwaregrp.net/api/v3/repos/MQM/mqm", result);
    result = handler.getApiPath("https://github.houston.softwaregrp.net/MQM/mqm.git");
    Assert.assertEquals("getApiPath for https failed", "https://github.houston.softwaregrp.net/api/v3", result);
}
Also used : NoCredentialsStrategy(com.hp.octane.integrations.services.pullrequestsandbranches.rest.authentication.NoCredentialsStrategy) GithubServerFetchHandler(com.hp.octane.integrations.services.pullrequestsandbranches.github.GithubServerFetchHandler) Test(org.junit.Test)

Example 2 with GithubServerFetchHandler

use of com.hp.octane.integrations.services.pullrequestsandbranches.github.GithubServerFetchHandler in project octane-ci-java-sdk by MicroFocus.

the class FetchHandlerTests method githubServerParseLinks.

@Test
public void githubServerParseLinks() throws JsonProcessingException {
    String body = "{\"id\":237845737,\"node_id\":\"MDEwOlJlcG9zaXRvcnkyMzc4NDU3Mzc=\",\"name\":\"trial\",\"full_name\":\"radislavB/trial\",\"private\":false,\"owner\":{\"login\":\"radislavB\",\"id\":20180777,\"node_id\":\"MDQ6VXNlcjIwMTgwNzc3\",\"avatar_url\":\"https://avatars.githubusercontent.com/u/20180777?v=4\",\"gravatar_id\":\"\",\"url\":\"https://api.github.com/users/radislavB\",\"html_url\":\"https://github.com/radislavB\",\"followers_url\":\"https://api.github.com/users/radislavB/followers\",\"following_url\":\"https://api.github.com/users/radislavB/following{/other_user}\",\"gists_url\":\"https://api.github.com/users/radislavB/gists{/gist_id}\",\"starred_url\":\"https://api.github.com/users/radislavB/starred{/owner}{/repo}\",\"subscriptions_url\":\"https://api.github.com/users/radislavB/subscriptions\",\"organizations_url\":\"https://api.github.com/users/radislavB/orgs\",\"repos_url\":\"https://api.github.com/users/radislavB/repos\",\"events_url\":\"https://api.github.com/users/radislavB/events{/privacy}\",\"received_events_url\":\"https://api.github.com/users/radislavB/received_events\",\"type\":\"User\",\"site_admin\":false},\"html_url\":\"https://github.com/radislavB/trial\",\"description\":\"trial\",\"fork\":false,\"url\":\"https://api.github.com/repos/radislavB/trial\",\"forks_url\":\"https://api.github.com/repos/radislavB/trial/forks\",\"keys_url\":\"https://api.github.com/repos/radislavB/trial/keys{/key_id}\",\"collaborators_url\":\"https://api.github.com/repos/radislavB/trial/collaborators{/collaborator}\",\"teams_url\":\"https://api.github.com/repos/radislavB/trial/teams\",\"hooks_url\":\"https://api.github.com/repos/radislavB/trial/hooks\",\"issue_events_url\":\"https://api.github.com/repos/radislavB/trial/issues/events{/number}\",\"events_url\":\"https://api.github.com/repos/radislavB/trial/events\",\"assignees_url\":\"https://api.github.com/repos/radislavB/trial/assignees{/user}\",\"branches_url\":\"https://api.github.com/repos/radislavB/trial/branches{/branch}\",\"tags_url\":\"https://api.github.com/repos/radislavB/trial/tags\",\"blobs_url\":\"https://api.github.com/repos/radislavB/trial/git/blobs{/sha}\",\"git_tags_url\":\"https://api.github.com/repos/radislavB/trial/git/tags{/sha}\",\"git_refs_url\":\"https://api.github.com/repos/radislavB/trial/git/refs{/sha}\",\"trees_url\":\"https://api.github.com/repos/radislavB/trial/git/trees{/sha}\",\"statuses_url\":\"https://api.github.com/repos/radislavB/trial/statuses/{sha}\",\"languages_url\":\"https://api.github.com/repos/radislavB/trial/languages\",\"stargazers_url\":\"https://api.github.com/repos/radislavB/trial/stargazers\",\"contributors_url\":\"https://api.github.com/repos/radislavB/trial/contributors\",\"subscribers_url\":\"https://api.github.com/repos/radislavB/trial/subscribers\",\"subscription_url\":\"https://api.github.com/repos/radislavB/trial/subscription\",\"commits_url\":\"https://api.github.com/repos/radislavB/trial/commits{/sha}\",\"git_commits_url\":\"https://api.github.com/repos/radislavB/trial/git/commits{/sha}\",\"comments_url\":\"https://api.github.com/repos/radislavB/trial/comments{/number}\",\"issue_comment_url\":\"https://api.github.com/repos/radislavB/trial/issues/comments{/number}\",\"contents_url\":\"https://api.github.com/repos/radislavB/trial/contents/{+path}\",\"compare_url\":\"https://api.github.com/repos/radislavB/trial/compare/{base}...{head}\",\"merges_url\":\"https://api.github.com/repos/radislavB/trial/merges\",\"archive_url\":\"https://api.github.com/repos/radislavB/trial/{archive_format}{/ref}\",\"downloads_url\":\"https://api.github.com/repos/radislavB/trial/downloads\",\"issues_url\":\"https://api.github.com/repos/radislavB/trial/issues{/number}\",\"pulls_url\":\"https://api.github.com/repos/radislavB/trial/pulls{/number}\",\"milestones_url\":\"https://api.github.com/repos/radislavB/trial/milestones{/number}\",\"notifications_url\":\"https://api.github.com/repos/radislavB/trial/notifications{?since,all,participating}\",\"labels_url\":\"https://api.github.com/repos/radislavB/trial/labels{/name}\",\"releases_url\":\"https://api.github.com/repos/radislavB/trial/releases{/id}\",\"deployments_url\":\"https://api.github.com/repos/radislavB/trial/deployments\",\"created_at\":\"2020-02-02T22:21:33Z\",\"updated_at\":\"2021-03-04T12:02:08Z\",\"pushed_at\":\"2021-03-04T12:02:06Z\",\"git_url\":\"git://github.com/radislavB/trial.git\",\"ssh_url\":\"git@github.com:radislavB/trial.git\",\"clone_url\":\"https://github.com/radislavB/trial.git\",\"svn_url\":\"https://github.com/radislavB/trial\",\"homepage\":null,\"size\":45,\"stargazers_count\":0,\"watchers_count\":0,\"language\":null,\"has_issues\":true,\"has_projects\":true,\"has_downloads\":true,\"has_wiki\":true,\"has_pages\":false,\"forks_count\":0,\"mirror_url\":null,\"archived\":false,\"disabled\":false,\"open_issues_count\":4,\"license\":null,\"forks\":0,\"open_issues\":4,\"watchers\":0,\"default_branch\":\"master\",\"permissions\":{\"admin\":true,\"push\":true,\"pull\":true},\"temp_clone_token\":\"\",\"allow_squash_merge\":true,\"allow_merge_commit\":true,\"allow_rebase_merge\":true,\"delete_branch_on_merge\":false,\"network_count\":0,\"subscribers_count\":1}";
    GithubServerFetchHandler handler = new GithubServerFetchHandler(new NoCredentialsStrategy());
    SCMRepositoryLinks links = handler.parseSCMRepositoryLinks(body);
    Assert.assertEquals("git@github.com:radislavB/trial.git", links.getSshUrl());
    Assert.assertEquals("https://github.com/radislavB/trial.git", links.getHttpUrl());
}
Also used : NoCredentialsStrategy(com.hp.octane.integrations.services.pullrequestsandbranches.rest.authentication.NoCredentialsStrategy) SCMRepositoryLinks(com.hp.octane.integrations.dto.scm.SCMRepositoryLinks) GithubServerFetchHandler(com.hp.octane.integrations.services.pullrequestsandbranches.github.GithubServerFetchHandler) Test(org.junit.Test)

Aggregations

GithubServerFetchHandler (com.hp.octane.integrations.services.pullrequestsandbranches.github.GithubServerFetchHandler)2 NoCredentialsStrategy (com.hp.octane.integrations.services.pullrequestsandbranches.rest.authentication.NoCredentialsStrategy)2 Test (org.junit.Test)2 SCMRepositoryLinks (com.hp.octane.integrations.dto.scm.SCMRepositoryLinks)1