// Path: pmml-converter/src/main/java/org/jpmml/converter/InternableSimplePredicate.java
// public class InternableSimplePredicate extends SimplePredicate {
// 
// 	public InternableSimplePredicate(){
// 	}
// 
// 	public InternableSimplePredicate(String name, SimplePredicate.Operator operator, Object value){
// 		super(name, operator, value);
// 	}
// 
// 	@Override
// 	public int hashCode(){
// 		int result = 0;
// 
// 		result = (31 * result) + Objects.hashCode(this.getField());
// 		result = (31 * result) + Objects.hashCode(this.getOperator());
// 		result = (31 * result) + Objects.hashCode(this.getValue());
// 
// 		return result;
// 	}
// 
// 	@Override
// 	public boolean equals(Object object){
// 
// 		if(object instanceof InternableSimplePredicate){
// 			InternableSimplePredicate that = (InternableSimplePredicate)object;
// 
// 			return Objects.equals(this.getField(), that.getField()) && Objects.equals(this.getOperator(), that.getOperator()) && Objects.equals(this.getValue(), that.getValue());
// 		}
// 
// 		return false;
// 	}
// }


import org.dmg.pmml.tree.Node;
import org.dmg.pmml.tree.TreeModel;
import org.jpmml.converter.InternableSimplePredicate;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collections;
import org.dmg.pmml.False;
import org.dmg.pmml.MiningField;
import org.dmg.pmml.MiningFunction;
import org.dmg.pmml.MiningSchema;
import org.dmg.pmml.SimplePredicate;
import org.dmg.pmml.True;
import org.dmg.pmml.tree.BranchNode;
import org.dmg.pmml.tree.ComplexNode;
import org.dmg.pmml.tree.LeafNode;
/*
 * Copyright (c) 2021 Villu Ruusmann
 *
 * This file is part of JPMML-Converter
 *
 * JPMML-Converter is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JPMML-Converter is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with JPMML-Converter.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.jpmml.converter.visitors;




public class TreeModelPrunerTest {

	@Test
	public void pruneFalse(){
		Node parent = new BranchNode()
			.setId(0)
			.setPredicate(new SimplePredicate("x", SimplePredicate.Operator.IS_NOT_MISSING, null));

		Node firstChild = new LeafNode()
			.setId(1)
			.setPredicate(False.INSTANCE);

		Node secondChild = new LeafNode()
			.setId(2)
			.setPredicate(True.INSTANCE);

		parent
			.setDefaultChild(firstChild.getId())
			.addNodes(firstChild, secondChild);

		prune(parent);

		assertEquals(Arrays.asList(firstChild, secondChild), parent.getNodes());

		parent.setDefaultChild(secondChild);

		prune(parent);

		assertEquals(Collections.singletonList(secondChild), parent.getNodes());

		secondChild.setPredicate(False.INSTANCE);

		prune(parent);

		assertEquals(Collections.singletonList(secondChild), parent.getNodes());

		parent.setDefaultChild(null);

		prune(parent);

		assertEquals(Collections.emptyList(), parent.getNodes());
	}

	@Test
	public void pruneNoOp(){
// Path: pmml-converter/src/main/java/org/jpmml/converter/InternableSimplePredicate.java
// public class InternableSimplePredicate extends SimplePredicate {
// 
// 	public InternableSimplePredicate(){
// 	}
// 
// 	public InternableSimplePredicate(String name, SimplePredicate.Operator operator, Object value){
// 		super(name, operator, value);
// 	}
// 
// 	@Override
// 	public int hashCode(){
// 		int result = 0;
// 
// 		result = (31 * result) + Objects.hashCode(this.getField());
// 		result = (31 * result) + Objects.hashCode(this.getOperator());
// 		result = (31 * result) + Objects.hashCode(this.getValue());
// 
// 		return result;
// 	}
// 
// 	@Override
// 	public boolean equals(Object object){
// 
// 		if(object instanceof InternableSimplePredicate){
// 			InternableSimplePredicate that = (InternableSimplePredicate)object;
// 
// 			return Objects.equals(this.getField(), that.getField()) && Objects.equals(this.getOperator(), that.getOperator()) && Objects.equals(this.getValue(), that.getValue());
// 		}
// 
// 		return false;
// 	}
// }


// Path: pmml-converter/src/test/java/org/jpmml/converter/visitors/TreeModelPrunerTest.java
import org.dmg.pmml.tree.Node;
import org.dmg.pmml.tree.TreeModel;
import org.jpmml.converter.InternableSimplePredicate;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.Collections;
import org.dmg.pmml.False;
import org.dmg.pmml.MiningField;
import org.dmg.pmml.MiningFunction;
import org.dmg.pmml.MiningSchema;
import org.dmg.pmml.SimplePredicate;
import org.dmg.pmml.True;
import org.dmg.pmml.tree.BranchNode;
import org.dmg.pmml.tree.ComplexNode;
import org.dmg.pmml.tree.LeafNode;

/*
 * Copyright (c) 2021 Villu Ruusmann
 *
 * This file is part of JPMML-Converter
 *
 * JPMML-Converter is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JPMML-Converter is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with JPMML-Converter.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.jpmml.converter.visitors;




public class TreeModelPrunerTest {

	@Test
	public void pruneFalse(){
		Node parent = new BranchNode()
			.setId(0)
			.setPredicate(new SimplePredicate("x", SimplePredicate.Operator.IS_NOT_MISSING, null));

		Node firstChild = new LeafNode()
			.setId(1)
			.setPredicate(False.INSTANCE);

		Node secondChild = new LeafNode()
			.setId(2)
			.setPredicate(True.INSTANCE);

		parent
			.setDefaultChild(firstChild.getId())
			.addNodes(firstChild, secondChild);

		prune(parent);

		assertEquals(Arrays.asList(firstChild, secondChild), parent.getNodes());

		parent.setDefaultChild(secondChild);

		prune(parent);

		assertEquals(Collections.singletonList(secondChild), parent.getNodes());

		secondChild.setPredicate(False.INSTANCE);

		prune(parent);

		assertEquals(Collections.singletonList(secondChild), parent.getNodes());

		parent.setDefaultChild(null);

		prune(parent);

		assertEquals(Collections.emptyList(), parent.getNodes());
	}

	@Test
	public void pruneNoOp(){
		SimplePredicate parentPredicate = new InternableSimplePredicate("x", SimplePredicate.Operator.NOT_EQUAL, 0);