public Map<String, List<Tuple4>> buildTestcases(ArrayList<Tuple4> list){
Map<String, List<Tuple4>> map = new LinkedHashMap<String, List<Tuple4>>();
for(Tuple4 element: list){
String[] token = element.c.split("\\s");
if (!map.containsKey(token[1])) {
map.put(token[1], new ArrayList<Tuple4>());
}
map.get(token[1]).add(element);
}
System.out.println(map);
return map;
}
public Tuple4(String a, String b, String c, String d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
I am constructing a Testsuite for certain matching Testcases. Now I want to convert it to an Array since I'm constructing a dynamicTest from it:
return Stream.of(<Array needed>).map(
tuple -> DynamicTest.dynamicTest("Testcase: ", () -> { ... }
Is there any way to convert it to an Array like Object[String][Tuple4]
Edit:
Okay, now I have this piece of code:
`@TestFactory public Stream dynamicTuple4TestsFromStream() throws IOException{ initialize();
return map.entrySet().stream()
.flatMap(entry ->
entry.getValue().stream()
.map(s -> new AbstractMap.SimpleEntry<>(entry.getKey(), s)))
.forEach(e -> DynamicTest.dynamicTest("Testcase: " +e.getKey(), () -> {
tester = new XQueryTester(e.getValue().a, e.getValue().b);
if(e.getValue().c.contains("PAY")){
Assert.assertTrue(tester.testBody(e.getValue().c,e.getValue().d));
}
})); }`
and im getting this exception:
incompatible types: void cannot be converted to java.util.stream.Stream<org.junit.jupiter.api.DynamicTest>
How/Why?