mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#1953 Fix TODO items for: integrationtest-java8Test, integrationtest-lombokBuilderTest, processor-nullvaluemappingTest (#1955)
This commit is contained in:
parent
efea2fb662
commit
b26cd4e0cb
@ -10,6 +10,11 @@ import org.mapstruct.Mapper;
|
||||
@Mapper
|
||||
public interface SourceTargetBaseMapper {
|
||||
|
||||
// TODO.. move default and static interface method here when problem in eclipse processor is fixed.
|
||||
default Foo fooFromId(long id) {
|
||||
return new Foo(id);
|
||||
}
|
||||
|
||||
static Bar barFromId(String id) {
|
||||
return new Bar(id);
|
||||
}
|
||||
}
|
||||
|
@ -19,13 +19,4 @@ public interface SourceTargetMapper extends SourceTargetBaseMapper {
|
||||
@Mapping(source = "idBar", target = "bar")
|
||||
})
|
||||
Target mapSourceToTarget(Source source);
|
||||
|
||||
default Foo fooFromId(long id) {
|
||||
return new Foo(id);
|
||||
}
|
||||
|
||||
static Bar barFromId(String id) {
|
||||
return new Bar(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,9 +8,7 @@ package org.mapstruct.itest.lombok;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
//TODO make MapStruct DefaultBuilderProvider work with custom builder name
|
||||
//@Builder(builderMethodName = "foo", buildMethodName = "create", builderClassName = "Builder")
|
||||
@Builder(builderClassName = "Builder")
|
||||
@Builder(builderMethodName = "foo", buildMethodName = "create", builderClassName = "Builder")
|
||||
@Getter
|
||||
public class Person {
|
||||
private final String name;
|
||||
|
@ -19,13 +19,13 @@ public class LombokMapperTest {
|
||||
|
||||
@Test
|
||||
public void testSimpleImmutableBuilderHappyPath() {
|
||||
PersonDto personDto = PersonMapper.INSTANCE.toDto( Person.builder()
|
||||
PersonDto personDto = PersonMapper.INSTANCE.toDto( Person.foo()
|
||||
.age( 33 )
|
||||
.name( "Bob" )
|
||||
.address( Address.builder()
|
||||
.addressLine( "Wild Drive" )
|
||||
.build() )
|
||||
.build() );
|
||||
.create() );
|
||||
assertThat( personDto.getAge() ).isEqualTo( 33 );
|
||||
assertThat( personDto.getName() ).isEqualTo( "Bob" );
|
||||
assertThat( personDto.getAddress() ).isNotNull();
|
||||
|
@ -39,7 +39,6 @@ public interface CarMapper {
|
||||
@BeanMapping(nullValueMappingStrategy = RETURN_DEFAULT)
|
||||
@Mappings({
|
||||
@Mapping(target = "seatCount", source = "car.numberOfSeats"),
|
||||
@Mapping(target = "model", source = "model"), // TODO, should not be needed, must be made based on name only
|
||||
@Mapping(target = "catalogId", expression = "java( UUID.randomUUID().toString() )")
|
||||
})
|
||||
CarDto carToCarDto(Car car, String model);
|
||||
|
@ -83,6 +83,7 @@ public class NullValueMappingTest {
|
||||
//then
|
||||
assertThat( carDto1 ).isNotNull();
|
||||
assertThat( carDto1.getMake() ).isEqualTo( car.getMake() );
|
||||
assertThat( carDto1.getModel() ).isEqualTo( "ModelT" );
|
||||
assertThat( carDto1.getSeatCount() ).isEqualTo( car.getNumberOfSeats() );
|
||||
assertThat( carDto1.getCatalogId() ).isNotEmpty();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user