Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/test/java/oops/CodeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,32 @@ private Map<String, List<Steps>> separateSteps(List<Steps> steps) {
return allPairs;
}


private static Map<String, Collection<Steps>> separateSteps(List<Steps> steps) {
//import com.google.common.collect.LinkedListMultimap;
//import com.google.common.collect.Multimap;
Multimap<String, Steps> result = LinkedListMultimap.create();
AtomicReference<String> currentKey = new AtomicReference<>();

if (!steps.get(0).getClassName().contains("Reports.logCase")) {
currentKey.set("DefaultCaseId");
}

steps.forEach(s -> {
if (s.getClassName().contains("Reports.logCase")) {
currentKey.set(s.getCalssName()); // actualy we should get step parameter
} else {
result.put(currentKey.get(), s);
}
});

if (!result.containsKey(currentKey.get())) {
throws new RuntimeException("unexpected report step at the end of test");
}

return result.asMap();
}

private List<MethodSpec> buildMethods(Map<String, List<Steps>> allPairs, String className) {
List<MethodSpec> methods = new ArrayList<>();
allPairs.forEach((annotation, steps) -> {
Expand Down