Source:
public void testMergeOnlyAttributes ( ) throws java.io.IOException , javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException { java.lang.String higherPriority = "" + ( ( ( ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " xmlns:tools=\"http://schemas.android.com/tools\"\n" ) + " package=\"com.example.lib3\">\n" ) + "\n" ) + " <activity android:name=\"activityOne\" " ) + " android:exported=\"true\"" ) + " tools:node=\"mergeOnlyAttributes\">\n" ) + " <meta-data android:name=\"bird\" android:value=\"@string/hawk\" />\n" ) + " </activity>\n" ) + "\n" ) + "</manifest>" ) ; java.lang.String lowerPriority = "" + ( ( ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " xmlns:tools=\"http://schemas.android.com/tools\"\n" ) + " package=\"com.example.lib3\">\n" ) + "\n" ) + " <activity android:name=\"activityOne\"\n" ) + " android:screenOrientation=\"landscape\">\n" ) + " <meta-data android:name=\"dog\" android:value=\"@string/dog\" />\n" ) + " </activity>\n" ) + "\n" ) + "</manifest>" ) ; com.android.manifmerger.XmlDocument refDocument = com.android.manifmerger.TestUtils.xmlDocumentFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "higherPriority" ) , higherPriority ) ; com.android.manifmerger.XmlDocument otherDocument = com.android.manifmerger.TestUtils.xmlDocumentFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "lowerPriority" ) , lowerPriority ) ; com.android.manifmerger.MergingReport.Builder mergingReportBuilder = new com.android.manifmerger.MergingReport.Builder ( new com.android.utils.StdLogger ( StdLogger.Level.VERBOSE ) ) ; com.google.common.base.Optional < com.android.manifmerger.XmlDocument > result = refDocument.merge ( otherDocument , mergingReportBuilder ) ; assertTrue ( result.isPresent ( ) ) ; com.google.common.base.Optional < com.android.manifmerger.XmlElement > activityOne = result.get ( ) . getRootNode ( ) . getNodeByTypeAndKey ( ManifestModel.NodeTypes.ACTIVITY , "com.example.lib3.activityOne" ) ; assertTrue ( activityOne.isPresent ( ) ) ; assertEquals ( 1 , activityOne.get ( ) . getMergeableElements ( ) . size ( ) ) ; assertEquals ( 3 , activityOne.get ( ) . getAttributes ( ) . size ( ) ) ; com.android.manifmerger.XmlNode.NodeName nodeName = com.android.manifmerger.XmlNode.fromXmlName ( ( ( com.android.SdkConstants.ANDROID_NS_NAME_PREFIX ) + ( com.android.SdkConstants.ATTR_NAME ) ) ) ; assertEquals ( "bird" , activityOne.get ( ) . getMergeableElements ( ) . get ( 0 ) . getAttribute ( nodeName ) . get ( ) . getValue ( ) ) ; com.android.manifmerger.ActionRecorder actionRecorder = mergingReportBuilder.getActionRecorder ( ) . build ( ) ; assertEquals ( 3 , actionRecorder.getAllRecords ( ) . size ( ) ) ; com.android.manifmerger.ActionRecorder.DecisionTreeRecord decisionTreeRecord = actionRecorder.getAllRecords ( ) . get ( "activity#com.example.lib3.activityOne" ) ; for ( int i = 0 ; i < ( decisionTreeRecord.getNodeRecords ( ) . size ( ) ) ; i ++ ) { com.android.manifmerger.ActionRecorder.NodeRecord nodeRecord = decisionTreeRecord.getNodeRecords ( ) . get ( i ) ; if ( "meta-data#dog" . equals ( nodeRecord.getTargetId ( ) ) ) { assertEquals ( ActionRecorder.ActionType.REJECTED , nodeRecord.getActionType ( ) ) ; return ; } } fail ( "Did not find the meta-data rejection record" ) ; }

Target:
public void testMergeOnlyAttributes ( ) throws java.io.IOException , javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException { java.lang.String higherPriority = "" + ( ( ( ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " xmlns:tools=\"http://schemas.android.com/tools\"\n" ) + " package=\"com.example.lib3\">\n" ) + "\n" ) + " <activity android:name=\"activityOne\" " ) + " android:exported=\"true\"" ) + " tools:node=\"mergeOnlyAttributes\">\n" ) + " <meta-data android:name=\"bird\" android:value=\"@string/hawk\" />\n" ) + " </activity>\n" ) + "\n" ) + "</manifest>" ) ; java.lang.String lowerPriority = "" + ( ( ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " xmlns:tools=\"http://schemas.android.com/tools\"\n" ) + " package=\"com.example.lib3\">\n" ) + "\n" ) + " <activity android:name=\"activityOne\"\n" ) + " android:screenOrientation=\"landscape\">\n" ) + " <meta-data android:name=\"dog\" android:value=\"@string/dog\" />\n" ) + " </activity>\n" ) + "\n" ) + "</manifest>" ) ; com.android.manifmerger.XmlDocument refDocument = com.android.manifmerger.TestUtils.xmlDocumentFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "higherPriority" ) , higherPriority ) ; com.android.manifmerger.XmlDocument otherDocument = com.android.manifmerger.TestUtils.xmlDocumentFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "lowerPriority" ) , lowerPriority ) ; com.android.manifmerger.MergingReport.Builder mergingReportBuilder = new com.android.manifmerger.MergingReport.Builder ( new com.android.utils.StdLogger ( StdLogger.Level.VERBOSE ) ) ; com.google.common.base.Optional < com.android.manifmerger.XmlDocument > result = refDocument.merge ( otherDocument , mergingReportBuilder ) ; assertTrue ( result.isPresent ( ) ) ; com.google.common.base.Optional < com.android.manifmerger.XmlElement > activityOne = result.get ( ) . getRootNode ( ) . getNodeByTypeAndKey ( ManifestModel.NodeTypes.ACTIVITY , "com.example.lib3.activityOne" ) ; assertTrue ( activityOne.isPresent ( ) ) ; assertEquals ( 1 , activityOne.get ( ) . getMergeableElements ( ) . size ( ) ) ; assertEquals ( 3 , activityOne.get ( ) . getAttributes ( ) . size ( ) ) ; com.android.manifmerger.XmlNode.NodeName nodeName = com.android.manifmerger.XmlNode.fromXmlName ( ( ( com.android.SdkConstants.ANDROID_NS_NAME_PREFIX ) + ( com.android.SdkConstants.ATTR_NAME ) ) ) ; assertEquals ( "bird" , activityOne.get ( ) . getMergeableElements ( ) . get ( 0 ) . getAttribute ( nodeName ) . get ( ) . getValue ( ) ) ; com.android.manifmerger.Actions actionRecorder = mergingReportBuilder.getActionRecorder ( ) . build ( ) ; assertEquals ( 3 , actionRecorder.getNodeKeys ( ) . size ( ) ) ; com.google.common.collect.ImmutableList < com.android.manifmerger.Actions.NodeRecord > nodeRecords = actionRecorder.getNodeRecords ( new com.android.manifmerger.XmlNode.NodeKey ( "activity#com.example.lib3.activityOne" ) ) ; for ( com.android.manifmerger.Actions.NodeRecord nodeRecord : nodeRecords ) { if ( "meta-data#dog" . equals ( nodeRecord.getTargetId ( ) . toString ( ) ) ) { assertEquals ( Actions.ActionType.REJECTED , nodeRecord.getActionType ( ) ) ; return ; } } fail ( "Did not find the meta-data rejection record" ) ; }