Tabnine Logo
Cheese
Code IndexAdd Tabnine to your IDE (free)

How to use
Cheese
in
org.drools.core.test.model

Best Java code snippets using org.drools.core.test.model.Cheese (Showing top 20 results out of 315)

Refine searchRefine arrow

  • DefaultFactHandle
  • KnowledgeBaseFactory
  • InternalKnowledgeBase
  • StatefulKnowledgeSessionImpl
  • Declaration
  • KieSession
origin: org.drools/drools-compiler

@Test
public void updateFactOnRuleFireTest() {
  final Cheese camembert = new Cheese("Camembert", 19);
  final Cheese cheddar = new Cheese("Cheddar", 45);
  ksession.insert(camembert);
  ksession.insert(cheddar);
  verifyFactsWithQuery(Cheese.class, "cheeseTypes", camembert, cheddar);
  final List<Cheese> expensiveCheese = new ArrayList<>();
  ksession.setGlobal("expensiveCheese", expensiveCheese);
  final int firedRules = ksession.fireAllRules();
  assertThat(firedRules).isEqualTo(2);
  verifyList(expensiveCheese, camembert, cheddar);
  verifyFactsWithQuery(Cheese.class, "cheeseTypes", camembert, cheddar);
  assertThat(camembert.getPrice()).isEqualTo(21);
  assertThat(cheddar.getPrice()).isEqualTo(45);
}
origin: org.drools/drools-core

public boolean equals(final Object object) {
  if ( object == this ) {
    return true;
  }
  if ( object == null || !(object instanceof Cheese) ) {
    return false;
  }
  final Cheese other = (Cheese) object;
  return (this.type.equals( other.getType() ) && this.price == other.getPrice());
}
origin: org.drools/drools-core

@Test @Ignore
public void testAgendaEventListener() throws Exception {
  InternalKnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
  pkg.addRule( rule );
  kbase.addPackages( Collections.singleton(pkg) );
  KieSession ksession = kbase.newKieSession();
  final List agendaList = new ArrayList();
  final AgendaEventListener agendaEventListener = new AgendaEventListener() {
  ksession.addEventListener( agendaEventListener );
  assertEquals( 1, ksession.getAgendaEventListeners().size() );
  final Cheese cheddar = new Cheese( "cheddar",
                    15 );
  FactHandle cheddarHandle = ksession.insert( cheddar );
  InternalAgenda agenda = (InternalAgenda) ksession.getAgenda();
  cheddar.setPrice( 14 );
  ksession.update(cheddarHandle,
          cheddar);
  cheddar.setPrice( 14 );
  ksession.update( cheddarHandle,
           cheddar );
origin: org.drools/drools-core

@Test
public void testRemoveRuleRuntimeEventListener() {
  KieBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
  KieSession ksession = kbase.newKieSession();
  ksession.addEventListener( eventListener );
  ksession.removeEventListener( eventListener );
  final Cheese stilton = new Cheese( "stilton",
                 15 );
  final Cheese cheddar = new Cheese( "cheddar",
                 17 );
  final FactHandle stiltonHandle = ksession.insert( stilton );
  assertTrue( wmList.isEmpty() );
origin: org.drools/drools-compiler

@Test
public void deleteUpdatedFactDifferentClassTest() {
  FactHandle fact = ksession.insert(new Person("George", 18));
  Assertions.assertThat(ksession.getObjects()).hasSize(1);
  Assertions.assertThat(ksession.getObjects().iterator().next()).isInstanceOf(Person.class);
  ksession.update(fact, new Cheese("Cheddar", 50));
  Assertions.assertThat(ksession.getObjects()).hasSize(1);
  Assertions.assertThat(ksession.getObjects().iterator().next()).isInstanceOf(Cheese.class);
  ksession.delete(fact);
  Assertions.assertThat(ksession.getObjects()).isEmpty();
}
origin: org.drools/drools-core

@Test
public void testObjectIterator() {
  InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
  KieSession ksession = kBase.newKieSession();
  ksession.insert( new Person( "bob", 35) );
  ksession.insert( new Cheese( "stilton", 35) );
  ksession.insert( new Cheese( "brie", 35) );
  ksession.insert( new Person( "steve", 55) );
  ksession.insert( new Person( "tom", 100) );
  int i = 0;
  for ( FactHandle fh : ksession.getFactHandles()) {
    if ( i++ > 5 ) {
      fail( "should not iterate for than 3 times" );
    }
  }
  i = 0;
  for ( FactHandle fh : ksession.getFactHandles()) {
    if ( i++ > 5 ) {
      fail( "should not iterate for than 3 times" );
    }
  }
}
origin: org.drools/drools-core

InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession();
                               FieldFactory.getInstance().getFieldValue( 5 ),
                               extractor );
final Cheese cheddar = new Cheese( "cheddar",
                  5 );
final InternalFactHandle cheddarHandle = (InternalFactHandle) ksession.insert( cheddar );
                 ksession ) );
