From 973d6a99aecaee4195cba2a537371a22ff90ad2e Mon Sep 17 00:00:00 2001 From: Sven Strittmatter Date: Fri, 26 Jan 2024 22:37:06 +0100 Subject: [PATCH] #23 Also return false if id value in query params is null Since the implementation of isNameEqual returns false, if the value in the map is null, we do this for id the same way to be consistent. Signed-off-by: Sven Strittmatter --- .../persistence/defectdojo/model/QueryParamsComparator.java | 5 ++++- .../defectdojo/model/QueryParamsComparatorTest.java | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/securecodebox/persistence/defectdojo/model/QueryParamsComparator.java b/src/main/java/io/securecodebox/persistence/defectdojo/model/QueryParamsComparator.java index bcc30c6b..9715aae5 100644 --- a/src/main/java/io/securecodebox/persistence/defectdojo/model/QueryParamsComparator.java +++ b/src/main/java/io/securecodebox/persistence/defectdojo/model/QueryParamsComparator.java @@ -39,7 +39,10 @@ static boolean isIdEqual(HasId model, Map queryParams) { return false; } - // FIXME: Since th generic type for value is Object, possible NPE here! + if (isNull(queryParams.get(QUERY_PARAM_KEY_FOR_ID))) { + return false; + } + return queryParams.get(QUERY_PARAM_KEY_FOR_ID).equals(model.getId()); } diff --git a/src/test/java/io/securecodebox/persistence/defectdojo/model/QueryParamsComparatorTest.java b/src/test/java/io/securecodebox/persistence/defectdojo/model/QueryParamsComparatorTest.java index 956e9e07..9a6ebad8 100644 --- a/src/test/java/io/securecodebox/persistence/defectdojo/model/QueryParamsComparatorTest.java +++ b/src/test/java/io/securecodebox/persistence/defectdojo/model/QueryParamsComparatorTest.java @@ -50,7 +50,6 @@ void isIdEqual_falseIfQueryParamsDoesNotContainId() { } @Test - @Disabled("Unclear if this behaviour will break something.") void isIdEqual_falseIfQueryParamValueIsNull() { final var queryParams = new HashMap(); queryParams.put(QueryParamsComparator.QUERY_PARAM_KEY_FOR_ID, null);