Skip to content

Commit 0ce35bb

Browse files
yasin3061pivovarit
authored andcommitted
BAEL-900 Input generator simplified (eugenp#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 d0d45c9. * 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
1 parent b9b642c commit 0ce35bb

1 file changed

Lines changed: 3 additions & 24 deletions

File tree

‎junit5/src/test/java/com/baeldung/DynamicTestsExample.java‎

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.junit.jupiter.api.Assertions.assertTrue;
55

6-
import java.util.ArrayList;
76
import java.util.Arrays;
87
import java.util.Collection;
98
import java.util.HashMap;
@@ -56,32 +55,12 @@ Stream<DynamicTest> dynamicTestsFromStream() {
5655

5756
// sample input and output
5857
List<String> inputList =
59-
new ArrayList<>(Arrays.asList("www.somedomain.com", "www.anotherdomain.com", "www.yetanotherdomain.com"));
58+
Arrays.asList("www.somedomain.com", "www.anotherdomain.com", "www.yetanotherdomain.com");
6059
List<String> outputList =
61-
new ArrayList<>(Arrays.asList("154.174.10.56", "211.152.104.132", "178.144.120.156"));
60+
Arrays.asList("154.174.10.56", "211.152.104.132", "178.144.120.156");
6261

6362
// input generator that generates inputs using inputList
64-
Iterator<String> inputGenerator = new Iterator<String>() {
65-
66-
String current;
67-
int size = inputList.size();
68-
int index = 0;
69-
70-
@Override
71-
public boolean hasNext() {
72-
if(index == size) {
73-
return false;
74-
}
75-
current = inputList.get(index);
76-
index++;
77-
return true;
78-
}
79-
80-
@Override
81-
public String next() {
82-
return current;
83-
}
84-
};
63+
Iterator<String> inputGenerator = inputList.iterator();
8564

8665
// a display name generator that creates a different name based on the input
8766
Function<String, String> displayNameGenerator = (input) -> "Resolving: " + input;

0 commit comments

Comments
 (0)