Skip to content

Add logic to handle number acceptors #5813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 27, 2025

Conversation

RanVaknin
Copy link
Contributor

@RanVaknin RanVaknin commented Jan 21, 2025

Motivation and Context

Currently the Java SDK waiter matcher acceptor only support Integers. According to the cross SDK spec waiter matcher acceptor must support all number types.

Modifications

  • Changed jmspathruntime numbers internally to use BigDecimal for all number types in order to support arbitrary precision.
  • Updated Jackson Jr version to 2.17.3 to support Big Decimal.

Testing

  • Added WaitersPathMatcherTest for numeric matchers
  • Added coverage to existing numeric handling tests

@RanVaknin RanVaknin changed the title add logic to handle number acceptors Add logic to handle number acceptors Jan 21, 2025
@RanVaknin RanVaknin force-pushed the rvaknin/number-support-for-waiters branch from 4fb548f to cd55716 Compare January 28, 2025 23:43
@RanVaknin RanVaknin marked this pull request as ready for review January 29, 2025 01:29
@RanVaknin RanVaknin requested a review from a team as a code owner January 29, 2025 01:29
Copy link
Contributor

@dagnir dagnir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add tests in codegen for generated waiters that use numbers?

Comment on lines 608 to 632
CodeBlock.Builder builder = CodeBlock.builder()
.add("response -> {")
.add("$1T input = new $1T(response);", poetExtensions.jmesPathRuntimeClass().nestedClass("Value"))
.add("$T<$T> resultValues = ", List.class, Object.class)
.add(jmesPathAcceptorGenerator.interpret(acceptor.getArgument(), "input"))
.add(".values();")
.add("return !resultValues.isEmpty() &&"
+ " resultValues.stream().anyMatch(v " + "-> $T.equals"
+ "(v, ", Objects.class);

if (isNumber) {
builder.add("new $T($S)", BigDecimal.class, expected);
} else if (isString) {
builder.add("$S", expected);
} else {
builder.add("$L", expected);
}

builder.add("));")
.add("}");

return builder.build();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the same change as in pathAcceptorBody to make it more readable?

Comment on lines 282 to 287
<dependency>
<groupId>backport-util-concurrent</groupId>
<artifactId>backport-util-concurrent</artifactId>
<version>3.1</version>
<scope>test</scope>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this dependency for?

@dagnir
Copy link
Contributor

dagnir commented Feb 14, 2025

Can we merge in master and run integ tests again?

@RanVaknin RanVaknin force-pushed the rvaknin/number-support-for-waiters branch from 02d1597 to f0e7e22 Compare February 20, 2025 18:55
@RanVaknin RanVaknin force-pushed the rvaknin/number-support-for-waiters branch from f0e7e22 to 6d859e2 Compare February 26, 2025 17:43
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
75.6% Coverage on New Code (required ≥ 80%)
12.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@RanVaknin RanVaknin added this pull request to the merge queue Feb 26, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 27, 2025
@RanVaknin RanVaknin added this pull request to the merge queue Feb 27, 2025
Merged via the queue into master with commit 95b30dc Feb 27, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants