/**
  * @covers WindowsAzure\Table\Models\GetEntityResult::setEntity
  * @covers WindowsAzure\Table\Models\GetEntityResult::getEntity
  */
 public function testSetEntity()
 {
     // Setup
     $result = new GetEntityResult();
     $entity = new Entity();
     // Test
     $result->setEntity($entity);
     // Assert
     $this->assertEquals($entity, $result->getEntity());
 }
 public function testRead()
 {
     $entity = new Entity();
     $entity->setRowKey('id');
     $entity->addProperty('data', null, base64_encode('data'));
     $entityResult = new GetEntityResult();
     $entityResult->setEntity($entity);
     $client = $this->getMockClient();
     $client->shouldReceive('getEntity')->andReturn($entityResult);
     $sessionHandler = new SessionHandler($client);
     $this->assertEquals('data', $sessionHandler->read('id'));
     $client = $this->getMockClient();
     $client->shouldReceive('createTable')->andThrow(new ServiceException('404'));
     $sessionHandler = new SessionHandler($client);
     $this->assertEquals('', $sessionHandler->read('id'));
 }
 /**
  * Gets table entity.
  * 
  * @param string                     $table        The name of the table.
  * @param string                     $partitionKey The entity partition key.
  * @param string                     $rowKey       The entity row key.
  * @param Models\TableServiceOptions $options      The optional parameters.
  * 
  * @return Models\GetEntityResult
  * 
  * @see http://msdn.microsoft.com/en-us/library/windowsazure/dd179421.aspx
  */
 public function getEntity($table, $partitionKey, $rowKey, $options = null)
 {
     Validate::isString($table, 'table');
     Validate::notNullOrEmpty($table, 'table');
     Validate::isTrue(!is_null($partitionKey), Resources::NULL_TABLE_KEY_MSG);
     Validate::isTrue(!is_null($rowKey), Resources::NULL_TABLE_KEY_MSG);
     $method = Resources::HTTP_GET;
     $headers = array();
     $queryParams = array();
     $statusCode = Resources::STATUS_OK;
     $path = $this->_getEntityPath($table, $partitionKey, $rowKey);
     if (is_null($options)) {
         $options = new TableServiceOptions();
     }
     $this->addOptionalHeader($headers, Resources::CONTENT_TYPE, Resources::XML_ATOM_CONTENT_TYPE);
     $this->addOptionalQueryParam($queryParams, Resources::QP_TIMEOUT, $options->getTimeout());
     $context = new HttpCallContext();
     $context->setHeaders($headers);
     $context->setMethod($method);
     $context->setPath($path);
     $context->setQueryParameters($queryParams);
     $context->addStatusCode($statusCode);
     $response = $this->sendContext($context);
     $entity = $this->_atomSerializer->parseEntity($response->getBody());
     $result = new GetEntityResult();
     $result->setEntity($entity);
     return $result;
 }