File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
errors/src/test/java/com/palantir/conjure/java/api/errors Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 2626import java .io .IOException ;
2727import java .util .List ;
2828import java .util .Map ;
29+ import java .util .Optional ;
2930import java .util .regex .Pattern ;
3031import org .junit .jupiter .api .Test ;
3132
@@ -125,6 +126,24 @@ public void forException_mapArrayArgValue_serializesWithToString() {
125126 assertThat (value ).matches (Pattern .quote ("[Ljava.lang.String;@" ) + "[0-9a-f]+" ));
126127 }
127128
129+ @ Test
130+ public void forException_optionalArgValue_serializesWithToString () {
131+ ErrorType error = ErrorType .INTERNAL ;
132+ ServiceException exception = new ServiceException (
133+ error ,
134+ SafeArg .of ("safe-optional-present" , Optional .of ("hello" )),
135+ UnsafeArg .of ("unsafe-optional-empty" , Optional .empty ()));
136+
137+ SerializableError expected = new SerializableError .Builder ()
138+ .errorCode (error .code ().name ())
139+ .errorName (error .name ())
140+ .errorInstanceId (exception .getErrorInstanceId ())
141+ .putParameters ("safe-optional-present" , "Optional[hello]" )
142+ .putParameters ("unsafe-optional-empty" , "Optional.empty" )
143+ .build ();
144+ assertThat (SerializableError .forException (exception )).isEqualTo (expected );
145+ }
146+
128147 @ Test
129148 public void testSerializationContainsRedundantParameters () throws Exception {
130149 assertThat (mapper .writeValueAsString (ERROR ))
You can’t perform that action at this time.
0 commit comments