Source:
public void testRemoveAndRemoveAll_withReplace ( ) 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" ) + " <permission" ) + " android:name=\"permissionOne\"\n" ) + " tools:node=\"remove\"\n" ) + " tools:selector=\"com.example.lib1\">\n" ) + " </permission>\n" ) + " <permission" ) + " tools:node=\"removeAll\"\n" ) + " tools:selector=\"com.example.lib3\">\n" ) + " </permission>\n" ) + " <permission android:name=\"permissionThree\"" ) + " android:protectionLevel=\"signature\"" ) + " tools:node=\"replace\">\n" ) + " </permission>\n" ) + "\n" ) + "</manifest>" ) ; java.lang.String lowerPriorityOne = "" + ( ( ( ( ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " xmlns:tools=\"http://schemas.android.com/tools\"\n" ) + " package=\"com.example.lib1\">\n" ) + "\n" ) + " <permission android:name=\"permissionOne\"" ) + " android:protectionLevel=\"signature\">\n" ) + " </permission>\n" ) + " <permission android:name=\"permissionTwo\"" ) + " android:protectionLevel=\"signature\">\n" ) + " </permission>\n" ) + "\n" ) + "</manifest>" ) ; java.lang.String lowerPriorityTwo = "" + ( ( ( ( ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " xmlns:tools=\"http://schemas.android.com/tools\"\n" ) + " package=\"com.example.lib2\">\n" ) + "\n" ) + " <permission android:name=\"permissionThree\"" ) + " android:protectionLevel=\"normal\">\n" ) + " </permission>\n" ) + " <permission android:name=\"permissionFour\"" ) + " android:protectionLevel=\"normal\">\n" ) + " </permission>\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 firstLibrary = com.android.manifmerger.TestUtils.xmlDocumentFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "lowerPriorityOne" ) , lowerPriorityOne ) ; com.android.manifmerger.XmlDocument secondLibrary = com.android.manifmerger.TestUtils.xmlDocumentFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "lowerPriorityTwo" ) , lowerPriorityTwo ) ; 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 ( firstLibrary , mergingReportBuilder ) ; assertTrue ( result.isPresent ( ) ) ; result = result.get ( ) . merge ( secondLibrary , mergingReportBuilder ) ; assertTrue ( result.isPresent ( ) ) ; com.google.common.collect.ImmutableList < com.android.manifmerger.XmlElement > mergeableElements = result.get ( ) . getRootNode ( ) . getMergeableElements ( ) ; assertEquals ( 5 , mergeableElements.size ( ) ) ; com.android.manifmerger.XmlNode.NodeName nodeName = com.android.manifmerger.XmlNode.fromXmlName ( "android:name" ) ; for ( int i = 0 ; i < 5 ; i ++ ) { com.android.manifmerger.XmlElement xmlElement = mergeableElements.get ( i ) ; com.google.common.base.Optional < com.android.manifmerger.XmlAttribute > optionalName = xmlElement.getAttribute ( nodeName ) ; if ( ! ( optionalName.isPresent ( ) ) ) { continue ; } java.lang.String elementName = optionalName.get ( ) . getValue ( ) ; if ( elementName.equals ( "permissionThree" ) ) { assertEquals ( "signature" , xmlElement.getAttribute ( com.android.manifmerger.XmlNode.fromXmlName ( "android:protectionLevel" ) ) . get ( ) . getValue ( ) ) ; } else { if ( ( ( ! ( elementName.equals ( "permissionOne" ) ) ) && ( ! ( elementName.equals ( "permissionTwo" ) ) ) ) && ( ! ( elementName.equals ( "permissionFour" ) ) ) ) { fail ( ( "Unexepected permission " + elementName ) ) ; } } } }

Target:
public void testRemoveAndRemoveAll_withReplace ( ) 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" ) + " <permission" ) + " android:name=\"permissionOne\"\n" ) + " tools:node=\"remove\"\n" ) + " tools:selector=\"com.example.lib1\">\n" ) + " </permission>\n" ) + " <permission" ) + " tools:node=\"removeAll\"\n" ) + " tools:selector=\"com.example.lib3\">\n" ) + " </permission>\n" ) + " <permission android:name=\"permissionThree\"" ) + " android:protectionLevel=\"signature\"" ) + " tools:node=\"replace\">\n" ) + " </permission>\n" ) + "\n" ) + "</manifest>" ) ; java.lang.String lowerPriorityOne = "" + ( ( ( ( ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " xmlns:tools=\"http://schemas.android.com/tools\"\n" ) + " package=\"com.example.lib1\">\n" ) + "\n" ) + " <permission android:name=\"permissionOne\"" ) + " android:protectionLevel=\"signature\">\n" ) + " </permission>\n" ) + " <permission android:name=\"permissionTwo\"" ) + " android:protectionLevel=\"signature\">\n" ) + " </permission>\n" ) + "\n" ) + "</manifest>" ) ; java.lang.String lowerPriorityTwo = "" + ( ( ( ( ( ( ( ( ( ( ( ( "<manifest\n" + " xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" ) + " xmlns:tools=\"http://schemas.android.com/tools\"\n" ) + " package=\"com.example.lib2\">\n" ) + "\n" ) + " <permission android:name=\"permissionThree\"" ) + " android:protectionLevel=\"normal\">\n" ) + " </permission>\n" ) + " <permission android:name=\"permissionFour\"" ) + " android:protectionLevel=\"normal\">\n" ) + " </permission>\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 firstLibrary = com.android.manifmerger.TestUtils.xmlLibraryFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "lowerPriorityOne" ) , lowerPriorityOne ) ; com.android.manifmerger.XmlDocument secondLibrary = com.android.manifmerger.TestUtils.xmlLibraryFromString ( new com.android.manifmerger.TestUtils.TestSourceLocation ( getClass ( ) , "lowerPriorityTwo" ) , lowerPriorityTwo ) ; 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 ( firstLibrary , mergingReportBuilder ) ; assertTrue ( result.isPresent ( ) ) ; result = result.get ( ) . merge ( secondLibrary , mergingReportBuilder ) ; assertTrue ( result.isPresent ( ) ) ; com.google.common.collect.ImmutableList < com.android.manifmerger.XmlElement > mergeableElements = result.get ( ) . getRootNode ( ) . getMergeableElements ( ) ; assertEquals ( 5 , mergeableElements.size ( ) ) ; com.android.manifmerger.XmlNode.NodeName nodeName = com.android.manifmerger.XmlNode.fromXmlName ( "android:name" ) ; for ( int i = 0 ; i < 5 ; i ++ ) { com.android.manifmerger.XmlElement xmlElement = mergeableElements.get ( i ) ; com.google.common.base.Optional < com.android.manifmerger.XmlAttribute > optionalName = xmlElement.getAttribute ( nodeName ) ; if ( ! ( optionalName.isPresent ( ) ) ) { continue ; } java.lang.String elementName = optionalName.get ( ) . getValue ( ) ; if ( elementName.equals ( "permissionThree" ) ) { assertEquals ( "signature" , xmlElement.getAttribute ( com.android.manifmerger.XmlNode.fromXmlName ( "android:protectionLevel" ) ) . get ( ) . getValue ( ) ) ; } else { if ( ( ( ! ( elementName.equals ( "permissionOne" ) ) ) && ( ! ( elementName.equals ( "permissionTwo" ) ) ) ) && ( ! ( elementName.equals ( "permissionFour" ) ) ) ) { fail ( ( "Unexepected permission " + elementName ) ) ; } } } }