Better indentation when adding GCP libraries to pom.xml#3511
Better indentation when adding GCP libraries to pom.xml#3511lak-proddev wants to merge 6 commits intoGoogleCloudPlatform:masterfrom
Conversation
…atform#3381 Change-Id: I5d4a22b089f1516845e8597cf11c5198772dc4dd
elharo
left a comment
There was a problem hiding this comment.
I'm not yet sure if this is the right approach but if it is, it needs a test.
Codecov Report
@@ Coverage Diff @@
## master #3511 +/- ##
=========================================
Coverage ? 70.10%
Complexity ? 2990
=========================================
Files ? 376
Lines ? 13632
Branches ? 1605
=========================================
Hits ? 9557
Misses ? 3432
Partials ? 643
Continue to review full report at Codecov.
|
...ine.libraries.test/src/com/google/cloud/tools/eclipse/appengine/libraries/POMFormatTest.java
Outdated
Show resolved
Hide resolved
...ine.libraries.test/src/com/google/cloud/tools/eclipse/appengine/libraries/POMFormatTest.java
Outdated
Show resolved
Hide resolved
...ine.libraries.test/src/com/google/cloud/tools/eclipse/appengine/libraries/POMFormatTest.java
Outdated
Show resolved
Hide resolved
...ine.libraries.test/src/com/google/cloud/tools/eclipse/appengine/libraries/POMFormatTest.java
Outdated
Show resolved
Hide resolved
| } | ||
| } | ||
| private static void assertFileContentsEqual(File actual, File expected) throws IOException { | ||
| assertArrayEquals(Files.readAllBytes(actual.toPath()), Files.readAllBytes(expected.toPath())); |
There was a problem hiding this comment.
swap arguments since expected customarily comes before actual
| File expected = new File(FileLocator.resolve(fileURL).toURI()); | ||
| URL fileUrl = bundle.getEntry("/testdata/formatRemove.xml"); | ||
| File expected = new File(FileLocator.resolve(fileUrl).toURI()); | ||
| assertFileContentsEqual(pomFile.getLocation().toFile(), expected); |
There was a problem hiding this comment.
swap arguments since expected customarily comes before actual
elharo
left a comment
There was a problem hiding this comment.
Tests are failing:
Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.634 s <<< FAILURE! - in com.google.cloud.tools.eclipse.appengine.libraries.PomFormatTest
testAddDependencies(com.google.cloud.tools.eclipse.appengine.libraries.PomFormatTest) Time elapsed: 0.36 s <<< FAILURE!
java.lang.AssertionError: array lengths differed, expected.length=1168 actual.length=1135
at org.junit.Assert.fail(Assert.java:88)
at org.junit.internal.ComparisonCriteria.assertArraysAreSameLength(ComparisonCriteria.java:76)
at org.junit.internal.ComparisonCriteria.arrayEquals(ComparisonCriteria.java:37)
at org.junit.Assert.internalArrayEquals(Assert.java:532)
lak-proddev
left a comment
There was a problem hiding this comment.
Tests are failing:
Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.634 s <<< FAILURE! - in com.google.cloud.tools.eclipse.appengine.libraries.PomFormatTest
testAddDependencies(com.google.cloud.tools.eclipse.appengine.libraries.PomFormatTest) Time elapsed: 0.36 s <<< FAILURE!
java.lang.AssertionError: array lengths differed, expected.length=1168 actual.length=1135
Not failing locally. will check
| private void writeDocument() throws CoreException, TransformerException { | ||
| Transformer transformer = transformerFactory.newTransformer(); | ||
| transformer.setOutputProperty(OutputKeys.INDENT, "yes"); | ||
| transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount","2"); //$NON-NLS-1$ //$NON-NLS-2$ |
There was a problem hiding this comment.
This is the core fix. Other changes are for removing extra spaces and blank line when add or removing libaries.
elharo
left a comment
There was a problem hiding this comment.
Sorry. Just noticed this was still out for review.
| return; | ||
| } | ||
|
|
||
| final List<String> diff = new ArrayList<>(); |
There was a problem hiding this comment.
Google style avoids final on local variables where not required.
|
|
||
| private void addChild(Node parent, Node newChild) { | ||
| parent.appendChild(newChild); | ||
| removeWhiteSpaceBefore(newChild);// for child indentation |
| } | ||
|
|
||
| private static void removeWhiteSpaceBefore(Node node) { | ||
| Node prevElement = node.getPreviousSibling(); |
Change-Id: I5d4a22b089f1516845e8597cf11c5198772dc4dd
fixes #3381