File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
jmolecules-bytebuddy-tests
jmolecules-bytebuddy-tests-core/src/main/java/example
jmolecules-bytebuddy-tests-vaadoo/src/test/java/org/jmolecules/bytebuddy Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 1717
1818import org .jmolecules .ddd .types .ValueObject ;
1919
20+ import jakarta .validation .constraints .NotEmpty ;
2021import jakarta .validation .constraints .NotNull ;
2122
2223public class SampleValueObject implements ValueObject {
2324
2425 private final String value ;
2526
26- public SampleValueObject (@ NotNull String value ) {
27+ public SampleValueObject (@ NotNull @ NotEmpty String value ) {
2728 this .value = value ;
2829 }
2930
31+ public String getValue () {
32+ return value ;
33+ }
34+
3035}
Original file line number Diff line number Diff line change @@ -72,7 +72,8 @@ void valueObjectWithAttribute(@TempDir File outputFolder) throws Exception {
7272 Class <?> transformedClass = transformedClass (ValueObjectWithAttribute .class , outputFolder );
7373 Constructor <?> stringArgConstructor = transformedClass .getDeclaredConstructor (String .class );
7474 assertThatException ().isThrownBy (() -> stringArgConstructor .newInstance ((String ) null ))
75- .satisfies (e -> assertThat (e .getCause ()).isInstanceOf (NullPointerException .class ).hasMessage ("someString must not be null" ));
75+ .satisfies (e -> assertThat (e .getCause ()).isInstanceOf (NullPointerException .class )
76+ .hasMessage ("someString must not be null" ));
7677 }
7778
7879 private Class <?> transformedClass (Class <?> clazz , File outputFolder ) throws Exception {
@@ -117,8 +118,14 @@ void throwsExceptionOnNullValue() {
117118 }
118119
119120 @ Test
120- void doesNotThrowExceptionOnNonNullValue () {
121- assertThatNoException ().isThrownBy (() -> new SampleValueObject ("test" ));
121+ void throwsExceptionOnEmptyValue () {
122+ assertThatRuntimeException ().isThrownBy (() -> new SampleValueObject ("" )).withMessage ("value must not be empty" );
123+ }
124+
125+ @ Test
126+ void doesNotThrowExceptionOnNonNullValueAndAssignsValues () {
127+ String value = "notNull" ;
128+ assertThat (new SampleValueObject (value ).getValue ()).isEqualTo (value );
122129 }
123130
124131 @ Test
You can’t perform that action at this time.
0 commit comments