public void render() { Graphics g = screen.getGraphics(); // Drawing Things! sky.render(g); level.render( g, (int) sX, (int) sY, (pixel.width / Tile.tileSize) + 2, (pixel.height / Tile.tileSize) + 2); character.render(g); inventory.render(g); health.render(g); for (int i = 0; i < mob.toArray().length; i++) { mob.get(i).render(g); } g = getGraphics(); g.drawImage(screen, 0, 0, size.width, size.height, 0, 0, pixel.width, pixel.height, null); g.dispose(); }
@Test public void picksHealth() { // jogador apanha um bonus de vida (ganha vida) Player p = new Player(true); int life = p.getLifepoints(); // cria objeto que da a vida ao player Health h = new Health(p.getX(), p.getY(), true); Obstacle ob = new Obstacle((int) p.getX(), (int) p.getY(), 20, true); // verifica se apanha assertTrue(h.colide(p)); h.caught(p, true); // verifica se nao ganha vida, pois tem a vida cheia assertEquals(life, p.getLifepoints()); // perde vida ob.damage(p); int life1 = p.getLifepoints(); assertTrue(life > life1); // ganha vida h.caught(p, true); assertTrue(life1 < p.getLifepoints()); }
@Test public void database() { this.indicator.setDataSource(this.dataSource); Health health = this.indicator.health(); assertNotNull(health.getDetails().get("database")); assertNotNull(health.getDetails().get("hello")); }
@Test public void error() { this.indicator.setDataSource(this.dataSource); this.indicator.setQuery("SELECT COUNT(*) from BAR"); Health health = this.indicator.health(); assertThat(health.getDetails().get("database"), notNullValue()); assertEquals(Status.DOWN, health.getStatus()); }
@Test public void diskSpaceIsDown() throws Exception { given(this.fileMock.getFreeSpace()).willReturn(THRESHOLD_BYTES - 10); given(this.fileMock.getTotalSpace()).willReturn(THRESHOLD_BYTES * 10); Health health = this.healthIndicator.health(); assertThat(health.getStatus()).isEqualTo(Status.DOWN); assertThat(health.getDetails().get("threshold")).isEqualTo(THRESHOLD_BYTES); assertThat(health.getDetails().get("free")).isEqualTo(THRESHOLD_BYTES - 10); assertThat(health.getDetails().get("total")).isEqualTo(THRESHOLD_BYTES * 10); }
@Test public void connectionClosed() throws Exception { DataSource dataSource = mock(DataSource.class); Connection connection = mock(Connection.class); given(connection.getMetaData()).willReturn(this.dataSource.getConnection().getMetaData()); given(dataSource.getConnection()).willReturn(connection); this.indicator.setDataSource(dataSource); Health health = this.indicator.health(); assertNotNull(health.getDetails().get("database")); verify(connection, times(2)).close(); }
@Test public void customQuery() { this.indicator.setDataSource(this.dataSource); new JdbcTemplate(this.dataSource).execute("CREATE TABLE FOO (id INTEGER IDENTITY PRIMARY KEY)"); this.indicator.setQuery("SELECT COUNT(*) from FOO"); Health health = this.indicator.health(); System.err.println(health); assertNotNull(health.getDetails().get("database")); assertEquals(Status.UP, health.getStatus()); assertNotNull(health.getDetails().get("hello")); }
private Color getColorFor(double health) { switch (Health.getHealthFor(health)) { case POOR: return Color.RED; case AVERAGE: return Color.YELLOW; default: return Color.GREEN; } }
@Override public int hashCode() { int result = 0; result = 31 * result + (health != null ? health.hashCode() : 0); result = 31 * result + (instances != null ? instances.hashCode() : 0); result = 31 * result + (instancesUrl != null ? instancesUrl.hashCode() : 0); result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (services != null ? services.hashCode() : 0); result = 31 * result + (url != null ? url.hashCode() : 0); return result; }
public void tick() { if (inGame) { level.tick( (int) sX, (int) sY, (pixel.width / Tile.tileSize) + 2, (pixel.height / Tile.tileSize) + 2); character.tick(); sky.tick(); health.tick(); for (int i = 0; i < mob.toArray().length; i++) { mob.get(i).tick(); } } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Cluster other = (Cluster) o; // NOPMD if (health != null ? !health.equals(other.health) : other.health != null) return false; if (instances != null ? !instances.equals(other.instances) : other.instances != null) return false; if (instancesUrl != null ? !instancesUrl.equals(other.instancesUrl) : other.instancesUrl != null) return false; if (name != null ? !name.equals(other.name) : other.name != null) return false; if (services != null ? !services.equals(other.services) : other.services != null) return false; if (url != null ? !url.equals(other.url) : other.url != null) return false; return true; }
public final int maxHp() { return health.getMaxHp(); }
public final int hp() { return health.getHp(); }