Skip to content

Commit

Permalink
Fix addTags API in EventMetadata (#2926)
Browse files Browse the repository at this point in the history
Signed-off-by: Krishna Kondaka <[email protected]>
Co-authored-by: Krishna Kondaka <[email protected]>
  • Loading branch information
kkondaka and Krishna Kondaka committed Jun 23, 2023
1 parent c2352ba commit 5565337
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ public Boolean hasTags(final List<String> tagsList) {

@Override
public void addTags(final List<String> newTags) {
tags.addAll(newTags);
if (Objects.nonNull(newTags)) {
tags.addAll(newTags);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ void fromEventMetadata_returns_matching_EventMetadata() {
assertThat(copiedMetadata.getAttributes(), not(sameInstance(attributes)));
}

@Test
public void testEventMetadata_withNullTags() {
final String testEventType = UUID.randomUUID().toString();

final EventMetadata eventMetadata = DefaultEventMetadata.builder()
.withEventType(testEventType)
.build();
assertThat(eventMetadata, notNullValue());
eventMetadata.addTags(null);
assertThat(eventMetadata.getTags(), equalTo(Collections.emptySet()));
}

@Test
public void testBuild_withTags() {
final String testEventType = UUID.randomUUID().toString();
Expand Down

0 comments on commit 5565337

Please sign in to comment.