AbstractBuilding implements Clickable, Drawable,
        Tickable { public void removeFromWorld() { if (world.containsBuilding(this)) { if (buildTask != null) { TaskManager.getInstance().removeTask(buildTask); buildTask = null; } this.handleRemove(); for (int i = 0; i < getTiles().size(); i++) { if (getTiles().get(i) == null) { continue; } getTiles().get(i).removeProperty(TileProperty.IS_BUILDING); try { getTiles().get(i).setTileEntity(originalTiles.get(i).getTileEntity()); } catch (IndexOutOfBoundsException e) { getTiles().get(i).setTileEntity(null); } } world.removeBuilding(this); } } 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 testRemoveFromWorld() { Tile tile = mock(Tile.class); when(tile.getTileEntity()).thenReturn(null); when(world.getTile(anyInt(), anyInt())).thenReturn(tile); building.setLocation(new Point(1, 1)); when(world.containsBuilding(building)).thenReturn(true); building.removeFromWorld(); verify(tile, times(4 * 3)).removeProperty(TileProperty.IS_BUILDING); verify(tile, times(4 * 3)).setTileEntity(null); verify(world).removeBuilding(building); when(world.getTile(anyInt(), anyInt())).thenReturn(null); building.removeFromWorld(); when(world.containsBuilding(building)).thenReturn(false); building.removeFromWorld(); }