@Test public void testMatchWithSomeNullParameters() throws Exception { RecordedStringHttpBody stringHttpBody1 = new RecordedStringHttpBody("a=a&b=&c=c&d="); RecordedStringHttpBody stringHttpBody2 = new RecordedStringHttpBody("a=a&b=&c=c&d="); Multimap<String, String> headers = LinkedHashMultimap.create(); headers.put("Content-Type", "application/x-www-form-urlencoded"); RecordedHttpRequest recordedHttpRequest1 = new RecordedHttpRequest(null, null, headers, stringHttpBody1); RecordedHttpRequest recordedHttpRequest2 = new RecordedHttpRequest(null, null, headers, stringHttpBody2); MatchRule matchRule = new MatchBodyPostParameters(); Assert.assertTrue(matchRule.test(recordedHttpRequest1, recordedHttpRequest2)); }
@Override public boolean test(RecordedHttpRequest incomingRequest, RecordedHttpRequest expectedRequest) { if (HttpUtilities.isFormURLEncodedContentType(incomingRequest.getContentType()) && HttpUtilities .isFormURLEncodedContentType(expectedRequest.getContentType())) { try { Map<String, String> incomingParams = getPostParametersFromRequest(incomingRequest); Map<String, String> expectedParams = getPostParametersFromRequest(expectedRequest); return testParameterEquivalency(incomingParams, expectedParams); } catch (UnsupportedEncodingException e) { logger.error("Caught exception " + e + " while decoding POST parameters"); } } return super.test(incomingRequest, expectedRequest); }
MatchBodyPostParameters extends MatchBody { @Override public boolean test(RecordedHttpRequest incomingRequest, RecordedHttpRequest expectedRequest) { if (HttpUtilities.isFormURLEncodedContentType(incomingRequest.getContentType()) && HttpUtilities .isFormURLEncodedContentType(expectedRequest.getContentType())) { try { Map<String, String> incomingParams = getPostParametersFromRequest(incomingRequest); Map<String, String> expectedParams = getPostParametersFromRequest(expectedRequest); return testParameterEquivalency(incomingParams, expectedParams); } catch (UnsupportedEncodingException e) { logger.error("Caught exception " + e + " while decoding POST parameters"); } } return super.test(incomingRequest, expectedRequest); } }
MatchBodyPostParameters extends MatchBody { @Override public boolean test(RecordedHttpRequest incomingRequest, RecordedHttpRequest expectedRequest) { if (HttpUtilities.isFormURLEncodedContentType(incomingRequest.getContentType()) && HttpUtilities .isFormURLEncodedContentType(expectedRequest.getContentType())) { try { Map<String, String> incomingParams = getPostParametersFromRequest(incomingRequest); Map<String, String> expectedParams = getPostParametersFromRequest(expectedRequest); return testParameterEquivalency(incomingParams, expectedParams); } catch (UnsupportedEncodingException e) { logger.error("Caught exception " + e + " while decoding POST parameters"); } } return super.test(incomingRequest, expectedRequest); } MatchBodyPostParameters();  MatchBodyPostParameters(MatchRuleMapTransform transform); }
MatchBodyPostParameters extends MatchBody { @Override public boolean test(RecordedHttpRequest incomingRequest, RecordedHttpRequest expectedRequest) { if (HttpUtilities.isFormURLEncodedContentType(incomingRequest.getContentType()) && HttpUtilities .isFormURLEncodedContentType(expectedRequest.getContentType())) { try { Map<String, String> incomingParams = getPostParametersFromRequest(incomingRequest); Map<String, String> expectedParams = getPostParametersFromRequest(expectedRequest); return testParameterEquivalency(incomingParams, expectedParams); } catch (UnsupportedEncodingException e) { logger.error("Caught exception " + e + " while decoding POST parameters"); } } return super.test(incomingRequest, expectedRequest); } MatchBodyPostParameters();  MatchBodyPostParameters(MatchRuleMapTransform transform); @Override boolean test(RecordedHttpRequest incomingRequest, RecordedHttpRequest expectedRequest); @Override String getMatchFailureDescriptionForRequests(RecordedHttpRequest incomingRequest, RecordedHttpRequest expectedRequest); }
MatchBodyPostParameters extends MatchBody { @Override public boolean test(RecordedHttpRequest incomingRequest, RecordedHttpRequest expectedRequest) { if (HttpUtilities.isFormURLEncodedContentType(incomingRequest.getContentType()) && HttpUtilities .isFormURLEncodedContentType(expectedRequest.getContentType())) { try { Map<String, String> incomingParams = getPostParametersFromRequest(incomingRequest); Map<String, String> expectedParams = getPostParametersFromRequest(expectedRequest); return testParameterEquivalency(incomingParams, expectedParams); } catch (UnsupportedEncodingException e) { logger.error("Caught exception " + e + " while decoding POST parameters"); } } return super.test(incomingRequest, expectedRequest); } MatchBodyPostParameters();  MatchBodyPostParameters(MatchRuleMapTransform transform); @Override boolean test(RecordedHttpRequest incomingRequest, RecordedHttpRequest expectedRequest); @Override String getMatchFailureDescriptionForRequests(RecordedHttpRequest incomingRequest, RecordedHttpRequest expectedRequest);  }