/**
  * Add separate flow for annotated data objects, all other objects are processed by original code.
  *
  * @param \Magento\Framework\Webapi\ServiceInputProcessor $subject
  * @param \Closure $proceed
  * @param $data
  * @param $type
  * @return mixed
  */
 public function aroundConvertValue(\Magento\Framework\Webapi\ServiceInputProcessor $subject, \Closure $proceed, $data, $type)
 {
     $result = null;
     if (is_subclass_of($type, \Flancer32\Lib\DataObject::class)) {
         if ($this->_typeProcessor->isTypeSimple($type) || $this->_typeProcessor->isTypeAny($type)) {
             $result = $this->_typeProcessor->processSimpleAndAnyType($data, $type);
         } else {
             /** Complex type or array of complex types */
             $isArrayType = $this->_typeProcessor->isArrayType($type);
             if ($isArrayType) {
                 // Initializing the result for array type else it will return null for empty array
                 $itemType = $this->_typeProcessor->getArrayItemType($type);
                 if (is_array($data)) {
                     $result = [];
                     foreach ($data as $key => $item) {
                         $result[$key] = $this->_parser->parseArrayData($itemType, $item);
                     }
                 }
             } else {
                 if (is_null($data)) {
                     // do nothing, result is null
                 } else {
                     $result = $this->_parser->parseArrayData($type, $data);
                 }
             }
         }
     } else {
         $result = $proceed($data, $type);
     }
     return $result;
 }
 public function test_parseArrayDataRecursive()
 {
     /** === Test Data === */
     $TYPE_NORM = 'Exception';
     $DATA = 'data';
     $RESULT = 'result';
     /** === Mock object itself === */
     $this->obj = \Mockery::mock(\Praxigento\Core\Plugin\Framework\Webapi\Sub\Parser::class . '[parseArrayData]', $this->objArgs);
     /** === Setup Mocks === */
     $this->obj->shouldReceive('parseArrayData')->once()->andReturn($RESULT);
     /** === Call and asserts  === */
     $res = $this->obj->parseArrayDataRecursive($TYPE_NORM, $DATA);
     $this->assertEquals($RESULT, $res);
 }