From 9a211982654d0a356a73efb29fa6322936bc4042 Mon Sep 17 00:00:00 2001 From: Gunnar Morling Date: Tue, 24 Jun 2014 22:43:04 +0200 Subject: [PATCH] #237 Improving test/method names --- .../{npe => nullcheck}/MyBigIntMapper.java | 3 +- .../{npe => nullcheck}/MyBigIntWrapper.java | 5 ++- .../NullCheckTest.java} | 36 +++++++++---------- .../test/{npe => nullcheck}/NullObject.java | 3 +- .../{npe => nullcheck}/NullObjectMapper.java | 3 +- .../ap/test/{npe => nullcheck}/Source.java | 11 +++--- .../SourceTargetMapper.java | 5 ++- .../ap/test/{npe => nullcheck}/Target.java | 14 +++----- 8 files changed, 35 insertions(+), 45 deletions(-) rename processor/src/test/java/org/mapstruct/ap/test/{npe => nullcheck}/MyBigIntMapper.java (96%) rename processor/src/test/java/org/mapstruct/ap/test/{npe => nullcheck}/MyBigIntWrapper.java (91%) rename processor/src/test/java/org/mapstruct/ap/test/{npe/NullPtrCheckTest.java => nullcheck/NullCheckTest.java} (75%) rename processor/src/test/java/org/mapstruct/ap/test/{npe => nullcheck}/NullObject.java (95%) rename processor/src/test/java/org/mapstruct/ap/test/{npe => nullcheck}/NullObjectMapper.java (95%) rename processor/src/test/java/org/mapstruct/ap/test/{npe => nullcheck}/Source.java (85%) rename processor/src/test/java/org/mapstruct/ap/test/{npe => nullcheck}/SourceTargetMapper.java (90%) rename processor/src/test/java/org/mapstruct/ap/test/{npe => nullcheck}/Target.java (85%) diff --git a/processor/src/test/java/org/mapstruct/ap/test/npe/MyBigIntMapper.java b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/MyBigIntMapper.java similarity index 96% rename from processor/src/test/java/org/mapstruct/ap/test/npe/MyBigIntMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/nullcheck/MyBigIntMapper.java index b7fb67931..d731d72a1 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/npe/MyBigIntMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/MyBigIntMapper.java @@ -16,12 +16,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.npe; +package org.mapstruct.ap.test.nullcheck; import java.math.BigInteger; /** - * * @author Sjaak Derksen */ public class MyBigIntMapper { diff --git a/processor/src/test/java/org/mapstruct/ap/test/npe/MyBigIntWrapper.java b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/MyBigIntWrapper.java similarity index 91% rename from processor/src/test/java/org/mapstruct/ap/test/npe/MyBigIntWrapper.java rename to processor/src/test/java/org/mapstruct/ap/test/nullcheck/MyBigIntWrapper.java index 95ba3c1ef..649cccac7 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/npe/MyBigIntWrapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/MyBigIntWrapper.java @@ -16,12 +16,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.npe; +package org.mapstruct.ap.test.nullcheck; import java.math.BigInteger; /** - * * @author Sjaak Derksen */ public class MyBigIntWrapper { @@ -32,7 +31,7 @@ public class MyBigIntWrapper { return myBigInt; } - public void setMyBigInt( BigInteger myBigInt ) { + public void setMyBigInt(BigInteger myBigInt) { this.myBigInt = myBigInt; } } diff --git a/processor/src/test/java/org/mapstruct/ap/test/npe/NullPtrCheckTest.java b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/NullCheckTest.java similarity index 75% rename from processor/src/test/java/org/mapstruct/ap/test/npe/NullPtrCheckTest.java rename to processor/src/test/java/org/mapstruct/ap/test/nullcheck/NullCheckTest.java index 6c4660b9c..423f80a09 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/npe/NullPtrCheckTest.java +++ b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/NullCheckTest.java @@ -16,21 +16,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.npe; +package org.mapstruct.ap.test.nullcheck; -import static org.fest.assertions.Assertions.assertThat; import org.junit.Test; import org.junit.runner.RunWith; import org.mapstruct.ap.testutil.IssueKey; import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; +import static org.fest.assertions.Assertions.assertThat; + /** * Test for correct handling of null checks. * * @author Sjaak Derksen */ -@WithClasses( { +@WithClasses({ SourceTargetMapper.class, NullObjectMapper.class, NullObject.class, @@ -38,12 +39,12 @@ import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; MyBigIntWrapper.class, Source.class, Target.class -} ) -@RunWith( AnnotationProcessorTestRunner.class ) -public class NullPtrCheckTest { +}) +@RunWith(AnnotationProcessorTestRunner.class) +public class NullCheckTest { - @IssueKey( "214" ) - @Test( expected = NullPointerException.class ) + @Test(expected = NullPointerException.class) + @IssueKey("214") public void shouldThrowNullptrWhenCustomMapperIsInvoked() { Source source = new Source(); @@ -52,41 +53,40 @@ public class NullPtrCheckTest { SourceTargetMapper.INSTANCE.sourceToTarget( source ); } - @IssueKey( "214" ) @Test - public void shouldSurroundTypeConversionWithNPECheck() { + @IssueKey("214") + public void shouldSurroundTypeConversionWithNullCheck() { Source source = new Source(); source.setSomeObject( new NullObject() ); source.setSomeInteger( 7 ); - Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); + Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); assertThat( target.getNumber() ).isNull(); } - @IssueKey( "214" ) @Test - public void shouldSurroundArrayListConstructionWithNPECheck() { + @IssueKey("214") + public void shouldSurroundArrayListConstructionWithNullCheck() { Source source = new Source(); source.setSomeObject( new NullObject() ); source.setSomeInteger( 7 ); - Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); + Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); assertThat( target.getSomeList() ).isNull(); } - @IssueKey( "237" ) @Test - public void shouldMapMappedTypeConversion() { + @IssueKey("237") + public void shouldSurroundConversionPassedToMappingMethodWithNullCheck() { Source source = new Source(); source.setSomeObject( new NullObject() ); - Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); + Target target = SourceTargetMapper.INSTANCE.sourceToTarget( source ); assertThat( target.getSomeList() ).isNull(); assertThat( target.getSomeInteger() ).isNull(); } - } diff --git a/processor/src/test/java/org/mapstruct/ap/test/npe/NullObject.java b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/NullObject.java similarity index 95% rename from processor/src/test/java/org/mapstruct/ap/test/npe/NullObject.java rename to processor/src/test/java/org/mapstruct/ap/test/nullcheck/NullObject.java index bcba6d1a5..437cc9a22 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/npe/NullObject.java +++ b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/NullObject.java @@ -16,10 +16,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.npe; +package org.mapstruct.ap.test.nullcheck; /** - * * @author Sjaak Derksen */ public class NullObject { diff --git a/processor/src/test/java/org/mapstruct/ap/test/npe/NullObjectMapper.java b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/NullObjectMapper.java similarity index 95% rename from processor/src/test/java/org/mapstruct/ap/test/npe/NullObjectMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/nullcheck/NullObjectMapper.java index 15f1303cd..0b3135be3 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/npe/NullObjectMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/NullObjectMapper.java @@ -16,10 +16,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.npe; +package org.mapstruct.ap.test.nullcheck; /** - * * @author Sjaak Derksen */ public class NullObjectMapper { diff --git a/processor/src/test/java/org/mapstruct/ap/test/npe/Source.java b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/Source.java similarity index 85% rename from processor/src/test/java/org/mapstruct/ap/test/npe/Source.java rename to processor/src/test/java/org/mapstruct/ap/test/nullcheck/Source.java index f0a8deda4..3e1d84fbf 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/npe/Source.java +++ b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/Source.java @@ -16,12 +16,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.npe; +package org.mapstruct.ap.test.nullcheck; import java.util.List; /** - * * @author Sjaak Derksen */ public class Source { @@ -35,7 +34,7 @@ public class Source { return someObject; } - public void setSomeObject( NullObject someObject ) { + public void setSomeObject(NullObject someObject) { this.someObject = someObject; } @@ -43,7 +42,7 @@ public class Source { return number; } - public void setNumber( String number ) { + public void setNumber(String number) { this.number = number; } @@ -51,7 +50,7 @@ public class Source { return someList; } - public void setSomeList( List someList ) { + public void setSomeList(List someList) { this.someList = someList; } @@ -59,7 +58,7 @@ public class Source { return someInteger; } - public void setSomeInteger( Integer someInteger ) { + public void setSomeInteger(Integer someInteger) { this.someInteger = someInteger; } diff --git a/processor/src/test/java/org/mapstruct/ap/test/npe/SourceTargetMapper.java b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/SourceTargetMapper.java similarity index 90% rename from processor/src/test/java/org/mapstruct/ap/test/npe/SourceTargetMapper.java rename to processor/src/test/java/org/mapstruct/ap/test/nullcheck/SourceTargetMapper.java index d45e36585..c90746b83 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/npe/SourceTargetMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/SourceTargetMapper.java @@ -16,16 +16,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.npe; +package org.mapstruct.ap.test.nullcheck; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; /** - * * @author Sjaak Derksen */ -@Mapper (uses = { NullObjectMapper.class, MyBigIntMapper.class } ) +@Mapper(uses = { NullObjectMapper.class, MyBigIntMapper.class }) public interface SourceTargetMapper { SourceTargetMapper INSTANCE = Mappers.getMapper( SourceTargetMapper.class ); diff --git a/processor/src/test/java/org/mapstruct/ap/test/npe/Target.java b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/Target.java similarity index 85% rename from processor/src/test/java/org/mapstruct/ap/test/npe/Target.java rename to processor/src/test/java/org/mapstruct/ap/test/nullcheck/Target.java index 4eafb2eb2..c4de61590 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/npe/Target.java +++ b/processor/src/test/java/org/mapstruct/ap/test/nullcheck/Target.java @@ -16,12 +16,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.mapstruct.ap.test.npe; +package org.mapstruct.ap.test.nullcheck; import java.util.List; /** - * * @author Sjaak Derksen */ public class Target { @@ -35,7 +34,7 @@ public class Target { return someObject; } - public void setSomeObject( String someObject ) { + public void setSomeObject(String someObject) { this.someObject = someObject; } @@ -43,7 +42,7 @@ public class Target { return number; } - public void setNumber( Integer number ) { + public void setNumber(Integer number) { this.number = number; } @@ -51,7 +50,7 @@ public class Target { return someList; } - public void setSomeList( List someList ) { + public void setSomeList(List someList) { this.someList = someList; } @@ -59,10 +58,7 @@ public class Target { return someInteger; } - public void setSomeInteger( MyBigIntWrapper someInteger ) { + public void setSomeInteger(MyBigIntWrapper someInteger) { this.someInteger = someInteger; } - - - }