/**
  * Write an association type end.
  * 
  * @param ResourceAssociationTypeEnd $resourceAssociationTypeEnd Resource 
  * association type end
  * 
  * @return nothing
  */
 private function _writeAssociationTypeEnd(ResourceAssociationTypeEnd $resourceAssociationTypeEnd)
 {
     $this->_iOdataWriter->startElement(ODataConstants::END);
     $this->_iOdataWriter->writeAttribute(ODataConstants::ROLE, $resourceAssociationTypeEnd->getName());
     $this->_iOdataWriter->writeAttribute(ODataConstants::TYPE1, $resourceAssociationTypeEnd->getResourceType()->getFullName());
     $this->_iOdataWriter->writeAttribute(ODataConstants::MULTIPLICITY, $resourceAssociationTypeEnd->getMultiplicity());
     $this->_iOdataWriter->endElement();
 }
 /**
  * Test ResourceAssociationTypeEnd class
  * Note: ResourceAssociationTypeEnd is an internal class used for metadata generation, not suppose to used by the developers 
  */
 public function testResourceAssociationTypeEnd()
 {
     try {
         $customerResType = $this->_getCustomerResourceType();
         $orderResType = $this->_getOrderResourceType();
         //Creates a one-to-many relationship from Customer to  Order entity
         $customerReferenceProperty = new ResourceProperty('Customer', null, ResourcePropertyKind::RESOURCE_REFERENCE, $customerResType);
         $ordersReferenceSetProperty = new ResourceProperty('Orders', null, ResourcePropertyKind::RESOURCESET_REFERENCE, $orderResType);
         $customerResType->addProperty($ordersReferenceSetProperty);
         $orderResType->addProperty($customerReferenceProperty);
         $customerToOrderAssoEnd1 = new ResourceAssociationTypeEnd('Orders', $customerResType, $ordersReferenceSetProperty, $customerReferenceProperty);
         $customerToOrderAssoEnd2 = new ResourceAssociationTypeEnd('Customers', $orderResType, $customerReferenceProperty, $ordersReferenceSetProperty);
         $this->AssertEquals($customerToOrderAssoEnd1->getName(), 'Orders');
         $this->AssertEquals($customerToOrderAssoEnd1->getResourceType()->getFullName(), 'Northwind.Customer');
         $this->AssertEquals($customerToOrderAssoEnd1->getResourceProperty()->getName(), 'Orders');
         $this->AssertEquals($customerToOrderAssoEnd1->getMultiplicity(), ODataConstants::ZERO_OR_ONE);
         $this->AssertEquals($customerToOrderAssoEnd2->getMultiplicity(), ODataConstants::MANY);
         $this->AssertTrue($customerToOrderAssoEnd1->isBelongsTo($customerResType, $ordersReferenceSetProperty));
     } catch (\Exception $exception) {
         $this->fail('An unexpected Exception has been raised' . $exception->getMessage());
     }
 }