AbstractBuilding implements Clickable, Drawable,
        Tickable { public boolean isLocationValid() { for (Tile tile : getTiles()) { if (tile == null || tile.getTileEntity() != null) { return false; } } return true; } AbstractBuilding(World world, int width, int height,
            String imageName); World getWorld(); Point getLocation(); void setLocation(Point location); boolean isLocationValid(); boolean addToWorld(); void removeFromWorld(); List<Tile> getTiles(); int getWidth(); int getHeight(); Image getSprite(); int getSpriteOffset(); void setSprite(String imageName); long getCurrentHealth(); void setHealth(long health); long getMaxHealth(); void setMaxHealth(long maxHealth); long damageHealth(long damage); long healHealth(long heal); void fullyRestoreHealth(); boolean onChangeHealth(long newHealth); void setPollutionSource(double rate); void removePollutionSource(); double getPollutionRate(); boolean isBuilt(); void completeBuilding(); void setBuildTime(int buildTime); int getBuildTime(); @Override void draw(Viewport viewport, GraphicsContext ctx); @Override double getWorldX(); @Override double getWorldY(); void onPlace(); void onBuild(); void onRemove(); @Override boolean containsPoint(Point point); @Override void click(Point location); void onClick(Point location); void onDoubleClick(Point location); @Override void tick(); @Override String toString(); static final int DOUBLE_CLICK_TIME; static final int DEFAULT_MAX_HEALTH; static final int DEFAULT_BUILD_TIME; }
@Test public void testIsLocationValid() { Tile tile = mock(Tile.class); when(tile.getTileEntity()).thenReturn(null); when(world.getTile(anyInt(), anyInt())).thenReturn(tile); building.setLocation(new Point(1, 1)); assertTrue("Building is in a valid location", building.isLocationValid()); TileEntity entity = mock(TileEntity.class); when(tile.getTileEntity()).thenReturn(entity); assertFalse("Building has a tile entity underneath it.", building.isLocationValid()); when(tile.getTileEntity()).thenReturn(null); setBuilding(new Point(2, 2), 5, 3, 1000); assertFalse("Building is not in a valid location", building.isLocationValid()); }