From 0ce35bb11e9e66af4764eac142821fc227f6bb1d Mon Sep 17 00:00:00 2001 From: Yasin Date: Sat, 27 May 2017 19:18:20 +0530 Subject: [PATCH] BAEL-900 Input generator simplified (#1941) * BAEL-900 Guide to dynamic tests in Junit 5 * BAEL-900 Guide to Dynamic Tests in Junit 5 * Revert "BAEL-900 Guide to Dynamic Tests in Junit 5" This reverts commit d0d45c9067223347da20d0f2c80de391fcade38e. * BAEL-900 Guide to Dynamic Tests in Junit 5 * BAEL-900 Guide to dynamic tests in Junit 5 * removed unnecessary annotation * BAEL-900 unused imports removed * BAEL-900 simplified input generator code --- .../com/baeldung/DynamicTestsExample.java | 27 +++---------------- 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/junit5/src/test/java/com/baeldung/DynamicTestsExample.java b/junit5/src/test/java/com/baeldung/DynamicTestsExample.java index 6a97f2347b..fd6bb3e0a8 100644 --- a/junit5/src/test/java/com/baeldung/DynamicTestsExample.java +++ b/junit5/src/test/java/com/baeldung/DynamicTestsExample.java @@ -3,7 +3,6 @@ package com.baeldung; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; @@ -56,32 +55,12 @@ public class DynamicTestsExample { // sample input and output List inputList = - new ArrayList<>(Arrays.asList("www.somedomain.com", "www.anotherdomain.com", "www.yetanotherdomain.com")); + Arrays.asList("www.somedomain.com", "www.anotherdomain.com", "www.yetanotherdomain.com"); List outputList = - new ArrayList<>(Arrays.asList("154.174.10.56", "211.152.104.132", "178.144.120.156")); + Arrays.asList("154.174.10.56", "211.152.104.132", "178.144.120.156"); // input generator that generates inputs using inputList - Iterator inputGenerator = new Iterator() { - - String current; - int size = inputList.size(); - int index = 0; - - @Override - public boolean hasNext() { - if(index == size) { - return false; - } - current = inputList.get(index); - index++; - return true; - } - - @Override - public String next() { - return current; - } - }; + Iterator inputGenerator = inputList.iterator(); // a display name generator that creates a different name based on the input Function displayNameGenerator = (input) -> "Resolving: " + input;