Skip to content
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

Quantity.fromNumericalAmount, the inverse of getNumericalAmount #5052

Merged
merged 13 commits into from
Apr 28, 2023

Conversation

rhuffy
Copy link
Contributor

@rhuffy rhuffy commented Apr 14, 2023

Description

We use getNumericalAmount to do some calculations on Quantity values as BigDecimals, and sometimes we want to convert back to a Quantity of the same units. This PR pulls the format multiplier math into a separate method and implements fromNumericalAmount as the inverse of getNumericalAmount.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change
  • Chore (non-breaking change which doesn't affect codebase;
    test, version modification, documentation, etc.)

Checklist

  • Code contributed by me aligns with current project license: Apache 2.0
  • I Added CHANGELOG entry regarding this change
  • I have implemented unit tests to cover my changes
  • I have added/updated the javadocs and other documentation accordingly
  • No new bugs, code smells, etc. in SonarCloud report
  • I tested my code in Kubernetes
  • I tested my code in OpenShift

@rhuffy rhuffy marked this pull request as ready for review April 14, 2023 18:30

@Test
@DisplayName("Test fromAmountInBytes method")
public void testFromAmountInBytes() {
Copy link
Member

Choose a reason for hiding this comment

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

Could you please make this test parameterized instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the suggestion. I made the change.

Copy link
Contributor

@shawkins shawkins left a comment

Choose a reason for hiding this comment

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

LGTM

@rohanKanojia
Copy link
Member

@rhuffy : Could you please address this minor sonar smell?

@rhuffy
Copy link
Contributor Author

rhuffy commented Apr 21, 2023

Can we get another CI run on this? I believe I've fixed the test failures.

@rhuffy
Copy link
Contributor Author

rhuffy commented Apr 27, 2023

bump @rohanKanojia

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

92.3% 92.3% Coverage
0.0% 0.0% Duplication

@manusa manusa merged commit 00d3803 into fabric8io:master Apr 28, 2023
@rhuffy rhuffy deleted the rh/quantity-from-numerical-amount branch April 28, 2023 20:46
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.

4 participants