mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
Fix minor warnings in package test.collection:
remove unnecessary generic-type in collections, remove unnecessary exception from signature, replace months numbers on Calendar constants
This commit is contained in:
parent
dc86d5df45
commit
148466ae3e
@ -113,7 +113,7 @@ public class CollectionMappingTest {
|
||||
assertThat( source.getOtherStringList() ).containsExactly( "Bob", "Alice" );
|
||||
|
||||
// prepare a test list to monitor add all behaviour
|
||||
List<String> testList = new TestList<String>();
|
||||
List<String> 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<String>( 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<String>( 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<String>( 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<String>( 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<String>( 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<String>( 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<String>( 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<Integer>( 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<Integer>( 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<String>( 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<String>( 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<String, Long> map = new HashMap<String, Long>();
|
||||
Map<String, Long> 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<String, Long> map = new HashMap<String, Long>();
|
||||
Map<String, Long> 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<String, Long> originalInstance = new TestMap<String, Long>();
|
||||
Map<String, Long> 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<Number> numbers = SourceTargetMapper.INSTANCE
|
||||
.integerSetToNumberSet( new HashSet<Integer>( 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<String>( 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<String, Long> map = new HashMap<String, Long>();
|
||||
Map<String, Long> map = new HashMap<>();
|
||||
map.put( "Bob", 123L );
|
||||
map.put( "Alice", 456L );
|
||||
source.setStringLongMapForNonGeneric( map );
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -144,14 +144,14 @@ public class Target {
|
||||
|
||||
public List<String> getStringListNoSetter() {
|
||||
if ( stringListNoSetter == null ) {
|
||||
stringListNoSetter = new ArrayList<String>();
|
||||
stringListNoSetter = new ArrayList<>();
|
||||
}
|
||||
return stringListNoSetter;
|
||||
}
|
||||
|
||||
public List<String> getStringListNoSetter2() {
|
||||
if ( stringListNoSetter2 == null ) {
|
||||
stringListNoSetter2 = new ArrayList<String>();
|
||||
stringListNoSetter2 = new ArrayList<>();
|
||||
}
|
||||
return stringListNoSetter2;
|
||||
}
|
||||
|
@ -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<Long>( 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();
|
||||
|
@ -63,7 +63,7 @@ public class PetMapper {
|
||||
* @throws DogException
|
||||
*/
|
||||
public List<Long> toPets(List<String> pets) throws CatException, DogException {
|
||||
List<Long> result = new ArrayList<Long>();
|
||||
List<Long> result = new ArrayList<>();
|
||||
for ( String pet : pets ) {
|
||||
result.add( toPet( pet ) );
|
||||
}
|
||||
@ -82,7 +82,7 @@ public class PetMapper {
|
||||
}
|
||||
|
||||
public List<String> toSourcePets(List<Long> pets) throws CatException, DogException {
|
||||
List<String> result = new ArrayList<String>();
|
||||
List<String> result = new ArrayList<>();
|
||||
for ( Long pet : pets ) {
|
||||
result.add( PETS_TO_SOURCE.get( pet ) );
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class Target {
|
||||
public Long addPet(Long pet) {
|
||||
AdderUsageObserver.setUsed( true );
|
||||
if ( pets == null ) {
|
||||
pets = new ArrayList<Long>();
|
||||
pets = new ArrayList<>();
|
||||
}
|
||||
pets.add( pet );
|
||||
return pet;
|
||||
|
@ -26,7 +26,7 @@ public class TargetDali {
|
||||
public void addTeeth(Integer tooth) {
|
||||
AdderUsageObserver.setUsed( true );
|
||||
if ( teeth == null ) {
|
||||
teeth = new ArrayList<Integer>();
|
||||
teeth = new ArrayList<>();
|
||||
}
|
||||
teeth.add( tooth );
|
||||
}
|
||||
|
@ -26,14 +26,14 @@ public class TargetHuman {
|
||||
public void addTooth(Integer pet) {
|
||||
AdderUsageObserver.setUsed( true );
|
||||
if ( teeth == null ) {
|
||||
teeth = new ArrayList<Integer>();
|
||||
teeth = new ArrayList<>();
|
||||
}
|
||||
teeth.add( pet );
|
||||
}
|
||||
|
||||
public void addTeeth(Integer tooth) {
|
||||
if ( teeth == null ) {
|
||||
teeth = new ArrayList<Integer>();
|
||||
teeth = new ArrayList<>();
|
||||
}
|
||||
teeth.add( tooth );
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class TargetOnlyGetter {
|
||||
public void addPet(Long pet) {
|
||||
AdderUsageObserver.setUsed( true );
|
||||
if ( pets == null ) {
|
||||
pets = new ArrayList<Long>();
|
||||
pets = new ArrayList<>();
|
||||
}
|
||||
pets.add( pet );
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class TargetViaTargetType {
|
||||
public void addPet(IndoorPet pet) {
|
||||
AdderUsageObserver.setUsed( true );
|
||||
if ( pets == null ) {
|
||||
pets = new ArrayList<IndoorPet>();
|
||||
pets = new ArrayList<>();
|
||||
}
|
||||
pets.add( pet );
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ public class TargetWithoutSetter {
|
||||
public void addPet(Long pet) {
|
||||
AdderUsageObserver.setUsed( true );
|
||||
if ( pets == null ) {
|
||||
pets = new ArrayList<Long>();
|
||||
pets = new ArrayList<>();
|
||||
}
|
||||
pets.add( pet );
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ public class DefaultCollectionImplementationTest {
|
||||
@IssueKey("6")
|
||||
public void shouldUseDefaultImplementationForSet() {
|
||||
Set<TargetFoo> target =
|
||||
SourceTargetMapper.INSTANCE.sourceFoosToTargetFoos( new HashSet<SourceFoo>( createSourceFooList() ) );
|
||||
SourceTargetMapper.INSTANCE.sourceFoosToTargetFoos( new HashSet<>( createSourceFooList() ) );
|
||||
|
||||
assertResultList( target );
|
||||
}
|
||||
@ -145,7 +145,7 @@ public class DefaultCollectionImplementationTest {
|
||||
@Test
|
||||
@IssueKey("19")
|
||||
public void shouldUseTargetParameterForMapping() {
|
||||
List<TargetFoo> target = new ArrayList<TargetFoo>();
|
||||
List<TargetFoo> target = new ArrayList<>();
|
||||
SourceTargetMapper.INSTANCE.sourceFoosToTargetFoosUsingTargetParameter(
|
||||
target,
|
||||
createSourceFooList()
|
||||
@ -157,7 +157,7 @@ public class DefaultCollectionImplementationTest {
|
||||
@Test
|
||||
@IssueKey("19")
|
||||
public void shouldUseAndReturnTargetParameterForMapping() {
|
||||
List<TargetFoo> target = new ArrayList<TargetFoo>();
|
||||
List<TargetFoo> target = new ArrayList<>();
|
||||
Iterable<TargetFoo> result =
|
||||
SourceTargetMapper.INSTANCE
|
||||
.sourceFoosToTargetFoosUsingTargetParameterAndReturn( createSourceFooList(), target );
|
||||
@ -189,7 +189,7 @@ public class DefaultCollectionImplementationTest {
|
||||
}
|
||||
|
||||
private Map<Long, SourceFoo> createSourceFooMap() {
|
||||
Map<Long, SourceFoo> map = new HashMap<Long, SourceFoo>();
|
||||
Map<Long, SourceFoo> map = new HashMap<>();
|
||||
map.put( 1L, new SourceFoo( "Bob" ) );
|
||||
map.put( 2L, new SourceFoo( "Alice" ) );
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class NoSetterCollectionMappingTest {
|
||||
public void compilesAndMapsCorrectly() {
|
||||
NoSetterSource source = new NoSetterSource();
|
||||
source.setListValues( Arrays.asList( "foo", "bar" ) );
|
||||
HashMap<String, String> mapValues = new HashMap<String, String>();
|
||||
HashMap<String, String> mapValues = new HashMap<>();
|
||||
mapValues.put( "fooKey", "fooVal" );
|
||||
mapValues.put( "barKey", "barVal" );
|
||||
|
||||
|
@ -14,7 +14,7 @@ public class Target {
|
||||
|
||||
public List<TargetFoo> getFooListNoSetter() {
|
||||
if ( fooListNoSetter == null ) {
|
||||
fooListNoSetter = new ArrayList<TargetFoo>();
|
||||
fooListNoSetter = new ArrayList<>();
|
||||
}
|
||||
return fooListNoSetter;
|
||||
}
|
||||
|
@ -45,14 +45,11 @@ public class TargetFoo implements Comparable<TargetFoo> {
|
||||
}
|
||||
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
|
||||
|
@ -34,7 +34,7 @@ public class ImmutableProductTest {
|
||||
CupboardDto in = new CupboardDto();
|
||||
in.setContent( Arrays.asList( "cups", "soucers" ) );
|
||||
CupboardEntity out = new CupboardEntity();
|
||||
out.setContent( Collections.<String>emptyList() );
|
||||
out.setContent( Collections.emptyList() );
|
||||
|
||||
CupboardMapper.INSTANCE.map( in, out );
|
||||
|
||||
|
@ -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<Long, Date> values = new HashMap<Long, Date>();
|
||||
values.put( 42L, new GregorianCalendar( 1980, 0, 1 ).getTime() );
|
||||
values.put( 121L, new GregorianCalendar( 2013, 6, 20 ).getTime() );
|
||||
Map<Long, Date> values = new HashMap<>();
|
||||
values.put( 42L, new GregorianCalendar( 1980, Calendar.JANUARY, 1 ).getTime() );
|
||||
values.put( 121L, new GregorianCalendar( 2013, Calendar.JULY, 20 ).getTime() );
|
||||
|
||||
Map<String, String> target = SourceTargetMapper.INSTANCE.longDateMapToStringStringMap( values );
|
||||
|
||||
@ -60,8 +61,8 @@ public class MapMappingTest {
|
||||
public void shouldCreateMapMethodImplementationWithTargetParameter() {
|
||||
Map<String, String> values = createStringStringMap();
|
||||
|
||||
Map<Long, Date> target = new HashMap<Long, Date>();
|
||||
target.put( 66L, new GregorianCalendar( 2013, 7, 16 ).getTime() );
|
||||
Map<Long, Date> 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<String, String> values = createStringStringMap();
|
||||
|
||||
Map<Long, Date> target = new HashMap<Long, Date>();
|
||||
target.put( 66L, new GregorianCalendar( 2013, 7, 16 ).getTime() );
|
||||
Map<Long, Date> target = new HashMap<>();
|
||||
target.put( 66L, new GregorianCalendar( 2013, Calendar.AUGUST, 16 ).getTime() );
|
||||
|
||||
Map<Long, Date> 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<String, String> createStringStringMap() {
|
||||
Map<String, String> values = new HashMap<String, String>();
|
||||
Map<String, String> 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<Long, Date> values = new HashMap<Long, Date>();
|
||||
values.put( 42L, new GregorianCalendar( 1980, 0, 1 ).getTime() );
|
||||
values.put( 121L, new GregorianCalendar( 2013, 6, 20 ).getTime() );
|
||||
Map<Long, Date> 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<Long, Date>( 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<String, String>( 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<Integer, Integer> createIntIntMap() {
|
||||
Map<Integer, Integer> values = new HashMap<Integer, Integer>();
|
||||
Map<Integer, Integer> values = new HashMap<>();
|
||||
values.put( 42, 47 );
|
||||
values.put( 121, 123 );
|
||||
return values;
|
||||
|
@ -29,7 +29,7 @@ public abstract class BeanMapper {
|
||||
}
|
||||
|
||||
JAXBElement<? super BigDecimal> map(BigDecimal value) {
|
||||
return new JAXBElement<BigDecimal>( new QName( "test" ), BigDecimal.class, value );
|
||||
return new JAXBElement<>( new QName( "test" ), BigDecimal.class, value );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ public class WildCardTest {
|
||||
public void shouldMapBean() {
|
||||
|
||||
GoodIdea aGoodIdea = new GoodIdea();
|
||||
aGoodIdea.setContent( new JAXBElement<BigDecimal>( 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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user