44import com .salesforce .dockerfileimageupdate .model .*;
55import com .salesforce .dockerfileimageupdate .process .*;
66import net .sourceforge .argparse4j .inf .*;
7+ import org .json .JSONException ;
78import org .kohsuke .github .*;
89import org .mockito .*;
910import org .testng .*;
@@ -199,7 +200,7 @@ public void testisRenovateEnabledReturnsTrueIfRenovateConfigFileFoundButEnabledK
199200 }
200201
201202 @ Test
202- public void testisRenovateEnabledReturnsTrueIfRenovateConfigFileFoundAndResourcesThrowAnException () throws IOException {
203+ public void testisRenovateEnabledReturnsFalseIfRenovateConfigFileFoundAndResourcesThrowAnException () throws IOException {
203204 PullRequests pullRequests = new PullRequests ();
204205 List <String > filePaths = Collections .singletonList ("renovate.json" );
205206 GitHubContentToProcess gitHubContentToProcess = mock (GitHubContentToProcess .class );
@@ -211,6 +212,19 @@ public void testisRenovateEnabledReturnsTrueIfRenovateConfigFileFoundAndResource
211212 Assert .assertFalse (pullRequests .isRenovateEnabled (filePaths , gitHubContentToProcess ));
212213 }
213214
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+
214228 @ Test
215229 public void testisRenovateEnabledReturnsTrueIfRenovateConfigFileFoundAndEnabledKeySetToTrue () throws IOException {
216230 PullRequests pullRequests = new PullRequests ();
0 commit comments