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

View File

@ -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 ) );

View File

@ -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<String>(), "-" ) ).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<String>() ) ).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<String>() ) ).isEqualTo( "intArray" );
assertThat( Strings.getSafeVariableName( "Extends", new ArrayList<String>() ) ).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" )

View File

@ -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" );

View File

@ -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

View File

@ -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<String> manuallyConverted = new Holder<String>( "What is the answer?" );
private final Holder<String> manuallyConverted = new Holder<>( "What is the answer?" );
public Source() {
publicSize = 191;

View File

@ -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

View File

@ -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<JAXBElement<String>, XMLGregorianCalendar>() );
source.setExample( new HashMap<>() );
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 ) );
MapTarget target = MapSourceTargetMapper.INSTANCE.sourceToTarget( source );
@ -417,11 +417,11 @@ public class BuiltInTest {
}
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) {
List<JAXBElement<String>> result = new ArrayList<JAXBElement<String>>();
List<JAXBElement<String>> result = new ArrayList<>();
result.add( createJaxb( test ) );
return result;
}

View File

@ -68,7 +68,7 @@ public class CallbackMethodTest {
@Test
public void callbackMethodsForIterableMappingWithResultParamCalled() {
SourceTargetCollectionMapper.INSTANCE.sourceToTarget(
Arrays.asList( createSource() ), new ArrayList<Target>() );
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<String, Target>() );
new HashMap<>() );
assertMapMappingInvocations( ClassContainingCallbacks.getInvocations() );
assertMapMappingInvocations( BaseMapper.getInvocations() );
@ -173,7 +173,7 @@ public class CallbackMethodTest {
}
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 );
return result;
}
@ -191,7 +191,7 @@ public class CallbackMethodTest {
}
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( allAfterMappingMethods( source, target, Target.class ) );
@ -200,7 +200,7 @@ public class CallbackMethodTest {
}
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( "withSourceAfterMapping", source ),
new Invocation( "withSourceAsObjectAfterMapping", source ),
@ -211,7 +211,7 @@ public class CallbackMethodTest {
}
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( "withSourceBeforeMapping", source ),
new Invocation( "withSourceAsObjectBeforeMapping", source ),
@ -226,7 +226,7 @@ public class CallbackMethodTest {
}
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 ) );
if ( source instanceof List || source instanceof Map ) {

View File

@ -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;
}
}

View File

@ -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

View File

@ -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

View File

@ -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 ) );
}

View File

@ -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 );

View File

@ -42,7 +42,7 @@ public class CallbacksWithReturnValuesTest {
@Test
public void mappingWithContextCorrectlyResolvesCycles() {
final AtomicReference<Integer> contextLevel = new AtomicReference<Integer>( null );
final AtomicReference<Integer> contextLevel = new AtomicReference<>( null );
ContextListener contextListener = new ContextListener() {
@Override
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.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<Person>()
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<Person>()
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<PersonDto>() );
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<Person>()
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<PersonDto>() );
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<Person>()
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<PersonDto>() );
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<Person>()
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<Person>()
new ArrayList<>()
);
//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
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<PersonDto>() );
CarDto car2 = new CarDto( "Railton", 4, "1934", new PersonDto( "Bill" ), 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<>() );
//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
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<Person>( 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<PersonDto>( Arrays.asList( new PersonDto( "Alice" ), new PersonDto( "Bill" ) ) )
Arrays.asList( new PersonDto( "Alice" ), new PersonDto( "Bill" ) )
);
//when

View File

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

View File

@ -19,7 +19,7 @@ import org.mapstruct.TargetType;
* @author Andreas Gudian
*/
public class SelfContainingCycleContext {
private Map<Object, Object> knownInstances = new IdentityHashMap<Object, Object>();
private Map<Object, Object> knownInstances = new IdentityHashMap<>();
@BeforeMapping
@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+
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<Date> 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<String> stringDates = SourceTargetMapper.INSTANCE.stringListToDateList( dates );
@ -122,9 +126,9 @@ public class DateConversionTest {
@Test
public void shouldApplyStringConversionForArrayMethod() {
List<Date> 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 );

View File

@ -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 );

View File

@ -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" ) );

View File

@ -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 );

View File

@ -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

View File

@ -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