diff --git a/processor/src/test/java/org/mapstruct/ap/internal/model/source/SelectionParametersTest.java b/processor/src/test/java/org/mapstruct/ap/internal/model/source/SelectionParametersTest.java index 7eb34135a..7f57ae75c 100644 --- a/processor/src/test/java/org/mapstruct/ap/internal/model/source/SelectionParametersTest.java +++ b/processor/src/test/java/org/mapstruct/ap/internal/model/source/SelectionParametersTest.java @@ -174,7 +174,7 @@ public class SelectionParametersTest { public void testGetters() { List qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); - List qualifiers = new ArrayList(); + List qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); @@ -226,7 +226,7 @@ public class SelectionParametersTest { public void testEqualsSameInstance() { List qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); - List qualifiers = new ArrayList(); + List qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); @@ -238,7 +238,7 @@ public class SelectionParametersTest { public void testEqualsWitNull() { List qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); - List qualifiers = new ArrayList(); + List qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); @@ -250,7 +250,7 @@ public class SelectionParametersTest { public void testEqualsQualifiersOneNull() { List qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); - List qualifiers = new ArrayList(); + List qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); @@ -264,12 +264,12 @@ public class SelectionParametersTest { public void testEqualsQualifiersInDifferentOrder() { List qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); - List qualifiers = new ArrayList(); + List qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); - List qualifiers2 = new ArrayList(); + List qualifiers2 = new ArrayList<>(); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames, resultType, typeUtils ); @@ -282,12 +282,12 @@ public class SelectionParametersTest { public void testEqualsQualifyingNamesOneNull() { List qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); - List qualifiers = new ArrayList(); + List qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); - List qualifiers2 = new ArrayList(); + List qualifiers2 = new ArrayList<>(); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params2 = new SelectionParameters( qualifiers2, null, resultType, typeUtils ); @@ -300,13 +300,13 @@ public class SelectionParametersTest { public void testEqualsQualifyingNamesInDifferentOrder() { List qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); - List qualifiers = new ArrayList(); + List qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); List qualifyingNames2 = Arrays.asList( "german", "language" ); - List qualifiers2 = new ArrayList(); + List qualifiers2 = new ArrayList<>(); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, resultType, typeUtils ); @@ -319,13 +319,13 @@ public class SelectionParametersTest { public void testEqualsResultTypeOneNull() { List qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); - List qualifiers = new ArrayList(); + List qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); List qualifyingNames2 = Arrays.asList( "language", "german" ); - List qualifiers2 = new ArrayList(); + List qualifiers2 = new ArrayList<>(); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, null, typeUtils ); @@ -338,14 +338,14 @@ public class SelectionParametersTest { public void testAllEqual() { List qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); - List qualifiers = new ArrayList(); + List qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); List qualifyingNames2 = Arrays.asList( "language", "german" ); TypeMirror resultType2 = new TestTypeMirror( "resultType" ); - List qualifiers2 = new ArrayList(); + List qualifiers2 = new ArrayList<>(); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, resultType2, typeUtils ); @@ -358,14 +358,14 @@ public class SelectionParametersTest { public void testDifferentResultTypes() { List qualifyingNames = Arrays.asList( "language", "german" ); TypeMirror resultType = new TestTypeMirror( "resultType" ); - List qualifiers = new ArrayList(); + List qualifiers = new ArrayList<>(); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); List qualifyingNames2 = Arrays.asList( "language", "german" ); TypeMirror resultType2 = new TestTypeMirror( "otherResultType" ); - List qualifiers2 = new ArrayList(); + List qualifiers2 = new ArrayList<>(); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, resultType2, typeUtils ); diff --git a/processor/src/test/java/org/mapstruct/ap/internal/util/NativeTypesTest.java b/processor/src/test/java/org/mapstruct/ap/internal/util/NativeTypesTest.java index 36f92af6b..74272cbae 100644 --- a/processor/src/test/java/org/mapstruct/ap/internal/util/NativeTypesTest.java +++ b/processor/src/test/java/org/mapstruct/ap/internal/util/NativeTypesTest.java @@ -19,7 +19,7 @@ import org.junit.Test; public class NativeTypesTest { @Test - public void testIsNumber() throws Exception { + public void testIsNumber() { assertFalse( NativeTypes.isNumber( null ) ); assertFalse( NativeTypes.isNumber( Object.class ) ); assertFalse( NativeTypes.isNumber( String.class ) ); diff --git a/processor/src/test/java/org/mapstruct/ap/internal/util/StringsTest.java b/processor/src/test/java/org/mapstruct/ap/internal/util/StringsTest.java index b21db49a3..ced598330 100644 --- a/processor/src/test/java/org/mapstruct/ap/internal/util/StringsTest.java +++ b/processor/src/test/java/org/mapstruct/ap/internal/util/StringsTest.java @@ -34,7 +34,7 @@ public class StringsTest { } @Test - public void testCapitalize() throws Exception { + public void testCapitalize() { assertThat( Strings.capitalize( null ) ).isNull(); assertThat( Strings.capitalize( "c" ) ).isEqualTo( "C" ); assertThat( Strings.capitalize( "capitalize" ) ).isEqualTo( "Capitalize" ); @@ -43,7 +43,7 @@ public class StringsTest { } @Test - public void testDecapitalize() throws Exception { + public void testDecapitalize() { assertThat( Strings.decapitalize( null ) ).isNull(); assertThat( Strings.decapitalize( "c" ) ).isEqualTo( "c" ); assertThat( Strings.decapitalize( "capitalize" ) ).isEqualTo( "capitalize" ); @@ -52,14 +52,14 @@ public class StringsTest { } @Test - public void testJoin() throws Exception { + public void testJoin() { assertThat( Strings.join( new ArrayList(), "-" ) ).isEqualTo( "" ); assertThat( Strings.join( Arrays.asList( "Hello", "World" ), "-" ) ).isEqualTo( "Hello-World" ); assertThat( Strings.join( Arrays.asList( "Hello" ), "-" ) ).isEqualTo( "Hello" ); } @Test - public void testJoinAndCamelize() throws Exception { + public void testJoinAndCamelize() { assertThat( Strings.joinAndCamelize( new ArrayList() ) ).isEqualTo( "" ); assertThat( Strings.joinAndCamelize( Arrays.asList( "Hello", "World" ) ) ).isEqualTo( "HelloWorld" ); assertThat( Strings.joinAndCamelize( Arrays.asList( "Hello", "world" ) ) ).isEqualTo( "HelloWorld" ); @@ -67,7 +67,7 @@ public class StringsTest { } @Test - public void testIsEmpty() throws Exception { + public void testIsEmpty() { assertThat( Strings.isEmpty( null ) ).isTrue(); assertThat( Strings.isEmpty( "" ) ).isTrue(); assertThat( Strings.isEmpty( " " ) ).isFalse(); @@ -75,7 +75,7 @@ public class StringsTest { } @Test - public void testGetSaveVariableNameWithArrayExistingVariables() throws Exception { + public void testGetSaveVariableNameWithArrayExistingVariables() { assertThat( Strings.getSafeVariableName( "int[]" ) ).isEqualTo( "intArray" ); assertThat( Strings.getSafeVariableName( "Extends" ) ).isEqualTo( "extends1" ); assertThat( Strings.getSafeVariableName( "class" ) ).isEqualTo( "class1" ); @@ -86,28 +86,28 @@ public class StringsTest { } @Test - public void testGetSaveVariableNameVariablesEndingOnNumberVariables() throws Exception { + public void testGetSaveVariableNameVariablesEndingOnNumberVariables() { assertThat( Strings.getSafeVariableName( "prop1", "prop1" ) ).isEqualTo( "prop1_1" ); assertThat( Strings.getSafeVariableName( "prop1", "prop1", "prop1_1" ) ).isEqualTo( "prop1_2" ); } @Test - public void testGetSaveVariableNameWithCollection() throws Exception { - assertThat( Strings.getSafeVariableName( "int[]", new ArrayList() ) ).isEqualTo( "intArray" ); - assertThat( Strings.getSafeVariableName( "Extends", new ArrayList() ) ).isEqualTo( "extends1" ); + public void testGetSaveVariableNameWithCollection() { + assertThat( Strings.getSafeVariableName( "int[]", new ArrayList<>() ) ).isEqualTo( "intArray" ); + assertThat( Strings.getSafeVariableName( "Extends", new ArrayList<>() ) ).isEqualTo( "extends1" ); assertThat( Strings.getSafeVariableName( "prop", Arrays.asList( "prop", "prop1" ) ) ).isEqualTo( "prop2" ); assertThat( Strings.getSafeVariableName( "prop.font", Arrays.asList( "propFont", "propFont_" ) ) ) .isEqualTo( "propFont1" ); } @Test - public void testSanitizeIdentifierName() throws Exception { + public void testSanitizeIdentifierName() { assertThat( Strings.sanitizeIdentifierName( "test" ) ).isEqualTo( "test" ); assertThat( Strings.sanitizeIdentifierName( "int[]" ) ).isEqualTo( "intArray" ); } @Test - public void findMostSimilarWord() throws Exception { + public void findMostSimilarWord() { String mostSimilarWord = Strings.getMostSimilarWord( "fulName", Arrays.asList( "fullAge", "fullName", "address", "status" ) diff --git a/processor/src/test/java/org/mapstruct/ap/spi/util/IntrospectorUtilsTest.java b/processor/src/test/java/org/mapstruct/ap/spi/util/IntrospectorUtilsTest.java index 02c171e63..7114f7b9f 100644 --- a/processor/src/test/java/org/mapstruct/ap/spi/util/IntrospectorUtilsTest.java +++ b/processor/src/test/java/org/mapstruct/ap/spi/util/IntrospectorUtilsTest.java @@ -15,7 +15,7 @@ import org.junit.Test; public class IntrospectorUtilsTest { @Test - public void testDecapitalize() throws Exception { + public void testDecapitalize() { assertThat( IntrospectorUtils.decapitalize( null ) ).isNull(); assertThat( IntrospectorUtils.decapitalize( "" ) ).isEqualTo( "" ); assertThat( IntrospectorUtils.decapitalize( "URL" ) ).isEqualTo( "URL" ); diff --git a/processor/src/test/java/org/mapstruct/ap/test/abstractclass/AbstractReferencedMapper.java b/processor/src/test/java/org/mapstruct/ap/test/abstractclass/AbstractReferencedMapper.java index 0bde73c97..8fd8ab0ef 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/abstractclass/AbstractReferencedMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/abstractclass/AbstractReferencedMapper.java @@ -16,11 +16,7 @@ public abstract class AbstractReferencedMapper implements ReferencedMapperInterf } public boolean objectToBoolean(Object obj) { - if ( obj instanceof String ) { - return true; - } - - return false; + return obj instanceof String; } @Override diff --git a/processor/src/test/java/org/mapstruct/ap/test/abstractclass/Source.java b/processor/src/test/java/org/mapstruct/ap/test/abstractclass/Source.java index f13efc978..703bc7daf 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/abstractclass/Source.java +++ b/processor/src/test/java/org/mapstruct/ap/test/abstractclass/Source.java @@ -15,7 +15,7 @@ public class Source extends AbstractDto implements HasId, AlsoHasId { private final int size; private final Calendar birthday; private final String notAttractingEqualsMethod = "no way"; - private final Holder manuallyConverted = new Holder( "What is the answer?" ); + private final Holder manuallyConverted = new Holder<>( "What is the answer?" ); public Source() { publicSize = 191; diff --git a/processor/src/test/java/org/mapstruct/ap/test/array/ArrayMappingTest.java b/processor/src/test/java/org/mapstruct/ap/test/array/ArrayMappingTest.java index 221bc361a..39adff4eb 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/array/ArrayMappingTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/array/ArrayMappingTest.java @@ -140,7 +140,7 @@ public class ArrayMappingTest { @IssueKey("534") @Test - public void shouldMapbooleanWhenReturnDefault() { + public void shouldMapBooleanWhenReturnDefault() { boolean[] existingTarget = new boolean[]{true}; boolean[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); @@ -152,7 +152,7 @@ public class ArrayMappingTest { } @Test - public void shouldMapshortWhenReturnDefault() { + public void shouldMapShortWhenReturnDefault() { short[] existingTarget = new short[]{ 5 }; short[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); @@ -161,7 +161,7 @@ public class ArrayMappingTest { } @Test - public void shouldMapcharWhenReturnDefault() { + public void shouldMapCharWhenReturnDefault() { char[] existingTarget = new char[]{ 'a' }; char[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); @@ -170,53 +170,53 @@ public class ArrayMappingTest { } @Test - public void shouldMapintWhenReturnDefault() { + public void shouldMapIntWhenReturnDefault() { int[] existingTarget = new int[]{ 5 }; int[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); - assertThat( target ).containsOnly( new int[] { 0 } ); - assertThat( existingTarget ).containsOnly( new int[] { 0 } ); + assertThat( target ).containsOnly( 0 ); + assertThat( existingTarget ).containsOnly( 0 ); } @Test - public void shouldMaplongWhenReturnDefault() { + public void shouldMapLongWhenReturnDefault() { long[] existingTarget = new long[]{ 5L }; long[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); - assertThat( target ).containsOnly( new long[] { 0L } ); - assertThat( existingTarget ).containsOnly( new long[] { 0L } ); + assertThat( target ).containsOnly( 0L ); + assertThat( existingTarget ).containsOnly( 0L ); } @Test - public void shouldMapfloatWhenReturnDefault() { + public void shouldMapFloatWhenReturnDefault() { float[] existingTarget = new float[]{ 3.1f }; float[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); - assertThat( target ).containsOnly( new float[] { 0.0f } ); - assertThat( existingTarget ).containsOnly( new float[] { 0.0f } ); + assertThat( target ).containsOnly( 0.0f ); + assertThat( existingTarget ).containsOnly( 0.0f ); } @Test - public void shouldMapdoubleWhenReturnDefault() { + public void shouldMapDoubleWhenReturnDefault() { double[] existingTarget = new double[]{ 5.0d }; double[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); - assertThat( target ).containsOnly( new double[] { 0.0d } ); - assertThat( existingTarget ).containsOnly( new double[] { 0.0d } ); + assertThat( target ).containsOnly( 0.0d ); + assertThat( existingTarget ).containsOnly( 0.0d ); } @Test - public void shouldVoidMapintWhenReturnNull() { + public void shouldVoidMapIntWhenReturnNull() { long[] existingTarget = new long[]{ 5L }; ScienceMapper.INSTANCE.nvmMappingVoidReturnNull( null, existingTarget ); - assertThat( existingTarget ).containsOnly( new long[] { 5L } ); + assertThat( existingTarget ).containsOnly( 5L ); } @Test - public void shouldVoidMapintWhenReturnDefault() { + public void shouldVoidMapIntWhenReturnDefault() { long[] existingTarget = new long[]{ 5L }; ScienceMapper.INSTANCE.nvmMappingVoidReturnDefault( null, existingTarget ); - assertThat( existingTarget ).containsOnly( new long[] { 0L } ); + assertThat( existingTarget ).containsOnly( 0L ); } @Test diff --git a/processor/src/test/java/org/mapstruct/ap/test/builtin/BuiltInTest.java b/processor/src/test/java/org/mapstruct/ap/test/builtin/BuiltInTest.java index d5e2de5b6..a16cb26ee 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/builtin/BuiltInTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/builtin/BuiltInTest.java @@ -145,7 +145,7 @@ public class BuiltInTest { @Test @WithClasses( JaxbListMapper.class ) @IssueKey( "141" ) - public void shouldApplyBuiltInOnJAXBElementList() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInOnJAXBElementList() { JaxbElementListProperty source = new JaxbElementListProperty(); source.setProp( createJaxbList( "TEST2" ) ); @@ -159,7 +159,7 @@ public class BuiltInTest { @Test @WithClasses( DateToXmlGregCalMapper.class ) - public void shouldApplyBuiltInOnDateToXmlGregCal() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInOnDateToXmlGregCal() throws ParseException { DateProperty source = new DateProperty(); source.setProp( createDate( "31-08-1982 10:20:56" ) ); @@ -175,7 +175,7 @@ public class BuiltInTest { @Test @WithClasses( XmlGregCalToDateMapper.class ) - public void shouldApplyBuiltInOnXmlGregCalToDate() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInOnXmlGregCalToDate() throws DatatypeConfigurationException { XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty(); source.setProp( createXmlCal( 1999, 3, 2, 60 ) ); @@ -192,7 +192,7 @@ public class BuiltInTest { @Test @WithClasses( StringToXmlGregCalMapper.class ) - public void shouldApplyBuiltInStringToXmlGregCal() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInStringToXmlGregCal() { StringProperty source = new StringProperty(); source.setProp( "05.07.1999" ); @@ -227,7 +227,7 @@ public class BuiltInTest { @Test @WithClasses( XmlGregCalToStringMapper.class ) - public void shouldApplyBuiltInXmlGregCalToString() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInXmlGregCalToString() throws DatatypeConfigurationException { XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty(); source.setProp( createXmlCal( 1999, 3, 2, 60 ) ); @@ -254,7 +254,7 @@ public class BuiltInTest { @Test @WithClasses( CalendarToXmlGregCalMapper.class ) - public void shouldApplyBuiltInOnCalendarToXmlGregCal() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInOnCalendarToXmlGregCal() throws ParseException { CalendarProperty source = new CalendarProperty(); source.setProp( createCalendar( "02.03.1999" ) ); @@ -270,7 +270,7 @@ public class BuiltInTest { @Test @WithClasses( XmlGregCalToCalendarMapper.class ) - public void shouldApplyBuiltInOnXmlGregCalToCalendar() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInOnXmlGregCalToCalendar() throws DatatypeConfigurationException { XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty(); source.setProp( createXmlCal( 1999, 3, 2, 60 ) ); @@ -288,7 +288,7 @@ public class BuiltInTest { @Test @WithClasses( CalendarToDateMapper.class ) - public void shouldApplyBuiltInOnCalendarToDate() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInOnCalendarToDate() throws ParseException { CalendarProperty source = new CalendarProperty(); source.setProp( createCalendar( "02.03.1999" ) ); @@ -304,7 +304,7 @@ public class BuiltInTest { @Test @WithClasses( DateToCalendarMapper.class ) - public void shouldApplyBuiltInOnDateToCalendar() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInOnDateToCalendar() throws ParseException { DateProperty source = new DateProperty(); source.setProp( new SimpleDateFormat( "dd.MM.yyyy" ).parse( "02.03.1999" ) ); @@ -321,7 +321,7 @@ public class BuiltInTest { @Test @WithClasses( CalendarToStringMapper.class ) - public void shouldApplyBuiltInOnCalendarToString() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInOnCalendarToString() throws ParseException { CalendarProperty source = new CalendarProperty(); source.setProp( createCalendar( "02.03.1999" ) ); @@ -337,7 +337,7 @@ public class BuiltInTest { @Test @WithClasses( StringToCalendarMapper.class ) - public void shouldApplyBuiltInOnStringToCalendar() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInOnStringToCalendar() throws ParseException { StringProperty source = new StringProperty(); source.setProp( "02.03.1999" ); @@ -354,11 +354,11 @@ public class BuiltInTest { @Test @WithClasses( IterableSourceTargetMapper.class ) - public void shouldApplyBuiltInOnIterable() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInOnIterable() throws DatatypeConfigurationException { IterableSource source = new IterableSource(); - source.setDates( Arrays.asList( new XMLGregorianCalendar[] { createXmlCal( 1999, 3, 2, 60 ) } ) ); - source.publicDates = Arrays.asList( new XMLGregorianCalendar[] { createXmlCal( 2016, 3, 2, 60 ) } ); + source.setDates( Arrays.asList( createXmlCal( 1999, 3, 2, 60 ) ) ); + source.publicDates = Arrays.asList( createXmlCal( 2016, 3, 2, 60 ) ); IterableTarget target = IterableSourceTargetMapper.INSTANCE.sourceToTarget( source ); assertThat( target ).isNotNull(); @@ -368,12 +368,12 @@ public class BuiltInTest { @Test @WithClasses( MapSourceTargetMapper.class ) - public void shouldApplyBuiltInOnMap() throws ParseException, DatatypeConfigurationException { + public void shouldApplyBuiltInOnMap() throws DatatypeConfigurationException { MapSource source = new MapSource(); - source.setExample( new HashMap, XMLGregorianCalendar>() ); + source.setExample( new HashMap<>() ); source.getExample().put( createJaxb( "TEST" ), createXmlCal( 1999, 3, 2, 60 ) ); - source.publicExample = new HashMap, XMLGregorianCalendar>(); + source.publicExample = new HashMap<>(); source.publicExample.put( createJaxb( "TEST" ), createXmlCal( 2016, 3, 2, 60 ) ); MapTarget target = MapSourceTargetMapper.INSTANCE.sourceToTarget( source ); @@ -417,11 +417,11 @@ public class BuiltInTest { } private JAXBElement createJaxb(String test) { - return new JAXBElement( new QName( "www.mapstruct.org", "test" ), String.class, test ); + return new JAXBElement<>( new QName( "www.mapstruct.org", "test" ), String.class, test ); } private List> createJaxbList(String test) { - List> result = new ArrayList>(); + List> result = new ArrayList<>(); result.add( createJaxb( test ) ); return result; } diff --git a/processor/src/test/java/org/mapstruct/ap/test/callbacks/CallbackMethodTest.java b/processor/src/test/java/org/mapstruct/ap/test/callbacks/CallbackMethodTest.java index 91a84655f..e4f363d4c 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/callbacks/CallbackMethodTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/callbacks/CallbackMethodTest.java @@ -68,7 +68,7 @@ public class CallbackMethodTest { @Test public void callbackMethodsForIterableMappingWithResultParamCalled() { SourceTargetCollectionMapper.INSTANCE.sourceToTarget( - Arrays.asList( createSource() ), new ArrayList() ); + Arrays.asList( createSource() ), new ArrayList<>() ); assertIterableMappingInvocations( ClassContainingCallbacks.getInvocations() ); assertIterableMappingInvocations( BaseMapper.getInvocations() ); @@ -86,7 +86,7 @@ public class CallbackMethodTest { public void callbackMethodsForMapMappingWithResultParamCalled() { SourceTargetCollectionMapper.INSTANCE.sourceToTarget( toMap( "foo", createSource() ), - new HashMap() ); + new HashMap<>() ); assertMapMappingInvocations( ClassContainingCallbacks.getInvocations() ); assertMapMappingInvocations( BaseMapper.getInvocations() ); @@ -173,7 +173,7 @@ public class CallbackMethodTest { } private Map toMap(String string, T value) { - Map result = new HashMap(); + Map result = new HashMap<>(); result.put( string, value ); return result; } @@ -191,7 +191,7 @@ public class CallbackMethodTest { } private List beanMappingInvocationList(Object source, Object target, Object emptyTarget) { - List invocations = new ArrayList(); + List invocations = new ArrayList<>(); invocations.addAll( allBeforeMappingMethods( source, emptyTarget, Target.class ) ); invocations.addAll( allAfterMappingMethods( source, target, Target.class ) ); @@ -200,7 +200,7 @@ public class CallbackMethodTest { } private List allAfterMappingMethods(Object source, Object target, Class targetClass) { - return new ArrayList( Arrays.asList( + return new ArrayList<>( Arrays.asList( new Invocation( "noArgsAfterMapping" ), new Invocation( "withSourceAfterMapping", source ), new Invocation( "withSourceAsObjectAfterMapping", source ), @@ -211,7 +211,7 @@ public class CallbackMethodTest { } private List allBeforeMappingMethods(Object source, Object emptyTarget, Class targetClass) { - return new ArrayList( Arrays.asList( + return new ArrayList<>( Arrays.asList( new Invocation( "noArgsBeforeMapping" ), new Invocation( "withSourceBeforeMapping", source ), new Invocation( "withSourceAsObjectBeforeMapping", source ), @@ -226,7 +226,7 @@ public class CallbackMethodTest { } private List allQualifiedCallbackMethods(Object source, Object target) { - List invocations = new ArrayList(); + List invocations = new ArrayList<>(); invocations.add( new Invocation( "withSourceBeforeMappingQualified", source ) ); if ( source instanceof List || source instanceof Map ) { diff --git a/processor/src/test/java/org/mapstruct/ap/test/callbacks/Invocation.java b/processor/src/test/java/org/mapstruct/ap/test/callbacks/Invocation.java index e408852a0..42d321af7 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/callbacks/Invocation.java +++ b/processor/src/test/java/org/mapstruct/ap/test/callbacks/Invocation.java @@ -62,13 +62,10 @@ public class Invocation { return false; } if ( methodName == null ) { - if ( other.methodName != null ) { - return false; - } + return other.methodName == null; } - else if ( !methodName.equals( other.methodName ) ) { - return false; + else { + return methodName.equals( other.methodName ); } - return true; } } diff --git a/processor/src/test/java/org/mapstruct/ap/test/callbacks/Source.java b/processor/src/test/java/org/mapstruct/ap/test/callbacks/Source.java index 7194ecc2a..69d91af39 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/callbacks/Source.java +++ b/processor/src/test/java/org/mapstruct/ap/test/callbacks/Source.java @@ -40,14 +40,11 @@ public class Source { } Source other = (Source) obj; if ( foo == null ) { - if ( other.foo != null ) { - return false; - } + return other.foo == null; } - else if ( !foo.equals( other.foo ) ) { - return false; + else { + return foo.equals( other.foo ); } - return true; } @Override diff --git a/processor/src/test/java/org/mapstruct/ap/test/callbacks/Target.java b/processor/src/test/java/org/mapstruct/ap/test/callbacks/Target.java index 90edbe462..d800bfbcd 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/callbacks/Target.java +++ b/processor/src/test/java/org/mapstruct/ap/test/callbacks/Target.java @@ -40,14 +40,11 @@ public class Target { } Target other = (Target) obj; if ( foo == null ) { - if ( other.foo != null ) { - return false; - } + return other.foo == null; } - else if ( !foo.equals( other.foo ) ) { - return false; + else { + return foo.equals( other.foo ); } - return true; } @Override diff --git a/processor/src/test/java/org/mapstruct/ap/test/callbacks/ongeneratedmethods/CompanyMapperPostProcessing.java b/processor/src/test/java/org/mapstruct/ap/test/callbacks/ongeneratedmethods/CompanyMapperPostProcessing.java index dd18e48aa..bb7f08a83 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/callbacks/ongeneratedmethods/CompanyMapperPostProcessing.java +++ b/processor/src/test/java/org/mapstruct/ap/test/callbacks/ongeneratedmethods/CompanyMapperPostProcessing.java @@ -17,9 +17,9 @@ public class CompanyMapperPostProcessing { @AfterMapping public void toAddressDto(Address address, @MappingTarget AddressDto addressDto) { String addressLine = address.getAddressLine(); - int seperatorIndex = addressLine.indexOf( ";" ); - addressDto.setStreet( addressLine.substring( 0, seperatorIndex ) ); - String houseNumber = addressLine.substring( seperatorIndex + 1, addressLine.length() ); + int separatorIndex = addressLine.indexOf( ";" ); + addressDto.setStreet( addressLine.substring( 0, separatorIndex ) ); + String houseNumber = addressLine.substring( separatorIndex + 1 ); addressDto.setHouseNumber( Integer.parseInt( houseNumber ) ); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/callbacks/ongeneratedmethods/MappingResultPostprocessorTest.java b/processor/src/test/java/org/mapstruct/ap/test/callbacks/ongeneratedmethods/MappingResultPostprocessorTest.java index 19feaefda..292710800 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/callbacks/ongeneratedmethods/MappingResultPostprocessorTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/callbacks/ongeneratedmethods/MappingResultPostprocessorTest.java @@ -44,7 +44,7 @@ public class MappingResultPostprocessorTest { Employee employee = new Employee(); employee.setAddress( address ); Company company = new Company(); - company.setEmployees( Arrays.asList( new Employee[] { employee } ) ); + company.setEmployees( Arrays.asList( employee ) ); // test CompanyDto companyDto = CompanyMapper.INSTANCE.toCompanyDto( company ); diff --git a/processor/src/test/java/org/mapstruct/ap/test/callbacks/returning/CallbacksWithReturnValuesTest.java b/processor/src/test/java/org/mapstruct/ap/test/callbacks/returning/CallbacksWithReturnValuesTest.java index bea89fa7f..6dac09f19 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/callbacks/returning/CallbacksWithReturnValuesTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/callbacks/returning/CallbacksWithReturnValuesTest.java @@ -42,7 +42,7 @@ public class CallbacksWithReturnValuesTest { @Test public void mappingWithContextCorrectlyResolvesCycles() { - final AtomicReference contextLevel = new AtomicReference( null ); + final AtomicReference contextLevel = new AtomicReference<>( null ); ContextListener contextListener = new ContextListener() { @Override public void methodCalled(Integer level, String method, Object source, Object target) { diff --git a/processor/src/test/java/org/mapstruct/ap/test/complex/CarMapperTest.java b/processor/src/test/java/org/mapstruct/ap/test/complex/CarMapperTest.java index 0b964d697..128abccf5 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/complex/CarMapperTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/complex/CarMapperTest.java @@ -9,6 +9,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.GregorianCalendar; import java.util.List; @@ -36,7 +37,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; public class CarMapperTest { @Test - public void shouldProvideMapperInstance() throws Exception { + public void shouldProvideMapperInstance() { assertThat( CarMapper.INSTANCE ).isNotNull(); } @@ -46,9 +47,9 @@ public class CarMapperTest { Car car = new Car( "Morris", 2, - new GregorianCalendar( 1980, 0, 1 ).getTime(), + new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime(), new Person( "Bob" ), - new ArrayList() + new ArrayList<>() ); //when @@ -65,9 +66,9 @@ public class CarMapperTest { Car car = new Car( "Morris", 2, - new GregorianCalendar( 1980, 0, 1 ).getTime(), + new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime(), new Person( "Bob" ), - new ArrayList() + new ArrayList<>() ); //when @@ -82,7 +83,7 @@ public class CarMapperTest { @Test public void shouldReverseMapReferenceAttribute() { //given - CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList() ); + CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<>() ); //when Car car = CarMapper.INSTANCE.carDtoToCar( carDto ); @@ -99,9 +100,9 @@ public class CarMapperTest { Car car = new Car( "Morris", 2, - new GregorianCalendar( 1980, 0, 1 ).getTime(), + new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime(), new Person( "Bob" ), - new ArrayList() + new ArrayList<>() ); //when @@ -115,7 +116,7 @@ public class CarMapperTest { @Test public void shouldConsiderCustomMappingForReverseMapping() { //given - CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList() ); + CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<>() ); //when Car car = CarMapper.INSTANCE.carDtoToCar( carDto ); @@ -131,9 +132,9 @@ public class CarMapperTest { Car car = new Car( "Morris", 2, - new GregorianCalendar( 1980, 0, 1 ).getTime(), + new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime(), new Person( "Bob" ), - new ArrayList() + new ArrayList<>() ); //when @@ -147,14 +148,16 @@ public class CarMapperTest { @Test public void shouldApplyConverterForReverseMapping() { //given - CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList() ); + CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<>() ); //when Car car = CarMapper.INSTANCE.carDtoToCar( carDto ); //then assertThat( car ).isNotNull(); - assertThat( car.getManufacturingDate() ).isEqualTo( new GregorianCalendar( 1980, 0, 1 ).getTime() ); + assertThat( car.getManufacturingDate() ).isEqualTo( + new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime() + ); } @Test @@ -163,20 +166,20 @@ public class CarMapperTest { Car car1 = new Car( "Morris", 2, - new GregorianCalendar( 1980, 0, 1 ).getTime(), + new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime(), new Person( "Bob" ), - new ArrayList() + new ArrayList<>() ); Car car2 = new Car( "Railton", 4, - new GregorianCalendar( 1934, 0, 1 ).getTime(), + new GregorianCalendar( 1934, Calendar.JANUARY, 1 ).getTime(), new Person( "Bill" ), - new ArrayList() + new ArrayList<>() ); //when - List dtos = CarMapper.INSTANCE.carsToCarDtos( new ArrayList( Arrays.asList( car1, car2 ) ) ); + List dtos = CarMapper.INSTANCE.carsToCarDtos( Arrays.asList( car1, car2 ) ); //then assertThat( dtos ).isNotNull(); @@ -196,11 +199,11 @@ public class CarMapperTest { @Test public void shouldReverseMapIterable() { //given - CarDto car1 = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList() ); - CarDto car2 = new CarDto( "Railton", 4, "1934", new PersonDto( "Bill" ), new ArrayList() ); + CarDto car1 = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<>() ); + CarDto car2 = new CarDto( "Railton", 4, "1934", new PersonDto( "Bill" ), new ArrayList<>() ); //when - List cars = CarMapper.INSTANCE.carDtosToCars( new ArrayList( Arrays.asList( car1, car2 ) ) ); + List cars = CarMapper.INSTANCE.carDtosToCars( Arrays.asList( car1, car2 ) ); //then assertThat( cars ).isNotNull(); @@ -208,12 +211,16 @@ public class CarMapperTest { assertThat( cars.get( 0 ).getMake() ).isEqualTo( "Morris" ); assertThat( cars.get( 0 ).getNumberOfSeats() ).isEqualTo( 2 ); - assertThat( cars.get( 0 ).getManufacturingDate() ).isEqualTo( new GregorianCalendar( 1980, 0, 1 ).getTime() ); + assertThat( cars.get( 0 ).getManufacturingDate() ).isEqualTo( + new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime() + ); assertThat( cars.get( 0 ).getDriver().getName() ).isEqualTo( "Bob" ); assertThat( cars.get( 1 ).getMake() ).isEqualTo( "Railton" ); assertThat( cars.get( 1 ).getNumberOfSeats() ).isEqualTo( 4 ); - assertThat( cars.get( 1 ).getManufacturingDate() ).isEqualTo( new GregorianCalendar( 1934, 0, 1 ).getTime() ); + assertThat( cars.get( 1 ).getManufacturingDate() ).isEqualTo( + new GregorianCalendar( 1934, Calendar.JANUARY, 1 ).getTime() + ); assertThat( cars.get( 1 ).getDriver().getName() ).isEqualTo( "Bill" ); } @@ -223,9 +230,9 @@ public class CarMapperTest { Car car = new Car( "Morris", 2, - new GregorianCalendar( 1980, 0, 1 ).getTime(), + new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime(), new Person( "Bob" ), - new ArrayList( Arrays.asList( new Person( "Alice" ), new Person( "Bill" ) ) ) + Arrays.asList( new Person( "Alice" ), new Person( "Bill" ) ) ); //when @@ -247,7 +254,7 @@ public class CarMapperTest { 2, "1980", new PersonDto( "Bob" ), - new ArrayList( Arrays.asList( new PersonDto( "Alice" ), new PersonDto( "Bill" ) ) ) + Arrays.asList( new PersonDto( "Alice" ), new PersonDto( "Bill" ) ) ); //when diff --git a/processor/src/test/java/org/mapstruct/ap/test/context/Node.java b/processor/src/test/java/org/mapstruct/ap/test/context/Node.java index 15a8effac..b663b7b15 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/context/Node.java +++ b/processor/src/test/java/org/mapstruct/ap/test/context/Node.java @@ -21,8 +21,8 @@ public class Node { public Node(String name) { this.name = name; - this.children = new ArrayList(); - this.attributes = new ArrayList(); + this.children = new ArrayList<>(); + this.attributes = new ArrayList<>(); } public Node getParent() { diff --git a/processor/src/test/java/org/mapstruct/ap/test/context/SelfContainingCycleContext.java b/processor/src/test/java/org/mapstruct/ap/test/context/SelfContainingCycleContext.java index 298b95aa2..8b4a21640 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/context/SelfContainingCycleContext.java +++ b/processor/src/test/java/org/mapstruct/ap/test/context/SelfContainingCycleContext.java @@ -19,7 +19,7 @@ import org.mapstruct.TargetType; * @author Andreas Gudian */ public class SelfContainingCycleContext { - private Map knownInstances = new IdentityHashMap(); + private Map knownInstances = new IdentityHashMap<>(); @BeforeMapping @SuppressWarnings("unchecked") diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/date/DateConversionTest.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/date/DateConversionTest.java index 680303b33..c7a3cf331 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/conversion/date/DateConversionTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/date/DateConversionTest.java @@ -50,8 +50,8 @@ public class DateConversionTest { // See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+ public void shouldApplyDateFormatForConversions() { Source source = new Source(); - source.setDate( new GregorianCalendar( 2013, 6, 6 ).getTime() ); - source.setAnotherDate( new GregorianCalendar( 2013, 1, 14 ).getTime() ); + source.setDate( new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime() ); + source.setAnotherDate( new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime() ); Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); @@ -65,8 +65,8 @@ public class DateConversionTest { // See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+ public void shouldApplyDateFormatForConversionsJdk11() { Source source = new Source(); - source.setDate( new GregorianCalendar( 2013, 6, 6 ).getTime() ); - source.setAnotherDate( new GregorianCalendar( 2013, 1, 14 ).getTime() ); + source.setDate( new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime() ); + source.setAnotherDate( new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime() ); Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); @@ -86,8 +86,10 @@ public class DateConversionTest { Source source = SourceTargetMapper.INSTANCE.targetToSource( target ); assertThat( source ).isNotNull(); - assertThat( source.getDate() ).isEqualTo( new GregorianCalendar( 2013, 6, 6 ).getTime() ); - assertThat( source.getAnotherDate() ).isEqualTo( new GregorianCalendar( 2013, 1, 14, 8, 30 ).getTime() ); + assertThat( source.getDate() ).isEqualTo( new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime() ); + assertThat( source.getAnotherDate() ).isEqualTo( + new GregorianCalendar( 2013, Calendar.FEBRUARY, 14, 8, 30 ).getTime() + ); } @Test @@ -101,16 +103,18 @@ public class DateConversionTest { Source source = SourceTargetMapper.INSTANCE.targetToSource( target ); assertThat( source ).isNotNull(); - assertThat( source.getDate() ).isEqualTo( new GregorianCalendar( 2013, 6, 6 ).getTime() ); - assertThat( source.getAnotherDate() ).isEqualTo( new GregorianCalendar( 2013, 1, 14, 8, 30 ).getTime() ); + assertThat( source.getDate() ).isEqualTo( new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime() ); + assertThat( source.getAnotherDate() ).isEqualTo( + new GregorianCalendar( 2013, Calendar.FEBRUARY, 14, 8, 30 ).getTime() + ); } @Test public void shouldApplyStringConversionForIterableMethod() { List dates = Arrays.asList( - new GregorianCalendar( 2013, 6, 6 ).getTime(), - new GregorianCalendar( 2013, 1, 14 ).getTime(), - new GregorianCalendar( 2013, 3, 11 ).getTime() + new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime(), + new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime(), + new GregorianCalendar( 2013, Calendar.APRIL, 11 ).getTime() ); List stringDates = SourceTargetMapper.INSTANCE.stringListToDateList( dates ); @@ -122,9 +126,9 @@ public class DateConversionTest { @Test public void shouldApplyStringConversionForArrayMethod() { List dates = Arrays.asList( - new GregorianCalendar( 2013, 6, 6 ).getTime(), - new GregorianCalendar( 2013, 1, 14 ).getTime(), - new GregorianCalendar( 2013, 3, 11 ).getTime() + new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime(), + new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime(), + new GregorianCalendar( 2013, Calendar.APRIL, 11 ).getTime() ); String[] stringDates = SourceTargetMapper.INSTANCE.stringListToDateArray( dates ); @@ -141,9 +145,9 @@ public class DateConversionTest { assertThat( dates ).isNotNull(); assertThat( dates ).containsExactly( - new GregorianCalendar( 2013, 6, 6 ).getTime(), - new GregorianCalendar( 2013, 1, 14 ).getTime(), - new GregorianCalendar( 2013, 3, 11 ).getTime() + new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime(), + new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime(), + new GregorianCalendar( 2013, Calendar.APRIL, 11 ).getTime() ); } @@ -155,18 +159,18 @@ public class DateConversionTest { assertThat( dates ).isNotNull(); assertThat( dates ).containsExactly( - new GregorianCalendar( 2013, 6, 6 ).getTime(), - new GregorianCalendar( 2013, 1, 14 ).getTime(), - new GregorianCalendar( 2013, 3, 11 ).getTime() + new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime(), + new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime(), + new GregorianCalendar( 2013, Calendar.APRIL, 11 ).getTime() ); } @Test public void shouldApplyStringConversionForReverseArrayArrayMethod() { Date[] dates = new Date[]{ - new GregorianCalendar( 2013, 6, 6 ).getTime(), - new GregorianCalendar( 2013, 1, 14 ).getTime(), - new GregorianCalendar( 2013, 3, 11 ).getTime() + new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime(), + new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime(), + new GregorianCalendar( 2013, Calendar.APRIL, 11 ).getTime() }; String[] stringDates = SourceTargetMapper.INSTANCE.dateArrayToStringArray( dates ); @@ -182,15 +186,15 @@ public class DateConversionTest { assertThat( dates ).isNotNull(); assertThat( dates ).isEqualTo( new Date[] { - new GregorianCalendar( 2013, 6, 6 ).getTime(), - new GregorianCalendar( 2013, 1, 14 ).getTime(), - new GregorianCalendar( 2013, 3, 11 ).getTime() + new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime(), + new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime(), + new GregorianCalendar( 2013, Calendar.APRIL, 11 ).getTime() } ); } @IssueKey("858") @Test - public void shouldApplyDateToSqlConversion() throws Exception { + public void shouldApplyDateToSqlConversion() { GregorianCalendar time = new GregorianCalendar( 2016, Calendar.AUGUST, 24, 20, 30, 30 ); GregorianCalendar sqlDate = new GregorianCalendar( 2016, Calendar.AUGUST, 23, 21, 35, 35 ); GregorianCalendar timestamp = new GregorianCalendar( 2016, Calendar.AUGUST, 22, 21, 35, 35 ); @@ -212,7 +216,7 @@ public class DateConversionTest { @IssueKey("858") @Test - public void shouldApplySqlToDateConversion() throws Exception { + public void shouldApplySqlToDateConversion() { Target target = new Target(); GregorianCalendar time = new GregorianCalendar( 2016, Calendar.AUGUST, 24, 20, 30, 30 ); GregorianCalendar sqlDate = new GregorianCalendar( 2016, Calendar.AUGUST, 23, 21, 35, 35 ); diff --git a/processor/src/test/java/org/mapstruct/ap/test/conversion/nativetypes/CharConversionTest.java b/processor/src/test/java/org/mapstruct/ap/test/conversion/nativetypes/CharConversionTest.java index f2cc7e341..cb5192d42 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/conversion/nativetypes/CharConversionTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/conversion/nativetypes/CharConversionTest.java @@ -35,7 +35,7 @@ public class CharConversionTest { @Test public void shouldApplyReverseCharConversion() { CharTarget target = new CharTarget(); - target.setC( Character.valueOf( 'G' ) ); + target.setC( 'G' ); CharSource source = CharMapper.INSTANCE.targetToSource( target ); diff --git a/processor/src/test/java/org/mapstruct/ap/test/decorator/DecoratorTest.java b/processor/src/test/java/org/mapstruct/ap/test/decorator/DecoratorTest.java index 08e71f836..84a565793 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/decorator/DecoratorTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/decorator/DecoratorTest.java @@ -43,7 +43,7 @@ public class DecoratorTest { public void shouldInvokeDecoratorMethods() { //given Calendar birthday = Calendar.getInstance(); - birthday.set( 1928, 4, 23 ); + birthday.set( 1928, Calendar.MAY, 23 ); Person person = new Person( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) ); //when @@ -99,7 +99,7 @@ public class DecoratorTest { public void shouldApplyDecoratorWithDefaultConstructor() { //given Calendar birthday = Calendar.getInstance(); - birthday.set( 1928, 4, 23 ); + birthday.set( 1928, Calendar.MAY, 23 ); Person person = new Person( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) ); //when @@ -120,7 +120,7 @@ public class DecoratorTest { public void shouldApplyDelegateToClassBasedMapper() { //given Calendar birthday = Calendar.getInstance(); - birthday.set( 1928, 4, 23 ); + birthday.set( 1928, Calendar.MAY, 23 ); Person person = new Person2( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) ); @@ -150,7 +150,7 @@ public class DecoratorTest { public void shouldApplyCustomMappers() { //given Calendar birthday = Calendar.getInstance(); - birthday.set( 1928, 4, 23 ); + birthday.set( 1928, Calendar.MAY, 23 ); Person2 person = new Person2( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) ); person.setEmployer( new Employer( "ACME" ) ); person.setSportsClub( new SportsClub( "SC Duckburg" ) ); diff --git a/processor/src/test/java/org/mapstruct/ap/test/decorator/jsr330/Jsr330DecoratorTest.java b/processor/src/test/java/org/mapstruct/ap/test/decorator/jsr330/Jsr330DecoratorTest.java index 2e95f3d2e..ba1f6012b 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/decorator/jsr330/Jsr330DecoratorTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/decorator/jsr330/Jsr330DecoratorTest.java @@ -78,7 +78,7 @@ public class Jsr330DecoratorTest { @Test public void shouldInvokeDecoratorMethods() { Calendar birthday = Calendar.getInstance(); - birthday.set( 1928, 4, 23 ); + birthday.set( 1928, Calendar.MAY, 23 ); Person person = new Person( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) ); PersonDto personDto = personMapper.personToPersonDto( person ); diff --git a/processor/src/test/java/org/mapstruct/ap/test/decorator/spring/constructor/SpringDecoratorTest.java b/processor/src/test/java/org/mapstruct/ap/test/decorator/spring/constructor/SpringDecoratorTest.java index 2ed238490..feffc8c52 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/decorator/spring/constructor/SpringDecoratorTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/decorator/spring/constructor/SpringDecoratorTest.java @@ -66,7 +66,7 @@ public class SpringDecoratorTest { public void shouldInvokeDecoratorMethods() { //given Calendar birthday = Calendar.getInstance(); - birthday.set( 1928, 4, 23 ); + birthday.set( 1928, Calendar.MAY, 23 ); Person person = new Person( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) ); //when diff --git a/processor/src/test/java/org/mapstruct/ap/test/decorator/spring/field/SpringDecoratorTest.java b/processor/src/test/java/org/mapstruct/ap/test/decorator/spring/field/SpringDecoratorTest.java index 2890a4a9e..d882dfc6d 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/decorator/spring/field/SpringDecoratorTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/decorator/spring/field/SpringDecoratorTest.java @@ -66,7 +66,7 @@ public class SpringDecoratorTest { public void shouldInvokeDecoratorMethods() { //given Calendar birthday = Calendar.getInstance(); - birthday.set( 1928, 4, 23 ); + birthday.set( 1928, Calendar.MAY, 23 ); Person person = new Person( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) ); //when