final Cheese stilton = new Cheese( "stilton",
                  10 );
final InternalFactHandle stiltonHandle = (InternalFactHandle) ksession.insert( stilton );
origin: org.drools/drools-core

@Test
public void testLiteralConstraintAssertObjectWithoutMemory() throws Exception {
  InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
  BuildContext buildContext = new BuildContext( kBase );
  buildContext.setRule(new RuleImpl("test"));
  StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession();
  PropagationContextFactory pctxFactory = kBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
  final PropagationContext context = pctxFactory.createPropagationContext(0, PropagationContext.Type.INSERTION, null, null, null);
  alphaNode.addObjectSink( sink );
  final Cheese cheddar = new Cheese( "cheddar",
                    5 );
  final DefaultFactHandle f0 = (DefaultFactHandle) ksession.insert( cheddar );
        ksession.getObject( (DefaultFactHandle) list[0] ) );
  final Cheese stilton = new Cheese( "stilton",
                    6 );
  final DefaultFactHandle f1 = new DefaultFactHandle( 1,
                            stilton );
        ksession.getObject( (DefaultFactHandle) list[0] ) );
origin: org.drools/drools-core

@Test
public void testReturnValueConstraintAssertObject() throws Exception {
  InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
  BuildContext buildContext = new BuildContext( kBase );
  buildContext.setRule(new RuleImpl("test"));
  StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession();
  PropagationContextFactory pctxFactory = kBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
  final PropagationContext context = pctxFactory.createPropagationContext(0, PropagationContext.Type.INSERTION, null, null, null);
  alphaNode.addObjectSink( sink );
  final Cheese cheddar = new Cheese( "cheddar",
                    5 );
  final DefaultFactHandle f0 = (DefaultFactHandle) ksession.insert( cheddar );
  final Object[] list = (Object[]) sink.getAsserted().get( 0 );
  assertSame( cheddar,
        ksession.getObject( (DefaultFactHandle) list[0] ) );
  final Cheese stilton = new Cheese( "stilton",
                    6 );
  f0.setObject( stilton );
origin: org.drools/drools-core

            "org.drools.core.test.model.Cheese");
RuleBaseConfiguration conf = new RuleBaseConfiguration(properties);
InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase(conf);
buildContext = new BuildContext(kBase);
final StatefulKnowledgeSessionImpl ksession = new StatefulKnowledgeSessionImpl(1L, kBase);
final Rete rete = kBase.getRete();
final EntryPointNode entryPoint = new EntryPointNode(0,
                           rete,
final Cheese cheese = new Cheese("brie",
                 15);
final DefaultFactHandle h1 = new DefaultFactHandle(1,
                          cheese);
         ksession);
ksession.fireAllRules();
origin: org.drools/drools-core

