From 9b3aedfb57f23873a1064247e889d34efacbbb66 Mon Sep 17 00:00:00 2001 From: Natan Deitch Date: Thu, 20 Feb 2020 05:39:32 -0300 Subject: [PATCH] #90: Use correct field to retrieve Github repository name 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. --- .../ce/pullrequest/github/v4/GraphqlCheckRunProvider.java | 2 +- .../pullrequest/github/v4/GraphqlCheckRunProviderTest.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProvider.java b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProvider.java index be4fd617d..276261f09 100644 --- a/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProvider.java +++ b/src/main/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProvider.java @@ -99,7 +99,7 @@ public void createCheckRun(AnalysisDetails analysisDetails, AlmSettingDto almSet ProjectAlmSettingDto projectAlmSettingDto) throws IOException, GeneralSecurityException { String apiUrl = almSettingDto.getUrl(); String apiPrivateKey = almSettingDto.getPrivateKey(); - String projectPath = projectAlmSettingDto.getAlmSlug(); + String projectPath = projectAlmSettingDto.getAlmRepo(); String appId = almSettingDto.getAppId(); RepositoryAuthenticationToken repositoryAuthenticationToken = diff --git a/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProviderTest.java b/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProviderTest.java index 5c1ef9117..d089fbd92 100644 --- a/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProviderTest.java +++ b/src/test/java/com/github/mc1arke/sonarqube/plugin/ce/pullrequest/github/v4/GraphqlCheckRunProviderTest.java @@ -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"); @@ -325,7 +325,7 @@ private void createCheckRunHappyPath(QualityGate.Status status) throws IOExcepti 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"); @@ -505,4 +505,4 @@ public void checkCorrectDefaultValuesInjected() { .isEqualTo(new GraphqlCheckRunProvider(new DefaultGraphqlProvider(), clock, githubApplicationAuthenticationProvider, server)); } -} \ No newline at end of file +}