package jacobi.core.classifier.cart.node;

import java.util.HashSet;
import java.util.Set;

import org.junit.Assert;
import org.junit.Test;

public class DecisionTest {
	
	@Test
	public void shouldBeAbleToGetBackDecisionItem() {
		Assert.assertEquals(42, new Decision<>(42).decide().intValue());
		Assert.assertEquals("This is a text", new Decision<>("This is a text").decide());
				
	}
	
	@Test
	public void shouldDecisionDoesNotHaveSplit() {
		Assert.assertNull(new Decision<>(42).split());
		Assert.assertNull(new Decision<>("ABC").split());
		Assert.assertNull(new Decision<>(new Object()).split());
		
		Assert.assertFalse(new Decision<>(42).decide(7).isPresent());
		Assert.assertFalse(new Decision<>("String.").decide(new double[] {1, 2, 3}).isPresent());
	}
	
	@Test
	public void shouldBeAbleToUseDecisionInHashSet() {
		Set<Decision<String>> set = new HashSet<>();
		set.add(new Decision<>("John Wayne"));
		set.add(new Decision<>("Bruce Wayne"));
		set.add(new Decision<>("John Locke"));
		set.add(new Decision<>("Johanne Sebastian Bach"));
		
		Assert.assertTrue(set.contains(new Decision<>("Bruce Wayne")));
		Assert.assertTrue(set.contains(new Decision<>("Johanne Sebastian Bach")));
		Assert.assertTrue(set.contains(set.iterator().next()));
		Assert.assertFalse(set.contains(new Decision<>(42)));
		Assert.assertFalse(set.contains(new Decision<>("John Wayne Gacy")));
	}

}

@@ -1419,14 +1419,400 @@
 ));%0D%0A%09%7D%0D
+%0A%09%0D%0A%09@Test%0D%0A%09public void shouldDecisionNodeEqualsToItselfByInstance() %7B%0D%0A%09%09Decision%3CString%3E decision = new Decision%3C%3E(%22eureka%22);%0D%0A%09%09Assert.assertTrue(decision.equals(decision));%0D%0A%09%7D%0D%0A%09%0D%0A%09@Test%0D%0A%09public void shouldDecisionNodeNotEqualsToOtherObject() %7B%0D%0A%09%09Assert.assertFalse(new Decision%3C%3E(%22eureka%22).equals(Boolean.TRUE));%0D%0A%09%09Assert.assertFalse(new Decision%3C%3E(%22eureka%22).equals(10));%0D%0A%09%7D%0D
 %0A%0D%0A%7D%0D%0A

Increase test coverage