3636import java .util .UUID ;
3737import java .util .stream .Collectors ;
3838
39+ import static org .neo4j .gds .doc .DocumentationTestToolsConstants .CLEANUP_QUERY_ROLE ;
3940import static org .neo4j .gds .doc .DocumentationTestToolsConstants .CODE_BLOCK_CONTEXT ;
4041import static org .neo4j .gds .doc .DocumentationTestToolsConstants .GRAPH_PROJECT_QUERY_ROLE ;
4142import static org .neo4j .gds .doc .DocumentationTestToolsConstants .QUERY_EXAMPLE_ROLE ;
@@ -70,6 +71,8 @@ public class QueryCollectingTreeProcessor extends Treeprocessor {
7071
7172 private final List <DocQuery > beforeEachQueries = new ArrayList <>();
7273
74+ private final List <QueryExample > afterAllQueries = new ArrayList <>();
75+
7376 /**
7477 * "Group encounter order" is preserved if we use a LinkedHashMap, and while that is not strictly necessary, I think
7578 * it is a nice touch. Not sure if JUnit UI reflects it, TBD.
@@ -86,6 +89,7 @@ public Document process(Document document) {
8689 collectBeforeAllQueries (document );
8790 collectBeforeEachQueries (document );
8891 collectQueryExamples (document );
92+ collectAfterAllExampleQueries (document );
8993
9094 return document ;
9195 }
@@ -98,6 +102,10 @@ public List<DocQuery> getBeforeEachQueries() {
98102 return beforeEachQueries ;
99103 }
100104
105+ public List <QueryExample > getAfterAllQueries () {
106+ return afterAllQueries ;
107+ }
108+
101109 /**
102110 * Do grouping into QueryExampleGroups
103111 */
@@ -111,16 +119,24 @@ public List<QueryExampleGroup> getQueryExampleGroups() {
111119 }
112120
113121 private void collectBeforeAllQueries (StructuralNode document ) {
114- var queries = CollectSetupQueries (document , SETUP_QUERY_ROLE );
122+ var queries = collectSetupQueries (document , SETUP_QUERY_ROLE );
115123 beforeAllQueries .addAll (queries );
116124 }
117125
118126 private void collectBeforeEachQueries (StructuralNode document ) {
119- var queries = CollectSetupQueries (document , GRAPH_PROJECT_QUERY_ROLE );
127+ var queries = collectSetupQueries (document , GRAPH_PROJECT_QUERY_ROLE );
120128 beforeEachQueries .addAll (queries );
121129 }
122130
123- private static List <DocQuery > CollectSetupQueries (StructuralNode node , String setupQueryType ) {
131+ private void collectAfterAllExampleQueries (StructuralNode document ) {
132+ var examples = document .findBy (Map .of (ROLE_SELECTOR , CLEANUP_QUERY_ROLE ));
133+ for (StructuralNode example : examples ) {
134+ var queryExample = convertToQueryExample (example );
135+ afterAllQueries .add (queryExample );
136+ }
137+ }
138+
139+ private static List <DocQuery > collectSetupQueries (StructuralNode node , String setupQueryType ) {
124140 var nodes = node .findBy (Map .of (ROLE_SELECTOR , setupQueryType ));
125141
126142 return nodes .stream ()
0 commit comments