I've a connector class which utilizes the wrapper utilities for HTTP connections.
ServiceResponse getResponse() {
return connectorUtility.get(ServiceKey.MY_SERVICE_1_KEY)
.addHeader("clientId", CLIENT_ID)
.addHeader("Device-User-Agent-ID", duid)
.routeParam("userId", userContext.getUser().getUserId())
.routeParam("tuid", userContext.getUser().getTuid())
.routeParam("siteId", userContext.getSiteContext().getSite().getId().getId())
.withTraceContext(userContext.getTraceContext())
.withObjectMapper(objectMapper)
.asObject(ServiceResponse.class);
}
What's the right way to test right set of headers are passed to HTTP request? I want to get response "only" when right-set of headers, and only if URL is correct (with params passed). Also, I want my tests to fail if some one miss to add trace context (it can be null).
Should I use wiremock? Does it give flexibility to trigger when headers match?
Aucun commentaire:
Enregistrer un commentaire