@@ -156,19 +156,35 @@ public void testReviewComment() throws IOException {
156156 }
157157
158158 @ Test
159- public void testCreateReviewDiscussionMissingIidFail () {
159+ public void testCreateReviewDiscussionMissingIidFallbackCommentOnCommit () throws IOException {
160160 GitLabPluginConfiguration gitLabPluginConfiguration = mock (GitLabPluginConfiguration .class );
161+ when (gitLabPluginConfiguration .commitSHA ()).thenReturn (Collections .singletonList ("1" ));
162+ when (gitLabPluginConfiguration .refName ()).thenReturn ("master" );
161163 when (gitLabPluginConfiguration .mergeRequestIid ()).thenReturn (-1 );
162164 when (gitLabPluginConfiguration .isMergeRequestDiscussionEnabled ()).thenReturn (true );
163165
164166 GitLabApiV4Wrapper facade = new GitLabApiV4Wrapper (gitLabPluginConfiguration );
165167
168+ GitLabAPI gitLabAPI = mock (GitLabAPI .class );
169+ facade .setGitLabAPI (gitLabAPI );
170+
171+ GitLabAPICommits gitLabAPICommits = mock (GitLabAPICommits .class );
172+ when (gitLabAPICommits .postCommitComments ("1" , "1" , "pending" , "master" , null , null )).thenReturn (null );
173+
174+ when (gitLabAPI .getGitLabAPICommits ()).thenReturn (gitLabAPICommits );
175+
166176 GitLabProject gitLabProject = mock (GitLabProject .class );
167177 when (gitLabProject .getId ()).thenReturn (1 );
168178 facade .setGitLabProject (gitLabProject );
169179
170- assertThatIllegalArgumentException ().isThrownBy (() ->
171- facade .createOrUpdateReviewComment (null , "src/main/Foo.java" , 5 , "nothing" ));
180+ facade .createOrUpdateReviewComment (null , "src/main/Foo.java" , 5 , "nothing" );
181+
182+ verify (gitLabAPICommits ).postCommitComments (1 , "1" , "nothing" , "src/main/Foo.java" , 5 , "new" );
183+
184+
185+
186+ //assertThatIllegalArgumentException().isThrownBy(() ->
187+ // facade.createOrUpdateReviewComment(null, "src/main/Foo.java", 5, "nothing"));
172188 }
173189
174190 @ Test
0 commit comments