4
4
import com .salesforce .dockerfileimageupdate .model .*;
5
5
import com .salesforce .dockerfileimageupdate .process .*;
6
6
import net .sourceforge .argparse4j .inf .*;
7
+ import org .json .JSONException ;
7
8
import org .kohsuke .github .*;
8
9
import org .mockito .*;
9
10
import org .testng .*;
@@ -199,7 +200,7 @@ public void testisRenovateEnabledReturnsTrueIfRenovateConfigFileFoundButEnabledK
199
200
}
200
201
201
202
@ Test
202
- public void testisRenovateEnabledReturnsTrueIfRenovateConfigFileFoundAndResourcesThrowAnException () throws IOException {
203
+ public void testisRenovateEnabledReturnsFalseIfRenovateConfigFileFoundAndResourcesThrowAnException () throws IOException {
203
204
PullRequests pullRequests = new PullRequests ();
204
205
List <String > filePaths = Collections .singletonList ("renovate.json" );
205
206
GitHubContentToProcess gitHubContentToProcess = mock (GitHubContentToProcess .class );
@@ -211,6 +212,19 @@ public void testisRenovateEnabledReturnsTrueIfRenovateConfigFileFoundAndResource
211
212
Assert .assertFalse (pullRequests .isRenovateEnabled (filePaths , gitHubContentToProcess ));
212
213
}
213
214
215
+ @ Test
216
+ public void testisRenovateEnabledReturnsFalseIfRenovateConfigFileFoundAndJSONParsingThrowsAnException () throws IOException {
217
+ PullRequests pullRequests = new PullRequests ();
218
+ List <String > filePaths = Collections .singletonList ("renovate.json" );
219
+ GitHubContentToProcess gitHubContentToProcess = mock (GitHubContentToProcess .class );
220
+ GHRepository ghRepository = mock (GHRepository .class );
221
+ GHContent content = mock (GHContent .class );
222
+ when (gitHubContentToProcess .getParent ()).thenReturn (ghRepository );
223
+ when (ghRepository .getFileContent (anyString ())).thenReturn (content );
224
+ when (content .read ()).thenThrow (new JSONException ("" ));
225
+ Assert .assertFalse (pullRequests .isRenovateEnabled (filePaths , gitHubContentToProcess ));
226
+ }
227
+
214
228
@ Test
215
229
public void testisRenovateEnabledReturnsTrueIfRenovateConfigFileFoundAndEnabledKeySetToTrue () throws IOException {
216
230
PullRequests pullRequests = new PullRequests ();
0 commit comments