/*
 * FXGL - JavaFX Game Library. The MIT License (MIT).
 * Copyright (c) AlmasB (almaslvl@gmail.com).
 * See LICENSE for details.
 */

package com.almasb.fxgl.pathfinding.astar;

import com.almasb.fxgl.pathfinding.CellState;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class AStarPathfinderTest {

    private static final int GRID_SIZE = 20;
    private AStarGrid grid;
    private AStarPathfinder pathfinder;

    @BeforeEach
    public void setUp() {
        grid = new AStarGrid(GRID_SIZE, GRID_SIZE);
        pathfinder = new AStarPathfinder(grid);
    }

    @Test
    public void testFindPath() {
        List<AStarCell> path = pathfinder.findPath(3, 0, 5, 0);
        assertPathEquals(path, 4, 0, 5, 0);

        // Add barriers.
        for (int i = 0; i <= 4; i++)
            grid.get(4, i).setState(CellState.NOT_WALKABLE);
        path = pathfinder.findPath(3, 0, 5, 0);
        assertPathEquals(path,
                3, 1,
                3, 2,
                3, 3,
                3, 4,
                3, 5,
                4, 5,
                5, 5,
                5, 4,
                5, 3,
                5, 2,
                5, 1,
                5, 0);

        // Make passing impossible.
        for (int i = 0; i <= 19; i++)
            grid.get(4, i).setState(CellState.NOT_WALKABLE);
        path = pathfinder.findPath(3, 0, 5, 0);
        assertTrue(path.isEmpty());
    }

    @Test
    public void testFindPathWithBusyCells() {
        grid.get(3, 0).setState(CellState.NOT_WALKABLE);
        grid.get(3, 1).setState(CellState.NOT_WALKABLE);
        grid.get(3, 2).setState(CellState.NOT_WALKABLE);
        grid.get(3, 3).setState(CellState.NOT_WALKABLE);
        grid.get(3, 5).setState(CellState.NOT_WALKABLE);
        grid.get(1, 4).setState(CellState.NOT_WALKABLE);


        List<AStarCell> path = pathfinder.findPath(1, 1, 4, 5, new ArrayList<>());
        System.out.println("Solution: " + path);
        assertPathEquals(path,
                2, 1,
                2, 2,
                2, 3,
                2, 4,
                3, 4,
                4, 4,
                4, 5);
        List<AStarCell> pathWithBusyCell = pathfinder.findPath(1, 1, 4, 5, Collections.singletonList(grid.get(3, 4)));
        System.out.println("Solution: " + pathWithBusyCell);
        assertPathEquals(pathWithBusyCell,
                2, 1,
                2, 2,
                2, 3,
                2, 4,
                2, 5,
                2, 6,
                3, 6,
                4, 6,
                4, 5);
    }

    private void assertPathEquals(List<AStarCell> path, int... points) {
        assertEquals(points.length / 2, path.size());

        int i = 0;
        for (AStarCell cell : path) {
            assertEquals(points[i++], cell.getX());
            assertEquals(points[i++], cell.getY());
        }

        assertEquals(points.length, i);
    }
}
@@ -324,16 +324,41 @@
 ayList;%0A
+import java.util.Arrays;%0A
 import j
@@ -401,16 +401,52 @@
 il.List;
+%0Aimport java.util.function.Supplier;
 %0A%0Aimport
@@ -2192,57 +2192,8 @@
 ));%0A
-        System.out.println(%22Solution: %22 + path);%0A
     
@@ -2497,69 +2497,8 @@
 ));%0A
-        System.out.println(%22Solution: %22 + pathWithBusyCell);%0A
     
@@ -2866,16 +2866,54 @@
 h.size()
+, reportNotMatchingPaths(path, points)
 );%0A%0A    
@@ -3014,16 +3014,54 @@
 l.getX()
+, reportNotMatchingPaths(path, points)
 );%0A     
@@ -3104,16 +3104,54 @@
 l.getY()
+, reportNotMatchingPaths(path, points)
 );%0A     
@@ -3193,16 +3193,244 @@
 ength, i
+, reportNotMatchingPaths(path, points));%0A    %7D%0A%0A    private Supplier%3CString%3E reportNotMatchingPaths(List%3CAStarCell%3E path, int... points)%7B%0A        return () -%3E %22Paths do not match: %5Cn%22 + path + %22%5Cn != %5Cn%22 + Arrays.toString(points
 );%0A    %7D

Add proper reporting