Skip to content

Commit

Permalink
Fix comparison of repo URI
Browse files Browse the repository at this point in the history
  • Loading branch information
fabapp2 committed Nov 7, 2023
1 parent 6ddb121 commit 1a5b999
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ public ParallelParsingResult parseParallel(Path baseDir, ParserProperties parser
AtomicReference<RewriteProjectParsingResult> comparingParsingResultRef = new AtomicReference<>();

threadPool.submit(() -> {
Supplier<RewriteProjectParsingResult> s = () -> parseWithRewriteProjectParser(baseDir, parserProperties, executionContext);
handleResult(latch, s, testedParsingResultRef);
RewriteProjectParsingResult parsingResult = parseWithRewriteProjectParser(baseDir, parserProperties);;
testedParsingResultRef.set(parsingResult);
latch.countDown();
});

threadPool.submit(() -> {
Supplier<RewriteProjectParsingResult> s = () -> parseWithComparingParser(baseDir, parserProperties, executionContext);
handleResult(latch, s, comparingParsingResultRef);
RewriteProjectParsingResult parsingResult = parseWithComparingParser(baseDir, parserProperties, executionContext);
comparingParsingResultRef.set(parsingResult);
latch.countDown();
});
latch.await(60, TimeUnit.SECONDS);
return new ParallelParsingResult(comparingParsingResultRef.get(), testedParsingResultRef.get());
Expand All @@ -76,7 +78,6 @@ public ParallelParsingResult parseParallel(Path baseDir, ParserProperties parser
}

private static void handleResult(CountDownLatch latch, Supplier<RewriteProjectParsingResult> s, AtomicReference<RewriteProjectParsingResult> ar) {
System.out.println("Start parsing with RewriteProjectParser");
ar.set(s.get());
latch.countDown();
}
Expand All @@ -90,7 +91,7 @@ public RewriteProjectParsingResult parseWithComparingParser(Path baseDir, Parser
}
}

public RewriteProjectParsingResult parseWithRewriteProjectParser(Path baseDir, ParserProperties parserProperties, ExecutionContext executionContext) {
public RewriteProjectParsingResult parseWithRewriteProjectParser(Path baseDir, ParserProperties parserProperties) {
AtomicReference<RewriteProjectParsingResult> atomicRef = new AtomicReference<>();
new ApplicationContextRunner().withUserConfiguration(SbmSupportRewriteConfiguration.class)
.withBean("parser-org.springframework.sbm.parsers.ParserProperties", ParserProperties.class, () -> parserProperties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void verifyParity(ParserResultParityChecker parserResultParityChecker) {
comparingParserResult = result.comparingParsingResult();
testedParserResult = result.testedParsingResult();
} else {
testedParserResult = parserExecutionHelper.parseWithRewriteProjectParser(baseDir, parserProperties, executionContext);
testedParserResult = parserExecutionHelper.parseWithRewriteProjectParser(baseDir, parserProperties);
comparingParserResult = parserExecutionHelper.parseWithComparingParser(baseDir, parserProperties, executionContext);
}

Expand Down Expand Up @@ -274,11 +274,26 @@ private void compareMavenResolutionResultMarker(SoftAssertions softAssertions, M
softAssertions.assertThat(testedDependencies)
.usingRecursiveComparison()
.withEqualsForFieldsMatchingRegexes(
(URI f1, URI f2) -> {
return f1.getScheme().equals(f2.getScheme()) &&
f1.getHost().equals(f2.getHost()) &&
f1.getPath().equals(f2.getPath()) &&
f1.getFragment().equals(f2.getFragment());
(Object fi1, Object fi2) -> {
boolean equals = fi1.equals(fi2);
if(equals) {
return true;
}
if(fi1.getClass() == fi1.getClass()) {
if(fi1 instanceof URI) {
URI f1 = (URI) fi1;
URI f2 = (URI) fi2;
return equals ? true : f1.getScheme().equals(f2.getScheme()) &&
f1.getHost().equals(f2.getHost()) &&
f1.getPath().equals(f2.getPath()) &&
f1.getFragment().equals(f2.getFragment());
} else {
return false;
}
} else {
return false;
}

},
".*\\.repository")
// .ignoringFields("parent.dependencies.Provided.gav.repository")
Expand Down

0 comments on commit 1a5b999

Please sign in to comment.