#1921 Fix minor warnings in testutil

This commit is contained in:
Andrei Arlou 2019-09-23 22:19:05 +03:00 committed by Filip Hrisafov
parent 0d23f09e37
commit 81cd439343
6 changed files with 13 additions and 37 deletions

View File

@ -13,7 +13,6 @@ import java.io.UncheckedIOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.assertj.core.api.AbstractCharSequenceAssert;
@ -101,13 +100,7 @@ public class JavaFileAssert extends FileAssert {
expected,
charset
) );
Iterator<Delta<String>> iterator = diffs.iterator();
while ( iterator.hasNext() ) {
Delta<String> delta = iterator.next();
if ( ignoreDelta( delta ) ) {
iterator.remove();
}
}
diffs.removeIf( this::ignoreDelta );
if ( !diffs.isEmpty() ) {
throw Failures.instance()
.failure( info, ShouldHaveSameContent.shouldHaveSameContent( actual, expected, diffs ) );

View File

@ -8,6 +8,7 @@ package org.mapstruct.ap.testutil.compilation.model;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -143,12 +144,7 @@ public class CompilationOutcomeDescriptor {
if ( compilationResult != other.compilationResult ) {
return false;
}
if ( diagnostics == null ) {
if ( other.diagnostics != null ) {
return false;
}
}
else if ( !diagnostics.equals( other.diagnostics ) ) {
if ( !Objects.equals( diagnostics, other.diagnostics ) ) {
return false;
}
return true;

View File

@ -9,6 +9,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Objects;
import javax.tools.Diagnostic.Kind;
import javax.tools.JavaFileObject;
@ -180,20 +181,10 @@ public class DiagnosticDescriptor {
if ( line != other.line ) {
return false;
}
if ( message == null ) {
if ( other.message != null ) {
return false;
}
}
else if ( !message.equals( other.message ) ) {
if ( !Objects.equals( message, other.message ) ) {
return false;
}
if ( sourceFileName == null ) {
if ( other.sourceFileName != null ) {
return false;
}
}
else if ( !sourceFileName.equals( other.sourceFileName ) ) {
if ( !Objects.equals( sourceFileName, other.sourceFileName ) ) {
return false;
}
return true;

View File

@ -130,10 +130,10 @@ public class AnnotationProcessorTestRunner extends ParentRunner<Runner> {
}
private Description withoutParameterizedName(Description description) {
String cleanDispayName = removeParameter( description.getDisplayName() );
String cleanDisplayName = removeParameter( description.getDisplayName() );
Description cleanDescription =
Description.createSuiteDescription(
cleanDispayName,
cleanDisplayName,
description.getAnnotations().toArray( new Annotation[description.getAnnotations().size()] ) );
for ( Description child : description.getChildren() ) {

View File

@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Stream;
import com.puppycrawl.tools.checkstyle.api.AutomaticBean;
import org.junit.runners.model.FrameworkMethod;
@ -164,12 +165,7 @@ abstract class CompilingStatement extends Statement {
}
private static boolean isWhitelisted(String path, String[] whitelist) {
for ( String whitelisted : whitelist ) {
if ( path.contains( whitelisted ) ) {
return true;
}
}
return false;
return Stream.of( whitelist ).anyMatch( path::contains );
}
protected void generateMapperImplementation() throws Exception {
@ -279,8 +275,8 @@ abstract class CompilingStatement extends Statement {
private void assertDiagnostics(List<DiagnosticDescriptor> actualDiagnostics,
List<DiagnosticDescriptor> expectedDiagnostics) {
Collections.sort( actualDiagnostics, COMPARATOR );
Collections.sort( expectedDiagnostics, COMPARATOR );
actualDiagnostics.sort( COMPARATOR );
expectedDiagnostics.sort( COMPARATOR );
expectedDiagnostics = filterExpectedDiagnostics( expectedDiagnostics );
Iterator<DiagnosticDescriptor> actualIterator = actualDiagnostics.iterator();

View File

@ -22,7 +22,7 @@ final class FilteringParentClassLoader extends ClassLoader {
* @param excludedPrefixes class name prefixes to exclude
*/
FilteringParentClassLoader(String... excludedPrefixes) {
this.excludedPrefixes = new ArrayList<String>( Arrays.asList( excludedPrefixes ) );
this.excludedPrefixes = new ArrayList<>( Arrays.asList( excludedPrefixes ) );
}
/**