{And|Or|Not|Field}PredicateTest: Move duplicate code to base class
Each of these test classes declares the exact same inner static class and helper method. Remove them and declare them once in the base class instead. Change-Id: I4f1b8a020b409ad40d6392680cda4061539bc425
This commit is contained in:
@@ -28,26 +28,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AndPredicateTest extends PredicateTest {
|
||||
private static final class TestPredicate extends OperatorPredicate<String> {
|
||||
private TestPredicate(String name, String value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(String object) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCost() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static TestPredicate f(final String name, final String value) {
|
||||
return new TestPredicate(name, value);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChildren() {
|
||||
final TestPredicate a = f("author", "alice");
|
||||
|
@@ -23,27 +23,7 @@ import org.junit.Test;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class FieldPredicateTest {
|
||||
private static final class TestPredicate extends OperatorPredicate<String> {
|
||||
private TestPredicate(String name, String value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(String object) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCost() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static TestPredicate f(final String name, final String value) {
|
||||
return new TestPredicate(name, value);
|
||||
}
|
||||
|
||||
public class FieldPredicateTest extends PredicateTest {
|
||||
@Test
|
||||
public void testToString() {
|
||||
assertEquals("author:bob", f("author", "bob").toString());
|
||||
|
@@ -28,26 +28,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class NotPredicateTest extends PredicateTest {
|
||||
private static final class TestPredicate extends OperatorPredicate<String> {
|
||||
private TestPredicate(String name, String value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(String object) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCost() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static TestPredicate f(final String name, final String value) {
|
||||
return new TestPredicate(name, value);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotNot() {
|
||||
final TestPredicate p = f("author", "bob");
|
||||
|
@@ -28,26 +28,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class OrPredicateTest extends PredicateTest {
|
||||
private static final class TestPredicate extends OperatorPredicate<String> {
|
||||
private TestPredicate(String name, String value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(String object) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCost() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static TestPredicate f(final String name, final String value) {
|
||||
return new TestPredicate(name, value);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChildren() {
|
||||
final TestPredicate a = f("author", "alice");
|
||||
|
@@ -17,4 +17,23 @@ package com.google.gerrit.server.query;
|
||||
import com.google.gerrit.testutil.GerritBaseTests;
|
||||
|
||||
public class PredicateTest extends GerritBaseTests {
|
||||
protected static final class TestPredicate extends OperatorPredicate<String> {
|
||||
protected TestPredicate(String name, String value) {
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(String object) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCost() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected static TestPredicate f(String name, String value) {
|
||||
return new TestPredicate(name, value);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user