Hamcrest number matchers

Is closeTo

@Test
public void number_close_to_number () {
    assertThat(200.24, is(closeTo(200, 1)));
}

greaterThan

@Test
public void number_greaterthan () {
    assertThat(20, greaterThan(18));
}

Every item greaterThan

@Test
public void everyitem_in_list_greaterthan_number () {
     
    List<Integer> ages = Lists.newArrayList(21, 25, 30);
    assertThat(ages, everyItem(greaterThan(18)));
}

Every item greaterThanOrEqualTo

@Test
public void everyitem_in_list_greaterthan_or_equal_to_number () {
     
    List<Integer> ages = Lists.newArrayList(21, 25, 30, 18);
    assertThat(ages, everyItem(greaterThanOrEqualTo(18)));
}

Every item lessthan

@Test
public void everyitem_in_list_lessthan_number() {
     
    List<Integer> ages = Lists.newArrayList(21, 25, 30);
    assertThat(ages, everyItem(lessThan(31)));
}

Every item lessThanOrEqualTo

@Test
public void everyitem_in_list_lessthan_or_equal_to_number () {
     
    List<Integer> ages = Lists.newArrayList(21, 25, 30, 18);
    assertThat(ages, everyItem(lessThanOrEqualTo(30)));
}

Is closeTo

@Test
public void bigdecimal_is_close_to_bigdecimal () {
    
    BigDecimal seniorCitizen = new BigDecimal(65);
    
    // is close to retirement 
    assertThat(new BigDecimal(60), 
            is(closeTo(seniorCitizen, new BigDecimal(5))));
}