@Test
public void testUpdateSinkWithoutMemory() {
  InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase();
  BuildContext buildContext = new BuildContext( kBase );
  buildContext.setRule(new RuleImpl("test"));
  StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession();
  PropagationContextFactory pctxFactory = kBase.getConfiguration().getComponentFactory().getPropagationContextFactory();
  final PropagationContext context = pctxFactory.createPropagationContext(0, PropagationContext.Type.INSERTION, null, null, null);
  final Cheese cheese = new Cheese( "cheddar",
                   0 );
  final DefaultFactHandle handle1 = new DefaultFactHandle( 1,
                               cheese );
  final Cheese stilton = new Cheese( "stilton",
                    10 );
  final DefaultFactHandle handle2 = new DefaultFactHandle( 2,
                               stilton );
origin: org.drools/drools-core

@Test
public void testIsShadowed() {
  StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newKieSession();
  // Create a Rete network with ObjectTypeNodes for List, Collection and ArrayList
  final Rete rete = kBase.getRete();
  final ObjectTypeNode objectTypeNode = new ObjectTypeNode(1,
                               this.entryPoint,
                               new ClassObjectType(Cheese.class),
                               buildContext);
  objectTypeNode.attach(buildContext);
  final MockObjectSink sink1 = new MockObjectSink();
  objectTypeNode.addObjectSink(sink1);
  // There are no String ObjectTypeNodes, make sure its not propagated
  final Cheese cheese = new Cheese("brie",
                   15);
  final DefaultFactHandle h1 = new DefaultFactHandle(1,
                            cheese);
  rete.assertObject(h1,
           pctxFactory.createPropagationContext(0,
                              PropagationContext.Type.INSERTION,
                              null,
                              null,
                              null),
           ksession);
  ksession.fireAllRules();
  final Object[] results = (Object[]) sink1.getAsserted().get(0);
}
origin: org.drools/drools-reteoo

IdGenerator idGenerator = kBase.getReteooBuilder().getIdGenerator();
final Rete rete = kBase.getRete();
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( idGenerator.getNextId(),
                             this.entryPoint,
final Agenda agenda = ksession.getAgenda();
rule1.setConsequence( consequence );
                                    true );
final PropagationContext context1 = pctxFactory.createPropagationContext(0, PropagationContext.INSERTION, null, null, new DefaultFactHandle());
           ksession );
final Cheese cheese = new Cheese( "brie",
                 10 );
final FactHandle cheeseHandle = ksession.insert( cheese,
                           null,
                           false,
                           (Activation) tuple1.getContextObject() );
cheese.setType( "cheddar" );
cheese.setPrice( 20 );
TruthMaintenanceSystem tms = ((NamedEntryPoint)ksession.getWorkingMemoryEntryPoint( EntryPointId.DEFAULT.getEntryPointId() ) ).getTruthMaintenanceSystem();
origin: org.drools/drools-core

                       new Declaration("id", extractor, null) ,
                       MvelConstraint.INDEX_EVALUATOR );
final SingleIndex singleIndex = new SingleIndex( new FieldIndex[]{fieldIndex},
                         1 );
Tuple tuple = new RightTupleImpl( new DefaultFactHandle( 1, new Cheese("stilton", 10) ) );
final TupleList index = new AbstractHashTable.SingleIndexTupleList( singleIndex, tuple, "stilton".hashCode(), false );
       index.hashCode() );
final Cheese stilton1 = new Cheese( "stilton",
                  35 );
final InternalFactHandle h1 = new DefaultFactHandle( 1,
                           stilton1 );
origin: org.drools/drools-core

                             "type" );
final FieldIndex fieldIndex = new FieldIndex( extractor,
                       new Declaration("id", extractor, null) ,
                       MvelConstraint.INDEX_EVALUATOR );
final SingleIndex singleIndex = new SingleIndex( new FieldIndex[]{fieldIndex},
                         1 );
Tuple tuple = new RightTupleImpl( new DefaultFactHandle( 1, new Cheese("stilton", 10) ) );
final TupleList index = new AbstractHashTable.SingleIndexTupleList( singleIndex, tuple, "stilton".hashCode(), false );
final Cheese stilton1 = new Cheese( "stilton",
                  35 );
final InternalFactHandle h1 = new DefaultFactHandle( 1,
                           stilton1 );
final Cheese stilton2 = new Cheese( "stilton",
                  59 );
