2
0

Allow filtering Java test cases.

This commit is contained in:
Maarten Billemont
2018-06-03 16:50:19 -04:00
parent 073ef4f439
commit 5501f1f97d
3 changed files with 31 additions and 7 deletions

View File

@@ -25,7 +25,8 @@ import static com.lyndir.lhunath.opal.system.util.StringUtils.*;
import com.google.common.primitives.UnsignedInteger;
import com.lyndir.lhunath.opal.system.logging.Logger;
import com.lyndir.lhunath.opal.system.util.NNSupplier;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlTransient;
@@ -41,11 +42,21 @@ public class MPTests {
@SuppressWarnings("UnusedDeclaration")
private static final Logger logger = Logger.get( MPTests.class );
private final Set<String> filters = new HashSet<>();
List<Case> cases;
@Nonnull
public List<Case> getCases() {
return checkNotNull( cases );
if (filters.isEmpty())
return checkNotNull( cases );
return checkNotNull( cases ).stream().filter( testCase -> {
for (final String filter : filters)
if (testCase.getIdentifier().startsWith( filter ))
return true;
return false;
} ).collect( Collectors.toList() );
}
public Case getCase(final String identifier) {
@@ -65,6 +76,10 @@ public class MPTests {
}
}
public boolean addFilters(final String... filters) {
return this.filters.addAll( Arrays.asList( filters ) );
}
public static class Case {
String identifier;