Source:
<code>public static void testPatchLineOfCredit() throws MambuApiException{ String methodName = new Object() {}.getClass().getEnclosingMethod().getName(); System.out.println("\nIn " + methodName); LinesOfCreditService linesOfCreditService = MambuAPIFactory.getLineOfCreditService(); final String clientId = DemoUtil.getDemoClient().getId(); List<LineOfCredit> clientLoCs = linesOfCreditService.getClientLinesOfCredit(clientId, 0, 5); System.out.println(clientLoCs.size() + " lines of credit for Client " + clientId); <START> if(clientLoCs.isEmpty() && clientLoCs.get(0) == null){ <END> System.out.println("WARNING: " + methodName + " could not be tested because there are no LoCs to be patched"); }else{ LineOfCredit lineOfCredit = clientLoCs.get(0); Calendar patchDate = Calendar.getInstance(); lineOfCredit.setId("LOC" + System.currentTimeMillis()); patchDate.add(Calendar.DAY_OF_MONTH, 1); lineOfCredit.setStartDate(patchDate.getTime()); patchDate.add(Calendar.YEAR, 2); lineOfCredit.setExpiryDate(patchDate.getTime()); lineOfCredit.setAmount(lineOfCredit.getAmount().add(new Money("5000"))); lineOfCredit.setNotes("Note updated through APIs today " + new Date()); boolean booleanResult = linesOfCreditService.patchLinesOfCredit(lineOfCredit.getEncodedKey(), lineOfCredit); System.out.println("PATCH LoC result is = " + booleanResult); lineOfCredit = linesOfCreditService.getLineOfCredit(lineOfCredit.getEncodedKey()); logLineOfCreditDetails(lineOfCredit); } }</code><technical_language>operator instead of AND. If part of condition is true, meaning list of lines of credit is empty, is reason check item ( .get(0)) of collection is null not. other hand, if collection is empty, element null. Therefore, I suggest transform condition clientLoCs.isEmpty() || clientLoCs.get(0) == null</technical_language>

Target:
public static void testPatchLineOfCredit() throws MambuApiException{ String methodName = new Object() {}.getClass().getEnclosingMethod().getName(); System.out.println("\nIn " + methodName); LinesOfCreditService linesOfCreditService = MambuAPIFactory.getLineOfCreditService(); final String clientId = DemoUtil.getDemoClient().getId(); List<LineOfCredit> clientLoCs = linesOfCreditService.getClientLinesOfCredit(clientId, 0, 5); System.out.println(clientLoCs.size() + " lines of credit for Client " + clientId); if(clientLoCs.isEmpty() || clientLoCs.get(0) == null){ System.out.println("WARNING: " + methodName + " could not be tested because there are no LoCs to be patched"); }else{ LineOfCredit lineOfCredit = clientLoCs.get(0); Calendar patchDate = Calendar.getInstance(); lineOfCredit.setId("LOC" + System.currentTimeMillis()); patchDate.add(Calendar.DAY_OF_MONTH, 1); lineOfCredit.setStartDate(patchDate.getTime()); patchDate.add(Calendar.YEAR, 2); lineOfCredit.setExpiryDate(patchDate.getTime()); lineOfCredit.setAmount(lineOfCredit.getAmount().add(new Money("5000"))); lineOfCredit.setNotes("Note updated through APIs today " + new Date()); boolean patchResult = linesOfCreditService.patchLinesOfCredit(lineOfCredit); System.out.println("PATCH LoC result is = " + patchResult); lineOfCredit = linesOfCreditService.getLineOfCredit(lineOfCredit.getEncodedKey()); logLineOfCreditDetails(lineOfCredit); } }