Beispiel #1
0
 public function testExecuteCommand()
 {
     $response = new SearchResponse();
     $command = Search::builder()->withReturnFields(['email', 'name', 'age'])->withFilterQuery('age:[18 TO *]')->withDefaultOperation('and')->withReturnField('username')->withQuery('name:Fabio*')->withDefaultField('name')->withIndex('index-name')->withSortField('name')->withPresort('score')->withNumRows(10)->withStart(1)->build();
     $response->maxScore = 1;
     $response->numFound = 2;
     $response->docs = [['email' => ['*****@*****.**'], 'name' => ['Fabio B. Silva'], 'username' => ['FabioBatSilva'], 'age' => ['30']], ['email' => ['*****@*****.**'], 'name' => ['Fabio B. Silva'], 'username' => ['fabios'], 'age' => ['30']]];
     $callback = function ($subject) {
         $this->assertInstanceOf('Riak\\Client\\Core\\Message\\Search\\SearchRequest', $subject);
         $this->assertEquals('age:[18 TO *]', $subject->filter);
         $this->assertEquals('index-name', $subject->index);
         $this->assertEquals('name:Fabio*', $subject->q);
         $this->assertEquals('score', $subject->presort);
         $this->assertEquals('name', $subject->sort);
         $this->assertEquals('name', $subject->df);
         $this->assertEquals('and', $subject->op);
         $this->assertEquals(10, $subject->rows);
         $this->assertEquals(1, $subject->start);
         $this->assertCount(4, $subject->fl);
         $this->assertContains('age', $subject->fl);
         $this->assertContains('name', $subject->fl);
         $this->assertContains('email', $subject->fl);
         $this->assertContains('username', $subject->fl);
         return true;
     };
     $this->adapter->expects($this->once())->method('send')->with($this->callback($callback))->will($this->returnValue($response));
     $result = $this->client->execute($command);
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\SearchResponse', $result);
     $this->assertEquals($response->numFound, $result->getNumResults());
     $this->assertEquals($response->maxScore, $result->getMaxScore());
     $this->assertEquals($response->docs, $result->getAllResults());
     $this->assertEquals([['email' => '*****@*****.**', 'name' => 'Fabio B. Silva', 'username' => 'FabioBatSilva', 'age' => '30'], ['email' => '*****@*****.**', 'name' => 'Fabio B. Silva', 'username' => 'fabios', 'age' => '30']], $result->getSingleResults());
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $request = $this->createMapReduceRequest();
     $response = $adapter->send($request);
     $iterator = new MapReduceEntryIterator($response->iterator);
     return $this->createMapReduceResponse($iterator);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $request = $this->createRequest();
     $response = $adapter->send($request);
     $iterator = new ListBucketsIterator($response->iterator);
     return new ListBucketsResponse($iterator);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $request = $this->createRequest();
     $response = $adapter->send($request);
     $iterator = new ListKeysLocationIterator($this->namespace, $response->iterator);
     return new ListKeysResponse($iterator);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $getRequest = $this->createGetRequest();
     $getResponse = $adapter->send($getRequest);
     $bucketProps = $this->createBucketProps($getResponse);
     $response = new FetchBucketPropertiesResponse($this->namespace, $bucketProps);
     return $response;
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $request = $this->createIndexQueryRequest();
     $namespace = $this->query->getNamespace();
     $response = $adapter->send($request);
     $iterator = new IndexEntryIterator($namespace, $response->iterator);
     return new IndexQueryResponse($namespace, $iterator, $response->continuation);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $putRequest = $this->createGetRequest();
     $putResponse = $adapter->send($putRequest);
     $datatype = $this->converter->convert($putResponse);
     $response = $this->createDataTypeResponse($datatype, $putResponse->context);
     return $response;
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $schema = null;
     $response = $adapter->send($this->createGetIndexRequest());
     if ($response && $response->name) {
         $schema = new YokozunaIndex($response->name, $response->schema);
         $schema->setNVal($response->nVal);
     }
     return new FetchIndexResponse($schema);
 }
 public function testExecuteOperation()
 {
     $response = new DeleteIndexResponse();
     $operation = new DeleteIndexOperation('index-name');
     $callback = function ($subject) {
         $this->assertInstanceOf('Riak\\Client\\Core\\Message\\Search\\DeleteIndexRequest', $subject);
         $this->assertEquals('index-name', $subject->name);
         return true;
     };
     $this->adapter->expects($this->once())->method('send')->willReturn($response)->with($this->callback($callback));
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\DeleteIndexResponse', $operation->execute($this->adapter));
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $putRequest = $this->createDeleteRequest();
     $putResponse = $adapter->send($putRequest);
     $resolverFactory = $this->config->getResolverFactory();
     $converterFactory = $this->config->getConverterFactory();
     $objectConverter = $this->config->getRiakObjectConverter();
     $vClock = $putResponse->vClock;
     $contentList = $putResponse->contentList;
     $values = $objectConverter->convertToRiakObjectList($contentList, $vClock);
     $response = new DeleteValueResponse($converterFactory, $resolverFactory, $this->location, $values);
     return $response;
 }
 public function testExecuteCommand()
 {
     $index = new YokozunaSchema('schema-name', 'schema-content');
     $response = new PutSchemaResponse();
     $command = StoreSchema::builder()->withSchema($index)->build();
     $callback = function ($subject) {
         $this->assertInstanceOf('Riak\\Client\\Core\\Message\\Search\\PutSchemaRequest', $subject);
         $this->assertEquals('schema-content', $subject->content);
         $this->assertEquals('schema-name', $subject->name);
         return true;
     };
     $this->adapter->expects($this->once())->method('send')->with($this->callback($callback))->will($this->returnValue($response));
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\StoreSchemaResponse', $this->client->execute($command));
 }
 public function testExecuteCommand()
 {
     $response = new DeleteIndexResponse();
     $command = DeleteIndex::builder()->withIndexName('index-name')->build();
     $response->nVal = 10;
     $response->name = 'index-name';
     $response->schema = 'schema-name';
     $callback = function ($subject) {
         $this->assertInstanceOf('Riak\\Client\\Core\\Message\\Search\\DeleteIndexRequest', $subject);
         $this->assertEquals('index-name', $subject->name);
         return true;
     };
     $this->adapter->expects($this->once())->method('send')->with($this->callback($callback))->will($this->returnValue($response));
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\DeleteIndexResponse', $this->client->execute($command));
 }
 public function testExecuteOperation()
 {
     $response = new PutIndexResponse();
     $index = new YokozunaIndex(null, null);
     $operation = new StoreIndexOperation($index);
     $callback = function ($subject) {
         $this->assertInstanceOf('Riak\\Client\\Core\\Message\\Search\\PutIndexRequest', $subject);
         $this->assertEquals('schema-name', $subject->schema);
         $this->assertEquals('index-name', $subject->name);
         return true;
     };
     $index->setName('index-name');
     $index->setSchema('schema-name');
     $this->adapter->expects($this->once())->method('send')->willReturn($response)->with($this->callback($callback));
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\StoreIndexResponse', $operation->execute($this->adapter));
 }
