@@ -156,19 +156,35 @@ public void testReviewComment() throws IOException {
156
156
}
157
157
158
158
@ Test
159
- public void testCreateReviewDiscussionMissingIidFail () {
159
+ public void testCreateReviewDiscussionMissingIidFallbackCommentOnCommit () throws IOException {
160
160
GitLabPluginConfiguration gitLabPluginConfiguration = mock (GitLabPluginConfiguration .class );
161
+ when (gitLabPluginConfiguration .commitSHA ()).thenReturn (Collections .singletonList ("1" ));
162
+ when (gitLabPluginConfiguration .refName ()).thenReturn ("master" );
161
163
when (gitLabPluginConfiguration .mergeRequestIid ()).thenReturn (-1 );
162
164
when (gitLabPluginConfiguration .isMergeRequestDiscussionEnabled ()).thenReturn (true );
163
165
164
166
GitLabApiV4Wrapper facade = new GitLabApiV4Wrapper (gitLabPluginConfiguration );
165
167
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
+
166
176
GitLabProject gitLabProject = mock (GitLabProject .class );
167
177
when (gitLabProject .getId ()).thenReturn (1 );
168
178
facade .setGitLabProject (gitLabProject );
169
179
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"));
172
188
}
173
189
174
190
@ Test
0 commit comments