Coverage Report - org.mule.config.spring.parsers.generic.GrandchildDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
GrandchildDefinitionParser
0%
0/18
0%
0/6
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.config.spring.parsers.generic;
 8  
 
 9  
 import org.w3c.dom.Element;
 10  
 import org.w3c.dom.Node;
 11  
 
 12  
 /**
 13  
  * Same as ChildDefinitionParser but injects the child element into the grandparent object 
 14  
  * (2 levels up in the XML tree).
 15  
  */
 16  
 public class GrandchildDefinitionParser extends ChildDefinitionParser
 17  
 {
 18  
     public GrandchildDefinitionParser(String setterMethod, Class clazz)
 19  
     {
 20  0
         super(setterMethod, clazz);
 21  0
     }
 22  
 
 23  
     public GrandchildDefinitionParser(String setterMethod, Class clazz, Class constraint, boolean allowClassAttribute)
 24  
     {
 25  0
         super(setterMethod, clazz, constraint, allowClassAttribute);
 26  0
     }
 27  
 
 28  
     @Override
 29  
     protected String getParentBeanName(Element element)
 30  
     {
 31  0
         return getGrandparentBeanName(element);
 32  
     }
 33  
 
 34  
     protected String getGrandparentBeanName(Element element)
 35  
     {
 36  0
         Node parent = element.getParentNode();
 37  0
         if (parent == null)
 38  
         {
 39  0
             logger.error("No parent node found for element " + element);
 40  0
             return null;
 41  
         }
 42  0
         Node grandparent = parent.getParentNode();
 43  0
         if (grandparent == null)
 44  
         {
 45  0
             logger.error("No parent node found for element " + parent);
 46  0
             return null;
 47  
         }
 48  0
         Node grandparentNameAttribute = grandparent.getAttributes().getNamedItem("name");
 49  0
         if (grandparentNameAttribute == null)
 50  
         {
 51  0
             logger.error("Grandparent node has no 'name' attribute: " + grandparent);
 52  0
             return null;
 53  
         }
 54  0
         return grandparentNameAttribute.getNodeValue();
 55  
     }
 56  
 }