galovics commented on code in PR #2744:
URL: https://github.com/apache/fineract/pull/2744#discussion_r1021800789
##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/jobs/filter/LoanCOBApiFilter.java:
##########
@@ -133,17 +133,9 @@ private void reject(Long loanId, HttpServletResponse
response, int status) throw
private Long getLoanId(boolean isGlim, Supplier<Stream<String>>
streamSupplier) {
if (!isGlim) {
- if (streamSupplier.get().count() >= LOAN_ID_INDEX_IN_URL + 1) {
- return
Long.valueOf(streamSupplier.get().skip(LOAN_ID_INDEX_IN_URL).findFirst().get());
- } else {
- return null;
- }
+ return
streamSupplier.get().skip(LOAN_ID_INDEX_IN_URL).findFirst().map(Long::valueOf).orElse(null);
Review Comment:
As far as I can tell the original test suite for this class doesn't cover
the else branch so please add new tests for it.
##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/jobs/filter/LoanCOBApiFilter.java:
##########
@@ -155,9 +147,6 @@ private boolean isOnApiList(HttpServletRequest request) {
}
private boolean isGlim(Supplier<Stream<String>> streamSupplier) {
- if (streamSupplier.get().count() >= GLIM_STRING_INDEX_IN_URL + 1) {
- return
"glimAccount".equals(streamSupplier.get().skip(GLIM_STRING_INDEX_IN_URL).findFirst().get());
- }
- return false;
+ return
streamSupplier.get().skip(GLIM_STRING_INDEX_IN_URL).findFirst().map(s ->
s.equals("glimAccount")).orElse(false);
Review Comment:
Same as above.
##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/jobs/filter/LoanCOBApiFilter.java:
##########
@@ -133,17 +133,9 @@ private void reject(Long loanId, HttpServletResponse
response, int status) throw
private Long getLoanId(boolean isGlim, Supplier<Stream<String>>
streamSupplier) {
if (!isGlim) {
- if (streamSupplier.get().count() >= LOAN_ID_INDEX_IN_URL + 1) {
- return
Long.valueOf(streamSupplier.get().skip(LOAN_ID_INDEX_IN_URL).findFirst().get());
- } else {
- return null;
- }
+ return
streamSupplier.get().skip(LOAN_ID_INDEX_IN_URL).findFirst().map(Long::valueOf).orElse(null);
} else {
- if (streamSupplier.get().count() >= GLIM_ID_INDEX_IN_URL + 1) {
- return
Long.valueOf(streamSupplier.get().skip(GLIM_ID_INDEX_IN_URL).findFirst().get());
- } else {
- return null;
- }
+ return
streamSupplier.get().skip(GLIM_ID_INDEX_IN_URL).findFirst().map(Long::valueOf).orElse(null);
Review Comment:
Same as above.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]