Search in sources :

Example 1 with CheckTypeTree

use of fr.neatmonster.nocheatplus.components.data.checktype.CheckTypeTree in project NoCheatPlus by NoCheatPlus.

the class TestCheckTypeTree method testCreationCompleteness.

@Test
public void testCreationCompleteness() {
    CheckTypeTree<TestNode> tree = new CheckTypeTree<TestNode>() {

        @Override
        protected TestNode newNode(CheckType checkType, TestNode parent, CheckTypeTreeNodeFactory<TestNode> factory) {
            return new TestNode(checkType, parent, factory);
        }
    };
    for (CheckType checkType : CheckType.values()) {
        TestNode node = tree.getNode(checkType);
        CheckType rct = node.getCheckType();
        if (rct != checkType) {
            fail("Bad check type, expext " + checkType + ", got instead: " + rct);
        }
        if (rct.getParent() != null && node.getParent().getCheckType() != rct.getParent()) {
            fail("Wrong type of parent.");
        }
        if (node.getChildren().size() != CheckTypeUtil.getDirectChildren(checkType).size()) {
            fail("Wrong size of children.");
        }
    }
    if (tree.getNode(null) != null) {
        fail("tree.getNode(null) returns a non null node for CheckType: " + tree.getNode(null).getCheckType());
    }
}
Also used : CheckTypeTreeNodeFactory(fr.neatmonster.nocheatplus.components.data.checktype.CheckTypeTree.CheckTypeTreeNodeFactory) CheckType(fr.neatmonster.nocheatplus.checks.CheckType) CheckTypeTree(fr.neatmonster.nocheatplus.components.data.checktype.CheckTypeTree) Test(org.junit.Test)

Aggregations

CheckType (fr.neatmonster.nocheatplus.checks.CheckType)1 CheckTypeTree (fr.neatmonster.nocheatplus.components.data.checktype.CheckTypeTree)1 CheckTypeTreeNodeFactory (fr.neatmonster.nocheatplus.components.data.checktype.CheckTypeTree.CheckTypeTreeNodeFactory)1 Test (org.junit.Test)1