@Test public void parseIssueInformation() throws Exception { GithubResult githubResult = GithubResultMother.kazuki43zooApiStub42().build(); String owner = "kazuki43zoo"; String repo = "api-stub"; String number = "42"; when(githubGateway.getIssue(owner, repo, number)) .thenReturn(githubResult); String platformId = owner + PLATFORM_ID_GITHUB_DELIMTER + repo + PLATFORM_ID_GITHUB_DELIMTER + number; IssueInformation result = parser.parseIssue(platformId); assertThat(result.getNumber()).isEqualTo(number); assertThat(result.getOwner()).isEqualTo(owner); assertThat(result.getRepo()).isEqualTo(repo); assertThat(result.getTitle()).isEqualTo(githubResult.getTitle()); assertThat(result.getPlatform()).isEqualTo(Platform.GITHUB); assertThat(result.getPlatformId()).isEqualTo(platformId); }
public IssueInformation parseIssue(String platformId) { IssueInformation issueInformation = IssueInformation.builder().build(); String[] splitted = platformId.split(Pattern.quote(PLATFORM_ID_GITHUB_DELIMTER)); issueInformation.setOwner(splitted[0]); issueInformation.setRepo(splitted[1]); issueInformation.setNumber(splitted[2]); GithubResult githubResult = githubGateway.getIssue( issueInformation.getOwner(), issueInformation.getRepo(), issueInformation.getNumber() ); issueInformation.setTitle(githubResult.getTitle()); issueInformation.setPlatform(Platform.GITHUB); issueInformation.setPlatformId(platformId); return issueInformation; }
GithubPlatformIdParser { public IssueInformation parseIssue(String platformId) { IssueInformation issueInformation = IssueInformation.builder().build(); String[] splitted = platformId.split(Pattern.quote(PLATFORM_ID_GITHUB_DELIMTER)); issueInformation.setOwner(splitted[0]); issueInformation.setRepo(splitted[1]); issueInformation.setNumber(splitted[2]); GithubResult githubResult = githubGateway.getIssue( issueInformation.getOwner(), issueInformation.getRepo(), issueInformation.getNumber() ); issueInformation.setTitle(githubResult.getTitle()); issueInformation.setPlatform(Platform.GITHUB); issueInformation.setPlatformId(platformId); return issueInformation; } }
GithubPlatformIdParser { public IssueInformation parseIssue(String platformId) { IssueInformation issueInformation = IssueInformation.builder().build(); String[] splitted = platformId.split(Pattern.quote(PLATFORM_ID_GITHUB_DELIMTER)); issueInformation.setOwner(splitted[0]); issueInformation.setRepo(splitted[1]); issueInformation.setNumber(splitted[2]); GithubResult githubResult = githubGateway.getIssue( issueInformation.getOwner(), issueInformation.getRepo(), issueInformation.getNumber() ); issueInformation.setTitle(githubResult.getTitle()); issueInformation.setPlatform(Platform.GITHUB); issueInformation.setPlatformId(platformId); return issueInformation; } GithubPlatformIdParser(GithubGateway githubGateway); }
GithubPlatformIdParser { public IssueInformation parseIssue(String platformId) { IssueInformation issueInformation = IssueInformation.builder().build(); String[] splitted = platformId.split(Pattern.quote(PLATFORM_ID_GITHUB_DELIMTER)); issueInformation.setOwner(splitted[0]); issueInformation.setRepo(splitted[1]); issueInformation.setNumber(splitted[2]); GithubResult githubResult = githubGateway.getIssue( issueInformation.getOwner(), issueInformation.getRepo(), issueInformation.getNumber() ); issueInformation.setTitle(githubResult.getTitle()); issueInformation.setPlatform(Platform.GITHUB); issueInformation.setPlatformId(platformId); return issueInformation; } GithubPlatformIdParser(GithubGateway githubGateway); static String extractOwner(final String platformId); static String extractRepo(String platformId); static String extractIssueNumber(final String platformId); IssueInformation parseIssue(String platformId); }
GithubPlatformIdParser { public IssueInformation parseIssue(String platformId) { IssueInformation issueInformation = IssueInformation.builder().build(); String[] splitted = platformId.split(Pattern.quote(PLATFORM_ID_GITHUB_DELIMTER)); issueInformation.setOwner(splitted[0]); issueInformation.setRepo(splitted[1]); issueInformation.setNumber(splitted[2]); GithubResult githubResult = githubGateway.getIssue( issueInformation.getOwner(), issueInformation.getRepo(), issueInformation.getNumber() ); issueInformation.setTitle(githubResult.getTitle()); issueInformation.setPlatform(Platform.GITHUB); issueInformation.setPlatformId(platformId); return issueInformation; } GithubPlatformIdParser(GithubGateway githubGateway); static String extractOwner(final String platformId); static String extractRepo(String platformId); static String extractIssueNumber(final String platformId); IssueInformation parseIssue(String platformId); static final String PLATFORM_ID_GITHUB_DELIMTER; }