use of com.google.api.ads.common.lib.client.ResponseInfo.Builder in project googleads-java-lib by googleads.
the class ResponseInfoXPathSetTest method testParseWithNullMessage.
@Test
public void testParseWithNullMessage() {
Builder builder = Mockito.mock(Builder.class);
assertSame("parseMessage should return the same builder passed in", builder, xPathSet.parseMessage(builder, (SOAPMessage) null));
// Message was null, so no methods should have been called on the builder.
verifyNoMoreInteractions(builder);
}
use of com.google.api.ads.common.lib.client.ResponseInfo.Builder in project googleads-java-lib by googleads.
the class ResponseInfoXPathSetTest method testParseActualMessage.
@Test
public void testParseActualMessage() throws SOAPException, IOException {
Builder builder = new Builder();
SOAPMessage message = Mockito.mock(SOAPMessage.class);
SOAPHeader header = Mockito.mock(SOAPHeader.class);
when(message.getSOAPHeader()).thenReturn(header);
final String payload = "<foo><bar>MyBar</bar></foo>";
doAnswer(invocation -> {
OutputStream outputStream = (OutputStream) invocation.getArguments()[0];
outputStream.write(payload.getBytes(StandardCharsets.UTF_8));
return null;
}).when(message).writeTo(org.mockito.ArgumentMatchers.any(OutputStream.class));
assertSame("parseMessage should return the same builder passed in", builder, xPathSet.parseMessage(builder, message));
ResponseInfo responseInfo = builder.build();
assertEquals("Payload doesn't match", payload, responseInfo.getPayload());
}
Aggregations