Beispiel #14
0
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $getRequest = $this->createGetRequest();
     $getResponse = $adapter->send($getRequest);
     $resolverFactory = $this->config->getResolverFactory();
     $converterFactory = $this->config->getConverterFactory();
     $objectConverter = $this->config->getRiakObjectConverter();
     $vClock = $getResponse->vClock;
     $unchanged = $getResponse->unchanged;
     $contentList = $getResponse->contentList;
     $notFound = empty($getResponse->contentList);
     $objectList = $objectConverter->convertToRiakObjectList($contentList, $vClock);
     $response = new FetchValueResponse($converterFactory, $resolverFactory, $this->location, $objectList);
     $response->setNotFound($notFound);
     $response->setUnchanged($unchanged);
     return $response;
 }
 public function testExecuteCommand()
 {
     $response = new GetSchemaResponse();
     $command = FetchSchema::builder()->withSchemaName('schema-name')->build();
     $response->name = 'schema-name';
     $response->content = 'schema-content';
     $callback = function ($subject) {
         $this->assertInstanceOf('Riak\\Client\\Core\\Message\\Search\\GetSchemaRequest', $subject);
         $this->assertEquals('schema-name', $subject->name);
         return true;
     };
     $this->adapter->expects($this->once())->method('send')->with($this->callback($callback))->will($this->returnValue($response));
     $result = $this->client->execute($command);
     $this->assertInstanceOf('Riak\\Client\\Command\\Search\\Response\\FetchSchemaResponse', $result);
     $this->assertInstanceOf('Riak\\Client\\Core\\Query\\Search\\YokozunaSchema', $result->getSchema());
     $this->assertEquals('schema-content', $result->getSchema()->getContent());
     $this->assertEquals('schema-name', $result->getSchema()->getName());
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $adapter->send($this->createPutIndexRequest());
     return new StoreIndexResponse();
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $response = $adapter->send($this->createGetSchemaRequest());
     $schema = $response && $response->name ? new YokozunaSchema($response->name, $response->content) : null;
     return new FetchSchemaResponse($schema);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $response = $adapter->send($this->createGetSearchRequest());
     return new SearchResponse($response->docs, $response->maxScore, $response->numFound);
 }
 /**
  * {@inheritdoc}
  */
 public function execute(RiakTransport $adapter)
 {
     $adapter->send($this->createGetRequest());
     return new StoreBucketPropertiesResponse($this->namespace);
 }