Fix minor warnings in tests, packages internal, spi and some others packages:

remove unnecessary generic-type in collections, simplify conditions,
remove unnecessary exception from signature,
replace months numbers on Calendar constants
This commit is contained in:
Andrei Arlou 2019-08-17 00:44:29 +03:00 committed by Filip Hrisafov
parent 148466ae3e
commit 1ee59fd123
24 changed files with 167 additions and 169 deletions

View File

@ -174,7 +174,7 @@ public class SelectionParametersTest {
public void testGetters() { public void testGetters() {
List<String> qualifyingNames = Arrays.asList( "language", "german" ); List<String> qualifyingNames = Arrays.asList( "language", "german" );
TypeMirror resultType = new TestTypeMirror( "resultType" ); TypeMirror resultType = new TestTypeMirror( "resultType" );
List<TypeMirror> qualifiers = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers = new ArrayList<>();
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils );
@ -226,7 +226,7 @@ public class SelectionParametersTest {
public void testEqualsSameInstance() { public void testEqualsSameInstance() {
List<String> qualifyingNames = Arrays.asList( "language", "german" ); List<String> qualifyingNames = Arrays.asList( "language", "german" );
TypeMirror resultType = new TestTypeMirror( "resultType" ); TypeMirror resultType = new TestTypeMirror( "resultType" );
List<TypeMirror> qualifiers = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers = new ArrayList<>();
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils );
@ -238,7 +238,7 @@ public class SelectionParametersTest {
public void testEqualsWitNull() { public void testEqualsWitNull() {
List<String> qualifyingNames = Arrays.asList( "language", "german" ); List<String> qualifyingNames = Arrays.asList( "language", "german" );
TypeMirror resultType = new TestTypeMirror( "resultType" ); TypeMirror resultType = new TestTypeMirror( "resultType" );
List<TypeMirror> qualifiers = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers = new ArrayList<>();
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils );
@ -250,7 +250,7 @@ public class SelectionParametersTest {
public void testEqualsQualifiersOneNull() { public void testEqualsQualifiersOneNull() {
List<String> qualifyingNames = Arrays.asList( "language", "german" ); List<String> qualifyingNames = Arrays.asList( "language", "german" );
TypeMirror resultType = new TestTypeMirror( "resultType" ); TypeMirror resultType = new TestTypeMirror( "resultType" );
List<TypeMirror> qualifiers = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers = new ArrayList<>();
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils );
@ -264,12 +264,12 @@ public class SelectionParametersTest {
public void testEqualsQualifiersInDifferentOrder() { public void testEqualsQualifiersInDifferentOrder() {
List<String> qualifyingNames = Arrays.asList( "language", "german" ); List<String> qualifyingNames = Arrays.asList( "language", "german" );
TypeMirror resultType = new TestTypeMirror( "resultType" ); TypeMirror resultType = new TestTypeMirror( "resultType" );
List<TypeMirror> qualifiers = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers = new ArrayList<>();
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils );
List<TypeMirror> qualifiers2 = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers2 = new ArrayList<>();
qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames, resultType, typeUtils ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames, resultType, typeUtils );
@ -282,12 +282,12 @@ public class SelectionParametersTest {
public void testEqualsQualifyingNamesOneNull() { public void testEqualsQualifyingNamesOneNull() {
List<String> qualifyingNames = Arrays.asList( "language", "german" ); List<String> qualifyingNames = Arrays.asList( "language", "german" );
TypeMirror resultType = new TestTypeMirror( "resultType" ); TypeMirror resultType = new TestTypeMirror( "resultType" );
List<TypeMirror> qualifiers = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers = new ArrayList<>();
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils );
List<TypeMirror> qualifiers2 = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers2 = new ArrayList<>();
qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params2 = new SelectionParameters( qualifiers2, null, resultType, typeUtils ); SelectionParameters params2 = new SelectionParameters( qualifiers2, null, resultType, typeUtils );
@ -300,13 +300,13 @@ public class SelectionParametersTest {
public void testEqualsQualifyingNamesInDifferentOrder() { public void testEqualsQualifyingNamesInDifferentOrder() {
List<String> qualifyingNames = Arrays.asList( "language", "german" ); List<String> qualifyingNames = Arrays.asList( "language", "german" );
TypeMirror resultType = new TestTypeMirror( "resultType" ); TypeMirror resultType = new TestTypeMirror( "resultType" );
List<TypeMirror> qualifiers = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers = new ArrayList<>();
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils );
List<String> qualifyingNames2 = Arrays.asList( "german", "language" ); List<String> qualifyingNames2 = Arrays.asList( "german", "language" );
List<TypeMirror> qualifiers2 = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers2 = new ArrayList<>();
qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, resultType, typeUtils ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, resultType, typeUtils );
@ -319,13 +319,13 @@ public class SelectionParametersTest {
public void testEqualsResultTypeOneNull() { public void testEqualsResultTypeOneNull() {
List<String> qualifyingNames = Arrays.asList( "language", "german" ); List<String> qualifyingNames = Arrays.asList( "language", "german" );
TypeMirror resultType = new TestTypeMirror( "resultType" ); TypeMirror resultType = new TestTypeMirror( "resultType" );
List<TypeMirror> qualifiers = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers = new ArrayList<>();
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils );
List<String> qualifyingNames2 = Arrays.asList( "language", "german" ); List<String> qualifyingNames2 = Arrays.asList( "language", "german" );
List<TypeMirror> qualifiers2 = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers2 = new ArrayList<>();
qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, null, typeUtils ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, null, typeUtils );
@ -338,14 +338,14 @@ public class SelectionParametersTest {
public void testAllEqual() { public void testAllEqual() {
List<String> qualifyingNames = Arrays.asList( "language", "german" ); List<String> qualifyingNames = Arrays.asList( "language", "german" );
TypeMirror resultType = new TestTypeMirror( "resultType" ); TypeMirror resultType = new TestTypeMirror( "resultType" );
List<TypeMirror> qualifiers = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers = new ArrayList<>();
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils );
List<String> qualifyingNames2 = Arrays.asList( "language", "german" ); List<String> qualifyingNames2 = Arrays.asList( "language", "german" );
TypeMirror resultType2 = new TestTypeMirror( "resultType" ); TypeMirror resultType2 = new TestTypeMirror( "resultType" );
List<TypeMirror> qualifiers2 = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers2 = new ArrayList<>();
qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, resultType2, typeUtils ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, resultType2, typeUtils );
@ -358,14 +358,14 @@ public class SelectionParametersTest {
public void testDifferentResultTypes() { public void testDifferentResultTypes() {
List<String> qualifyingNames = Arrays.asList( "language", "german" ); List<String> qualifyingNames = Arrays.asList( "language", "german" );
TypeMirror resultType = new TestTypeMirror( "resultType" ); TypeMirror resultType = new TestTypeMirror( "resultType" );
List<TypeMirror> qualifiers = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers = new ArrayList<>();
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils ); SelectionParameters params = new SelectionParameters( qualifiers, qualifyingNames, resultType, typeUtils );
List<String> qualifyingNames2 = Arrays.asList( "language", "german" ); List<String> qualifyingNames2 = Arrays.asList( "language", "german" );
TypeMirror resultType2 = new TestTypeMirror( "otherResultType" ); TypeMirror resultType2 = new TestTypeMirror( "otherResultType" );
List<TypeMirror> qualifiers2 = new ArrayList<TypeMirror>(); List<TypeMirror> qualifiers2 = new ArrayList<>();
qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeType" ) );
qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) ); qualifiers2.add( new TestTypeMirror( "org.mapstruct.test.SomeOtherType" ) );
SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, resultType2, typeUtils ); SelectionParameters params2 = new SelectionParameters( qualifiers2, qualifyingNames2, resultType2, typeUtils );

View File

@ -19,7 +19,7 @@ import org.junit.Test;
public class NativeTypesTest { public class NativeTypesTest {
@Test @Test
public void testIsNumber() throws Exception { public void testIsNumber() {
assertFalse( NativeTypes.isNumber( null ) ); assertFalse( NativeTypes.isNumber( null ) );
assertFalse( NativeTypes.isNumber( Object.class ) ); assertFalse( NativeTypes.isNumber( Object.class ) );
assertFalse( NativeTypes.isNumber( String.class ) ); assertFalse( NativeTypes.isNumber( String.class ) );

View File

@ -34,7 +34,7 @@ public class StringsTest {
} }
@Test @Test
public void testCapitalize() throws Exception { public void testCapitalize() {
assertThat( Strings.capitalize( null ) ).isNull(); assertThat( Strings.capitalize( null ) ).isNull();
assertThat( Strings.capitalize( "c" ) ).isEqualTo( "C" ); assertThat( Strings.capitalize( "c" ) ).isEqualTo( "C" );
assertThat( Strings.capitalize( "capitalize" ) ).isEqualTo( "Capitalize" ); assertThat( Strings.capitalize( "capitalize" ) ).isEqualTo( "Capitalize" );
@ -43,7 +43,7 @@ public class StringsTest {
} }
@Test @Test
public void testDecapitalize() throws Exception { public void testDecapitalize() {
assertThat( Strings.decapitalize( null ) ).isNull(); assertThat( Strings.decapitalize( null ) ).isNull();
assertThat( Strings.decapitalize( "c" ) ).isEqualTo( "c" ); assertThat( Strings.decapitalize( "c" ) ).isEqualTo( "c" );
assertThat( Strings.decapitalize( "capitalize" ) ).isEqualTo( "capitalize" ); assertThat( Strings.decapitalize( "capitalize" ) ).isEqualTo( "capitalize" );
@ -52,14 +52,14 @@ public class StringsTest {
} }
@Test @Test
public void testJoin() throws Exception { public void testJoin() {
assertThat( Strings.join( new ArrayList<String>(), "-" ) ).isEqualTo( "" ); assertThat( Strings.join( new ArrayList<String>(), "-" ) ).isEqualTo( "" );
assertThat( Strings.join( Arrays.asList( "Hello", "World" ), "-" ) ).isEqualTo( "Hello-World" ); assertThat( Strings.join( Arrays.asList( "Hello", "World" ), "-" ) ).isEqualTo( "Hello-World" );
assertThat( Strings.join( Arrays.asList( "Hello" ), "-" ) ).isEqualTo( "Hello" ); assertThat( Strings.join( Arrays.asList( "Hello" ), "-" ) ).isEqualTo( "Hello" );
} }
@Test @Test
public void testJoinAndCamelize() throws Exception { public void testJoinAndCamelize() {
assertThat( Strings.joinAndCamelize( new ArrayList<String>() ) ).isEqualTo( "" ); assertThat( Strings.joinAndCamelize( new ArrayList<String>() ) ).isEqualTo( "" );
assertThat( Strings.joinAndCamelize( Arrays.asList( "Hello", "World" ) ) ).isEqualTo( "HelloWorld" ); assertThat( Strings.joinAndCamelize( Arrays.asList( "Hello", "World" ) ) ).isEqualTo( "HelloWorld" );
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 @Test
public void testIsEmpty() throws Exception { public void testIsEmpty() {
assertThat( Strings.isEmpty( null ) ).isTrue(); assertThat( Strings.isEmpty( null ) ).isTrue();
assertThat( Strings.isEmpty( "" ) ).isTrue(); assertThat( Strings.isEmpty( "" ) ).isTrue();
assertThat( Strings.isEmpty( " " ) ).isFalse(); assertThat( Strings.isEmpty( " " ) ).isFalse();
@ -75,7 +75,7 @@ public class StringsTest {
} }
@Test @Test
public void testGetSaveVariableNameWithArrayExistingVariables() throws Exception { public void testGetSaveVariableNameWithArrayExistingVariables() {
assertThat( Strings.getSafeVariableName( "int[]" ) ).isEqualTo( "intArray" ); assertThat( Strings.getSafeVariableName( "int[]" ) ).isEqualTo( "intArray" );
assertThat( Strings.getSafeVariableName( "Extends" ) ).isEqualTo( "extends1" ); assertThat( Strings.getSafeVariableName( "Extends" ) ).isEqualTo( "extends1" );
assertThat( Strings.getSafeVariableName( "class" ) ).isEqualTo( "class1" ); assertThat( Strings.getSafeVariableName( "class" ) ).isEqualTo( "class1" );
@ -86,28 +86,28 @@ public class StringsTest {
} }
@Test @Test
public void testGetSaveVariableNameVariablesEndingOnNumberVariables() throws Exception { public void testGetSaveVariableNameVariablesEndingOnNumberVariables() {
assertThat( Strings.getSafeVariableName( "prop1", "prop1" ) ).isEqualTo( "prop1_1" ); assertThat( Strings.getSafeVariableName( "prop1", "prop1" ) ).isEqualTo( "prop1_1" );
assertThat( Strings.getSafeVariableName( "prop1", "prop1", "prop1_1" ) ).isEqualTo( "prop1_2" ); assertThat( Strings.getSafeVariableName( "prop1", "prop1", "prop1_1" ) ).isEqualTo( "prop1_2" );
} }
@Test @Test
public void testGetSaveVariableNameWithCollection() throws Exception { public void testGetSaveVariableNameWithCollection() {
assertThat( Strings.getSafeVariableName( "int[]", new ArrayList<String>() ) ).isEqualTo( "intArray" ); assertThat( Strings.getSafeVariableName( "int[]", new ArrayList<>() ) ).isEqualTo( "intArray" );
assertThat( Strings.getSafeVariableName( "Extends", new ArrayList<String>() ) ).isEqualTo( "extends1" ); assertThat( Strings.getSafeVariableName( "Extends", new ArrayList<>() ) ).isEqualTo( "extends1" );
assertThat( Strings.getSafeVariableName( "prop", Arrays.asList( "prop", "prop1" ) ) ).isEqualTo( "prop2" ); assertThat( Strings.getSafeVariableName( "prop", Arrays.asList( "prop", "prop1" ) ) ).isEqualTo( "prop2" );
assertThat( Strings.getSafeVariableName( "prop.font", Arrays.asList( "propFont", "propFont_" ) ) ) assertThat( Strings.getSafeVariableName( "prop.font", Arrays.asList( "propFont", "propFont_" ) ) )
.isEqualTo( "propFont1" ); .isEqualTo( "propFont1" );
} }
@Test @Test
public void testSanitizeIdentifierName() throws Exception { public void testSanitizeIdentifierName() {
assertThat( Strings.sanitizeIdentifierName( "test" ) ).isEqualTo( "test" ); assertThat( Strings.sanitizeIdentifierName( "test" ) ).isEqualTo( "test" );
assertThat( Strings.sanitizeIdentifierName( "int[]" ) ).isEqualTo( "intArray" ); assertThat( Strings.sanitizeIdentifierName( "int[]" ) ).isEqualTo( "intArray" );
} }
@Test @Test
public void findMostSimilarWord() throws Exception { public void findMostSimilarWord() {
String mostSimilarWord = Strings.getMostSimilarWord( String mostSimilarWord = Strings.getMostSimilarWord(
"fulName", "fulName",
Arrays.asList( "fullAge", "fullName", "address", "status" ) Arrays.asList( "fullAge", "fullName", "address", "status" )

View File

@ -15,7 +15,7 @@ import org.junit.Test;
public class IntrospectorUtilsTest { public class IntrospectorUtilsTest {
@Test @Test
public void testDecapitalize() throws Exception { public void testDecapitalize() {
assertThat( IntrospectorUtils.decapitalize( null ) ).isNull(); assertThat( IntrospectorUtils.decapitalize( null ) ).isNull();
assertThat( IntrospectorUtils.decapitalize( "" ) ).isEqualTo( "" ); assertThat( IntrospectorUtils.decapitalize( "" ) ).isEqualTo( "" );
assertThat( IntrospectorUtils.decapitalize( "URL" ) ).isEqualTo( "URL" ); assertThat( IntrospectorUtils.decapitalize( "URL" ) ).isEqualTo( "URL" );

View File

@ -16,11 +16,7 @@ public abstract class AbstractReferencedMapper implements ReferencedMapperInterf
} }
public boolean objectToBoolean(Object obj) { public boolean objectToBoolean(Object obj) {
if ( obj instanceof String ) { return obj instanceof String;
return true;
}
return false;
} }
@Override @Override

View File

@ -15,7 +15,7 @@ public class Source extends AbstractDto implements HasId, AlsoHasId {
private final int size; private final int size;
private final Calendar birthday; private final Calendar birthday;
private final String notAttractingEqualsMethod = "no way"; private final String notAttractingEqualsMethod = "no way";
private final Holder<String> manuallyConverted = new Holder<String>( "What is the answer?" ); private final Holder<String> manuallyConverted = new Holder<>( "What is the answer?" );
public Source() { public Source() {
publicSize = 191; publicSize = 191;

View File

@ -140,7 +140,7 @@ public class ArrayMappingTest {
@IssueKey("534") @IssueKey("534")
@Test @Test
public void shouldMapbooleanWhenReturnDefault() { public void shouldMapBooleanWhenReturnDefault() {
boolean[] existingTarget = new boolean[]{true}; boolean[] existingTarget = new boolean[]{true};
boolean[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); boolean[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget );
@ -152,7 +152,7 @@ public class ArrayMappingTest {
} }
@Test @Test
public void shouldMapshortWhenReturnDefault() { public void shouldMapShortWhenReturnDefault() {
short[] existingTarget = new short[]{ 5 }; short[] existingTarget = new short[]{ 5 };
short[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); short[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget );
@ -161,7 +161,7 @@ public class ArrayMappingTest {
} }
@Test @Test
public void shouldMapcharWhenReturnDefault() { public void shouldMapCharWhenReturnDefault() {
char[] existingTarget = new char[]{ 'a' }; char[] existingTarget = new char[]{ 'a' };
char[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); char[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget );
@ -170,53 +170,53 @@ public class ArrayMappingTest {
} }
@Test @Test
public void shouldMapintWhenReturnDefault() { public void shouldMapIntWhenReturnDefault() {
int[] existingTarget = new int[]{ 5 }; int[] existingTarget = new int[]{ 5 };
int[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); int[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget );
assertThat( target ).containsOnly( new int[] { 0 } ); assertThat( target ).containsOnly( 0 );
assertThat( existingTarget ).containsOnly( new int[] { 0 } ); assertThat( existingTarget ).containsOnly( 0 );
} }
@Test @Test
public void shouldMaplongWhenReturnDefault() { public void shouldMapLongWhenReturnDefault() {
long[] existingTarget = new long[]{ 5L }; long[] existingTarget = new long[]{ 5L };
long[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); long[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget );
assertThat( target ).containsOnly( new long[] { 0L } ); assertThat( target ).containsOnly( 0L );
assertThat( existingTarget ).containsOnly( new long[] { 0L } ); assertThat( existingTarget ).containsOnly( 0L );
} }
@Test @Test
public void shouldMapfloatWhenReturnDefault() { public void shouldMapFloatWhenReturnDefault() {
float[] existingTarget = new float[]{ 3.1f }; float[] existingTarget = new float[]{ 3.1f };
float[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); float[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget );
assertThat( target ).containsOnly( new float[] { 0.0f } ); assertThat( target ).containsOnly( 0.0f );
assertThat( existingTarget ).containsOnly( new float[] { 0.0f } ); assertThat( existingTarget ).containsOnly( 0.0f );
} }
@Test @Test
public void shouldMapdoubleWhenReturnDefault() { public void shouldMapDoubleWhenReturnDefault() {
double[] existingTarget = new double[]{ 5.0d }; double[] existingTarget = new double[]{ 5.0d };
double[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget ); double[] target = ScienceMapper.INSTANCE.nvmMapping( null, existingTarget );
assertThat( target ).containsOnly( new double[] { 0.0d } ); assertThat( target ).containsOnly( 0.0d );
assertThat( existingTarget ).containsOnly( new double[] { 0.0d } ); assertThat( existingTarget ).containsOnly( 0.0d );
} }
@Test @Test
public void shouldVoidMapintWhenReturnNull() { public void shouldVoidMapIntWhenReturnNull() {
long[] existingTarget = new long[]{ 5L }; long[] existingTarget = new long[]{ 5L };
ScienceMapper.INSTANCE.nvmMappingVoidReturnNull( null, existingTarget ); ScienceMapper.INSTANCE.nvmMappingVoidReturnNull( null, existingTarget );
assertThat( existingTarget ).containsOnly( new long[] { 5L } ); assertThat( existingTarget ).containsOnly( 5L );
} }
@Test @Test
public void shouldVoidMapintWhenReturnDefault() { public void shouldVoidMapIntWhenReturnDefault() {
long[] existingTarget = new long[]{ 5L }; long[] existingTarget = new long[]{ 5L };
ScienceMapper.INSTANCE.nvmMappingVoidReturnDefault( null, existingTarget ); ScienceMapper.INSTANCE.nvmMappingVoidReturnDefault( null, existingTarget );
assertThat( existingTarget ).containsOnly( new long[] { 0L } ); assertThat( existingTarget ).containsOnly( 0L );
} }
@Test @Test

View File

@ -145,7 +145,7 @@ public class BuiltInTest {
@Test @Test
@WithClasses( JaxbListMapper.class ) @WithClasses( JaxbListMapper.class )
@IssueKey( "141" ) @IssueKey( "141" )
public void shouldApplyBuiltInOnJAXBElementList() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInOnJAXBElementList() {
JaxbElementListProperty source = new JaxbElementListProperty(); JaxbElementListProperty source = new JaxbElementListProperty();
source.setProp( createJaxbList( "TEST2" ) ); source.setProp( createJaxbList( "TEST2" ) );
@ -159,7 +159,7 @@ public class BuiltInTest {
@Test @Test
@WithClasses( DateToXmlGregCalMapper.class ) @WithClasses( DateToXmlGregCalMapper.class )
public void shouldApplyBuiltInOnDateToXmlGregCal() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInOnDateToXmlGregCal() throws ParseException {
DateProperty source = new DateProperty(); DateProperty source = new DateProperty();
source.setProp( createDate( "31-08-1982 10:20:56" ) ); source.setProp( createDate( "31-08-1982 10:20:56" ) );
@ -175,7 +175,7 @@ public class BuiltInTest {
@Test @Test
@WithClasses( XmlGregCalToDateMapper.class ) @WithClasses( XmlGregCalToDateMapper.class )
public void shouldApplyBuiltInOnXmlGregCalToDate() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInOnXmlGregCalToDate() throws DatatypeConfigurationException {
XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty(); XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty();
source.setProp( createXmlCal( 1999, 3, 2, 60 ) ); source.setProp( createXmlCal( 1999, 3, 2, 60 ) );
@ -192,7 +192,7 @@ public class BuiltInTest {
@Test @Test
@WithClasses( StringToXmlGregCalMapper.class ) @WithClasses( StringToXmlGregCalMapper.class )
public void shouldApplyBuiltInStringToXmlGregCal() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInStringToXmlGregCal() {
StringProperty source = new StringProperty(); StringProperty source = new StringProperty();
source.setProp( "05.07.1999" ); source.setProp( "05.07.1999" );
@ -227,7 +227,7 @@ public class BuiltInTest {
@Test @Test
@WithClasses( XmlGregCalToStringMapper.class ) @WithClasses( XmlGregCalToStringMapper.class )
public void shouldApplyBuiltInXmlGregCalToString() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInXmlGregCalToString() throws DatatypeConfigurationException {
XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty(); XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty();
source.setProp( createXmlCal( 1999, 3, 2, 60 ) ); source.setProp( createXmlCal( 1999, 3, 2, 60 ) );
@ -254,7 +254,7 @@ public class BuiltInTest {
@Test @Test
@WithClasses( CalendarToXmlGregCalMapper.class ) @WithClasses( CalendarToXmlGregCalMapper.class )
public void shouldApplyBuiltInOnCalendarToXmlGregCal() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInOnCalendarToXmlGregCal() throws ParseException {
CalendarProperty source = new CalendarProperty(); CalendarProperty source = new CalendarProperty();
source.setProp( createCalendar( "02.03.1999" ) ); source.setProp( createCalendar( "02.03.1999" ) );
@ -270,7 +270,7 @@ public class BuiltInTest {
@Test @Test
@WithClasses( XmlGregCalToCalendarMapper.class ) @WithClasses( XmlGregCalToCalendarMapper.class )
public void shouldApplyBuiltInOnXmlGregCalToCalendar() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInOnXmlGregCalToCalendar() throws DatatypeConfigurationException {
XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty(); XmlGregorianCalendarProperty source = new XmlGregorianCalendarProperty();
source.setProp( createXmlCal( 1999, 3, 2, 60 ) ); source.setProp( createXmlCal( 1999, 3, 2, 60 ) );
@ -288,7 +288,7 @@ public class BuiltInTest {
@Test @Test
@WithClasses( CalendarToDateMapper.class ) @WithClasses( CalendarToDateMapper.class )
public void shouldApplyBuiltInOnCalendarToDate() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInOnCalendarToDate() throws ParseException {
CalendarProperty source = new CalendarProperty(); CalendarProperty source = new CalendarProperty();
source.setProp( createCalendar( "02.03.1999" ) ); source.setProp( createCalendar( "02.03.1999" ) );
@ -304,7 +304,7 @@ public class BuiltInTest {
@Test @Test
@WithClasses( DateToCalendarMapper.class ) @WithClasses( DateToCalendarMapper.class )
public void shouldApplyBuiltInOnDateToCalendar() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInOnDateToCalendar() throws ParseException {
DateProperty source = new DateProperty(); DateProperty source = new DateProperty();
source.setProp( new SimpleDateFormat( "dd.MM.yyyy" ).parse( "02.03.1999" ) ); source.setProp( new SimpleDateFormat( "dd.MM.yyyy" ).parse( "02.03.1999" ) );
@ -321,7 +321,7 @@ public class BuiltInTest {
@Test @Test
@WithClasses( CalendarToStringMapper.class ) @WithClasses( CalendarToStringMapper.class )
public void shouldApplyBuiltInOnCalendarToString() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInOnCalendarToString() throws ParseException {
CalendarProperty source = new CalendarProperty(); CalendarProperty source = new CalendarProperty();
source.setProp( createCalendar( "02.03.1999" ) ); source.setProp( createCalendar( "02.03.1999" ) );
@ -337,7 +337,7 @@ public class BuiltInTest {
@Test @Test
@WithClasses( StringToCalendarMapper.class ) @WithClasses( StringToCalendarMapper.class )
public void shouldApplyBuiltInOnStringToCalendar() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInOnStringToCalendar() throws ParseException {
StringProperty source = new StringProperty(); StringProperty source = new StringProperty();
source.setProp( "02.03.1999" ); source.setProp( "02.03.1999" );
@ -354,11 +354,11 @@ public class BuiltInTest {
@Test @Test
@WithClasses( IterableSourceTargetMapper.class ) @WithClasses( IterableSourceTargetMapper.class )
public void shouldApplyBuiltInOnIterable() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInOnIterable() throws DatatypeConfigurationException {
IterableSource source = new IterableSource(); IterableSource source = new IterableSource();
source.setDates( Arrays.asList( new XMLGregorianCalendar[] { createXmlCal( 1999, 3, 2, 60 ) } ) ); source.setDates( Arrays.asList( createXmlCal( 1999, 3, 2, 60 ) ) );
source.publicDates = Arrays.asList( new XMLGregorianCalendar[] { createXmlCal( 2016, 3, 2, 60 ) } ); source.publicDates = Arrays.asList( createXmlCal( 2016, 3, 2, 60 ) );
IterableTarget target = IterableSourceTargetMapper.INSTANCE.sourceToTarget( source ); IterableTarget target = IterableSourceTargetMapper.INSTANCE.sourceToTarget( source );
assertThat( target ).isNotNull(); assertThat( target ).isNotNull();
@ -368,12 +368,12 @@ public class BuiltInTest {
@Test @Test
@WithClasses( MapSourceTargetMapper.class ) @WithClasses( MapSourceTargetMapper.class )
public void shouldApplyBuiltInOnMap() throws ParseException, DatatypeConfigurationException { public void shouldApplyBuiltInOnMap() throws DatatypeConfigurationException {
MapSource source = new MapSource(); MapSource source = new MapSource();
source.setExample( new HashMap<JAXBElement<String>, XMLGregorianCalendar>() ); source.setExample( new HashMap<>() );
source.getExample().put( createJaxb( "TEST" ), createXmlCal( 1999, 3, 2, 60 ) ); source.getExample().put( createJaxb( "TEST" ), createXmlCal( 1999, 3, 2, 60 ) );
source.publicExample = new HashMap<JAXBElement<String>, XMLGregorianCalendar>(); source.publicExample = new HashMap<>();
source.publicExample.put( createJaxb( "TEST" ), createXmlCal( 2016, 3, 2, 60 ) ); source.publicExample.put( createJaxb( "TEST" ), createXmlCal( 2016, 3, 2, 60 ) );
MapTarget target = MapSourceTargetMapper.INSTANCE.sourceToTarget( source ); MapTarget target = MapSourceTargetMapper.INSTANCE.sourceToTarget( source );
@ -417,11 +417,11 @@ public class BuiltInTest {
} }
private JAXBElement<String> createJaxb(String test) { private JAXBElement<String> createJaxb(String test) {
return new JAXBElement<String>( new QName( "www.mapstruct.org", "test" ), String.class, test ); return new JAXBElement<>( new QName( "www.mapstruct.org", "test" ), String.class, test );
} }
private List<JAXBElement<String>> createJaxbList(String test) { private List<JAXBElement<String>> createJaxbList(String test) {
List<JAXBElement<String>> result = new ArrayList<JAXBElement<String>>(); List<JAXBElement<String>> result = new ArrayList<>();
result.add( createJaxb( test ) ); result.add( createJaxb( test ) );
return result; return result;
} }

View File

@ -68,7 +68,7 @@ public class CallbackMethodTest {
@Test @Test
public void callbackMethodsForIterableMappingWithResultParamCalled() { public void callbackMethodsForIterableMappingWithResultParamCalled() {
SourceTargetCollectionMapper.INSTANCE.sourceToTarget( SourceTargetCollectionMapper.INSTANCE.sourceToTarget(
Arrays.asList( createSource() ), new ArrayList<Target>() ); Arrays.asList( createSource() ), new ArrayList<>() );
assertIterableMappingInvocations( ClassContainingCallbacks.getInvocations() ); assertIterableMappingInvocations( ClassContainingCallbacks.getInvocations() );
assertIterableMappingInvocations( BaseMapper.getInvocations() ); assertIterableMappingInvocations( BaseMapper.getInvocations() );
@ -86,7 +86,7 @@ public class CallbackMethodTest {
public void callbackMethodsForMapMappingWithResultParamCalled() { public void callbackMethodsForMapMappingWithResultParamCalled() {
SourceTargetCollectionMapper.INSTANCE.sourceToTarget( SourceTargetCollectionMapper.INSTANCE.sourceToTarget(
toMap( "foo", createSource() ), toMap( "foo", createSource() ),
new HashMap<String, Target>() ); new HashMap<>() );
assertMapMappingInvocations( ClassContainingCallbacks.getInvocations() ); assertMapMappingInvocations( ClassContainingCallbacks.getInvocations() );
assertMapMappingInvocations( BaseMapper.getInvocations() ); assertMapMappingInvocations( BaseMapper.getInvocations() );
@ -173,7 +173,7 @@ public class CallbackMethodTest {
} }
private <T> Map<String, T> toMap(String string, T value) { private <T> Map<String, T> toMap(String string, T value) {
Map<String, T> result = new HashMap<String, T>(); Map<String, T> result = new HashMap<>();
result.put( string, value ); result.put( string, value );
return result; return result;
} }
@ -191,7 +191,7 @@ public class CallbackMethodTest {
} }
private List<Invocation> beanMappingInvocationList(Object source, Object target, Object emptyTarget) { private List<Invocation> beanMappingInvocationList(Object source, Object target, Object emptyTarget) {
List<Invocation> invocations = new ArrayList<Invocation>(); List<Invocation> invocations = new ArrayList<>();
invocations.addAll( allBeforeMappingMethods( source, emptyTarget, Target.class ) ); invocations.addAll( allBeforeMappingMethods( source, emptyTarget, Target.class ) );
invocations.addAll( allAfterMappingMethods( source, target, Target.class ) ); invocations.addAll( allAfterMappingMethods( source, target, Target.class ) );
@ -200,7 +200,7 @@ public class CallbackMethodTest {
} }
private List<Invocation> allAfterMappingMethods(Object source, Object target, Class<?> targetClass) { private List<Invocation> allAfterMappingMethods(Object source, Object target, Class<?> targetClass) {
return new ArrayList<Invocation>( Arrays.asList( return new ArrayList<>( Arrays.asList(
new Invocation( "noArgsAfterMapping" ), new Invocation( "noArgsAfterMapping" ),
new Invocation( "withSourceAfterMapping", source ), new Invocation( "withSourceAfterMapping", source ),
new Invocation( "withSourceAsObjectAfterMapping", source ), new Invocation( "withSourceAsObjectAfterMapping", source ),
@ -211,7 +211,7 @@ public class CallbackMethodTest {
} }
private List<Invocation> allBeforeMappingMethods(Object source, Object emptyTarget, Class<?> targetClass) { private List<Invocation> allBeforeMappingMethods(Object source, Object emptyTarget, Class<?> targetClass) {
return new ArrayList<Invocation>( Arrays.asList( return new ArrayList<>( Arrays.asList(
new Invocation( "noArgsBeforeMapping" ), new Invocation( "noArgsBeforeMapping" ),
new Invocation( "withSourceBeforeMapping", source ), new Invocation( "withSourceBeforeMapping", source ),
new Invocation( "withSourceAsObjectBeforeMapping", source ), new Invocation( "withSourceAsObjectBeforeMapping", source ),
@ -226,7 +226,7 @@ public class CallbackMethodTest {
} }
private List<Invocation> allQualifiedCallbackMethods(Object source, Object target) { private List<Invocation> allQualifiedCallbackMethods(Object source, Object target) {
List<Invocation> invocations = new ArrayList<Invocation>(); List<Invocation> invocations = new ArrayList<>();
invocations.add( new Invocation( "withSourceBeforeMappingQualified", source ) ); invocations.add( new Invocation( "withSourceBeforeMappingQualified", source ) );
if ( source instanceof List || source instanceof Map ) { if ( source instanceof List || source instanceof Map ) {

View File

@ -62,13 +62,10 @@ public class Invocation {
return false; return false;
} }
if ( methodName == null ) { if ( methodName == null ) {
if ( other.methodName != null ) { return other.methodName == null;
return false;
} }
else {
return methodName.equals( other.methodName );
} }
else if ( !methodName.equals( other.methodName ) ) {
return false;
}
return true;
} }
} }

View File

@ -40,14 +40,11 @@ public class Source {
} }
Source other = (Source) obj; Source other = (Source) obj;
if ( foo == null ) { if ( foo == null ) {
if ( other.foo != null ) { return other.foo == null;
return false;
} }
else {
return foo.equals( other.foo );
} }
else if ( !foo.equals( other.foo ) ) {
return false;
}
return true;
} }
@Override @Override

View File

@ -40,14 +40,11 @@ public class Target {
} }
Target other = (Target) obj; Target other = (Target) obj;
if ( foo == null ) { if ( foo == null ) {
if ( other.foo != null ) { return other.foo == null;
return false;
} }
else {
return foo.equals( other.foo );
} }
else if ( !foo.equals( other.foo ) ) {
return false;
}
return true;
} }
@Override @Override

View File

@ -17,9 +17,9 @@ public class CompanyMapperPostProcessing {
@AfterMapping @AfterMapping
public void toAddressDto(Address address, @MappingTarget AddressDto addressDto) { public void toAddressDto(Address address, @MappingTarget AddressDto addressDto) {
String addressLine = address.getAddressLine(); String addressLine = address.getAddressLine();
int seperatorIndex = addressLine.indexOf( ";" ); int separatorIndex = addressLine.indexOf( ";" );
addressDto.setStreet( addressLine.substring( 0, seperatorIndex ) ); addressDto.setStreet( addressLine.substring( 0, separatorIndex ) );
String houseNumber = addressLine.substring( seperatorIndex + 1, addressLine.length() ); String houseNumber = addressLine.substring( separatorIndex + 1 );
addressDto.setHouseNumber( Integer.parseInt( houseNumber ) ); addressDto.setHouseNumber( Integer.parseInt( houseNumber ) );
} }

View File

@ -44,7 +44,7 @@ public class MappingResultPostprocessorTest {
Employee employee = new Employee(); Employee employee = new Employee();
employee.setAddress( address ); employee.setAddress( address );
Company company = new Company(); Company company = new Company();
company.setEmployees( Arrays.asList( new Employee[] { employee } ) ); company.setEmployees( Arrays.asList( employee ) );
// test // test
CompanyDto companyDto = CompanyMapper.INSTANCE.toCompanyDto( company ); CompanyDto companyDto = CompanyMapper.INSTANCE.toCompanyDto( company );

View File

@ -42,7 +42,7 @@ public class CallbacksWithReturnValuesTest {
@Test @Test
public void mappingWithContextCorrectlyResolvesCycles() { public void mappingWithContextCorrectlyResolvesCycles() {
final AtomicReference<Integer> contextLevel = new AtomicReference<Integer>( null ); final AtomicReference<Integer> contextLevel = new AtomicReference<>( null );
ContextListener contextListener = new ContextListener() { ContextListener contextListener = new ContextListener() {
@Override @Override
public void methodCalled(Integer level, String method, Object source, Object target) { public void methodCalled(Integer level, String method, Object source, Object target) {

View File

@ -9,6 +9,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
@ -36,7 +37,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
public class CarMapperTest { public class CarMapperTest {
@Test @Test
public void shouldProvideMapperInstance() throws Exception { public void shouldProvideMapperInstance() {
assertThat( CarMapper.INSTANCE ).isNotNull(); assertThat( CarMapper.INSTANCE ).isNotNull();
} }
@ -46,9 +47,9 @@ public class CarMapperTest {
Car car = new Car( Car car = new Car(
"Morris", "Morris",
2, 2,
new GregorianCalendar( 1980, 0, 1 ).getTime(), new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime(),
new Person( "Bob" ), new Person( "Bob" ),
new ArrayList<Person>() new ArrayList<>()
); );
//when //when
@ -65,9 +66,9 @@ public class CarMapperTest {
Car car = new Car( Car car = new Car(
"Morris", "Morris",
2, 2,
new GregorianCalendar( 1980, 0, 1 ).getTime(), new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime(),
new Person( "Bob" ), new Person( "Bob" ),
new ArrayList<Person>() new ArrayList<>()
); );
//when //when
@ -82,7 +83,7 @@ public class CarMapperTest {
@Test @Test
public void shouldReverseMapReferenceAttribute() { public void shouldReverseMapReferenceAttribute() {
//given //given
CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<PersonDto>() ); CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<>() );
//when //when
Car car = CarMapper.INSTANCE.carDtoToCar( carDto ); Car car = CarMapper.INSTANCE.carDtoToCar( carDto );
@ -99,9 +100,9 @@ public class CarMapperTest {
Car car = new Car( Car car = new Car(
"Morris", "Morris",
2, 2,
new GregorianCalendar( 1980, 0, 1 ).getTime(), new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime(),
new Person( "Bob" ), new Person( "Bob" ),
new ArrayList<Person>() new ArrayList<>()
); );
//when //when
@ -115,7 +116,7 @@ public class CarMapperTest {
@Test @Test
public void shouldConsiderCustomMappingForReverseMapping() { public void shouldConsiderCustomMappingForReverseMapping() {
//given //given
CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<PersonDto>() ); CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<>() );
//when //when
Car car = CarMapper.INSTANCE.carDtoToCar( carDto ); Car car = CarMapper.INSTANCE.carDtoToCar( carDto );
@ -131,9 +132,9 @@ public class CarMapperTest {
Car car = new Car( Car car = new Car(
"Morris", "Morris",
2, 2,
new GregorianCalendar( 1980, 0, 1 ).getTime(), new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime(),
new Person( "Bob" ), new Person( "Bob" ),
new ArrayList<Person>() new ArrayList<>()
); );
//when //when
@ -147,14 +148,16 @@ public class CarMapperTest {
@Test @Test
public void shouldApplyConverterForReverseMapping() { public void shouldApplyConverterForReverseMapping() {
//given //given
CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<PersonDto>() ); CarDto carDto = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<>() );
//when //when
Car car = CarMapper.INSTANCE.carDtoToCar( carDto ); Car car = CarMapper.INSTANCE.carDtoToCar( carDto );
//then //then
assertThat( car ).isNotNull(); 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 @Test
@ -163,20 +166,20 @@ public class CarMapperTest {
Car car1 = new Car( Car car1 = new Car(
"Morris", "Morris",
2, 2,
new GregorianCalendar( 1980, 0, 1 ).getTime(), new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime(),
new Person( "Bob" ), new Person( "Bob" ),
new ArrayList<Person>() new ArrayList<>()
); );
Car car2 = new Car( Car car2 = new Car(
"Railton", "Railton",
4, 4,
new GregorianCalendar( 1934, 0, 1 ).getTime(), new GregorianCalendar( 1934, Calendar.JANUARY, 1 ).getTime(),
new Person( "Bill" ), new Person( "Bill" ),
new ArrayList<Person>() new ArrayList<>()
); );
//when //when
List<CarDto> dtos = CarMapper.INSTANCE.carsToCarDtos( new ArrayList<Car>( Arrays.asList( car1, car2 ) ) ); List<CarDto> dtos = CarMapper.INSTANCE.carsToCarDtos( Arrays.asList( car1, car2 ) );
//then //then
assertThat( dtos ).isNotNull(); assertThat( dtos ).isNotNull();
@ -196,11 +199,11 @@ public class CarMapperTest {
@Test @Test
public void shouldReverseMapIterable() { public void shouldReverseMapIterable() {
//given //given
CarDto car1 = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<PersonDto>() ); CarDto car1 = new CarDto( "Morris", 2, "1980", new PersonDto( "Bob" ), new ArrayList<>() );
CarDto car2 = new CarDto( "Railton", 4, "1934", new PersonDto( "Bill" ), new ArrayList<PersonDto>() ); CarDto car2 = new CarDto( "Railton", 4, "1934", new PersonDto( "Bill" ), new ArrayList<>() );
//when //when
List<Car> cars = CarMapper.INSTANCE.carDtosToCars( new ArrayList<CarDto>( Arrays.asList( car1, car2 ) ) ); List<Car> cars = CarMapper.INSTANCE.carDtosToCars( Arrays.asList( car1, car2 ) );
//then //then
assertThat( cars ).isNotNull(); assertThat( cars ).isNotNull();
@ -208,12 +211,16 @@ public class CarMapperTest {
assertThat( cars.get( 0 ).getMake() ).isEqualTo( "Morris" ); assertThat( cars.get( 0 ).getMake() ).isEqualTo( "Morris" );
assertThat( cars.get( 0 ).getNumberOfSeats() ).isEqualTo( 2 ); 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( 0 ).getDriver().getName() ).isEqualTo( "Bob" );
assertThat( cars.get( 1 ).getMake() ).isEqualTo( "Railton" ); assertThat( cars.get( 1 ).getMake() ).isEqualTo( "Railton" );
assertThat( cars.get( 1 ).getNumberOfSeats() ).isEqualTo( 4 ); 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" ); assertThat( cars.get( 1 ).getDriver().getName() ).isEqualTo( "Bill" );
} }
@ -223,9 +230,9 @@ public class CarMapperTest {
Car car = new Car( Car car = new Car(
"Morris", "Morris",
2, 2,
new GregorianCalendar( 1980, 0, 1 ).getTime(), new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime(),
new Person( "Bob" ), new Person( "Bob" ),
new ArrayList<Person>( Arrays.asList( new Person( "Alice" ), new Person( "Bill" ) ) ) Arrays.asList( new Person( "Alice" ), new Person( "Bill" ) )
); );
//when //when
@ -247,7 +254,7 @@ public class CarMapperTest {
2, 2,
"1980", "1980",
new PersonDto( "Bob" ), new PersonDto( "Bob" ),
new ArrayList<PersonDto>( Arrays.asList( new PersonDto( "Alice" ), new PersonDto( "Bill" ) ) ) Arrays.asList( new PersonDto( "Alice" ), new PersonDto( "Bill" ) )
); );
//when //when

View File

@ -21,8 +21,8 @@ public class Node {
public Node(String name) { public Node(String name) {
this.name = name; this.name = name;
this.children = new ArrayList<Node>(); this.children = new ArrayList<>();
this.attributes = new ArrayList<Attribute>(); this.attributes = new ArrayList<>();
} }
public Node getParent() { public Node getParent() {

View File

@ -19,7 +19,7 @@ import org.mapstruct.TargetType;
* @author Andreas Gudian * @author Andreas Gudian
*/ */
public class SelfContainingCycleContext { public class SelfContainingCycleContext {
private Map<Object, Object> knownInstances = new IdentityHashMap<Object, Object>(); private Map<Object, Object> knownInstances = new IdentityHashMap<>();
@BeforeMapping @BeforeMapping
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@ -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+ // See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+
public void shouldApplyDateFormatForConversions() { public void shouldApplyDateFormatForConversions() {
Source source = new Source(); Source source = new Source();
source.setDate( new GregorianCalendar( 2013, 6, 6 ).getTime() ); source.setDate( new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime() );
source.setAnotherDate( new GregorianCalendar( 2013, 1, 14 ).getTime() ); source.setAnotherDate( new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime() );
Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); 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+ // See https://bugs.openjdk.java.net/browse/JDK-8211262, there is a difference in the default formats on Java 9+
public void shouldApplyDateFormatForConversionsJdk11() { public void shouldApplyDateFormatForConversionsJdk11() {
Source source = new Source(); Source source = new Source();
source.setDate( new GregorianCalendar( 2013, 6, 6 ).getTime() ); source.setDate( new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime() );
source.setAnotherDate( new GregorianCalendar( 2013, 1, 14 ).getTime() ); source.setAnotherDate( new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime() );
Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source );
@ -86,8 +86,10 @@ public class DateConversionTest {
Source source = SourceTargetMapper.INSTANCE.targetToSource( target ); Source source = SourceTargetMapper.INSTANCE.targetToSource( target );
assertThat( source ).isNotNull(); assertThat( source ).isNotNull();
assertThat( source.getDate() ).isEqualTo( new GregorianCalendar( 2013, 6, 6 ).getTime() ); assertThat( source.getDate() ).isEqualTo( new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime() );
assertThat( source.getAnotherDate() ).isEqualTo( new GregorianCalendar( 2013, 1, 14, 8, 30 ).getTime() ); assertThat( source.getAnotherDate() ).isEqualTo(
new GregorianCalendar( 2013, Calendar.FEBRUARY, 14, 8, 30 ).getTime()
);
} }
@Test @Test
@ -101,16 +103,18 @@ public class DateConversionTest {
Source source = SourceTargetMapper.INSTANCE.targetToSource( target ); Source source = SourceTargetMapper.INSTANCE.targetToSource( target );
assertThat( source ).isNotNull(); assertThat( source ).isNotNull();
assertThat( source.getDate() ).isEqualTo( new GregorianCalendar( 2013, 6, 6 ).getTime() ); assertThat( source.getDate() ).isEqualTo( new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime() );
assertThat( source.getAnotherDate() ).isEqualTo( new GregorianCalendar( 2013, 1, 14, 8, 30 ).getTime() ); assertThat( source.getAnotherDate() ).isEqualTo(
new GregorianCalendar( 2013, Calendar.FEBRUARY, 14, 8, 30 ).getTime()
);
} }
@Test @Test
public void shouldApplyStringConversionForIterableMethod() { public void shouldApplyStringConversionForIterableMethod() {
List<Date> dates = Arrays.asList( List<Date> dates = Arrays.asList(
new GregorianCalendar( 2013, 6, 6 ).getTime(), new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime(),
new GregorianCalendar( 2013, 1, 14 ).getTime(), new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime(),
new GregorianCalendar( 2013, 3, 11 ).getTime() new GregorianCalendar( 2013, Calendar.APRIL, 11 ).getTime()
); );
List<String> stringDates = SourceTargetMapper.INSTANCE.stringListToDateList( dates ); List<String> stringDates = SourceTargetMapper.INSTANCE.stringListToDateList( dates );
@ -122,9 +126,9 @@ public class DateConversionTest {
@Test @Test
public void shouldApplyStringConversionForArrayMethod() { public void shouldApplyStringConversionForArrayMethod() {
List<Date> dates = Arrays.asList( List<Date> dates = Arrays.asList(
new GregorianCalendar( 2013, 6, 6 ).getTime(), new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime(),
new GregorianCalendar( 2013, 1, 14 ).getTime(), new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime(),
new GregorianCalendar( 2013, 3, 11 ).getTime() new GregorianCalendar( 2013, Calendar.APRIL, 11 ).getTime()
); );
String[] stringDates = SourceTargetMapper.INSTANCE.stringListToDateArray( dates ); String[] stringDates = SourceTargetMapper.INSTANCE.stringListToDateArray( dates );
@ -141,9 +145,9 @@ public class DateConversionTest {
assertThat( dates ).isNotNull(); assertThat( dates ).isNotNull();
assertThat( dates ).containsExactly( assertThat( dates ).containsExactly(
new GregorianCalendar( 2013, 6, 6 ).getTime(), new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime(),
new GregorianCalendar( 2013, 1, 14 ).getTime(), new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime(),
new GregorianCalendar( 2013, 3, 11 ).getTime() new GregorianCalendar( 2013, Calendar.APRIL, 11 ).getTime()
); );
} }
@ -155,18 +159,18 @@ public class DateConversionTest {
assertThat( dates ).isNotNull(); assertThat( dates ).isNotNull();
assertThat( dates ).containsExactly( assertThat( dates ).containsExactly(
new GregorianCalendar( 2013, 6, 6 ).getTime(), new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime(),
new GregorianCalendar( 2013, 1, 14 ).getTime(), new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime(),
new GregorianCalendar( 2013, 3, 11 ).getTime() new GregorianCalendar( 2013, Calendar.APRIL, 11 ).getTime()
); );
} }
@Test @Test
public void shouldApplyStringConversionForReverseArrayArrayMethod() { public void shouldApplyStringConversionForReverseArrayArrayMethod() {
Date[] dates = new Date[]{ Date[] dates = new Date[]{
new GregorianCalendar( 2013, 6, 6 ).getTime(), new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime(),
new GregorianCalendar( 2013, 1, 14 ).getTime(), new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime(),
new GregorianCalendar( 2013, 3, 11 ).getTime() new GregorianCalendar( 2013, Calendar.APRIL, 11 ).getTime()
}; };
String[] stringDates = SourceTargetMapper.INSTANCE.dateArrayToStringArray( dates ); String[] stringDates = SourceTargetMapper.INSTANCE.dateArrayToStringArray( dates );
@ -182,15 +186,15 @@ public class DateConversionTest {
assertThat( dates ).isNotNull(); assertThat( dates ).isNotNull();
assertThat( dates ).isEqualTo( new Date[] { assertThat( dates ).isEqualTo( new Date[] {
new GregorianCalendar( 2013, 6, 6 ).getTime(), new GregorianCalendar( 2013, Calendar.JULY, 6 ).getTime(),
new GregorianCalendar( 2013, 1, 14 ).getTime(), new GregorianCalendar( 2013, Calendar.FEBRUARY, 14 ).getTime(),
new GregorianCalendar( 2013, 3, 11 ).getTime() new GregorianCalendar( 2013, Calendar.APRIL, 11 ).getTime()
} ); } );
} }
@IssueKey("858") @IssueKey("858")
@Test @Test
public void shouldApplyDateToSqlConversion() throws Exception { public void shouldApplyDateToSqlConversion() {
GregorianCalendar time = new GregorianCalendar( 2016, Calendar.AUGUST, 24, 20, 30, 30 ); GregorianCalendar time = new GregorianCalendar( 2016, Calendar.AUGUST, 24, 20, 30, 30 );
GregorianCalendar sqlDate = new GregorianCalendar( 2016, Calendar.AUGUST, 23, 21, 35, 35 ); GregorianCalendar sqlDate = new GregorianCalendar( 2016, Calendar.AUGUST, 23, 21, 35, 35 );
GregorianCalendar timestamp = new GregorianCalendar( 2016, Calendar.AUGUST, 22, 21, 35, 35 ); GregorianCalendar timestamp = new GregorianCalendar( 2016, Calendar.AUGUST, 22, 21, 35, 35 );
@ -212,7 +216,7 @@ public class DateConversionTest {
@IssueKey("858") @IssueKey("858")
@Test @Test
public void shouldApplySqlToDateConversion() throws Exception { public void shouldApplySqlToDateConversion() {
Target target = new Target(); Target target = new Target();
GregorianCalendar time = new GregorianCalendar( 2016, Calendar.AUGUST, 24, 20, 30, 30 ); GregorianCalendar time = new GregorianCalendar( 2016, Calendar.AUGUST, 24, 20, 30, 30 );
GregorianCalendar sqlDate = new GregorianCalendar( 2016, Calendar.AUGUST, 23, 21, 35, 35 ); GregorianCalendar sqlDate = new GregorianCalendar( 2016, Calendar.AUGUST, 23, 21, 35, 35 );

View File

@ -35,7 +35,7 @@ public class CharConversionTest {
@Test @Test
public void shouldApplyReverseCharConversion() { public void shouldApplyReverseCharConversion() {
CharTarget target = new CharTarget(); CharTarget target = new CharTarget();
target.setC( Character.valueOf( 'G' ) ); target.setC( 'G' );
CharSource source = CharMapper.INSTANCE.targetToSource( target ); CharSource source = CharMapper.INSTANCE.targetToSource( target );

View File

@ -43,7 +43,7 @@ public class DecoratorTest {
public void shouldInvokeDecoratorMethods() { public void shouldInvokeDecoratorMethods() {
//given //given
Calendar birthday = Calendar.getInstance(); 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" ) ); Person person = new Person( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) );
//when //when
@ -99,7 +99,7 @@ public class DecoratorTest {
public void shouldApplyDecoratorWithDefaultConstructor() { public void shouldApplyDecoratorWithDefaultConstructor() {
//given //given
Calendar birthday = Calendar.getInstance(); 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" ) ); Person person = new Person( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) );
//when //when
@ -120,7 +120,7 @@ public class DecoratorTest {
public void shouldApplyDelegateToClassBasedMapper() { public void shouldApplyDelegateToClassBasedMapper() {
//given //given
Calendar birthday = Calendar.getInstance(); 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" ) ); Person person = new Person2( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) );
@ -150,7 +150,7 @@ public class DecoratorTest {
public void shouldApplyCustomMappers() { public void shouldApplyCustomMappers() {
//given //given
Calendar birthday = Calendar.getInstance(); 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" ) ); Person2 person = new Person2( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) );
person.setEmployer( new Employer( "ACME" ) ); person.setEmployer( new Employer( "ACME" ) );
person.setSportsClub( new SportsClub( "SC Duckburg" ) ); person.setSportsClub( new SportsClub( "SC Duckburg" ) );

View File

@ -78,7 +78,7 @@ public class Jsr330DecoratorTest {
@Test @Test
public void shouldInvokeDecoratorMethods() { public void shouldInvokeDecoratorMethods() {
Calendar birthday = Calendar.getInstance(); 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" ) ); Person person = new Person( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) );
PersonDto personDto = personMapper.personToPersonDto( person ); PersonDto personDto = personMapper.personToPersonDto( person );

View File

@ -66,7 +66,7 @@ public class SpringDecoratorTest {
public void shouldInvokeDecoratorMethods() { public void shouldInvokeDecoratorMethods() {
//given //given
Calendar birthday = Calendar.getInstance(); 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" ) ); Person person = new Person( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) );
//when //when

View File

@ -66,7 +66,7 @@ public class SpringDecoratorTest {
public void shouldInvokeDecoratorMethods() { public void shouldInvokeDecoratorMethods() {
//given //given
Calendar birthday = Calendar.getInstance(); 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" ) ); Person person = new Person( "Gary", "Crant", birthday.getTime(), new Address( "42 Ocean View Drive" ) );
//when //when