From 28d1db6cb4ec81234e6371ac7f1d7a9fa511f026 Mon Sep 17 00:00:00 2001 From: soloturn Date: Sun, 26 Nov 2023 12:23:52 +0100 Subject: [PATCH] pmd warnings in CountCallsTest --- .../engine/logic/behavior/CountCallsTest.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/engine-tests/src/test/java/org/terasology/engine/logic/behavior/CountCallsTest.java b/engine-tests/src/test/java/org/terasology/engine/logic/behavior/CountCallsTest.java index 7a073a20045..317ee793cde 100644 --- a/engine-tests/src/test/java/org/terasology/engine/logic/behavior/CountCallsTest.java +++ b/engine-tests/src/test/java/org/terasology/engine/logic/behavior/CountCallsTest.java @@ -12,6 +12,8 @@ import org.terasology.engine.logic.behavior.core.DelegateNode; import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -49,16 +51,12 @@ public void assertBT(String tree, List result, List exec assertBT(tree, result, executed, true); } - public void assertBT(String tree, List result, List executed, boolean step) { + public void assertBT(String tree, List result, List executed, boolean ignoredStep) { BehaviorNode node = fromJson(tree); node.construct(null); - List actualStates = Lists.newArrayList(); - for (int i = 0; i < result.size(); i++) { - BehaviorState state = node.execute(null); - actualStates.add(state); - - } + List actualStates = + IntStream.range(0, result.size()).mapToObj(i -> node.execute(null)).collect(Collectors.toList()); node.destruct(null); assertEquals(result, actualStates);