Viewport { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || this.getClass() != o.getClass()) { return false; } Viewport that = (Viewport) o; return this.x == that.x && this.y == that.y && this.width == that.width && this.height == that.height; } Viewport();  Viewport(int x, int y, int width, int height);  Viewport(Viewport viewport); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); Viewport set(int x, int y, int width, int height); Viewport set(Viewport viewport); Viewport setEmpty(); boolean isEmpty(); boolean intersects(int x, int y, int width, int height); @SuppressWarnings("UnnecessaryLocalVariable") boolean intersects(Viewport viewport); boolean intersect(int x, int y, int width, int height); @SuppressWarnings("UnnecessaryLocalVariable") boolean intersect(Viewport viewport); boolean contains(int x, int y); public int x; public int y; public int width; public int height; }
@Test public void testEquals() throws Exception { Viewport viewport1 = new Viewport(1, 2, 3, 4); Viewport viewport2 = new Viewport(1, 2, 3, 4); assertTrue("equals", viewport1.equals(viewport2)); }
@Test public void testEquals_Null() throws Exception { Viewport viewport = new Viewport(1, 2, 3, 4); assertFalse("inequality with null", viewport.equals(null)); }
@Test public void testEquals_Inequality() throws Exception { Viewport viewport1 = new Viewport(1, 2, 3, 4); Viewport viewport2 = new Viewport(4, 3, 2, 1); assertFalse("not equals", viewport1.equals(viewport2)); }