### Question:
CacheEntry { public final float getHitRate() { final int total = this.getTotal(); if (total == 0) { return 0; } return this.getHits() / (float) total; } CacheEntry(); final String getData(); final void setData(final String data); final int getHits(); final void incrementHits(); final int getMisses(); final void incrementMisses(); final boolean isExpired(final Date date); final void setExpiresIn(final int expiresInSeconds); final float getHitRate(); final float getMissRate();  }### Answer:
@Test public void testGetHitRate() throws Exception { CacheEntry cacheEntry = new CacheEntry(); final int hits = 7; final int misses = 3; final float expResult = 0.7F; for(int i = 0; i < hits; i++) { cacheEntry.incrementHits(); } for(int i = 0; i < misses; i++) { cacheEntry.incrementMisses(); } final float result = cacheEntry.getHitRate(); assertEquals(expResult, result, 0.001); }