20 package net.sf.gridarta.model.baseobject;
22 import java.awt.Point;
38 import org.jetbrains.annotations.NotNull;
39 import org.jetbrains.annotations.Nullable;
40 import org.junit.Assert;
41 import org.junit.Test;
63 Assert.assertNull(archetype.getFaceName());
64 archetype.setAttributeString(
"face",
"arch_face");
65 Assert.assertEquals(
"arch_face", archetype.getFaceName());
79 Assert.assertEquals(
"face2", gameObject.
getFaceName());
81 Assert.assertEquals(
"face2", gameObject.
getFaceName());
88 gameObject.
setObjectText(
"abc 1\n" +
"face face4\n" +
"def 2\n");
89 Assert.assertEquals(
"face4", gameObject.
getFaceName());
96 gameObject.
setObjectText(
"abc 1\n" +
"face arch_face\n" +
"def 2\n");
112 Assert.assertEquals(
"face1", gameObject.
getFaceName());
114 Assert.assertEquals(
"face2", gameObject.
getFaceName());
125 final TestArchetype archetype =
newArchetype(
"arch",
"key1 value1\n" +
"key2 value2\n", faceObjectProviders, animationObjects);
151 Assert.assertEquals(
"key3 value3\n", gameObject.
getObjectText());
164 Assert.assertEquals(
"key3 value3\n" +
"key2 VALUE2\n", gameObject.
getObjectText());
177 Assert.assertEquals(
"key2 VALUE2\n", gameObject.
getObjectText());
255 Assert.assertEquals(direction, gameObject.getDirection());
256 Assert.assertEquals(direction, gameObject.getAttributeInt(
"direction"));
321 Assert.assertEquals(type, gameObject.getTypeNo());
322 Assert.assertEquals(type, gameObject.getAttributeInt(
BaseObject.
TYPE));
337 gameObject.removeAttribute(
"name");
355 gameObject.removeAttribute(
"name");
395 gameObject.setAttributeInt(
"a", 1);
396 gameObject.setAttributeInt(
"b", 0);
397 gameObject.setAttributeInt(
"c", 2);
398 gameObject.setAttributeInt(
"d", 0);
404 gameObject.setAttributeInt(
"a", 0);
405 gameObject.setAttributeInt(
"b", 1);
406 gameObject.setAttributeInt(
"c", 0);
407 gameObject.setAttributeInt(
"d", 2);
413 gameObject.setAttributeInt(
"a", 1);
414 gameObject.setAttributeInt(
"b", 0);
415 gameObject.setAttributeInt(
"c", 2);
416 gameObject.setAttributeInt(
"d", 0);
436 Assert.assertEquals(
"format", gameObject.
toString(
"format"));
437 Assert.assertEquals(
"Name TitleNameName TitleTitle", gameObject.
toString(
"${NAME}${name}${NAME}${title}${other}"));
438 Assert.assertEquals(
"", gameObject.
toString(
"${other:abc}"));
439 Assert.assertEquals(
"abc", gameObject.
toString(
"${name:abc}"));
440 Assert.assertEquals(
"abc", gameObject.
toString(
"${level:abc}"));
441 Assert.assertEquals(
"test", gameObject.
toString(
"te${other: 1${other}2 }st"));
442 Assert.assertEquals(
"te 1Name2 st", gameObject.
toString(
"te${name: 1${name}2 }st"));
443 Assert.assertEquals(
"te 1102 st", gameObject.
toString(
"te${level: 1${level}2 }st"));
457 mapModelCreator.addGameObjectToMap(mapModel,
"floor",
"1", 0, 0, topmostInsertionMode);
466 gameObject.setObjectText(
"a 1\nb 2\n");
475 gameObject.setObjectText(
"b 2\na 1\n");
490 Assert.assertEquals(name, gameObject.getObjName());
491 Assert.assertEquals(nameAttribute, gameObject.getAttributeString(
BaseObject.
NAME));
506 if (objectText != null) {
507 archetype.setObjectText(objectText);
534 assert resourceIcons != null;
Regression tests for AbstractBaseObject.
static void checkDirection(@NotNull final BaseObject<?, ?, ?, ?> gameObject, final int direction)
Checks that the "direction" attribute of a GameObject contains the expected value.
final ResourceIcons resourceIcons
The ResourceIcons instance.
void testSetFaceName1()
Checks that setting the face name does work.
A FaceObjects for regression tests.
A MapModel reflects the data of a map.
Helper class for regression tests to create MapModel instances.
void endTransaction()
End a transaction.
void setArchetype(@NotNull R archetype)
Set the Archetype of this GameObject.
Gridarta can handle frame information of animations and allow the selection of an animation using a t...
void testSetObjectTextAttributeOrdering()
Checks that BaseObject#setObjectText(String) ignores attribute ordering.
An AnimationObjects for regression tests.
void testSetFaceName2()
Checks that a custom face may be changed.
boolean isModified()
Return whether the map has been modified from the on-disk state.
void testName1()
Checks that caching the "name" attribute does work.
A MapArchObject implementation for testing purposes.
void removeAttribute(@NotNull String attributeName)
Removes the String of an archetype attribute from the objectText.
void testName2()
Checks that caching the "name" attribute does work.
String getAttributeString(@NotNull String attributeName, boolean queryArchetype)
Returns the requested attribute value of this GameObject as String.
String TYPE
The attribute name of the object's type.
void testDirection2()
Checks that caching the "direction" attribute does work.
void testSetAttributeString()
Checks that GameObject#setAttributeString(String, String) does work.
Base package of all Gridarta classes.
static void checkType(@NotNull final BaseObject<?, ?, ?, ?> gameObject, final int type)
Checks that the BaseObject#TYPE attribute of a GameObject contains the expected value.
void testDirection1()
Checks that caching the "direction" attribute does work.
String getFaceName()
Returns the name of the face of this Archetype or GameObject.
Reflects a game object (object on a map).
An Archetype implementation for testing purposes.
void testToString1()
Checks that AbstractBaseObject#toString(String) works as expected.
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
AnimationObjects is a container for AnimationObjects.
void testDirection3()
Checks that caching the "direction" attribute does work.
GameObjects are the objects based on Archetypes found on maps.
void testType1()
Checks that caching the "type" attribute does work.
void testName3()
Checks that caching the "name" attribute does work.
FaceObjects is a container for FaceObjects.
void setObjectText(@NotNull String objectText)
Sets.
FaceObjectProviders newFaceObjectProviders()
Creates a new FaceObjectProviders instance.
Provider for faces of GameObjects and Archetypes.
static GameObject< TestGameObject, TestMapArchObject, TestArchetype > newGameObject(@NotNull final TestArchetype archetype, @NotNull final String name, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects)
Creates a new game object instance.
The face is the appearance of an object.
static void checkName(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final String name, @NotNull final String nameAttribute)
Checks that the BaseObject#NAME attribute of an GameObject contains the expected value.
String toString(@NotNull String format)
Returns a string representation of this game object.
void resetModified()
Resets the modified flag to false.
Creates ImageIcon instances from resources.
String NAME
The attribute name of the object's name.
An Archetype implementation for testing purposes.
String getObjectText()
Returns the object text of this GameObject as String.
A GameObject implementation for testing purposes.
void testType2()
Checks that caching the "type" attribute does work.
void beginTransaction(@NotNull String name)
Starts a new transaction.
void testSetAttributeInt1()
Checks that AbstractBaseObject#setAttributeInt(String, int) works as expected.
static TestArchetype newArchetype(@NotNull final String archetypeName, @Nullable final String objectText, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects)
Creates a new TestArchetype instance.
void testType3()
Checks that caching the "type" attribute does work.
void setAttributeString(@NotNull String attributeName, @NotNull String value)
Sets the String of an archetype attribute in the objectText.