@@ -45,35 +45,41 @@ public void error_handling_in_stub() {
45
45
} catch (ExternalResourceException actual ) {
46
46
String incidentReferenceId = actual .getMetaData ().httpResponseMetaData .problemResponse .incidentReferenceId ;
47
47
assertThat (incidentReferenceId ).isNotEmpty ();
48
- assertThat (actual .getMetaData ()).isEqualToComparingFieldByFieldRecursively (
49
- MetaData .builder ()
50
- .gotAnswer (true )
51
- .httpRequestMetaData (ExternalResourceException .HttpRequestMetaData .builder ()
52
- .url ("http://localhost:0/path" )
53
- .header ("Accept" , "application/json" )
54
- .header ("User-Agent" , "Jersey/2.25.1 (Jersey InMemory Connector)" )
55
- .build ()
56
- )
57
- .httpResponseMetaData (ExternalResourceException .HttpResponseMetaData .builder ()
58
- .problemResponse (ProblemResponse .builder ()
59
- .title ("Internal Server Error" )
60
- .detail ("Det har oppstått en intern feil" )
61
- .incidentReferenceId (incidentReferenceId )
62
- .status (500 )
63
- .suggestedUserMessageInDetail (false )
64
- .build ()
65
- )
66
- .incidentReferenceId (incidentReferenceId )
67
- .status (500 )
68
- .header ("Content-Length" , "258" )
69
- .header ("Content-Type" , "application/problem+json" )
70
- .build ()
71
- )
72
- .targetName ("test" )
73
- );
48
+ assertThat (actual .getMetaData ().httpResponseMetaData .status )
49
+ .isEqualTo (buildTestMetadata (incidentReferenceId ).httpResponseMetaData .status );
50
+ assertThat (actual .getMetaData ().httpResponseMetaData .problemResponse .status )
51
+ .isEqualTo (buildTestMetadata (incidentReferenceId ).httpResponseMetaData .problemResponse .status );
74
52
}
75
53
}
76
54
55
+ private MetaData buildTestMetadata (String incidentReferenceId ) {
56
+ return MetaData .builder ()
57
+ .gotAnswer (true )
58
+ .httpRequestMetaData (ExternalResourceException .HttpRequestMetaData .builder ()
59
+ .url ("http://localhost:0/path" )
60
+ .header ("Accept" , "application/json" )
61
+ .header ("User-Agent" , "Jersey/2.25.1 (Jersey InMemory Connector)" )
62
+ .build ()
63
+ )
64
+ .httpResponseMetaData (ExternalResourceException .HttpResponseMetaData .builder ()
65
+ .problemResponse (ProblemResponse .builder ()
66
+ .title ("Internal Server Error" )
67
+ .detail ("Det har oppstått en intern feil" )
68
+ .incidentReferenceId (incidentReferenceId )
69
+ .status (500 )
70
+ .suggestedUserMessageInDetail (false )
71
+ .build ()
72
+ )
73
+ .incidentReferenceId (incidentReferenceId )
74
+ .status (500 )
75
+ .header ("Content-Length" , "258" )
76
+ .header ("Content-Type" , "application/problem+json" )
77
+ .build ()
78
+ )
79
+ .targetName ("test" )
80
+ .build ();
81
+ }
82
+
77
83
@ Test (expected = ProcessingException .class )
78
84
public void no_custom_error_handling_when_call_fails_before_network () {
79
85
Client client = ClientGenerator .defaults (TestService .instance ).generate ();
0 commit comments