Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Convert group function results to PercentType if DecimalType is not s… #3758

Merged

Conversation

triller-telekom
Copy link
Contributor

…upported

Fixes #3734

And converts the test cases from Groovy to Java

Signed-off-by: Stefan Triller stefan.triller@telekom.de

…upported

Fixes eclipse-archived#3734

And converts the test cases from Groovy to Java

Signed-off-by: Stefan Triller <stefan.triller@telekom.de>
Copy link
Contributor

@maggu2810 maggu2810 left a comment

Choose a reason for hiding this comment

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

Hm, couldn't we use two separate PRs?
One that migrates the tests and the other one that implements that fix?
I don't see any realtionship between that changes. Do I miss something?

State calculatedState = function.calculate(members);

// functions return DecimalTypes so we have to convert them if the baseItem type only supports PercentType
if (baseItem.getAcceptedDataTypes().contains(PercentType.class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it make sense to check the type of calculatedState first?

if (calculatedState instanceof DecimalType && !baseItem.getAcceptedDataTypes().contains(DecimalType.class) ...)

if (function != null && baseItem != null) {
State calculatedState = function.calculate(members);

// functions return DecimalTypes so we have to convert them if the baseItem type only supports PercentType
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be a pretty specific solution...
Is there anything speaking against using ItemUtil.convertToAcceptedState(State, Item) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, this method is exactly what i was looking for, but I was not aware of that it exists ;) I have changed it now.

@triller-telekom
Copy link
Contributor Author

I have included the converted test in this PR because it adds a new test for the implemented fix, see this test method

Signed-off-by: Stefan Triller <stefan.triller@telekom.de>
Copy link
Contributor

@sjsf sjsf left a comment

Choose a reason for hiding this comment

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

Although I have to second @maggu2810 that it would have been better to create a separate PR (or at least a separate commit) for the test migration, the change itself looks good to me now.
@maggu2810 okay for you too?

@maggu2810
Copy link
Contributor

@maggu2810 okay for you too?

Okay for me. Personally I would use a one-liner and drop the variable declarations, but all fine...

@sjsf sjsf merged commit cc65016 into eclipse-archived:master Jun 29, 2017
@triller-telekom triller-telekom deleted the groupFunctionAveragePercent branch June 29, 2017 09:56
@kaikreuzer kaikreuzer added this to the 0.9.0 milestone Nov 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants