Created
June 11, 2014 06:46
-
-
Save MartinAhrer/1a57fc227ec433999cfb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.modelmapper.internal; | |
import de.troi.common.util.mapper.ModelMapperConfiguration; | |
import org.junit.Test; | |
import org.modelmapper.ModelMapper; | |
import java.util.Map; | |
import java.util.UUID; | |
import static org.junit.Assert.assertEquals; | |
public class ModelMapperTypeInfoLearningTest { | |
@Test | |
public void typeInfoReference() { | |
//given: | |
ModelMapper modelMapper = new ModelMapperConfiguration().modelMapper(); | |
TypeInfo typeInfo = new TypeInfoImpl(new UpdatePersonResource(), UpdatePersonResource.class, (InheritingConfiguration) modelMapper.getConfiguration()); | |
//when: | |
Map<String, Accessor> accessors = typeInfo.getAccessors(); | |
//then: | |
assertEquals(accessors.get("reference").getType(), UUID.class); | |
} | |
@Test | |
public void typeInfoReference1() { | |
//given: | |
ModelMapper modelMapper = new ModelMapperConfiguration().modelMapper(); | |
TypeInfo typeInfo = new TypeInfoImpl(new UpdatePersonResource1(), UpdatePersonResource1.class, (InheritingConfiguration) modelMapper.getConfiguration()); | |
//when: | |
Map<String, Accessor> accessors = typeInfo.getAccessors(); | |
//then: | |
assertEquals(accessors.get("reference").getType(), UUID.class); | |
} | |
} | |
/** | |
* Adding the generics parameter T breaks the test on Java (build 1.7.0_55-b13) but runs fine on Java 8. | |
* @param <T> | |
*/ | |
interface ReferenceableResource<T> { | |
T getReference(); | |
} | |
class UpdatePersonResource implements ReferenceableResource { | |
private UUID reference; | |
public UUID getReference() { | |
return reference; | |
} | |
public void setReference(UUID reference) { | |
this.reference = reference; | |
} | |
} | |
interface ReferenceableResource1 { | |
UUID getReference(); | |
} | |
class UpdatePersonResource1 implements ReferenceableResource1 { | |
private UUID reference; | |
public UUID getReference() { | |
return reference; | |
} | |
public void setReference(UUID reference) { | |
this.reference = reference; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment