mirror of
https://github.com/mapstruct/mapstruct.git
synced 2025-07-12 00:00:08 +08:00
#237 Improving test/method names
This commit is contained in:
parent
02c81ae651
commit
9a21198265
@ -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 {
|
@ -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;
|
||||
}
|
||||
}
|
@ -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,9 +53,9 @@ 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() );
|
||||
@ -65,9 +66,9 @@ public class NullPtrCheckTest {
|
||||
|
||||
}
|
||||
|
||||
@IssueKey( "214" )
|
||||
@Test
|
||||
public void shouldSurroundArrayListConstructionWithNPECheck() {
|
||||
@IssueKey("214")
|
||||
public void shouldSurroundArrayListConstructionWithNullCheck() {
|
||||
|
||||
Source source = new Source();
|
||||
source.setSomeObject( new NullObject() );
|
||||
@ -77,9 +78,9 @@ public class NullPtrCheckTest {
|
||||
assertThat( target.getSomeList() ).isNull();
|
||||
}
|
||||
|
||||
@IssueKey( "237" )
|
||||
@Test
|
||||
public void shouldMapMappedTypeConversion() {
|
||||
@IssueKey("237")
|
||||
public void shouldSurroundConversionPassedToMappingMethodWithNullCheck() {
|
||||
|
||||
Source source = new Source();
|
||||
source.setSomeObject( new NullObject() );
|
||||
@ -88,5 +89,4 @@ public class NullPtrCheckTest {
|
||||
assertThat( target.getSomeList() ).isNull();
|
||||
assertThat( target.getSomeInteger() ).isNull();
|
||||
}
|
||||
|
||||
}
|
@ -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 {
|
@ -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 {
|
@ -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;
|
||||
}
|
||||
|
@ -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 );
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user