Skip to content

Commit

Permalink
fix: NPE when delete eventVisualization (#19313)
Browse files Browse the repository at this point in the history
  • Loading branch information
vietnguyen authored Nov 27, 2024
1 parent 5efe91f commit 947d4dc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,13 @@ private void collectScanTargets(Map<Class<?>, List<?>> targets) {
}

objects.forEach(
o -> list.addAll(ReflectionUtils.invokeMethod(o, property.getGetterMethod())));
o -> {
Collection<Object> propertyValue =
ReflectionUtils.invokeMethod(o, property.getGetterMethod());
if (!org.apache.commons.collections4.CollectionUtils.isEmpty(propertyValue)) {
list.addAll(propertyValue);
}
});
targets.put(property.getItemKlass(), list);
} else {
List<Object> list = new ArrayList<>();
Expand All @@ -783,7 +789,12 @@ private void collectScanTargets(Map<Class<?>, List<?>> targets) {
}

objects.forEach(
o -> list.add(ReflectionUtils.invokeMethod(o, property.getGetterMethod())));
o -> {
Object item = ReflectionUtils.invokeMethod(o, property.getGetterMethod());
if (item != null) {
list.add(item);
}
});
targets.put(property.getKlass(), list);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,27 @@ void testPostForSingleEventDate() {
assertThat(response.get("filters").toString(), not(containsString(eventDateDimension)));
}

@Test
void testDelete() {
// Given
String eventDateDimension = "eventDate";
String eventDate = "2021-07-21_2021-08-01";
String dimensionBody =
"{'dimension': '" + eventDateDimension + "', 'items': [{'id': '" + eventDate + "'}]}";
String body =
"{'name': 'Name Test', 'type': 'STACKED_COLUMN','eventRepetitions':null, 'program': {'id':'"
+ mockProgram.getUid()
+ "'}, 'columns': ["
+ dimensionBody
+ "]}";

// When
String uid = assertStatus(CREATED, POST("/eventVisualizations/", body));

// Then
DELETE("/eventVisualizations/" + uid).content(OK);
}

@Test
void testPostForMultiEventDates() {
// Given
Expand Down

0 comments on commit 947d4dc

Please sign in to comment.