You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "pibizza (via GitHub)" <gi...@apache.org> on 2024/09/05 09:28:58 UTC
[PR] NO ISSUE: Improving stream assertions in tests [incubator-kie-drools]
pibizza opened a new pull request, #6068:
URL: https://github.com/apache/incubator-kie-drools/pull/6068
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
This PR improves on stream assertions in tests.
It makes better use of the assertions available in assertj.
<details>
<summary>
How to replicate CI configuration locally?
</summary>
Build Chain tool does "simple" maven build(s), the builds are just Maven commands, but because the repositories relates and depends on each other and any change in API or class method could affect several of those repositories there is a need to use [build-chain tool](https://github.com/kiegroup/github-action-build-chain) to handle cross repository builds and be sure that we always use latest version of the code for each repository.
[build-chain tool](https://github.com/kiegroup/github-action-build-chain) is a build tool which can be used on command line locally or in Github Actions workflow(s), in case you need to change multiple repositories and send multiple dependent pull requests related with a change you can easily reproduce the same build by executing it on Github hosted environment or locally in your development environment. See [local execution](https://github.com/kiegroup/github-action-build-chain#local-execution) details to get more information about it.
</details>
<details>
<summary>
How to retest this PR or trigger a specific build:
</summary>
- for <b>pull request and downstream checks</b>
- Push a new commit to the PR. An empty commit would be enough.
- for a <b>full downstream build</b>
- for <b>github actions</b> job: add the label `run_fdb`
- for <b>Jenkins PR check only</b>
- If you are an ASF committer for KIE podling, login to Jenkins (https://ci-builds.apache.org/job/KIE/job/drools/), go to the specific PR job, and click on `Build Now` button.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] NO ISSUE: Improving stream assertions in tests [incubator-kie-drools]
Posted by "JaredDavis22 (via GitHub)" <gi...@apache.org>.
JaredDavis22 commented on code in PR #6068:
URL: https://github.com/apache/incubator-kie-drools/pull/6068#discussion_r1745350855
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/LocalDateRangeIteratorTest.java:
##########
@@ -65,16 +62,14 @@ void hasNextDescendantTest() {
@Test
void nextAscendantTest() {
- List<LocalDate> expected = Arrays.asList(LocalDate.of(2021, 1, 1), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 3));
LocalDateRangeIterator iterator = new LocalDateRangeIterator(before, after);
- IntStream.range(0, 3).forEach(i -> assertThat(expected.get(i)).isEqualTo(iterator.next()));
+ assertThat(iterator).toIterable().containsExactlyInAnyOrder(LocalDate.of(2021, 1, 1), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 3));
Review Comment:
No shame implied! I'm learning by looking at the commits. Thanks for helping me learn.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] NO ISSUE: Improving stream assertions in tests [incubator-kie-drools]
Posted by "pibizza (via GitHub)" <gi...@apache.org>.
pibizza merged PR #6068:
URL: https://github.com/apache/incubator-kie-drools/pull/6068
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] NO ISSUE: Improving stream assertions in tests [incubator-kie-drools]
Posted by "JaredDavis22 (via GitHub)" <gi...@apache.org>.
JaredDavis22 commented on code in PR #6068:
URL: https://github.com/apache/incubator-kie-drools/pull/6068#discussion_r1745331657
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/LocalDateRangeIteratorTest.java:
##########
@@ -65,16 +62,14 @@ void hasNextDescendantTest() {
@Test
void nextAscendantTest() {
- List<LocalDate> expected = Arrays.asList(LocalDate.of(2021, 1, 1), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 3));
LocalDateRangeIterator iterator = new LocalDateRangeIterator(before, after);
- IntStream.range(0, 3).forEach(i -> assertThat(expected.get(i)).isEqualTo(iterator.next()));
+ assertThat(iterator).toIterable().containsExactlyInAnyOrder(LocalDate.of(2021, 1, 1), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 3));
Review Comment:
Probably my lack of knowledge, but, I don't understand how the order does not matter for nextAscendantTest and nextDescendantTest tests?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org
Re: [PR] NO ISSUE: Improving stream assertions in tests [incubator-kie-drools]
Posted by "pibizza (via GitHub)" <gi...@apache.org>.
pibizza commented on code in PR #6068:
URL: https://github.com/apache/incubator-kie-drools/pull/6068#discussion_r1745341391
##########
kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/LocalDateRangeIteratorTest.java:
##########
@@ -65,16 +62,14 @@ void hasNextDescendantTest() {
@Test
void nextAscendantTest() {
- List<LocalDate> expected = Arrays.asList(LocalDate.of(2021, 1, 1), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 3));
LocalDateRangeIterator iterator = new LocalDateRangeIterator(before, after);
- IntStream.range(0, 3).forEach(i -> assertThat(expected.get(i)).isEqualTo(iterator.next()));
+ assertThat(iterator).toIterable().containsExactlyInAnyOrder(LocalDate.of(2021, 1, 1), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 3));
Review Comment:
@JaredDavis22 you are right. this is a mistake. Shame on me.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org