Skip to content

Commit

Permalink
#90: Use correct field to retrieve Github repository name
Browse files Browse the repository at this point in the history
The Github ALM Binding Web Service uses the `AlmRepo` field to store the repository name, but the Github decorator was using `AlmSlug` to try and retrieve the repository name, so was getting a `null` value back and failing to find a matching repository. Switching to using `AlmRepo` in the decorator overcomes this issues.
  • Loading branch information
ndeitch authored and mc1arke committed Jun 7, 2020
1 parent 928c766 commit 89b5982
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public DecorationResult createCheckRun(AnalysisDetails analysisDetails, AlmSetti
ProjectAlmSettingDto projectAlmSettingDto) throws IOException, GeneralSecurityException {
String apiUrl = Optional.ofNullable(almSettingDto.getUrl()).orElseThrow(() -> new IllegalArgumentException("No URL has been set for Github connections"));
String apiPrivateKey = Optional.ofNullable(almSettingDto.getPrivateKey()).orElseThrow(() -> new IllegalArgumentException("No private key has been set for Github connections"));
String projectPath = Optional.ofNullable(projectAlmSettingDto.getAlmSlug()).orElseThrow(() -> new IllegalArgumentException("No repository name has been set for Github connections"));
String projectPath = Optional.ofNullable(projectAlmSettingDto.getAlmRepo()).orElseThrow(() -> new IllegalArgumentException("No repository name has been set for Github connections"));
String appId = Optional.ofNullable(almSettingDto.getAppId()).orElseThrow(() -> new IllegalArgumentException("No App ID has been set for Github connections"));

RepositoryAuthenticationToken repositoryAuthenticationToken =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void createCheckRunExceptionOnErrorResponse() throws IOException, General
when(graphqlProvider.createGraphQLTemplate()).thenReturn(graphQLTemplate);

ProjectAlmSettingDto projectAlmSettingDto = mock(ProjectAlmSettingDto.class);
when(projectAlmSettingDto.getAlmSlug()).thenReturn("dummy/repo");
when(projectAlmSettingDto.getAlmRepo()).thenReturn("dummy/repo");
AlmSettingDto almSettingDto = mock(AlmSettingDto.class);
when(almSettingDto.getUrl()).thenReturn("http://host.name");
when(almSettingDto.getAppId()).thenReturn("app id");
Expand Down Expand Up @@ -169,7 +169,7 @@ public void createCheckRunExceptionOnInvalidIssueSeverity() throws IOException,
when(almSettingDto.getUrl()).thenReturn("url");
when(almSettingDto.getAppId()).thenReturn("app ID");
when(almSettingDto.getPrivateKey()).thenReturn("key");
when(projectAlmSettingDto.getAlmSlug()).thenReturn("group/repo");
when(projectAlmSettingDto.getAlmRepo()).thenReturn("group/repo");

GraphqlCheckRunProvider testCase =
new GraphqlCheckRunProvider(graphqlProvider, clock, githubApplicationAuthenticationProvider, server);
Expand Down Expand Up @@ -382,7 +382,7 @@ private void createCheckRunHappyPath(QualityGate.Status status, String basePath,
when(graphqlProvider.createGraphQLTemplate()).thenReturn(graphQLTemplate);

ProjectAlmSettingDto projectAlmSettingDto = mock(ProjectAlmSettingDto.class);
when(projectAlmSettingDto.getAlmSlug()).thenReturn("dummy/repo");
when(projectAlmSettingDto.getAlmRepo()).thenReturn("dummy/repo");
AlmSettingDto almSettingDto = mock(AlmSettingDto.class);
when(almSettingDto.getUrl()).thenReturn(basePath);
when(almSettingDto.getAppId()).thenReturn("app id");
Expand Down Expand Up @@ -538,7 +538,7 @@ public void checkExcessIssuesCorrectlyReported() throws IOException, GeneralSecu
Server server = mock(Server.class);

ProjectAlmSettingDto projectAlmSettingDto = mock(ProjectAlmSettingDto.class);
when(projectAlmSettingDto.getAlmSlug()).thenReturn("dummy/repo");
when(projectAlmSettingDto.getAlmRepo()).thenReturn("dummy/repo");
AlmSettingDto almSettingDto = mock(AlmSettingDto.class);
when(almSettingDto.getUrl()).thenReturn("http://host.name");
when(almSettingDto.getAppId()).thenReturn("app id");
Expand Down Expand Up @@ -612,12 +612,12 @@ public void checkExceptionThrownOnMissingAppId() {
when(almSettingDto.getUrl()).thenReturn("url");
when(almSettingDto.getPrivateKey()).thenReturn("private key");
ProjectAlmSettingDto projectAlmSettingDto = mock(ProjectAlmSettingDto.class);
when(projectAlmSettingDto.getAlmSlug()).thenReturn("alm/repo");
when(projectAlmSettingDto.getAlmRepo()).thenReturn("alm/repo");

GraphqlCheckRunProvider underTest = new GraphqlCheckRunProvider(mock(Clock.class), mock(GithubApplicationAuthenticationProvider.class), mock(Server.class));
assertThatThrownBy(() -> underTest.createCheckRun(analysisDetails, almSettingDto, projectAlmSettingDto))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("No App ID has been set for Github connections");
}

}
}

0 comments on commit 89b5982

Please sign in to comment.