diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/CollectionMappingTest.java b/processor/src/test/java/org/mapstruct/ap/test/collection/CollectionMappingTest.java index 8f752ec49..d67df4a98 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/CollectionMappingTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/CollectionMappingTest.java @@ -113,7 +113,7 @@ public class CollectionMappingTest { assertThat( source.getOtherStringList() ).containsExactly( "Bob", "Alice" ); // prepare a test list to monitor add all behaviour - List testList = new TestList(); + List testList = new TestList<>(); testList.addAll( target.getOtherStringList() ); TestList.setAddAllCalled( false ); target.setOtherStringList( testList ); @@ -146,7 +146,7 @@ public class CollectionMappingTest { @IssueKey("6") public void shouldMapArrayList() { Source source = new Source(); - source.setStringArrayList( new ArrayList( Arrays.asList( "Bob", "Alice" ) ) ); + source.setStringArrayList( new ArrayList<>( Arrays.asList( "Bob", "Alice" ) ) ); Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); @@ -158,7 +158,7 @@ public class CollectionMappingTest { @IssueKey("6") public void shouldReverseMapArrayList() { Target target = new Target(); - target.setStringArrayList( new ArrayList( Arrays.asList( "Bob", "Alice" ) ) ); + target.setStringArrayList( new ArrayList<>( Arrays.asList( "Bob", "Alice" ) ) ); Source source = SourceTargetMapper.INSTANCE.targetToSource( target ); @@ -170,7 +170,7 @@ public class CollectionMappingTest { @IssueKey("6") public void shouldMapSet() { Source source = new Source(); - source.setStringSet( new HashSet( Arrays.asList( "Bob", "Alice" ) ) ); + source.setStringSet( new HashSet<>( Arrays.asList( "Bob", "Alice" ) ) ); Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); @@ -182,7 +182,7 @@ public class CollectionMappingTest { @IssueKey("6") public void shouldReverseMapSet() { Target target = new Target(); - target.setStringSet( new HashSet( Arrays.asList( "Bob", "Alice" ) ) ); + target.setStringSet( new HashSet<>( Arrays.asList( "Bob", "Alice" ) ) ); Source source = SourceTargetMapper.INSTANCE.targetToSource( target ); @@ -194,7 +194,7 @@ public class CollectionMappingTest { @IssueKey("6") public void shouldMapSetAsCopy() { Source source = new Source(); - source.setStringSet( new HashSet( Arrays.asList( "Bob", "Alice" ) ) ); + source.setStringSet( new HashSet<>( Arrays.asList( "Bob", "Alice" ) ) ); Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); target.getStringSet().add( "Bill" ); @@ -206,7 +206,7 @@ public class CollectionMappingTest { @IssueKey("6") public void shouldMapHashSetAsCopy() { Source source = new Source(); - source.setStringHashSet( new HashSet( Arrays.asList( "Bob", "Alice" ) ) ); + source.setStringHashSet( new HashSet<>( Arrays.asList( "Bob", "Alice" ) ) ); Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); target.getStringHashSet().add( "Bill" ); @@ -218,7 +218,7 @@ public class CollectionMappingTest { @IssueKey("6") public void shouldReverseMapSetAsCopy() { Target target = new Target(); - target.setStringSet( new HashSet( Arrays.asList( "Bob", "Alice" ) ) ); + target.setStringSet( new HashSet<>( Arrays.asList( "Bob", "Alice" ) ) ); Source source = SourceTargetMapper.INSTANCE.targetToSource( target ); source.getStringSet().add( "Bill" ); @@ -254,7 +254,7 @@ public class CollectionMappingTest { @IssueKey("6") public void shouldMapIntegerSetToRawSet() { Source source = new Source(); - source.setIntegerSet( new HashSet( Arrays.asList( 1, 2 ) ) ); + source.setIntegerSet( new HashSet<>( Arrays.asList( 1, 2 ) ) ); Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); @@ -266,7 +266,7 @@ public class CollectionMappingTest { @IssueKey("6") public void shouldMapIntegerSetToStringSet() { Source source = new Source(); - source.setAnotherIntegerSet( new HashSet( Arrays.asList( 1, 2 ) ) ); + source.setAnotherIntegerSet( new HashSet<>( Arrays.asList( 1, 2 ) ) ); Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); @@ -278,7 +278,7 @@ public class CollectionMappingTest { @IssueKey("6") public void shouldReverseMapIntegerSetToStringSet() { Target target = new Target(); - target.setAnotherStringSet( new HashSet( Arrays.asList( "1", "2" ) ) ); + target.setAnotherStringSet( new HashSet<>( Arrays.asList( "1", "2" ) ) ); Source source = SourceTargetMapper.INSTANCE.targetToSource( target ); @@ -302,7 +302,7 @@ public class CollectionMappingTest { @IssueKey("6") public void shouldReverseMapSetOfEnumToStringSet() { Target target = new Target(); - target.setColours( new HashSet( Arrays.asList( "BLUE", "GREEN" ) ) ); + target.setColours( new HashSet<>( Arrays.asList( "BLUE", "GREEN" ) ) ); Source source = SourceTargetMapper.INSTANCE.targetToSource( target ); @@ -314,7 +314,7 @@ public class CollectionMappingTest { public void shouldMapMapAsCopy() { Source source = new Source(); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put( "Bob", 123L ); map.put( "Alice", 456L ); source.setStringLongMap( map ); @@ -331,7 +331,7 @@ public class CollectionMappingTest { public void shouldMapMapWithClearAndPutAll() { Source source = new Source(); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put( "Bob", 123L ); map.put( "Alice", 456L ); source.setOtherStringLongMap( map ); @@ -345,7 +345,7 @@ public class CollectionMappingTest { source.getOtherStringLongMap().remove( "Alice" ); // prepare a test list to monitor add all behaviour - Map originalInstance = new TestMap(); + Map originalInstance = new TestMap<>(); originalInstance.putAll( target.getOtherStringLongMap() ); TestMap.setPuttAllCalled( false ); target.setOtherStringLongMap( originalInstance ); @@ -362,7 +362,7 @@ public class CollectionMappingTest { @IssueKey("87") public void shouldMapIntegerSetToNumberSet() { Set numbers = SourceTargetMapper.INSTANCE - .integerSetToNumberSet( new HashSet( Arrays.asList( 123, 456 ) ) ); + .integerSetToNumberSet( new HashSet<>( Arrays.asList( 123, 456 ) ) ); assertThat( numbers ).isNotNull(); assertThat( numbers ).containsOnly( 123, 456 ); @@ -385,7 +385,7 @@ public class CollectionMappingTest { @IssueKey("853") public void shouldMapNonGenericList() { Source source = new Source(); - source.setStringList3( new ArrayList( Arrays.asList( "Bob", "Alice" ) ) ); + source.setStringList3( new ArrayList<>( Arrays.asList( "Bob", "Alice" ) ) ); Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); @@ -406,12 +406,11 @@ public class CollectionMappingTest { assertThat( mappedSource.getStringList3() ).containsExactly( "Bill", "Bob" ); } - @SuppressWarnings("unchecked") @Test @IssueKey("853") public void shouldMapNonGenericMap() { Source source = new Source(); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put( "Bob", 123L ); map.put( "Alice", 456L ); source.setStringLongMapForNonGeneric( map ); diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/StringHolder.java b/processor/src/test/java/org/mapstruct/ap/test/collection/StringHolder.java index 36cb8f38d..af3539ff9 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/StringHolder.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/StringHolder.java @@ -41,13 +41,10 @@ public class StringHolder { } StringHolder other = (StringHolder) obj; if ( string == null ) { - if ( other.string != null ) { - return false; - } + return other.string == null; } - else if ( !string.equals( other.string ) ) { - return false; + else { + return string.equals( other.string ); } - return true; } } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/Target.java b/processor/src/test/java/org/mapstruct/ap/test/collection/Target.java index e4e445962..51a1eddda 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/Target.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/Target.java @@ -144,14 +144,14 @@ public class Target { public List getStringListNoSetter() { if ( stringListNoSetter == null ) { - stringListNoSetter = new ArrayList(); + stringListNoSetter = new ArrayList<>(); } return stringListNoSetter; } public List getStringListNoSetter2() { if ( stringListNoSetter2 == null ) { - stringListNoSetter2 = new ArrayList(); + stringListNoSetter2 = new ArrayList<>(); } return stringListNoSetter2; } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/AdderTest.java b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/AdderTest.java index 1507f5639..3398a99d7 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/AdderTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/AdderTest.java @@ -117,14 +117,14 @@ public class AdderTest { @IssueKey("241") @Test - public void testAddwithExistingTarget() throws DogException { + public void testAddWithExistingTarget() { AdderUsageObserver.setUsed( false ); Source source = new Source(); source.setPets( Arrays.asList( "mouse" ) ); Target target = new Target(); - target.setPets( new ArrayList( Arrays.asList( 1L ) ) ); + target.setPets( new ArrayList<>( Arrays.asList( 1L ) ) ); SourceTargetMapper.INSTANCE.toExistingTarget( source, target ); assertThat( target ).isNotNull(); @@ -178,7 +178,7 @@ public class AdderTest { } @Test - public void testshouldFallBackToDaliSingularInAbsenseOfHumanSingular() { + public void testShouldFallBackToDaliSingularInAbsenseOfHumanSingular() { AdderUsageObserver.setUsed( false ); SourceTeeth source = new SourceTeeth(); @@ -192,7 +192,7 @@ public class AdderTest { } @Test - public void testAddReverse() throws DogException { + public void testAddReverse() { AdderUsageObserver.setUsed( false ); Target source = new Target(); @@ -219,7 +219,7 @@ public class AdderTest { } @Test - public void testAddViaTargetType() throws DogException { + public void testAddViaTargetType() { AdderUsageObserver.setUsed( false ); Source source = new Source(); @@ -235,7 +235,7 @@ public class AdderTest { @IssueKey("242") @Test - public void testSingleElementSource() throws DogException { + public void testSingleElementSource() { AdderUsageObserver.setUsed( false ); SingleElementSource source = new SingleElementSource(); @@ -250,7 +250,7 @@ public class AdderTest { @IssueKey( "310" ) @Test - public void testMissingImport() throws DogException { + public void testMissingImport() { generatedSource.addComparisonToFixtureFor( Source2Target2Mapper.class ); Source2 source = new Source2(); diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/PetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/PetMapper.java index 9cb74c7dc..c2cf92ed6 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/PetMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/PetMapper.java @@ -63,7 +63,7 @@ public class PetMapper { * @throws DogException */ public List toPets(List pets) throws CatException, DogException { - List result = new ArrayList(); + List result = new ArrayList<>(); for ( String pet : pets ) { result.add( toPet( pet ) ); } @@ -82,7 +82,7 @@ public class PetMapper { } public List toSourcePets(List pets) throws CatException, DogException { - List result = new ArrayList(); + List result = new ArrayList<>(); for ( Long pet : pets ) { result.add( PETS_TO_SOURCE.get( pet ) ); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/Target.java b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/Target.java index 022d59365..0a112ac21 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/Target.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/Target.java @@ -38,7 +38,7 @@ public class Target { public Long addPet(Long pet) { AdderUsageObserver.setUsed( true ); if ( pets == null ) { - pets = new ArrayList(); + pets = new ArrayList<>(); } pets.add( pet ); return pet; diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetDali.java b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetDali.java index 3d437b3ab..30f11f380 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetDali.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetDali.java @@ -26,7 +26,7 @@ public class TargetDali { public void addTeeth(Integer tooth) { AdderUsageObserver.setUsed( true ); if ( teeth == null ) { - teeth = new ArrayList(); + teeth = new ArrayList<>(); } teeth.add( tooth ); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetHuman.java b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetHuman.java index 8117abf2b..3a2efb9b8 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetHuman.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetHuman.java @@ -26,14 +26,14 @@ public class TargetHuman { public void addTooth(Integer pet) { AdderUsageObserver.setUsed( true ); if ( teeth == null ) { - teeth = new ArrayList(); + teeth = new ArrayList<>(); } teeth.add( pet ); } public void addTeeth(Integer tooth) { if ( teeth == null ) { - teeth = new ArrayList(); + teeth = new ArrayList<>(); } teeth.add( tooth ); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetOnlyGetter.java b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetOnlyGetter.java index 1e21e819c..09a3bc8e4 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetOnlyGetter.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetOnlyGetter.java @@ -34,7 +34,7 @@ public class TargetOnlyGetter { public void addPet(Long pet) { AdderUsageObserver.setUsed( true ); if ( pets == null ) { - pets = new ArrayList(); + pets = new ArrayList<>(); } pets.add( pet ); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetViaTargetType.java b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetViaTargetType.java index 0840e0115..22123aa97 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetViaTargetType.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetViaTargetType.java @@ -26,7 +26,7 @@ public class TargetViaTargetType { public void addPet(IndoorPet pet) { AdderUsageObserver.setUsed( true ); if ( pets == null ) { - pets = new ArrayList(); + pets = new ArrayList<>(); } pets.add( pet ); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetWithoutSetter.java b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetWithoutSetter.java index 69613854d..61e670c3a 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetWithoutSetter.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/adder/_target/TargetWithoutSetter.java @@ -22,7 +22,7 @@ public class TargetWithoutSetter { public void addPet(Long pet) { AdderUsageObserver.setUsed( true ); if ( pets == null ) { - pets = new ArrayList(); + pets = new ArrayList<>(); } pets.add( pet ); } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/DefaultCollectionImplementationTest.java b/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/DefaultCollectionImplementationTest.java index b5de8abaa..a6ba036e8 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/DefaultCollectionImplementationTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/DefaultCollectionImplementationTest.java @@ -128,7 +128,7 @@ public class DefaultCollectionImplementationTest { @IssueKey("6") public void shouldUseDefaultImplementationForSet() { Set target = - SourceTargetMapper.INSTANCE.sourceFoosToTargetFoos( new HashSet( createSourceFooList() ) ); + SourceTargetMapper.INSTANCE.sourceFoosToTargetFoos( new HashSet<>( createSourceFooList() ) ); assertResultList( target ); } @@ -145,7 +145,7 @@ public class DefaultCollectionImplementationTest { @Test @IssueKey("19") public void shouldUseTargetParameterForMapping() { - List target = new ArrayList(); + List target = new ArrayList<>(); SourceTargetMapper.INSTANCE.sourceFoosToTargetFoosUsingTargetParameter( target, createSourceFooList() @@ -157,7 +157,7 @@ public class DefaultCollectionImplementationTest { @Test @IssueKey("19") public void shouldUseAndReturnTargetParameterForMapping() { - List target = new ArrayList(); + List target = new ArrayList<>(); Iterable result = SourceTargetMapper.INSTANCE .sourceFoosToTargetFoosUsingTargetParameterAndReturn( createSourceFooList(), target ); @@ -189,7 +189,7 @@ public class DefaultCollectionImplementationTest { } private Map createSourceFooMap() { - Map map = new HashMap(); + Map map = new HashMap<>(); map.put( 1L, new SourceFoo( "Bob" ) ); map.put( 2L, new SourceFoo( "Alice" ) ); diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/NoSetterCollectionMappingTest.java b/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/NoSetterCollectionMappingTest.java index 914a5e3f0..1d9747854 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/NoSetterCollectionMappingTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/NoSetterCollectionMappingTest.java @@ -32,7 +32,7 @@ public class NoSetterCollectionMappingTest { public void compilesAndMapsCorrectly() { NoSetterSource source = new NoSetterSource(); source.setListValues( Arrays.asList( "foo", "bar" ) ); - HashMap mapValues = new HashMap(); + HashMap mapValues = new HashMap<>(); mapValues.put( "fooKey", "fooVal" ); mapValues.put( "barKey", "barVal" ); diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/Target.java b/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/Target.java index 8a5cc6200..713865da6 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/Target.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/Target.java @@ -14,7 +14,7 @@ public class Target { public List getFooListNoSetter() { if ( fooListNoSetter == null ) { - fooListNoSetter = new ArrayList(); + fooListNoSetter = new ArrayList<>(); } return fooListNoSetter; } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/TargetFoo.java b/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/TargetFoo.java index da76cc413..5a843b045 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/TargetFoo.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/defaultimplementation/TargetFoo.java @@ -45,14 +45,11 @@ public class TargetFoo implements Comparable { } TargetFoo other = (TargetFoo) obj; if ( name == null ) { - if ( other.name != null ) { - return false; - } + return other.name == null; } - else if ( !name.equals( other.name ) ) { - return false; + else { + return name.equals( other.name ); } - return true; } @Override diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/immutabletarget/ImmutableProductTest.java b/processor/src/test/java/org/mapstruct/ap/test/collection/immutabletarget/ImmutableProductTest.java index f196a1ed9..4c4932e2c 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/immutabletarget/ImmutableProductTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/immutabletarget/ImmutableProductTest.java @@ -34,7 +34,7 @@ public class ImmutableProductTest { CupboardDto in = new CupboardDto(); in.setContent( Arrays.asList( "cups", "soucers" ) ); CupboardEntity out = new CupboardEntity(); - out.setContent( Collections.emptyList() ); + out.setContent( Collections.emptyList() ); CupboardMapper.INSTANCE.map( in, out ); diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/map/MapMappingTest.java b/processor/src/test/java/org/mapstruct/ap/test/collection/map/MapMappingTest.java index 45ccbb911..a9a17e541 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/map/MapMappingTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/map/MapMappingTest.java @@ -8,6 +8,7 @@ package org.mapstruct.ap.test.collection.map; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.entry; +import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; @@ -32,9 +33,9 @@ public class MapMappingTest { @Test public void shouldCreateMapMethodImplementation() { - Map values = new HashMap(); - values.put( 42L, new GregorianCalendar( 1980, 0, 1 ).getTime() ); - values.put( 121L, new GregorianCalendar( 2013, 6, 20 ).getTime() ); + Map values = new HashMap<>(); + values.put( 42L, new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime() ); + values.put( 121L, new GregorianCalendar( 2013, Calendar.JULY, 20 ).getTime() ); Map target = SourceTargetMapper.INSTANCE.longDateMapToStringStringMap( values ); @@ -60,8 +61,8 @@ public class MapMappingTest { public void shouldCreateMapMethodImplementationWithTargetParameter() { Map values = createStringStringMap(); - Map target = new HashMap(); - target.put( 66L, new GregorianCalendar( 2013, 7, 16 ).getTime() ); + Map target = new HashMap<>(); + target.put( 66L, new GregorianCalendar( 2013, Calendar.AUGUST, 16 ).getTime() ); SourceTargetMapper.INSTANCE.stringStringMapToLongDateMapUsingTargetParameter( target, values ); @@ -73,8 +74,8 @@ public class MapMappingTest { public void shouldCreateMapMethodImplementationWithReturnedTargetParameter() { Map values = createStringStringMap(); - Map target = new HashMap(); - target.put( 66L, new GregorianCalendar( 2013, 7, 16 ).getTime() ); + Map target = new HashMap<>(); + target.put( 66L, new GregorianCalendar( 2013, Calendar.AUGUST, 16 ).getTime() ); Map returnedTarget = SourceTargetMapper.INSTANCE .stringStringMapToLongDateMapUsingTargetParameterAndReturn( values, target ); @@ -88,13 +89,13 @@ public class MapMappingTest { assertThat( target ).isNotNull(); assertThat( target ).hasSize( 2 ); assertThat( target ).contains( - entry( 42L, new GregorianCalendar( 1980, 0, 1 ).getTime() ), - entry( 121L, new GregorianCalendar( 2013, 6, 20 ).getTime() ) + entry( 42L, new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime() ), + entry( 121L, new GregorianCalendar( 2013, Calendar.JULY, 20 ).getTime() ) ); } private Map createStringStringMap() { - Map values = new HashMap(); + Map values = new HashMap<>(); values.put( "42", "01.01.1980" ); values.put( "121", "20.07.2013" ); return values; @@ -102,13 +103,13 @@ public class MapMappingTest { @Test public void shouldInvokeMapMethodImplementationForMapTypedProperty() { - Map values = new HashMap(); - values.put( 42L, new GregorianCalendar( 1980, 0, 1 ).getTime() ); - values.put( 121L, new GregorianCalendar( 2013, 6, 20 ).getTime() ); + Map values = new HashMap<>(); + values.put( 42L, new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime() ); + values.put( 121L, new GregorianCalendar( 2013, Calendar.JULY, 20 ).getTime() ); Source source = new Source(); source.setValues( values ); - source.setPublicValues( new HashMap( values ) ); + source.setPublicValues( new HashMap<>( values ) ); Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); @@ -135,7 +136,7 @@ public class MapMappingTest { Target target = new Target(); target.setValues( values ); - target.publicValues = new HashMap( values ); + target.publicValues = new HashMap<>( values ); Source source = SourceTargetMapper.INSTANCE.targetToSource( target ); @@ -143,21 +144,21 @@ public class MapMappingTest { assertThat( source.getValues() ).isNotNull(); assertThat( source.getValues() ).hasSize( 2 ); assertThat( source.getValues() ).contains( - entry( 42L, new GregorianCalendar( 1980, 0, 1 ).getTime() ), - entry( 121L, new GregorianCalendar( 2013, 6, 20 ).getTime() ) + entry( 42L, new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime() ), + entry( 121L, new GregorianCalendar( 2013, Calendar.JULY, 20 ).getTime() ) ); assertThat( source.getPublicValues() ) .isNotNull() .hasSize( 2 ) .contains( - entry( 42L, new GregorianCalendar( 1980, 0, 1 ).getTime() ), - entry( 121L, new GregorianCalendar( 2013, 6, 20 ).getTime() ) + entry( 42L, new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime() ), + entry( 121L, new GregorianCalendar( 2013, Calendar.JULY, 20 ).getTime() ) ); } private Map createIntIntMap() { - Map values = new HashMap(); + Map values = new HashMap<>(); values.put( 42, 47 ); values.put( 121, 123 ); return values; diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/BeanMapper.java b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/BeanMapper.java index 146c87687..0fd26e11f 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/BeanMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/BeanMapper.java @@ -29,7 +29,7 @@ public abstract class BeanMapper { } JAXBElement map(BigDecimal value) { - return new JAXBElement( new QName( "test" ), BigDecimal.class, value ); + return new JAXBElement<>( new QName( "test" ), BigDecimal.class, value ); } } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/WildCardTest.java b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/WildCardTest.java index 3e6da19cb..4f5c161a2 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/WildCardTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/wildcard/WildCardTest.java @@ -140,7 +140,7 @@ public class WildCardTest { public void shouldMapBean() { GoodIdea aGoodIdea = new GoodIdea(); - aGoodIdea.setContent( new JAXBElement( new QName( "test" ), BigDecimal.class, BigDecimal.ONE ) ); + aGoodIdea.setContent( new JAXBElement<>( new QName( "test" ), BigDecimal.class, BigDecimal.ONE ) ); aGoodIdea.setDescription( BigDecimal.ZERO ); CunningPlan aCunningPlan = BeanMapper.STM.transformA( aGoodIdea );