[
https://issues.apache.org/jira/browse/NIFI-11035?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17677493#comment-17677493
]
Daniel Stieglitz edited comment on NIFI-11035 at 1/16/23 7:03 PM:
------------------------------------------------------------------
[~exceptionfactory] Thanks for the clarification. I have a specific question
for conversion to JUnit 5 assertions.
In
nifi/nifi-commons/nifi-utils/src/test/groovy/org/apache/nifi/util/TestFormatUtilsGroovy.groovy
in test testMakeWholeNumberTimeShouldHandleMetricConversions
I tried replacing
{code:java}
results.every { String key, List values ->
assert values.first() == SCENARIOS[key].expectedValue
assert values.last() == SCENARIOS[key].expectedUnits
}
{code}
with
{code:java}
results.entrySet().forEach(entry -> {
assertEquals(SCENARIOS.get(entry.getKey()).expectedValue,
entry.getValue().get(0))
assertEquals(SCENARIOS.get(entry.getKey()).expectedUnits,
entry.getValue().get(1))
})
{code}
When I do that I see the unit test fails with
{code:java}
junit.framework.AssertionFailedError: expected:<750000> but was:<750>
Expected :750000
Actual :750
{code}
When I added a log statement within the original Groovy code (in the closure) I
noticed "every" does not iterate through all the results only the first one
which is not what "every" is supposed to do. Do you have any insight as to why
I would see this behavior?
was (Author: JIRAUSER294662):
[~exceptionfactory] Thanks for the clarification. I have a specific question
for conversion to JUnit 5 assertions.
In
nifi/nifi-commons/nifi-utils/src/test/groovy/org/apache/nifi/util/TestFormatUtilsGroovy.groovy
in test testMakeWholeNumberTimeShouldHandleMetricConversions
I tried replacing
{code:java}
results.every { String key, List values ->
assert values.first() == SCENARIOS[key].expectedValue
assert values.last() == SCENARIOS[key].expectedUnits
}
{code}
with
{code:java}
results.entrySet().forEach(entry -> {
assertEquals(SCENARIOS.get(entry.getKey()).expectedValue,
entry.getValue().get(0))
assertEquals(SCENARIOS.get(entry.getKey()).expectedUnits,
entry.getValue().get(1))
})
{code}
When I do that I see the unit test fails with
{code:java}
junit.framework.AssertionFailedError: expected:<750000> but was:<750>
Expected :750000
Actual :750
{code}
When I through a log statement within the original Groovy code (in the closure)
I noticed "every" does not iterate through all the results only the first one
which is not what "every" is supposed to do. Do you have any insight as to why
I would see this behavior?
> Replace remaining JUnit 4 assertions in nifi-commons with JUnit 5 assertions
> ----------------------------------------------------------------------------
>
> Key: NIFI-11035
> URL: https://issues.apache.org/jira/browse/NIFI-11035
> Project: Apache NiFi
> Issue Type: Sub-task
> Reporter: Daniel Stieglitz
> Assignee: Daniel Stieglitz
> Priority: Minor
>
> A quick search nifi-commons for "org.junit.Assert" indicates there are over
> 50 cases where JUnit 4 assertions are still being used. These should be
> replaced with JUnit 5 assertions.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)