BAEL 4401 (#9913)
* BAEL-4401 * Update with master and resolve conflicts
This commit is contained in:
parent
bbeb322d41
commit
aa96649458
@ -30,5 +30,4 @@
|
|||||||
<!-- testing -->
|
<!-- testing -->
|
||||||
<assertj-core.version>3.10.0</assertj-core.version>
|
<assertj-core.version>3.10.0</assertj-core.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.baeldung.nullmethodparameter;
|
||||||
|
|
||||||
|
public class NullParameterExample {
|
||||||
|
public void processSomethingNotNull(Object myParameter) {
|
||||||
|
if (myParameter == null) {
|
||||||
|
throw new IllegalArgumentException("Parameter 'myParameter' cannot be null");
|
||||||
|
}
|
||||||
|
//Do something with the parameter
|
||||||
|
}
|
||||||
|
|
||||||
|
public void processSomethingElseNotNull(Object myParameter) {
|
||||||
|
if (myParameter == null) {
|
||||||
|
throw new NullPointerException("Parameter 'myParameter' cannot be null");
|
||||||
|
}
|
||||||
|
//Do something with the parameter
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.baeldung.nullmethodparameter;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class NullParameterExampleUnitTest {
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void givenNullParameter_whenProcessSomethingNotNull_thenIllegalArgumentException() {
|
||||||
|
NullParameterExample example = new NullParameterExample();
|
||||||
|
example.processSomethingNotNull(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expected = NullPointerException.class)
|
||||||
|
public void givenNullParameter_whenProcessSomethingElseNotNull_thenNullPointerException() {
|
||||||
|
NullParameterExample example = new NullParameterExample();
|
||||||
|
example.processSomethingElseNotNull(null);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user