diff --git a/IF/src/main/java/com/github/stefvanschie/inventoryframework/pane/Pane.java b/IF/src/main/java/com/github/stefvanschie/inventoryframework/pane/Pane.java index 710163bb..79a7afed 100644 --- a/IF/src/main/java/com/github/stefvanschie/inventoryframework/pane/Pane.java +++ b/IF/src/main/java/com/github/stefvanschie/inventoryframework/pane/Pane.java @@ -88,6 +88,10 @@ public abstract class Pane { * @param priority the priority of the pane */ protected Pane(int x, int y, int length, int height, @NotNull Priority priority) { + if (length == 0 || height == 0) { + throw new IllegalArgumentException("Length and height of pane must be greater than zero"); + } + this.x = x; this.y = y; @@ -107,6 +111,10 @@ protected Pane(int x, int y, int length, int height, @NotNull Priority priority) * @param height the height of the pane */ protected Pane(int length, int height) { + if (length == 0 || height == 0) { + throw new IllegalArgumentException("Length and height of pane must be greater than zero"); + } + this.length = length; this.height = height; diff --git a/IF/src/test/java/com/github/stefvanschie/inventoryframework/gui/InventoryComponentTest.java b/IF/src/test/java/com/github/stefvanschie/inventoryframework/gui/InventoryComponentTest.java index c5d04ed4..e9f58386 100644 --- a/IF/src/test/java/com/github/stefvanschie/inventoryframework/gui/InventoryComponentTest.java +++ b/IF/src/test/java/com/github/stefvanschie/inventoryframework/gui/InventoryComponentTest.java @@ -21,7 +21,7 @@ void testConstructor() { void testAddPane() { InventoryComponent inventoryComponent = new InventoryComponent(0, 0); - inventoryComponent.addPane(new StaticPane(0, 0)); + inventoryComponent.addPane(new StaticPane(1, 1)); List panes = inventoryComponent.getPanes(); @@ -33,8 +33,8 @@ void testAddPane() { void testCopy() { InventoryComponent original = new InventoryComponent(0, 0); - original.addPane(new StaticPane(0, 0)); - original.addPane(new OutlinePane(0, 0)); + original.addPane(new StaticPane(1, 1)); + original.addPane(new OutlinePane(1, 1)); InventoryComponent copy = original.copy(); @@ -49,10 +49,10 @@ void testCopy() { void testExcludeRowsValid() { InventoryComponent original = new InventoryComponent(0, 6); - original.addPane(new StaticPane(0, 0)); - original.addPane(new OutlinePane(0, 0)); - original.addPane(new PaginatedPane(0, 0)); - original.addPane(new MasonryPane(0, 0)); + original.addPane(new StaticPane(1, 1)); + original.addPane(new OutlinePane(1, 1)); + original.addPane(new PaginatedPane(1, 1)); + original.addPane(new MasonryPane(1, 1)); InventoryComponent shrunk = original.excludeRows(4, 4); @@ -81,9 +81,9 @@ void testGetPanesEmptyWhenNone() { void testGetPanesSorted() { InventoryComponent inventoryComponent = new InventoryComponent(0, 0); - inventoryComponent.addPane(new StaticPane(0, 0, 0, 0, Pane.Priority.HIGHEST)); - inventoryComponent.addPane(new OutlinePane(0, 0, 0, 0, Pane.Priority.LOW)); - inventoryComponent.addPane(new PaginatedPane(0, 0, 0, 0, Pane.Priority.MONITOR)); + inventoryComponent.addPane(new StaticPane(0, 0, 1, 1, Pane.Priority.HIGHEST)); + inventoryComponent.addPane(new OutlinePane(0, 0, 1, 1, Pane.Priority.LOW)); + inventoryComponent.addPane(new PaginatedPane(0, 0, 1, 1, Pane.Priority.MONITOR)); List panes = inventoryComponent.getPanes(); diff --git a/IF/src/test/java/com/github/stefvanschie/inventoryframework/util/PaginatedPaneTest.java b/IF/src/test/java/com/github/stefvanschie/inventoryframework/util/PaginatedPaneTest.java index f7141724..1f22d992 100644 --- a/IF/src/test/java/com/github/stefvanschie/inventoryframework/util/PaginatedPaneTest.java +++ b/IF/src/test/java/com/github/stefvanschie/inventoryframework/util/PaginatedPaneTest.java @@ -13,7 +13,7 @@ public class PaginatedPaneTest { @Test void testGetPanesNonExistentPage() { - PaginatedPane pane = new PaginatedPane(0, 0); + PaginatedPane pane = new PaginatedPane(1, 1); //noinspection ResultOfMethodCallIgnored assertThrows(IllegalArgumentException.class, () -> pane.getPanes(0)); @@ -21,11 +21,11 @@ void testGetPanesNonExistentPage() { @Test void testGetPanesCollectionContents() { - PaginatedPane paginatedPane = new PaginatedPane(0, 0); + PaginatedPane paginatedPane = new PaginatedPane(1, 1); - StaticPane pane0 = new StaticPane(0, 0); - StaticPane pane1 = new StaticPane(0, 0); - StaticPane pane2 = new StaticPane(0, 0); + StaticPane pane0 = new StaticPane(1, 1); + StaticPane pane1 = new StaticPane(1, 1); + StaticPane pane2 = new StaticPane(1, 1); paginatedPane.addPane(0, pane0); paginatedPane.addPane(0, pane1); @@ -39,11 +39,11 @@ void testGetPanesCollectionContents() { @Test void testGetPanesCollectionSize() { - PaginatedPane paginatedPane = new PaginatedPane(0, 0); + PaginatedPane paginatedPane = new PaginatedPane(1, 1); - StaticPane pane0 = new StaticPane(0, 0); - StaticPane pane1 = new StaticPane(0, 0); - StaticPane pane2 = new StaticPane(0, 0); + StaticPane pane0 = new StaticPane(1, 1); + StaticPane pane1 = new StaticPane(1, 1); + StaticPane pane2 = new StaticPane(1, 1); paginatedPane.addPane(0, pane0); paginatedPane.addPane(0, pane1);