((InternalKnowledgeBase) kbase), (InternalWorkingMemory) ((StatefulKnowledgeSessionImpl) ksession), RuleBaseNodes.getNodeMap(((InternalKnowledgeBase) kbase)), marshallingConfig.getObjectMarshallingStrategyStore(), marshallingConfig.isMarshallProcessInstances(), MarshallerReaderContext readerContext = new MarshallerReaderContext(bais, ((KnowledgeBaseImpl) kbase), RuleBaseNodes.getNodeMap( ((KnowledgeBaseImpl) kbase)), marshallingConfig.getObjectMarshallingStrategyStore(), ProtobufMarshaller.TIMER_READERS,
@Test public void testEmptyRule() throws Exception { String rule = "package org.drools.compiler.test;\n"; rule += "global java.util.List list\n"; rule += "rule \"Rule 1\"\n"; rule += "when\n"; rule += "then\n"; rule += " list.add( \"fired\" );\n"; rule += "end"; KieBase kBase = loadKnowledgeBaseFromString( rule ); // Make sure the rete node map is created correctly Map<Integer, BaseNode> nodes = RuleBaseNodes.getNodeMap((InternalKnowledgeBase) kBase); assertEquals( 2, nodes.size() ); assertEquals( "InitialFactImpl", ((ClassObjectType) ((ObjectTypeNode) nodes.get( 2 )).getObjectType()).getClassType().getSimpleName() ); assertEquals( "Rule 1", ((RuleTerminalNode) nodes.get( 4 )).getRule().getName() ); KieSession session = kBase.newKieSession(); List list = new ArrayList(); session.setGlobal( "list", list ); session = SerializationHelper.getSerialisedStatefulKnowledgeSession( session, kBase, true ); session.fireAllRules(); session = SerializationHelper.getSerialisedStatefulKnowledgeSession( session, kBase, true ); assertEquals( 1, ((List) session.getGlobal( "list" )).size() ); assertEquals( "fired", ((List) session.getGlobal( "list" )).get( 0 ) ); }
Map<Integer, BaseNode> nodes = RuleBaseNodes.getNodeMap((InternalKnowledgeBase) kBase); assertEquals( 3, nodes.size() );
Map<Integer, BaseNode> nodes = RuleBaseNodes.getNodeMap((InternalKnowledgeBase) kBase);
Map<Integer, BaseNode> nodes = RuleBaseNodes.getNodeMap( (InternalKnowledgeBase) kBase );
@Test public void testEmptyRule() throws Exception { String rule = "package org.drools.compiler.test;\n"; rule += "global java.util.List list\n"; rule += "rule \"Rule 1\"\n"; rule += "when\n"; rule += "then\n"; rule += " list.add( \"fired\" );\n"; rule += "end"; KnowledgeBase kBase = loadKnowledgeBaseFromString( rule ); // Make sure the rete node map is created correctly Map<Integer, BaseNode> nodes = RuleBaseNodes.getNodeMap((InternalKnowledgeBase) kBase); assertEquals( 2, nodes.size() ); assertEquals( "InitialFactImpl", ((ClassObjectType) ((ObjectTypeNode) nodes.get( 2 )).getObjectType()).getClassType().getSimpleName() ); assertEquals( "Rule 1", ((RuleTerminalNode) nodes.get( 4 )).getRule().getName() ); StatefulKnowledgeSession session = kBase.newStatefulKnowledgeSession(); List list = new ArrayList(); session.setGlobal( "list", list ); session = SerializationHelper.getSerialisedStatefulKnowledgeSession( session, kBase, true ); session.fireAllRules(); session = SerializationHelper.getSerialisedStatefulKnowledgeSession( session, kBase, true ); assertEquals( 1, ((List) session.getGlobal( "list" )).size() ); assertEquals( "fired", ((List) session.getGlobal( "list" )).get( 0 ) ); }
Map<Integer, BaseNode> nodes = RuleBaseNodes.getNodeMap((InternalKnowledgeBase) kBase); assertEquals( 3, nodes.size() );
Map<Integer, BaseNode> nodes = RuleBaseNodes.getNodeMap((InternalKnowledgeBase) kBase);
Map<Integer, BaseNode> nodes = RuleBaseNodes.getNodeMap((InternalKnowledgeBase) kBase);