Skip to content

Commit

Permalink
Address PR Comments
Browse files Browse the repository at this point in the history
Signed-off-by: Andre Kurait <[email protected]>
  • Loading branch information
AndreKurait committed Oct 24, 2024
1 parent 590f6b0 commit 5f64ef7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public JsonJMESPathPredicate(BaseRuntime<Object> runtime, String script) {
}

@Override
public boolean evaluatePredicate(Map<String, Object> incomingJson) {
public boolean test(Map<String, Object> incomingJson) {
var output = expression.search(incomingJson);
log.atDebug().setMessage("output={}").addArgument(output).log();
return (Boolean) output;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.opensearch.migrations.transform;

import java.util.Map;
import java.util.function.Predicate;


public interface IJsonPredicate {
boolean evaluatePredicate(Map<String, Object> incomingJson);
public interface IJsonPredicate extends Predicate<Map<String, Object>> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public JsonCompositePredicate(@NonNull CompositeOperation operation,
}

@Override
public boolean evaluatePredicate(Map<String, Object> incomingJson) {
public boolean test(Map<String, Object> incomingJson) {
var Predicates = jsonPredicateList.stream();
Predicate<IJsonPredicate> predicate = p -> p.evaluatePredicate(incomingJson);
Predicate<IJsonPredicate> predicate = p -> p.test(incomingJson);
switch (operation) {
case ALL:
return Predicates.allMatch(predicate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public JsonConditionalTransformer(IJsonPredicate jsonPredicate, IJsonTransformer

@Override
public Map<String, Object> transformJson(Map<String, Object> incomingJson) {
if (jsonPredicate.evaluatePredicate(incomingJson)) {
if (jsonPredicate.test(incomingJson)) {
return jsonTransformer.transformJson(incomingJson);
}
return incomingJson;

Check warning on line 19 in TrafficCapture/transformationPlugins/jsonMessageTransformers/jsonMessageTransformerInterface/src/main/java/org/opensearch/migrations/transform/JsonConditionalTransformer.java

View check run for this annotation

Codecov / codecov/patch

TrafficCapture/transformationPlugins/jsonMessageTransformers/jsonMessageTransformerInterface/src/main/java/org/opensearch/migrations/transform/JsonConditionalTransformer.java#L19

Added line #L19 was not covered by tests
Expand Down

0 comments on commit 5f64ef7

Please sign in to comment.