Search in sources :

Example 1 with Builder

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);
}
Also used : Builder(com.google.api.ads.common.lib.client.ResponseInfo.Builder) SOAPMessage(javax.xml.soap.SOAPMessage) Test(org.junit.Test)

Example 2 with 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());
}
Also used : ResponseInfo(com.google.api.ads.common.lib.client.ResponseInfo) Builder(com.google.api.ads.common.lib.client.ResponseInfo.Builder) OutputStream(java.io.OutputStream) SOAPMessage(javax.xml.soap.SOAPMessage) SOAPHeader(javax.xml.soap.SOAPHeader) Test(org.junit.Test)

Aggregations

Builder (com.google.api.ads.common.lib.client.ResponseInfo.Builder)2 SOAPMessage (javax.xml.soap.SOAPMessage)2 Test (org.junit.Test)2 ResponseInfo (com.google.api.ads.common.lib.client.ResponseInfo)1 OutputStream (java.io.OutputStream)1 SOAPHeader (javax.xml.soap.SOAPHeader)1