final InternalFactHandle h2 = new DefaultFactHandle( 2,
stilton1.setType( "cheddar" );
origin: org.drools/drools-reteoo

final PropagationContext context = pctxFactory.createPropagationContext(0, PropagationContext.INSERTION, null, null, null);
final StatefulKnowledgeSessionImpl workingMemory = new StatefulKnowledgeSessionImpl( 1L, (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase() );
                   new ClassObjectType( Person.class ) );
final Declaration declaration = new Declaration( "age",
                         ageExtractor,
                         pattern );
final Cheese cheese1 = new Cheese( "cheddar",
                  18 );
final Cheese cheese2 = new Cheese( "brie",
                  12 );
list.add( cheese1 );
cheese1.setPrice( 30 );
final Person person2 = new Person( "xxx2",
                  30 );
final FactHandle person2Handle = workingMemory.insert( person2 );
final LeftTuple tuple2 = new LeftTupleImpl( (DefaultFactHandle) person2Handle,
                      from,
      tuple.getObject(1) );
cheese2.setPrice( 30 );
final Person person3 = new Person( "xxx2",
                  30 );
origin: org.drools/drools-reteoo

@Test
public void testActivationUnMatchListener() {
  StatefulKnowledgeSessionImpl ksession = (StatefulKnowledgeSessionImpl)kBase.newStatefulKnowledgeSession();
  final InternalAgenda agenda = (InternalAgenda) ksession.getAgenda();
                            buildContext);
  Cheese cheese = new Cheese();
  cheese.setPrice(50);
  final RuleTerminalNodeLeftTuple tuple = new RuleTerminalNodeLeftTuple(new DefaultFactHandle(1, cheese), node1, true);
                                       rule1,
                                       null,
                                       new DefaultFactHandle());
  assertEquals(50, cheese.getPrice());
  assertEquals(100, cheese.getPrice());
  assertEquals(50, cheese.getPrice());
origin: org.drools/drools-reteoo

@Test
public void testRestract() {
  final PropagationContext context = pctxFactory.createPropagationContext(0, PropagationContext.INSERTION, null, null, null);
  final StatefulKnowledgeSessionImpl workingMemory = new StatefulKnowledgeSessionImpl( 1L, (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase() );
  final ClassFieldReader extractor = store.getReader( Cheese.class,
                            "type" );
  final Cheese cheese1 = new Cheese( "stilton",
                    5 );
  final Cheese cheese2 = new Cheese( "stilton",
                    15 );
  list.add( cheese1 );
  final FactHandle person1Handle = workingMemory.insert( person1 );
  final LeftTuple tuple = new LeftTupleImpl( (DefaultFactHandle) person1Handle,
                        from,
         asserted.size() );
  final FromMemory memory = (FromMemory) workingMemory.getNodeMemory( from );
  assertEquals( 1,
         memory.getBetaMemory().getLeftTupleMemory().size() );
origin: stackoverflow.com

 public Sandwich() {
  super();   // Compiler adds it if it is not explicitly added by programmer
  // All the instance variable initialization is moved here by the compiler.
  b = new Bread();
  c = new Cheese();
  l = new Lettuce();

  System.out.println("Sandwich()");
}
origin: org.drools/drools-reteoo

@Test
public void testAlphaNode() {
  final PropagationContext context = pctxFactory.createPropagationContext(0, PropagationContext.INSERTION, null, null, null);
  final StatefulKnowledgeSessionImpl workingMemory = new StatefulKnowledgeSessionImpl(1L, kBase);
  final Cheese cheese1 = new Cheese("cheddar",
                   20);
  final Cheese cheese2 = new Cheese("brie",
                   20);
  list.add(cheese1);
  final FactHandle person1Handle = workingMemory.insert( person1 );
  final LeftTuple tuple1 = new LeftTupleImpl( (DefaultFactHandle) person1Handle,
                        from,
  cheese1.setType( "stilton" );
  final Person person2 = new Person( "xxx2",
                    30 );
  final FactHandle person2Handle = workingMemory.insert( person2 );
  final LeftTuple tuple2 = new LeftTupleImpl( (DefaultFactHandle) person2Handle,
                        from,
        tuple.getObject(1) );
  cheese2.setType( "stilton" );
  final Person person3 = new Person( "xxx2",
                    30 );
org.drools.core.test.modelCheese

Most used methods

  • <init>
  • getPrice
  • getType
  • setPrice
  • setType
  • setCharObjectType
  • setCharType

Popular in Java

  • Making http requests using okhttp
  • onCreateOptionsMenu (Activity)
  • startActivity (Activity)
  • findViewById (Activity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • JPanel (javax.swing)
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now