Skip to content

Commit 5580d5d

Browse files
committed
[ITA-1649] Fix unit test failing on jenkins
1 parent 2120983 commit 5580d5d

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

servicebuilder-core-addons/src/test/java/no/obos/util/servicebuilder/addon/JerseyClientAddonErrorHandlingTest.java

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -45,35 +45,41 @@ public void error_handling_in_stub() {
4545
} catch (ExternalResourceException actual) {
4646
String incidentReferenceId = actual.getMetaData().httpResponseMetaData.problemResponse.incidentReferenceId;
4747
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);
7452
}
7553
}
7654

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+
7783
@Test(expected = ProcessingException.class)
7884
public void no_custom_error_handling_when_call_fails_before_network() {
7985
Client client = ClientGenerator.defaults(TestService.instance).generate();

0 commit comments

Comments
 (0)