mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#782 Rename Lombok Integration test classes
This commit is contained in:
parent
2b9fdac7f7
commit
73711cc683
@ -30,12 +30,12 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
* builder class, and some of the properties are written by the concrete builder implementation.
|
* builder class, and some of the properties are written by the concrete builder implementation.
|
||||||
*/
|
*/
|
||||||
@WithClasses({
|
@WithClasses({
|
||||||
Target.class,
|
Product.class,
|
||||||
AbstractTargetBuilder.class,
|
AbstractProductBuilder.class,
|
||||||
AbstractImmutableTarget.class,
|
AbstractImmutableProduct.class,
|
||||||
ImmutableTarget.class,
|
ImmutableProduct.class,
|
||||||
Source.class,
|
ProductDto.class,
|
||||||
ImmutableTargetMapper.class
|
ProductMapper.class
|
||||||
})
|
})
|
||||||
@RunWith(AnnotationProcessorTestRunner.class)
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
public class AbstractBuilderTest {
|
public class AbstractBuilderTest {
|
||||||
@ -51,20 +51,20 @@ public class AbstractBuilderTest {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testThatAbstractBuilderMapsAllProperties() {
|
public void testThatAbstractBuilderMapsAllProperties() {
|
||||||
ImmutableTarget sourceOne = ImmutableTargetMapper.INSTANCE.fromMutable( new Source( "foo", 31 ) );
|
ImmutableProduct product = ProductMapper.INSTANCE.fromMutable( new ProductDto( "router", 31 ) );
|
||||||
|
|
||||||
assertThat( sourceOne.getBar() ).isEqualTo( 31 );
|
assertThat( product.getPrice() ).isEqualTo( 31 );
|
||||||
assertThat( sourceOne.getFoo() ).isEqualTo( "foo" );
|
assertThat( product.getName() ).isEqualTo( "router" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testThatAbstractBuilderReverseMapsAllProperties() {
|
public void testThatAbstractBuilderReverseMapsAllProperties() {
|
||||||
Source sourceOne = ImmutableTargetMapper.INSTANCE.fromImmutable( ImmutableTarget.builder()
|
ProductDto product = ProductMapper.INSTANCE.fromImmutable( ImmutableProduct.builder()
|
||||||
.bar( 31 )
|
.price( 31000 )
|
||||||
.foo( "foo" )
|
.name( "car" )
|
||||||
.build() );
|
.build() );
|
||||||
|
|
||||||
assertThat( sourceOne.getBar() ).isEqualTo( 31 );
|
assertThat( product.getPrice() ).isEqualTo( 31000 );
|
||||||
assertThat( sourceOne.getFoo() ).isEqualTo( "foo" );
|
assertThat( product.getName() ).isEqualTo( "car" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,15 +21,15 @@ package org.mapstruct.ap.test.builder.abstractBuilder;
|
|||||||
/**
|
/**
|
||||||
* @author Filip Hrisafov
|
* @author Filip Hrisafov
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractImmutableTarget implements Target {
|
public abstract class AbstractImmutableProduct implements Product {
|
||||||
|
|
||||||
private final String foo;
|
private final String name;
|
||||||
|
|
||||||
public AbstractImmutableTarget(AbstractTargetBuilder<?> builder) {
|
public AbstractImmutableProduct(AbstractProductBuilder<?> builder) {
|
||||||
this.foo = builder.foo;
|
this.name = builder.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFoo() {
|
public String getName() {
|
||||||
return foo;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,12 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.builder.abstractBuilder;
|
package org.mapstruct.ap.test.builder.abstractBuilder;
|
||||||
|
|
||||||
public abstract class AbstractTargetBuilder<T extends Target> {
|
public abstract class AbstractProductBuilder<T extends Product> {
|
||||||
|
|
||||||
protected String foo;
|
protected String name;
|
||||||
|
|
||||||
public AbstractTargetBuilder<T> foo(String foo) {
|
public AbstractProductBuilder<T> name(String name) {
|
||||||
this.foo = foo;
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -18,35 +18,35 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.builder.abstractBuilder;
|
package org.mapstruct.ap.test.builder.abstractBuilder;
|
||||||
|
|
||||||
public class ImmutableTarget extends AbstractImmutableTarget {
|
public class ImmutableProduct extends AbstractImmutableProduct {
|
||||||
|
|
||||||
private final Integer bar;
|
private final Integer price;
|
||||||
|
|
||||||
public ImmutableTarget(ImmutableTargetBuilder builder) {
|
public ImmutableProduct(ImmutableProductBuilder builder) {
|
||||||
super( builder );
|
super( builder );
|
||||||
this.bar = builder.bar;
|
this.price = builder.price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImmutableTargetBuilder builder() {
|
public static ImmutableProductBuilder builder() {
|
||||||
return new ImmutableTargetBuilder();
|
return new ImmutableProductBuilder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getBar() {
|
public Integer getPrice() {
|
||||||
return bar;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ImmutableTargetBuilder extends AbstractTargetBuilder<ImmutableTarget> {
|
public static class ImmutableProductBuilder extends AbstractProductBuilder<ImmutableProduct> {
|
||||||
private Integer bar;
|
private Integer price;
|
||||||
|
|
||||||
public ImmutableTargetBuilder bar(Integer bar) {
|
public ImmutableProductBuilder price(Integer price) {
|
||||||
this.bar = bar;
|
this.price = price;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImmutableTarget build() {
|
public ImmutableProduct build() {
|
||||||
return new ImmutableTarget( this );
|
return new ImmutableProduct( this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,8 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.builder.abstractBuilder;
|
package org.mapstruct.ap.test.builder.abstractBuilder;
|
||||||
|
|
||||||
public interface Target {
|
public interface Product {
|
||||||
String getFoo();
|
String getName();
|
||||||
|
|
||||||
Integer getBar();
|
Integer getPrice();
|
||||||
}
|
}
|
@ -18,31 +18,31 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.builder.abstractBuilder;
|
package org.mapstruct.ap.test.builder.abstractBuilder;
|
||||||
|
|
||||||
public class Source {
|
public class ProductDto {
|
||||||
private String foo;
|
private String name;
|
||||||
private Integer bar;
|
private Integer price;
|
||||||
|
|
||||||
public Source() {
|
public ProductDto() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Source(String foo, Integer bar) {
|
public ProductDto(String name, Integer price) {
|
||||||
this.foo = foo;
|
this.name = name;
|
||||||
this.bar = bar;
|
this.price = price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFoo() {
|
public String getName() {
|
||||||
return foo;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFoo(String foo) {
|
public void setName(String name) {
|
||||||
this.foo = foo;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getBar() {
|
public Integer getPrice() {
|
||||||
return bar;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBar(Integer bar) {
|
public void setPrice(Integer price) {
|
||||||
this.bar = bar;
|
this.price = price;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,11 +22,11 @@ import org.mapstruct.Mapper;
|
|||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ImmutableTargetMapper {
|
public interface ProductMapper {
|
||||||
|
|
||||||
ImmutableTargetMapper INSTANCE = Mappers.getMapper( ImmutableTargetMapper.class );
|
ProductMapper INSTANCE = Mappers.getMapper( ProductMapper.class );
|
||||||
|
|
||||||
ImmutableTarget fromMutable(Source source);
|
ImmutableProduct fromMutable(ProductDto source);
|
||||||
|
|
||||||
Source fromImmutable(ImmutableTarget source);
|
ProductDto fromImmutable(ImmutableProduct source);
|
||||||
}
|
}
|
@ -18,44 +18,54 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mapstruct.ap.testutil.WithClasses;
|
import org.mapstruct.ap.testutil.WithClasses;
|
||||||
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies that abstract builders work when mapping to an abstract property type.
|
* Verifies that abstract builders work when mapping to an abstract property type.
|
||||||
*/
|
*/
|
||||||
@WithClasses({
|
@WithClasses({
|
||||||
AbstractChildTarget.class,
|
Child.class,
|
||||||
AbstractParentTarget.class,
|
Parent.class,
|
||||||
ChildSource.class,
|
ChildSource.class,
|
||||||
ImmutableChildTargetImpl.class,
|
ImmutableChild.class,
|
||||||
ImmutableParentTargetImpl.class,
|
ImmutableParent.class,
|
||||||
MutableChildTargetImpl.class,
|
MutableChild.class,
|
||||||
MutableParentTargetImpl.class,
|
MutableParent.class,
|
||||||
ParentSource.class,
|
ParentSource.class,
|
||||||
AbstractTargetMapper.class
|
ParentMapper.class
|
||||||
})
|
})
|
||||||
@RunWith(AnnotationProcessorTestRunner.class)
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
public class AbstractTargetBuilderTest {
|
public class AbstractGenericTargetBuilderTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAbstractTargetMapper() {
|
public void testAbstractTargetMapper() {
|
||||||
ParentSource parent = new ParentSource();
|
ParentSource parent = new ParentSource();
|
||||||
parent.setCount( 4 );
|
parent.setCount( 4 );
|
||||||
parent.setNested( new ChildSource( "Phineas" ) );
|
parent.setChild( new ChildSource( "Phineas" ) );
|
||||||
|
parent.setNonGenericChild( new ChildSource( "Ferb" ) );
|
||||||
|
|
||||||
// transform
|
// transform
|
||||||
AbstractParentTarget immutableTarget = AbstractTargetMapper.INSTANCE.toImmutable( parent );
|
Parent immutableParent = ParentMapper.INSTANCE.toImmutable( parent );
|
||||||
AbstractParentTarget mutableTarget = AbstractTargetMapper.INSTANCE.toMutable( parent );
|
assertThat( immutableParent.getCount() ).isEqualTo( 4 );
|
||||||
|
assertThat( immutableParent.getChild().getName() ).isEqualTo( "Phineas" );
|
||||||
|
assertThat( immutableParent.getNonGenericChild() )
|
||||||
|
.isNotNull()
|
||||||
|
.isInstanceOf( ImmutableChild.class );
|
||||||
|
assertThat( immutableParent.getNonGenericChild().getName() ).isEqualTo( "Ferb" );
|
||||||
|
|
||||||
assertThat( mutableTarget.getCount() ).isEqualTo( 4 );
|
Parent mutableParent = ParentMapper.INSTANCE.toMutable( parent );
|
||||||
assertThat( mutableTarget.getNested().getBar() ).isEqualTo( "Phineas" );
|
|
||||||
|
assertThat( mutableParent.getCount() ).isEqualTo( 4 );
|
||||||
|
assertThat( mutableParent.getChild().getName() ).isEqualTo( "Phineas" );
|
||||||
|
assertThat( mutableParent.getNonGenericChild() )
|
||||||
|
.isNotNull()
|
||||||
|
.isInstanceOf( ImmutableChild.class );
|
||||||
|
assertThat( mutableParent.getNonGenericChild().getName() ).isEqualTo( "Ferb" );
|
||||||
|
|
||||||
assertThat( immutableTarget.getCount() ).isEqualTo( 4 );
|
|
||||||
assertThat( immutableTarget.getNested().getBar() ).isEqualTo( "Phineas" );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,6 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
||||||
|
|
||||||
public interface AbstractChildTarget {
|
public interface Child {
|
||||||
String getBar();
|
String getName();
|
||||||
}
|
}
|
@ -19,20 +19,20 @@
|
|||||||
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
||||||
|
|
||||||
public class ChildSource {
|
public class ChildSource {
|
||||||
private String bar;
|
private String name;
|
||||||
|
|
||||||
public ChildSource() {
|
public ChildSource() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChildSource(String bar) {
|
public ChildSource(String name) {
|
||||||
this.bar = bar;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBar() {
|
public String getName() {
|
||||||
return bar;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBar(String bar) {
|
public void setName(String name) {
|
||||||
this.bar = bar;
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,31 +18,31 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
||||||
|
|
||||||
public class ImmutableChildTargetImpl implements AbstractChildTarget {
|
public class ImmutableChild implements Child {
|
||||||
private final String bar;
|
private final String name;
|
||||||
|
|
||||||
private ImmutableChildTargetImpl(ImmutableChildTargetImpl.Builder builder) {
|
private ImmutableChild(ImmutableChild.Builder builder) {
|
||||||
this.bar = builder.bar;
|
this.name = builder.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImmutableChildTargetImpl.Builder builder() {
|
public static ImmutableChild.Builder builder() {
|
||||||
return new ImmutableChildTargetImpl.Builder();
|
return new ImmutableChild.Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBar() {
|
public String getName() {
|
||||||
return bar;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private String bar;
|
private String name;
|
||||||
|
|
||||||
public ImmutableChildTargetImpl.Builder bar(String bar) {
|
public ImmutableChild.Builder name(String name) {
|
||||||
this.bar = bar;
|
this.name = name;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableChildTargetImpl build() {
|
public ImmutableChild build() {
|
||||||
return new ImmutableChildTargetImpl( this );
|
return new ImmutableChild( this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,15 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
||||||
|
|
||||||
public class ImmutableParentTargetImpl implements AbstractParentTarget<ImmutableChildTargetImpl> {
|
public class ImmutableParent implements Parent<ImmutableChild> {
|
||||||
private final int count;
|
private final int count;
|
||||||
private final ImmutableChildTargetImpl nested;
|
private final ImmutableChild child;
|
||||||
private final AbstractChildTarget nonGenericizedNested;
|
private final Child nonGenericChild;
|
||||||
|
|
||||||
public ImmutableParentTargetImpl(Builder builder) {
|
public ImmutableParent(Builder builder) {
|
||||||
this.count = builder.count;
|
this.count = builder.count;
|
||||||
this.nested = builder.nested;
|
this.child = builder.child;
|
||||||
this.nonGenericizedNested = builder.nonGenericizedNested;
|
this.nonGenericChild = builder.nonGenericChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
@ -34,8 +34,8 @@ public class ImmutableParentTargetImpl implements AbstractParentTarget<Immutable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractChildTarget getNonGenericizedNested() {
|
public Child getNonGenericChild() {
|
||||||
return nonGenericizedNested;
|
return nonGenericChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,32 +44,32 @@ public class ImmutableParentTargetImpl implements AbstractParentTarget<Immutable
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImmutableChildTargetImpl getNested() {
|
public ImmutableChild getChild() {
|
||||||
return nested;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private int count;
|
private int count;
|
||||||
private ImmutableChildTargetImpl nested;
|
private ImmutableChild child;
|
||||||
private AbstractChildTarget nonGenericizedNested;
|
private Child nonGenericChild;
|
||||||
|
|
||||||
public Builder count(int count) {
|
public Builder count(int count) {
|
||||||
this.count = count;
|
this.count = count;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder nonGenericizedNested(AbstractChildTarget nonGenericizedNested) {
|
public Builder nonGenericChild(Child nonGenericChild) {
|
||||||
this.nonGenericizedNested = nonGenericizedNested;
|
this.nonGenericChild = nonGenericChild;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder nested(ImmutableChildTargetImpl nested) {
|
public Builder child(ImmutableChild child) {
|
||||||
this.nested = nested;
|
this.child = child;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableParentTargetImpl build() {
|
public ImmutableParent build() {
|
||||||
return new ImmutableParentTargetImpl( this );
|
return new ImmutableParent( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -18,15 +18,15 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
||||||
|
|
||||||
public class MutableChildTargetImpl implements AbstractChildTarget {
|
public class MutableChild implements Child {
|
||||||
private String bar;
|
private String name;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBar() {
|
public String getName() {
|
||||||
return null;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBar(String bar) {
|
public void setName(String name) {
|
||||||
this.bar = bar;
|
this.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,10 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
||||||
|
|
||||||
public class MutableParentTargetImpl implements AbstractParentTarget<ImmutableChildTargetImpl> {
|
public class MutableParent implements Parent<ImmutableChild> {
|
||||||
private int count;
|
private int count;
|
||||||
private ImmutableChildTargetImpl nested;
|
private ImmutableChild child;
|
||||||
private AbstractChildTarget nonGenericizedNested;
|
private Child nonGenericChild;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
@ -33,20 +33,20 @@ public class MutableParentTargetImpl implements AbstractParentTarget<ImmutableCh
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ImmutableChildTargetImpl getNested() {
|
public ImmutableChild getChild() {
|
||||||
return nested;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNested(ImmutableChildTargetImpl nested) {
|
public void setChild(ImmutableChild child) {
|
||||||
this.nested = nested;
|
this.child = child;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractChildTarget getNonGenericizedNested() {
|
public Child getNonGenericChild() {
|
||||||
return nonGenericizedNested;
|
return nonGenericChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNonGenericizedNested(AbstractChildTarget nonGenericizedNested) {
|
public void setNonGenericChild(Child nonGenericChild) {
|
||||||
this.nonGenericizedNested = nonGenericizedNested;
|
this.nonGenericChild = nonGenericChild;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,10 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
||||||
|
|
||||||
public interface AbstractParentTarget<T extends AbstractChildTarget> {
|
public interface Parent<T extends Child> {
|
||||||
int getCount();
|
int getCount();
|
||||||
|
|
||||||
T getNested();
|
T getChild();
|
||||||
|
|
||||||
AbstractChildTarget getNonGenericizedNested();
|
Child getNonGenericChild();
|
||||||
}
|
}
|
@ -22,18 +22,18 @@ import org.mapstruct.Mapper;
|
|||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface AbstractTargetMapper {
|
public interface ParentMapper {
|
||||||
|
|
||||||
AbstractTargetMapper INSTANCE = Mappers.getMapper( AbstractTargetMapper.class );
|
ParentMapper INSTANCE = Mappers.getMapper( ParentMapper.class );
|
||||||
|
|
||||||
ImmutableParentTargetImpl toImmutable(ParentSource parentSource);
|
ImmutableParent toImmutable(ParentSource parentSource);
|
||||||
|
|
||||||
MutableParentTargetImpl toMutable(ParentSource parentSource);
|
MutableParent toMutable(ParentSource parentSource);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method allows mapstruct to successfully write to {@link ImmutableParentTargetImpl#nonGenericizedNested}
|
* This method allows mapstruct to successfully write to {@link ImmutableParent#nonGenericChild}
|
||||||
* by providing a concrete class to convert to.
|
* by providing a concrete class to convert to.
|
||||||
*/
|
*/
|
||||||
ImmutableChildTargetImpl toChild(ChildSource child);
|
ImmutableChild toChild(ChildSource child);
|
||||||
|
|
||||||
}
|
}
|
@ -20,15 +20,15 @@ package org.mapstruct.ap.test.builder.abstractGenericTarget;
|
|||||||
|
|
||||||
public class ParentSource {
|
public class ParentSource {
|
||||||
private int count;
|
private int count;
|
||||||
private ChildSource nested;
|
private ChildSource child;
|
||||||
private ChildSource nonGenericizedNested;
|
private ChildSource nonGenericChild;
|
||||||
|
|
||||||
public ChildSource getNonGenericizedNested() {
|
public ChildSource getNonGenericChild() {
|
||||||
return nonGenericizedNested;
|
return nonGenericChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNonGenericizedNested(ChildSource nonGenericizedNested) {
|
public void setNonGenericChild(ChildSource nonGenericChild) {
|
||||||
this.nonGenericizedNested = nonGenericizedNested;
|
this.nonGenericChild = nonGenericChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
@ -39,11 +39,11 @@ public class ParentSource {
|
|||||||
this.count = count;
|
this.count = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChildSource getNested() {
|
public ChildSource getChild() {
|
||||||
return nested;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNested(ChildSource nested) {
|
public void setChild(ChildSource child) {
|
||||||
this.nested = nested;
|
this.child = child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
|||||||
@RunWith(AnnotationProcessorTestRunner.class)
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
@WithClasses({CupboardDto.class, CupboardEntity.class, CupboardMapper.class})
|
@WithClasses({CupboardDto.class, CupboardEntity.class, CupboardMapper.class})
|
||||||
@IssueKey( "1126" )
|
@IssueKey( "1126" )
|
||||||
public class ImmutableTargetTest {
|
public class ImmutableProductTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldHandleImmutableTarget() {
|
public void shouldHandleImmutableTarget() {
|
@ -31,7 +31,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
|||||||
@WithClasses( { Foo9Base.class, Foo9Child.class, Bar9Base.class, Bar9Child.class, Bar9Factory.class,
|
@WithClasses( { Foo9Base.class, Foo9Child.class, Bar9Base.class, Bar9Child.class, Bar9Factory.class,
|
||||||
TargetTypeFactoryTestMapper.class } )
|
TargetTypeFactoryTestMapper.class } )
|
||||||
@RunWith( AnnotationProcessorTestRunner.class )
|
@RunWith( AnnotationProcessorTestRunner.class )
|
||||||
public class TargetTypeFactoryTest {
|
public class ProductTypeFactoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldUseFactoryTwoCreateBaseClassDueToTargetType() {
|
public void shouldUseFactoryTwoCreateBaseClassDueToTargetType() {
|
@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||||||
} )
|
} )
|
||||||
@IssueKey("389")
|
@IssueKey("389")
|
||||||
@RunWith(AnnotationProcessorTestRunner.class)
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
public class NestedTargetPropertiesTest {
|
public class NestedProductPropertiesTest {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
|
public GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(
|
@ -39,7 +39,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
|
|||||||
*/
|
*/
|
||||||
@IssueKey("35")
|
@IssueKey("35")
|
||||||
@RunWith(AnnotationProcessorTestRunner.class)
|
@RunWith(AnnotationProcessorTestRunner.class)
|
||||||
public class UnmappedTargetTest {
|
public class UnmappedProductTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@WithClasses({ Source.class, Target.class, SourceTargetMapper.class })
|
@WithClasses({ Source.class, Target.class, SourceTargetMapper.class })
|
Loading…
x
Reference in New Issue
Block a user