Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5d6d6bc

Browse filesBrowse files
add ItemNode.createNonOverlappingSet
1 parent ce56ec3 commit 5d6d6bc
Copy full SHA for 5d6d6bc

File tree

1 file changed

+45
-1
lines changed
Filter options
  • sqldev/src/main/java/org/utplsql/sqldev/model/runner

1 file changed

+45
-1
lines changed

‎sqldev/src/main/java/org/utplsql/sqldev/model/runner/ItemNode.java

Copy file name to clipboardExpand all lines: sqldev/src/main/java/org/utplsql/sqldev/model/runner/ItemNode.java
+45-1Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,30 @@
1515
*/
1616
package org.utplsql.sqldev.model.runner;
1717

18+
import java.util.ArrayList;
19+
import java.util.Collections;
1820
import java.util.Enumeration;
1921
import java.util.HashSet;
22+
import java.util.List;
2023
import java.util.Set;
2124

2225
import javax.swing.Icon;
2326
import javax.swing.tree.DefaultMutableTreeNode;
2427

2528
import org.utplsql.sqldev.resources.UtplsqlResources;
2629

27-
public class ItemNode extends DefaultMutableTreeNode {
30+
public class ItemNode extends DefaultMutableTreeNode implements Comparable<ItemNode> {
2831

2932
private static final long serialVersionUID = -4053143673822661743L;
3033

3134
public ItemNode(Item userObject) {
3235
super(userObject, userObject instanceof Suite);
3336
}
37+
38+
@Override
39+
public int compareTo(ItemNode other) {
40+
return getId().compareTo(other.getId());
41+
}
3442

3543
public String getId() {
3644
return ((Item) getUserObject()).getId();
@@ -153,5 +161,41 @@ public Icon getWarningIcon() {
153161
public Icon getInfoIcon() {
154162
return ((Item) getUserObject()).getInfoIcon();
155163
}
164+
165+
/**
166+
* Calculates non-overlapping items.
167+
*
168+
* This can be used to build a list of suites to be started by utPLSQL while ensuring that
169+
*
170+
* - all requested tests are executed, but not more than once
171+
* - the test execution is efficient by ensuring that the list is as short as possible
172+
*
173+
* This means if all tests of a suite shall be executed that the suit should be
174+
* part of the result list and not all of its tests.
175+
*
176+
* In other words, top-level nodes are preferred to produce an optimal result.
177+
*
178+
* @param selectedNodes all selected nodes must be part of the same tree
179+
* @return non-overlapping set of nodes
180+
*/
181+
public static Set<ItemNode> createNonOverlappingSet(List<ItemNode> selectedNodes) {
182+
HashSet<ItemNode> result = new HashSet<>();
183+
if (selectedNodes != null && selectedNodes.size() > 0) {
184+
HashSet<ItemNode> expandedResult = new HashSet<>();
185+
List<ItemNode> sortedNodes = new ArrayList<>(selectedNodes);
186+
Collections.sort(sortedNodes);
187+
for (ItemNode sortedNode : sortedNodes) {
188+
if (!expandedResult.contains(sortedNode)) {
189+
result.add(sortedNode);
190+
Enumeration<?> expandedNodes = sortedNode.preorderEnumeration();
191+
while (expandedNodes.hasMoreElements()) {
192+
ItemNode expandedNode = (ItemNode) expandedNodes.nextElement();
193+
expandedResult.add(expandedNode);
194+
}
195+
}
196+
}
197+
}
198+
return result;
199+
}
156200

157201
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.