public static XPathBody xpath(String xpath) { return new XPathBody(xpath); }
@Override public void serialize(XPathBody xPathBody, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeStartObject(); if (xPathBody.getNot() != null && xPathBody.getNot()) { jgen.writeBooleanField("not", xPathBody.getNot()); } jgen.writeStringField("type", xPathBody.getType().name()); jgen.writeStringField("xpath", xPathBody.getValue()); jgen.writeEndObject(); } }
public XPathBodyDTO(XPathBody xPathBody, Boolean not) { super(Body.Type.XPATH, not); this.xpath = xPathBody.getValue(); }
} else if (body instanceof XPathBody) { XPathBody xPathBody = (XPathBody) body; result = new XPathBodyDTO(xPathBody, xPathBody.getNot());
.when( request() .withBody(xpath("/bookstore/book[year=2005]/price")) .when( request() .withBody(xpath("/bookstore/book[year=2006]/price")) .clear( request() .withBody(xpath("/bookstore/book[year=2005]/price")) ); arrayContaining( new Expectation(request() .withBody(xpath("/bookstore/book[year=2006]/price"))) .thenRespond( response()
output.append(".withBody("); XPathBody xPathBody = (XPathBody) request.getBody(); output.append("new XPathBody(\"").append(StringEscapeUtils.escapeJava(xPathBody.getValue())).append("\")"); output.append(")"); } else if (request.getBody() instanceof XmlSchemaBody) {
} else if (body instanceof XPathBody) { XPathBody xPathBody = (XPathBody) body; result = new XPathBodyDTO(xPathBody, xPathBody.getNot());
@Test public void shouldReturnResponseByMatchingBodyWithXPath() { mockServerClient.when(request().withBody(xpath("/bookstore/book[price>30]/price")), exactly(2)).respond(response().withBody("some_body"));
public XPathBody buildObject() { return new XPathBody(getXPath()); } }
@Override public void serialize(XPathBody xPathBody, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeStartObject(); if (xPathBody.getNot() != null && xPathBody.getNot()) { jgen.writeBooleanField("not", xPathBody.getNot()); } jgen.writeStringField("type", xPathBody.getType().name()); jgen.writeStringField("xpath", xPathBody.getValue()); jgen.writeEndObject(); } }
XPathBody xPathBody = (XPathBody) body; bodyDTOMatcher = new XPathBodyDTO(xPathBody); this.bodyMatcher = new XPathMatcher(mockServerLogger, xPathBody.getValue()); break; case XML:
return new XmlSchemaBodyDTO(new XmlSchemaBody(valueJsonValue), not); case XPATH: return new XPathBodyDTO(new XPathBody(valueJsonValue), not);
public XPathBodyDTO(XPathBody xPathBody, Boolean not) { super(Body.Type.XPATH, not); this.xpath = xPathBody.getValue(); }
@Test public void shouldNotReturnResponseForNonMatchingXPathBody() { mockServerClient.when(request().withBody(new XPathBody("/bookstore/book[price>35]/price")), exactly(2)).respond(response().withBody("some_body"));
output.append(".withBody("); XPathBody xPathBody = (XPathBody) request.getBody(); output.append("new XPathBody(\"").append(StringEscapeUtils.escapeJava(xPathBody.getValue())).append("\")"); output.append(")"); } else if (request.getBody() instanceof XmlSchemaBody) {
public static XPathBody xpath(String xpath) { return new XPathBody(xpath); }
XPathBody xPathBody = (XPathBody) body; bodyDTOMatcher = new XPathBodyDTO(xPathBody); this.bodyMatcher = new XPathMatcher(mockServerLogger, xPathBody.getValue()); break; case XML:
public XPathBody buildObject() { return new XPathBody(getXPath()); } }
b = new XPathBody(bodyContent); } else if (matcher.equals("binary")) { b = new BinaryBody(bodyContent.getBytes());
return new XmlSchemaBodyDTO(new XmlSchemaBody(valueJsonValue), not); case XPATH: return new XPathBodyDTO(new XPathBody(valueJsonValue), not);