-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename GeneralOrdering to Orderer and make it no longer implement Ord…
…ering
- Loading branch information
Showing
9 changed files
with
86 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 0 additions & 41 deletions
41
src/main/java/org/junit/runner/manipulation/GeneralOrdering.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package org.junit.runner.manipulation; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import org.junit.runner.Description; | ||
|
||
/** | ||
* Orders tests. | ||
* | ||
* @since 4.13 | ||
*/ | ||
public final class Orderer { | ||
private final Ordering ordering; | ||
|
||
Orderer(Ordering delegate) { | ||
this.ordering = delegate; | ||
} | ||
|
||
/** | ||
* Orders the descriptions. | ||
* | ||
* @return descriptions in order | ||
*/ | ||
public List<Description> order(Collection<Description> descriptions) | ||
throws InvalidOrderingException { | ||
List<Description> inOrder = ordering.orderItems( | ||
Collections.unmodifiableCollection(descriptions)); | ||
if (!ordering.validateOrderingIsCorrect()) { | ||
return inOrder; | ||
} | ||
|
||
Set<Description> uniqueDescriptions = new HashSet<Description>(descriptions); | ||
if (!uniqueDescriptions.containsAll(inOrder)) { | ||
throw new InvalidOrderingException("Ordering added items"); | ||
} | ||
Set<Description> resultAsSet = new HashSet<Description>(inOrder); | ||
if (resultAsSet.size() != inOrder.size()) { | ||
throw new InvalidOrderingException("Ordering duplicated items"); | ||
} else if (!resultAsSet.containsAll(uniqueDescriptions)) { | ||
throw new InvalidOrderingException("Ordering removed items"); | ||
} | ||
|
||
return inOrder; | ||
} | ||
|
||
/** | ||
* Order the tests in <code>target</code>. | ||
* | ||
* @throws InvalidOrderingException if ordering does something invalid (like remove or add | ||
* children) | ||
*/ | ||
public void apply(Object target) throws InvalidOrderingException { | ||
if (target instanceof Orderable) { | ||
Orderable orderable = (Orderable) target; | ||
orderable.order(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters