Beispiel #1
0
 /**
  * Calls heartbeat
  * @return boolean
  */
 public function listenHeart()
 {
     $batch = new KieBatch(['lookup' => 'ksession']);
     $converter = new KieMomentConverter();
     $request = new KieHBRequest();
     $request->message = 'HeartBeat';
     $request->start = new Moment();
     $request->time = new Moment();
     $config = ['factName' => 'trimetis.heartbeat.Request', 'identifier' => 'hb_request', 'nodes' => ['message', 'start' => ['name' => 'start', 'converter' => $converter], 'time' => ['converter' => $converter]]];
     $this->req = new KieFact($request, $config);
     $batch->addFact($this->req);
     $batch->addQuery(new KieQuery(['name' => 'getResponse', 'identifier' => 'response']));
     return $this->execute($batch);
 }
Beispiel #2
0
 /**
  * @covers jarekkozak\helpers\KieServer::toXml
  */
 public function testToXml2()
 {
     $batch = new KieBatch(['lookup' => 'ksession']);
     $converter = new KieMomentConverter();
     $config = ['factName' => 'org.jarekkozak.Request', 'nodes' => ['message', 'start' => ['name' => 'start', 'converter' => $converter], 'time' => ['converter' => $converter]]];
     $request = new KieHBRequest();
     $request->message = 'Test message';
     $request->start = new Moment('2015-01-01T12:34:00');
     $request->time = new Moment('2015-01-02T12:34:00');
     //$config['object']=$request;
     $config['identifier'] = 'req1';
     $reqFact1 = new KieFact($request, $config);
     $request = new KieHBRequest();
     $request->message = 'Test message2';
     $request->start = new Moment('2015-02-01T12:34:00');
     $request->time = new Moment('2015-02-02T12:34:00');
     //$config['object']=$request;
     $config['identifier'] = 'req2';
     $reqFact2 = new KieFact($request, $config);
     $batch->addFact($reqFact1);
     $batch->addFact($reqFact2);
     $batch->addQuery(new KieQuery(['name' => 'response', 'identifier' => 'identyfikator']));
     self::assertEquals('<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<batch-execution lookup="ksession"><insert out-identifier="req1"><org.jarekkozak.Request><message>Test message</message><start>2015-01-01 12:34:00.000000 UTC</start><time>2015-01-02 12:34:00.000000 UTC</time></org.jarekkozak.Request></insert><insert out-identifier="req2"><org.jarekkozak.Request><message>Test message2</message><start>2015-02-01 12:34:00.000000 UTC</start><time>2015-02-02 12:34:00.000000 UTC</time></org.jarekkozak.Request></insert><fire-all-rules/><query out-identifier="identyfikator" name="response"/></batch-execution>' . "\n", $batch->toXml());
 }
 /**
  * @covers jarekkozak\kie\KieContainer::execute
  */
 public function testExecute()
 {
     $client = $this->getClient();
     $container = new KieContainer(['client' => $client, 'container' => 'heartbeat']);
     ///
     $batch = new KieBatch(['lookup' => 'ksession']);
     $converter = new KieMomentConverter();
     $config = ['factName' => 'trimetis.heartbeat.Request', 'nodes' => ['message', 'start' => ['name' => 'start', 'converter' => $converter], 'time' => ['converter' => $converter]]];
     $request = new KieHBRequest();
     $request->message = 'Test Message';
     $request->start = new Moment('2015-01-01T12:34:00');
     $request->time = new Moment('2015-01-02T12:34:00');
     $config['identifier'] = 'request1';
     $reqFact1 = new KieFact($request, $config);
     $batch->addFact($reqFact1);
     $batch->addQuery(new KieQuery(['name' => 'getResponse', 'identifier' => 'response']));
     ///
     $res = $container->execute($batch);
     self::assertTrue($res);
     $results = $container->getResults();
     self::assertCount(2, $results);
 }