Visitor { public boolean isMaxHitsBreached(Integer maxHits) { return maxHits != null && hits > maxHits; } Visitor(long id, String ipAddress, String countryId, String country, String agentType, int hits, Instant firstHit, Instant lastHit); long getId(); String getIpAddress(); String getCountryId(); String getCountry(); String getAgentType(); synchronized int getHits(); Instant getFirstHit(); synchronized Instant getLastHit(); synchronized Duration getAge(); synchronized void visit(); synchronized void unvisit(); boolean isMaxHitsBreached(Integer maxHits); boolean isHitRateBreached(Double maxHitRate, Duration maxHitRateDelay); synchronized boolean isDirty(); synchronized void clearDirty(); synchronized boolean isExpired(Duration expiryTimeout); @Override String toString();  }
@Test void checkIfMaxHitsIsBreached() { Instant now = Instant.now(); Visitor visitor = new Visitor(1L, "192.168.1.1", "SRB", "Serbia", WEB_BROWSER.name(), 100, now, now); assertThat(visitor.isMaxHitsBreached(null)).isFalse(); assertThat(visitor.isMaxHitsBreached(1000)).isFalse(); assertThat(visitor.isMaxHitsBreached(10)).isTrue(); }