20 package net.sf.gridarta.actions;
22 import java.awt.Point;
40 import org.jetbrains.annotations.NotNull;
41 import org.jetbrains.annotations.Nullable;
42 import org.junit.Assert;
43 import org.junit.Before;
44 import org.junit.Test;
107 final Point point1 =
new Point(3, 4);
108 Assert.assertTrue(actions.
doExitCopy(
false, mapControl, point1));
112 Assert.assertTrue(actions.
doExitCopy(
true, mapControl, point1));
118 Assert.assertFalse(actions.
doExitCopy(
false, mapControl, point1));
136 final Point point1 =
new Point(3, 4);
137 final Point point2 =
new Point(1, 2);
143 Assert.assertFalse(actions.
doExitPaste(
false, mapControl, point1));
154 Assert.assertFalse(actions.
doExitPaste(
false, mapControl, point1));
165 Assert.assertTrue(actions.
doExitPaste(
false, mapControl, point1));
166 checkExit(mapModel, point1, 1,
"",
new Point(0, 0));
169 Assert.assertTrue(actions.
doExitPaste(
true, mapControl, point1));
170 checkExit(mapModel, point1, 1,
"b", point2);
187 final Point point1 =
new Point(3, 4);
188 final Point point2 =
new Point(1, 2);
197 Assert.assertFalse(actions.
doExitCopy(
true, mapControl1, point1));
200 Assert.assertTrue(actions.
doExitPaste(
true, mapControl1, point1));
221 final Point point1 =
new Point(3, 4);
222 final Point point2 =
new Point(1, 2);
228 Assert.assertFalse(actions.
doExitConnect(
false, mapControl1, point1));
239 Assert.assertFalse(actions.
doExitConnect(
false, mapControl1, point1));
250 Assert.assertFalse(actions.
doExitConnect(
false, mapControl1, point1));
261 Assert.assertTrue(actions.
doExitConnect(
false, mapControl1, point1));
262 checkExit(mapModel1, point1, 1,
"",
new Point(0, 0));
263 checkExit(mapModel2, point2, 0,
"",
new Point(0, 0));
266 Assert.assertTrue(actions.
doExitConnect(
true, mapControl1, point1));
267 checkExit(mapModel1, point1, 1,
"b", point2);
268 checkExit(mapModel2, point2, 0,
"a", point1);
289 final Point point1 =
new Point(3, 4);
290 final Point point2 =
new Point(1, 2);
299 Assert.assertFalse(actions.
doExitConnect(
true, mapControl1, point1));
300 checkExit(mapModel1, point1, 0,
null,
null);
301 checkExit(mapModel2, point2, 0,
null,
null);
306 Assert.assertTrue(actions.
doExitConnect(
true, mapControl1, point1));
307 checkExit(mapModel1, point1, 0,
"b", point2);
308 checkExit(mapModel2, point2, 0,
"a", point1);
311 Assert.assertTrue(actions.
doExitConnect(
true, mapControl1, point1));
312 checkExit(mapModel1, point1, 0,
"b", point2);
313 checkExit(mapModel1, point1, 1,
null,
null);
314 checkExit(mapModel2, point2, 0,
"a", point1);
315 checkExit(mapModel2, point2, 1,
null,
null);
327 testPath(
"/HallOfSelection",
"/world/world_104_115",
"/world/world_104_115");
328 testPath(
"/world/world_104_115",
"/HallOfSelection",
"/HallOfSelection");
331 testPath(
"/a/b/c/d",
"/a/d/e",
"../../d/e");
332 testPath(
"/a/b/c/d",
"/a/b/d",
"../d");
334 testPath(
"/a/b/c",
"/a/b/c/d",
"c/d");
337 testPath(
"/a/b/c",
"/b/c/d",
"/b/c/d");
349 private void testPath(@NotNull
final String mapPathFrom, @NotNull
final String mapPathTo, @NotNull
final String expectedExitPath) {
363 final Point pointFrom =
new Point(3, 4);
364 final Point pointTo =
new Point(1, 2);
377 Assert.assertTrue(actions.
doExitPaste(
true, mapControl, pointFrom));
378 checkExit(mapModel, pointFrom, 0, expectedExitPath, pointTo);
398 assert tmpTestMapControlCreator !=
null;
415 if (thisIndex == index) {
420 if (exitPath ==
null || exitPoint ==
null) {
421 Assert.fail(
"exit found but none expected");
422 throw new AssertionError();
425 Assert.assertEquals(exitPath, gameObject.getAttributeString(
BaseObject.
SLAYING));
426 Assert.assertEquals(exitPoint.x, gameObject.getAttributeInt(
BaseObject.
HP));
427 Assert.assertEquals(exitPoint.y, gameObject.getAttributeInt(
BaseObject.
SP));
434 if (exitPath !=
null || exitPoint !=
null) {
435 Assert.fail(
"no exit found");