#237 Improving test/method names

This commit is contained in:
Gunnar Morling 2014-06-24 22:43:04 +02:00
parent 02c81ae651
commit 9a21198265
8 changed files with 35 additions and 45 deletions

View File

@ -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 {

View File

@ -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;
}
}

View File

@ -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();
}
}

View File

@ -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 {

View File

@ -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 {

View File

@ -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<String> someList ) {
public void setSomeList(List<String> 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;
}

View File

@ -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 );

View File

@ -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<String> someList ) {
public void setSomeList(List<String> 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;
}
}