File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed
main/java/ru/ewc/decita/core/value
test/java/ru/ewc/decita/core/value Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,8 @@ in the commit message.
18
18
19
19
## Fetching data from a constant value provider
20
20
21
- - Creating an empty ` ConstantValueProvider ` should not be possible.
22
- - Test creating a ` ConstantValueProvider ` with a single String value and getting that value back.
21
+ - [x] Creating an empty ` ConstantValueProvider ` should not be possible.
22
+ - [x] Test creating a ` ConstantValueProvider ` with a single String value and getting that value back.
23
23
24
24
## Fetching data from a complex object
25
25
Original file line number Diff line number Diff line change 24
24
25
25
package ru .ewc .decita .core .value ;
26
26
27
+ import java .util .Objects ;
27
28
import ru .ewc .decisions .api .ComputationContext ;
28
29
29
30
/**
@@ -44,7 +45,7 @@ public final class ConstantValueProvider<T> implements ValueProvider<T> {
44
45
* @param value The constant value to be provided.
45
46
*/
46
47
public ConstantValueProvider (final T value ) {
47
- this .value = value ;
48
+ this .value = Objects . requireNonNull ( value , "Constant value cannot be null" ) ;
48
49
}
49
50
50
51
@ Override
Original file line number Diff line number Diff line change 33
33
* @since 0.10.0
34
34
*/
35
35
final class ConstantValueProviderTest {
36
- /**
37
- * A simple test to check that the provider returns the value it was created with.
38
- */
39
36
@ Test
40
37
void returnsTheValueItWasCreatedWith () {
41
38
final var provider = new ConstantValueProvider <>("Hello, World!" );
42
39
Assertions .assertThat (provider .valueFrom (null )).isEqualTo ("Hello, World!" );
43
40
}
41
+
42
+ @ Test
43
+ void doesNotAllowEmptyValue () {
44
+ Assertions .assertThatThrownBy (() -> new ConstantValueProvider <>(null ))
45
+ .isInstanceOf (NullPointerException .class );
46
+ }
44
47
}
You can’t perform that action at this time.
0 commit comments