package com.levelup.java.hamcrest;

import static org.hamcrest.CoreMatchers.everyItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.number.IsCloseTo.*;
import static org.hamcrest.number.OrderingComparison.*;
import static org.junit.Assert.assertThat;

import java.util.List;

import org.junit.Test;

import com.google.common.collect.Lists;

/**
 * This java example will demonstrate junit 
 * test while using hamcrest matchers.
 * 
 * @author Justin Musgrove
 * @see <a href='http://www.leveluplunch.com/java/examples/junit-test-numbers-hamcrest/'>Unit test numbers</a>
 * 
 */
public class NumberMatchers {

	@Test
	public void item_close_to () {
		assertThat(200.24, is(closeTo(200, 1)));
	}
	
	@Test
	public void item_greaterthan () {
		assertThat(20, greaterThan(18));
	}
	
	@Test
	public void everyitem_in_list_greaterthan () {
		 
		List<Integer> ages = Lists.newArrayList(21, 25, 30);
		assertThat(ages, everyItem(greaterThan(18)));
	}
	
	@Test
	public void everyitem_in_list_greaterthan_or_equal_to () {
		 
		List<Integer> ages = Lists.newArrayList(21, 25, 30, 18);
		assertThat(ages, everyItem(greaterThanOrEqualTo(18)));
	}

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

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

	
}

@@ -270,16 +270,100 @@
 rtThat;%0A
+import static org.hamcrest.number.BigDecimalCloseTo.*;%0A%0Aimport java.math.BigDecimal;
 %0Aimport 
@@ -733,20 +733,22 @@
 ic void 
-item
+number
 _close_t
@@ -748,16 +748,23 @@
 close_to
+_number
  () %7B%0A%09%09
@@ -829,20 +829,22 @@
 ic void 
-item
+number
 _greater
@@ -934,32 +934,39 @@
 list_greaterthan
+_number
  () %7B%0A%09%09 %0A%09%09List
@@ -1120,32 +1120,39 @@
 than_or_equal_to
+_number
  () %7B%0A%09%09 %0A%09%09List
@@ -1307,25 +1307,31 @@
 ist_lessthan
- 
+_number
 () %7B%0A%09%09 %0A%09%09L
@@ -1491,16 +1491,23 @@
 equal_to
+_number
  () %7B%0A%09%09
@@ -1625,12 +1625,243 @@
 ));%0A%09%7D%0A%0A
+%09@Test%0A%09public void bigdecimal_is_close_to_bigdecimal () %7B%0A%09%09%0A%09%09BigDecimal seniorCitizen = new BigDecimal(65);%0A%09%09%0A%09%09// is close to retirement %0A%09%09assertThat(new BigDecimal(60), is(closeTo(seniorCitizen, new BigDecimal(5))));%0A%09%0A%09%7D%0A%09%0A
 %09%0A%7D%0A

change method names, added bigdecimal is close to