20 package net.sf.gridarta.model.mapmodel;
22 import java.util.Arrays;
23 import java.util.Collection;
24 import java.util.HashSet;
25 import java.util.Iterator;
26 import java.util.NoSuchElementException;
30 import org.jetbrains.annotations.NotNull;
31 import org.junit.Assert;
32 import org.junit.Test;
71 check(
new AcceptMatcher(o1, o2),
new ArrayGameObjectIterator(o1, o2, o3, o1, o2, o3, o1, o1, o2, o3, o3), o1, o2, o1, o2, o1, o1, o2);
86 Assert.assertTrue(filterGameObjectIterator.hasNext());
87 Assert.assertSame(gameObject, filterGameObjectIterator.next());
89 Assert.assertFalse(filterGameObjectIterator.hasNext());
123 private final Collection<GameObject<?, ?, ?>> gameObjects =
new HashSet<>();
130 this.gameObjects.addAll(Arrays.asList(gameObjects));
135 return gameObjects.contains(gameObject);
162 this.gameObjects = gameObjects.clone();
167 return index < gameObjects.length;
172 if (index >= gameObjects.length) {
173 throw new NoSuchElementException();
175 return gameObjects[index++];
179 public void remove() {
180 throw new UnsupportedOperationException();
boolean isMatching(@NotNull final GameObject<?, ?, ?> gameObject)
Matches an GameObject.
void testAcceptMatcher()
Checks that a matcher that accepts some game objects returns only the accepted game objects...
Interface for classes that match GameObjects.
This package contains classes related to matching GameObjects, so called GameObjectMatchers.
Helper class for regression tests to create MapModel instances.
static void check(@NotNull final GameObjectMatcher matcher, @NotNull final Iterator< TestGameObject > iterator, @NotNull final TestGameObject... gameObjects)
Creates a new FilterGameObjectIterator instance and checks that it returns the expected game objects...
AcceptMatcher(@NotNull final GameObject<?, ?, ?>... gameObjects)
Creates a new instance.
int index
The current index into gameObjects.
void testAllMatcher()
Checks that a matcher that accepts all game objects returns all game objects.
Regression tests for FilterGameObjectIterator.
A GameObjectMatcher that accepts all game objects.
Base package of all Gridarta classes.
A GameObjectMatcher that accepts a set of game objects.
Reflects a game object (object on a map).
An Iterator that filters another iterator according to a GameObjectMatcher.
ArrayGameObjectIterator(@NotNull final TestGameObject... gameObjects)
Creates a new instance.
TestGameObject newGameObject(@NotNull final String archetypeName, @NotNull final String objectName)
Creates a new game object.
GameObjects are the objects based on Archetypes found on maps.
void testEmptyIterator()
Checks that an empty iterator is filtered correctly.
final TestGameObject [] gameObjects
The GameObjects to return.
An Iterator that returns a fixed list of GameObjects.
A GameObject implementation for testing purposes.
static final long serialVersionUID
The serial version UID.
boolean isMatching(@NotNull final GameObject<?, ?, ?> gameObject)
Matches an GameObject.