#782 Rename Lombok Integration test classes

This commit is contained in:
Filip Hrisafov 2018-02-25 21:58:05 +01:00
parent 2b9fdac7f7
commit 73711cc683
21 changed files with 167 additions and 157 deletions

View File

@ -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.
*/
@WithClasses({
Target.class,
AbstractTargetBuilder.class,
AbstractImmutableTarget.class,
ImmutableTarget.class,
Source.class,
ImmutableTargetMapper.class
Product.class,
AbstractProductBuilder.class,
AbstractImmutableProduct.class,
ImmutableProduct.class,
ProductDto.class,
ProductMapper.class
})
@RunWith(AnnotationProcessorTestRunner.class)
public class AbstractBuilderTest {
@ -51,20 +51,20 @@ public class AbstractBuilderTest {
*/
@Test
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( sourceOne.getFoo() ).isEqualTo( "foo" );
assertThat( product.getPrice() ).isEqualTo( 31 );
assertThat( product.getName() ).isEqualTo( "router" );
}
@Test
public void testThatAbstractBuilderReverseMapsAllProperties() {
Source sourceOne = ImmutableTargetMapper.INSTANCE.fromImmutable( ImmutableTarget.builder()
.bar( 31 )
.foo( "foo" )
ProductDto product = ProductMapper.INSTANCE.fromImmutable( ImmutableProduct.builder()
.price( 31000 )
.name( "car" )
.build() );
assertThat( sourceOne.getBar() ).isEqualTo( 31 );
assertThat( sourceOne.getFoo() ).isEqualTo( "foo" );
assertThat( product.getPrice() ).isEqualTo( 31000 );
assertThat( product.getName() ).isEqualTo( "car" );
}
}

View File

@ -21,15 +21,15 @@ package org.mapstruct.ap.test.builder.abstractBuilder;
/**
* @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) {
this.foo = builder.foo;
public AbstractImmutableProduct(AbstractProductBuilder<?> builder) {
this.name = builder.name;
}
public String getFoo() {
return foo;
public String getName() {
return name;
}
}

View File

@ -18,12 +18,12 @@
*/
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) {
this.foo = foo;
public AbstractProductBuilder<T> name(String name) {
this.name = name;
return this;
}

View File

@ -18,35 +18,35 @@
*/
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 );
this.bar = builder.bar;
this.price = builder.price;
}
public static ImmutableTargetBuilder builder() {
return new ImmutableTargetBuilder();
public static ImmutableProductBuilder builder() {
return new ImmutableProductBuilder();
}
@Override
public Integer getBar() {
return bar;
public Integer getPrice() {
return price;
}
public static class ImmutableTargetBuilder extends AbstractTargetBuilder<ImmutableTarget> {
private Integer bar;
public static class ImmutableProductBuilder extends AbstractProductBuilder<ImmutableProduct> {
private Integer price;
public ImmutableTargetBuilder bar(Integer bar) {
this.bar = bar;
public ImmutableProductBuilder price(Integer price) {
this.price = price;
return this;
}
@Override
public ImmutableTarget build() {
return new ImmutableTarget( this );
public ImmutableProduct build() {
return new ImmutableProduct( this );
}
}
}

View File

@ -18,8 +18,8 @@
*/
package org.mapstruct.ap.test.builder.abstractBuilder;
public interface Target {
String getFoo();
public interface Product {
String getName();
Integer getBar();
Integer getPrice();
}

View File

@ -18,31 +18,31 @@
*/
package org.mapstruct.ap.test.builder.abstractBuilder;
public class Source {
private String foo;
private Integer bar;
public class ProductDto {
private String name;
private Integer price;
public Source() {
public ProductDto() {
}
public Source(String foo, Integer bar) {
this.foo = foo;
this.bar = bar;
public ProductDto(String name, Integer price) {
this.name = name;
this.price = price;
}
public String getFoo() {
return foo;
public String getName() {
return name;
}
public void setFoo(String foo) {
this.foo = foo;
public void setName(String name) {
this.name = name;
}
public Integer getBar() {
return bar;
public Integer getPrice() {
return price;
}
public void setBar(Integer bar) {
this.bar = bar;
public void setPrice(Integer price) {
this.price = price;
}
}

View File

@ -22,11 +22,11 @@ import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@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);
}

View File

@ -18,44 +18,54 @@
*/
package org.mapstruct.ap.test.builder.abstractGenericTarget;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mapstruct.ap.testutil.WithClasses;
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.
*/
@WithClasses({
AbstractChildTarget.class,
AbstractParentTarget.class,
Child.class,
Parent.class,
ChildSource.class,
ImmutableChildTargetImpl.class,
ImmutableParentTargetImpl.class,
MutableChildTargetImpl.class,
MutableParentTargetImpl.class,
ImmutableChild.class,
ImmutableParent.class,
MutableChild.class,
MutableParent.class,
ParentSource.class,
AbstractTargetMapper.class
ParentMapper.class
})
@RunWith(AnnotationProcessorTestRunner.class)
public class AbstractTargetBuilderTest {
public class AbstractGenericTargetBuilderTest {
@Test
public void testAbstractTargetMapper() {
ParentSource parent = new ParentSource();
parent.setCount( 4 );
parent.setNested( new ChildSource( "Phineas" ) );
parent.setChild( new ChildSource( "Phineas" ) );
parent.setNonGenericChild( new ChildSource( "Ferb" ) );
// transform
AbstractParentTarget immutableTarget = AbstractTargetMapper.INSTANCE.toImmutable( parent );
AbstractParentTarget mutableTarget = AbstractTargetMapper.INSTANCE.toMutable( parent );
Parent immutableParent = ParentMapper.INSTANCE.toImmutable( 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 );
assertThat( mutableTarget.getNested().getBar() ).isEqualTo( "Phineas" );
Parent mutableParent = ParentMapper.INSTANCE.toMutable( parent );
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" );
}
}

View File

@ -18,6 +18,6 @@
*/
package org.mapstruct.ap.test.builder.abstractGenericTarget;
public interface AbstractChildTarget {
String getBar();
public interface Child {
String getName();
}

View File

@ -19,20 +19,20 @@
package org.mapstruct.ap.test.builder.abstractGenericTarget;
public class ChildSource {
private String bar;
private String name;
public ChildSource() {
}
public ChildSource(String bar) {
this.bar = bar;
public ChildSource(String name) {
this.name = name;
}
public String getBar() {
return bar;
public String getName() {
return name;
}
public void setBar(String bar) {
this.bar = bar;
public void setName(String name) {
this.name = name;
}
}

View File

@ -18,31 +18,31 @@
*/
package org.mapstruct.ap.test.builder.abstractGenericTarget;
public class ImmutableChildTargetImpl implements AbstractChildTarget {
private final String bar;
public class ImmutableChild implements Child {
private final String name;
private ImmutableChildTargetImpl(ImmutableChildTargetImpl.Builder builder) {
this.bar = builder.bar;
private ImmutableChild(ImmutableChild.Builder builder) {
this.name = builder.name;
}
public static ImmutableChildTargetImpl.Builder builder() {
return new ImmutableChildTargetImpl.Builder();
public static ImmutableChild.Builder builder() {
return new ImmutableChild.Builder();
}
public String getBar() {
return bar;
public String getName() {
return name;
}
public static class Builder {
private String bar;
private String name;
public ImmutableChildTargetImpl.Builder bar(String bar) {
this.bar = bar;
public ImmutableChild.Builder name(String name) {
this.name = name;
return this;
}
public ImmutableChildTargetImpl build() {
return new ImmutableChildTargetImpl( this );
public ImmutableChild build() {
return new ImmutableChild( this );
}
}
}

View File

@ -18,15 +18,15 @@
*/
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 ImmutableChildTargetImpl nested;
private final AbstractChildTarget nonGenericizedNested;
private final ImmutableChild child;
private final Child nonGenericChild;
public ImmutableParentTargetImpl(Builder builder) {
public ImmutableParent(Builder builder) {
this.count = builder.count;
this.nested = builder.nested;
this.nonGenericizedNested = builder.nonGenericizedNested;
this.child = builder.child;
this.nonGenericChild = builder.nonGenericChild;
}
public static Builder builder() {
@ -34,8 +34,8 @@ public class ImmutableParentTargetImpl implements AbstractParentTarget<Immutable
}
@Override
public AbstractChildTarget getNonGenericizedNested() {
return nonGenericizedNested;
public Child getNonGenericChild() {
return nonGenericChild;
}
@Override
@ -44,32 +44,32 @@ public class ImmutableParentTargetImpl implements AbstractParentTarget<Immutable
}
@Override
public ImmutableChildTargetImpl getNested() {
return nested;
public ImmutableChild getChild() {
return child;
}
public static class Builder {
private int count;
private ImmutableChildTargetImpl nested;
private AbstractChildTarget nonGenericizedNested;
private ImmutableChild child;
private Child nonGenericChild;
public Builder count(int count) {
this.count = count;
return this;
}
public Builder nonGenericizedNested(AbstractChildTarget nonGenericizedNested) {
this.nonGenericizedNested = nonGenericizedNested;
public Builder nonGenericChild(Child nonGenericChild) {
this.nonGenericChild = nonGenericChild;
return this;
}
public Builder nested(ImmutableChildTargetImpl nested) {
this.nested = nested;
public Builder child(ImmutableChild child) {
this.child = child;
return this;
}
public ImmutableParentTargetImpl build() {
return new ImmutableParentTargetImpl( this );
public ImmutableParent build() {
return new ImmutableParent( this );
}
}

View File

@ -18,15 +18,15 @@
*/
package org.mapstruct.ap.test.builder.abstractGenericTarget;
public class MutableChildTargetImpl implements AbstractChildTarget {
private String bar;
public class MutableChild implements Child {
private String name;
@Override
public String getBar() {
return null;
public String getName() {
return name;
}
public void setBar(String bar) {
this.bar = bar;
public void setName(String name) {
this.name = name;
}
}

View File

@ -18,10 +18,10 @@
*/
package org.mapstruct.ap.test.builder.abstractGenericTarget;
public class MutableParentTargetImpl implements AbstractParentTarget<ImmutableChildTargetImpl> {
public class MutableParent implements Parent<ImmutableChild> {
private int count;
private ImmutableChildTargetImpl nested;
private AbstractChildTarget nonGenericizedNested;
private ImmutableChild child;
private Child nonGenericChild;
@Override
public int getCount() {
@ -33,20 +33,20 @@ public class MutableParentTargetImpl implements AbstractParentTarget<ImmutableCh
}
@Override
public ImmutableChildTargetImpl getNested() {
return nested;
public ImmutableChild getChild() {
return child;
}
public void setNested(ImmutableChildTargetImpl nested) {
this.nested = nested;
public void setChild(ImmutableChild child) {
this.child = child;
}
@Override
public AbstractChildTarget getNonGenericizedNested() {
return nonGenericizedNested;
public Child getNonGenericChild() {
return nonGenericChild;
}
public void setNonGenericizedNested(AbstractChildTarget nonGenericizedNested) {
this.nonGenericizedNested = nonGenericizedNested;
public void setNonGenericChild(Child nonGenericChild) {
this.nonGenericChild = nonGenericChild;
}
}

View File

@ -18,10 +18,10 @@
*/
package org.mapstruct.ap.test.builder.abstractGenericTarget;
public interface AbstractParentTarget<T extends AbstractChildTarget> {
public interface Parent<T extends Child> {
int getCount();
T getNested();
T getChild();
AbstractChildTarget getNonGenericizedNested();
Child getNonGenericChild();
}

View File

@ -22,18 +22,18 @@ import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@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.
*/
ImmutableChildTargetImpl toChild(ChildSource child);
ImmutableChild toChild(ChildSource child);
}

View File

@ -20,15 +20,15 @@ package org.mapstruct.ap.test.builder.abstractGenericTarget;
public class ParentSource {
private int count;
private ChildSource nested;
private ChildSource nonGenericizedNested;
private ChildSource child;
private ChildSource nonGenericChild;
public ChildSource getNonGenericizedNested() {
return nonGenericizedNested;
public ChildSource getNonGenericChild() {
return nonGenericChild;
}
public void setNonGenericizedNested(ChildSource nonGenericizedNested) {
this.nonGenericizedNested = nonGenericizedNested;
public void setNonGenericChild(ChildSource nonGenericChild) {
this.nonGenericChild = nonGenericChild;
}
public int getCount() {
@ -39,11 +39,11 @@ public class ParentSource {
this.count = count;
}
public ChildSource getNested() {
return nested;
public ChildSource getChild() {
return child;
}
public void setNested(ChildSource nested) {
this.nested = nested;
public void setChild(ChildSource child) {
this.child = child;
}
}

View File

@ -39,7 +39,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
@RunWith(AnnotationProcessorTestRunner.class)
@WithClasses({CupboardDto.class, CupboardEntity.class, CupboardMapper.class})
@IssueKey( "1126" )
public class ImmutableTargetTest {
public class ImmutableProductTest {
@Test
public void shouldHandleImmutableTarget() {

View File

@ -31,7 +31,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
@WithClasses( { Foo9Base.class, Foo9Child.class, Bar9Base.class, Bar9Child.class, Bar9Factory.class,
TargetTypeFactoryTestMapper.class } )
@RunWith( AnnotationProcessorTestRunner.class )
public class TargetTypeFactoryTest {
public class ProductTypeFactoryTest {
@Test
public void shouldUseFactoryTwoCreateBaseClassDueToTargetType() {

View File

@ -50,7 +50,7 @@ import static org.assertj.core.api.Assertions.assertThat;
} )
@IssueKey("389")
@RunWith(AnnotationProcessorTestRunner.class)
public class NestedTargetPropertiesTest {
public class NestedProductPropertiesTest {
@Rule
public GeneratedSource generatedSource = new GeneratedSource().addComparisonToFixtureFor(

View File

@ -39,7 +39,7 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner;
*/
@IssueKey("35")
@RunWith(AnnotationProcessorTestRunner.class)
public class UnmappedTargetTest {
public class UnmappedProductTest {
@Test
@WithClasses({ Source.class, Target.class, SourceTargetMapper.class })