mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +00:00
added static filter test, a few other small changes
This commit is contained in:
parent
afdae939c3
commit
dcb08be4c3
4 changed files with 42 additions and 3 deletions
|
@ -1,10 +1,10 @@
|
|||
|
||||
package mage.filter;
|
||||
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.game.Game;
|
||||
|
||||
/**
|
||||
* @param <E>
|
||||
|
@ -29,5 +29,9 @@ public interface Filter<E> extends Serializable {
|
|||
|
||||
Filter<E> copy();
|
||||
|
||||
public boolean isLockedFilter();
|
||||
|
||||
public void setLockedFilter(boolean lockedFilter);
|
||||
|
||||
List<Predicate<? super E>> getPredicates();
|
||||
}
|
||||
|
|
|
@ -67,10 +67,12 @@ public abstract class FilterImpl<E> implements Filter<E> {
|
|||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLockedFilter() {
|
||||
return lockedFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockedFilter(boolean lockedFilter) {
|
||||
this.lockedFilter = lockedFilter;
|
||||
}
|
||||
|
|
|
@ -752,6 +752,10 @@ public final class StaticFilters {
|
|||
|
||||
public static final FilterPermanent FILTER_PERMANENT_EQUIPMENT = new FilterEquipmentPermanent();
|
||||
|
||||
static {
|
||||
FILTER_PERMANENT_EQUIPMENT.setLockedFilter(true);
|
||||
}
|
||||
|
||||
public static final FilterPermanent FILTER_PERMANENT_FORTIFICATION = new FilterPermanent();
|
||||
|
||||
static {
|
||||
|
|
29
Mage/src/test/java/mage/StaticFilterTest.java
Normal file
29
Mage/src/test/java/mage/StaticFilterTest.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package mage;
|
||||
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.StaticFilters;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class StaticFilterTest {
|
||||
|
||||
@Test
|
||||
public void testStaticFilters() throws IllegalAccessException {
|
||||
for (Field field : StaticFilters.class.getFields()) {
|
||||
Assert.assertTrue("Field must be public: " + field, Modifier.isPublic(field.getModifiers()));
|
||||
Assert.assertTrue("Field must be static: " + field, Modifier.isStatic(field.getModifiers()));
|
||||
Assert.assertTrue("Field must be final: " + field, Modifier.isFinal(field.getModifiers()));
|
||||
Assert.assertTrue("Field name must start with \"FILTER_\"", field.getName().startsWith("FILTER_"));
|
||||
Assert.assertEquals("Field name must be all upper case letters", field.getName().toUpperCase(), field.getName());
|
||||
Object filter = field.get(field.getType());
|
||||
Assert.assertTrue("Field must be a filter: " + field, filter instanceof Filter);
|
||||
Assert.assertTrue("Field must be locked: " + field, ((Filter) filter).isLockedFilter());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue