public void setUp(int... type) {
    KieBaseConfiguration kconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
    kconf.setOption(RuleEngineOption.PHREAK);
    ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase((RuleBaseConfiguration) kconf);
    buildContext = new BuildContext(ruleBase, ruleBase.getReteooBuilder().getIdGenerator());

    PropagationContextFactory pctxFactory =
        ruleBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
    context =
        pctxFactory.createPropagationContext(0, PropagationContext.INSERTION, null, null, null);

    MockTupleSource mockTupleSource = new MockTupleSource(9);

    rule1 = new Rule("rule1");
    rule2 = new Rule("rule2");
    rule3 = new Rule("rule3");

    ObjectTypeNode otn =
        new ObjectTypeNode(2, null, new ClassObjectType(String.class), buildContext);
    liaNode = new LeftInputAdapterNode(3, otn, buildContext);

    // 3, 4, 5, 6 are in same shared segment
    n1 = createBetaNode(10, type[0], liaNode);
    n2 = createBetaNode(11, type[1], n1);
    RuleTerminalNode rtn1 = new RuleTerminalNode(18, n2, rule1, rule1.getLhs(), 0, buildContext);
    rtn1.attach();

    n3 = createBetaNode(12, type[2], n1);
    n4 = createBetaNode(13, type[3], n3);
    n5 = createBetaNode(14, type[4], n4);
    n6 = createBetaNode(15, type[5], n5);
    RuleTerminalNode rtn2 = new RuleTerminalNode(19, n6, rule2, rule2.getLhs(), 0, buildContext);
    rtn2.attach();

    n7 = createBetaNode(16, type[6], n6);
    n8 = createBetaNode(17, type[7], n7);
    RuleTerminalNode rtn3 = new RuleTerminalNode(20, n8, rule3, rule3.getLhs(), 0, buildContext);
    rtn3.attach();

    // n1 -> n2 -> r1
    //  \
    //   n3 -> n4 -> n5 -> n6 -> r2
    //                      \
    //                      n7 -> n8 -> r3

    n1.getAssociations().put(rule1, null);
    n1.getAssociations().put(rule2, null);
    n1.getAssociations().put(rule3, null);
    n2.getAssociations().put(rule1, null);
    n2.getAssociations().put(rule2, null);
    n2.getAssociations().put(rule3, null);

    n3.getAssociations().put(rule2, null);
    n3.getAssociations().put(rule3, null);
    n4.getAssociations().put(rule2, null);
    n4.getAssociations().put(rule3, null);
    n5.getAssociations().put(rule2, null);
    n5.getAssociations().put(rule3, null);
    n6.getAssociations().put(rule2, null);
    n6.getAssociations().put(rule3, null);

    n7.getAssociations().put(rule3, null);
    n8.getAssociations().put(rule3, null);
  }