Splits Gate into Gate, GateLayout and GateHandler, and creates a new portal package with portal related classes
This commit is contained in:
		@@ -3,6 +3,7 @@ package net.knarcraft.stargate;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
 | 
			
		||||
import static org.junit.jupiter.api.Assertions.assertEquals;
 | 
			
		||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
 | 
			
		||||
 | 
			
		||||
public class RelativeBlockVectorTest {
 | 
			
		||||
 | 
			
		||||
@@ -14,4 +15,18 @@ public class RelativeBlockVectorTest {
 | 
			
		||||
        assertEquals(23, relativeBlockVector.getDistance());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void equalsTest() {
 | 
			
		||||
        RelativeBlockVector vector1 = new RelativeBlockVector(56, 34, 76);
 | 
			
		||||
        RelativeBlockVector vector2 = new RelativeBlockVector(56, 34, 76);
 | 
			
		||||
        assertEquals(vector1, vector2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void notEqualsTest() {
 | 
			
		||||
        RelativeBlockVector vector1 = new RelativeBlockVector(456, 78, 234);
 | 
			
		||||
        RelativeBlockVector vector2 = new RelativeBlockVector(56, 34, 76);
 | 
			
		||||
        assertNotEquals(vector1, vector2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,95 @@
 | 
			
		||||
package net.knarcraft.stargate.portal;
 | 
			
		||||
 | 
			
		||||
import be.seeseemelk.mockbukkit.ServerMock;
 | 
			
		||||
import be.seeseemelk.mockbukkit.WorldMock;
 | 
			
		||||
import net.knarcraft.stargate.RelativeBlockVector;
 | 
			
		||||
import net.knarcraft.stargate.Stargate;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.junit.jupiter.api.BeforeAll;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
 | 
			
		||||
import static org.junit.jupiter.api.Assertions.assertEquals;
 | 
			
		||||
import static org.junit.jupiter.api.Assertions.assertTrue;
 | 
			
		||||
 | 
			
		||||
import be.seeseemelk.mockbukkit.MockBukkit;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
public class GateLayoutTest {
 | 
			
		||||
 | 
			
		||||
    private static GateLayout layout;
 | 
			
		||||
 | 
			
		||||
    @BeforeAll
 | 
			
		||||
    public static void setUp() {
 | 
			
		||||
        ServerMock server = MockBukkit.mock();
 | 
			
		||||
        server.addWorld(new WorldMock(Material.DIRT, 5));
 | 
			
		||||
        MockBukkit.load(Stargate.class);
 | 
			
		||||
        layout = GateHandler.getGateByName("nethergate.gate").getLayout();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void gateLayoutExitTest() {
 | 
			
		||||
        assertEquals(new RelativeBlockVector(1, 3, 0), layout.getExit());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void gateLayoutExitsTest() {
 | 
			
		||||
        List<RelativeBlockVector> expected = new ArrayList<>();
 | 
			
		||||
        expected.add(new RelativeBlockVector(1, 3, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(2, 3, 0));
 | 
			
		||||
 | 
			
		||||
        Set<RelativeBlockVector> exits = layout.getExits().keySet();
 | 
			
		||||
        exits.forEach((blockVector) -> assertTrue(expected.contains(blockVector)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void gateLayoutBorderTest() {
 | 
			
		||||
        List<RelativeBlockVector> expected = new ArrayList<>();
 | 
			
		||||
        expected.add(new RelativeBlockVector(1, 0, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(2, 0, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(0, 1, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(0, 2, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(0, 3, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(1, 4, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(2, 4, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(3, 1, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(3, 2, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(3, 3, 0));
 | 
			
		||||
 | 
			
		||||
        RelativeBlockVector[] borderBlocks = layout.getBorder();
 | 
			
		||||
        for (RelativeBlockVector blockVector : borderBlocks) {
 | 
			
		||||
            assertTrue(expected.contains(blockVector));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void gateLayoutControlsTest() {
 | 
			
		||||
        List<RelativeBlockVector> expected = new ArrayList<>();
 | 
			
		||||
        expected.add(new RelativeBlockVector(0, 2, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(3, 2, 0));
 | 
			
		||||
 | 
			
		||||
        RelativeBlockVector[] controlBlocks = layout.getControls();
 | 
			
		||||
        for (RelativeBlockVector blockVector : controlBlocks) {
 | 
			
		||||
            assertTrue(expected.contains(blockVector));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    public void gateLayoutEntrancesTest() {
 | 
			
		||||
        List<RelativeBlockVector> expected = new ArrayList<>();
 | 
			
		||||
        expected.add(new RelativeBlockVector(1, 1, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(2, 1, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(1, 2, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(2, 2, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(1, 3, 0));
 | 
			
		||||
        expected.add(new RelativeBlockVector(2, 3, 0));
 | 
			
		||||
 | 
			
		||||
        RelativeBlockVector[] controlBlocks = layout.getEntrances();
 | 
			
		||||
        for (RelativeBlockVector blockVector : controlBlocks) {
 | 
			
		||||
            assertTrue(expected.contains(blockVector));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user