Skip to content

Commit

Permalink
make category field optional
Browse files Browse the repository at this point in the history
Signed-off-by: Subhobrata Dey <[email protected]>
  • Loading branch information
sbcd90 committed Oct 4, 2023
1 parent 849ad58 commit 90cd502
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public CustomLogType(String id,
this.version = version != null ? version : NO_VERSION;
this.name = name;
this.description = description;
this.category = category;
this.category = category != null? category: "Other";
this.source = source;
this.tags = tags;
}
Expand All @@ -104,7 +104,7 @@ public CustomLogType(Map<String, Object> input) {
null,
input.get(NAME_FIELD).toString(),
input.get(DESCRIPTION_FIELD).toString(),
input.get(CATEGORY_FIELD).toString(),
input.containsKey(CATEGORY_FIELD)? input.get(CATEGORY_FIELD).toString(): null,
input.get(SOURCE_FIELD).toString(),
(Map<String, Object>) input.get(TAGS_FIELD)
);
Expand Down Expand Up @@ -159,7 +159,7 @@ public static CustomLogType parse(XContentParser xcp, String id, Long version) t
description = xcp.text();
break;
case CATEGORY_FIELD:
category = xcp.text();
category = xcp.textOrNull();
break;

Check warning on line 163 in src/main/java/org/opensearch/securityanalytics/model/CustomLogType.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/org/opensearch/securityanalytics/model/CustomLogType.java#L162-L163

Added lines #L162 - L163 were not covered by tests
case SOURCE_FIELD:
source = xcp.text();
Expand Down

0 comments on commit 90cd502

Please sign in to comment.