use of com.google.api.ads.common.lib.client.RequestInfo.Builder in project googleads-java-lib by googleads.
the class RequestInfoXPathSetTest method testParseTransformException.
@Test
public void testParseTransformException() throws TransformerException {
Builder builder = Mockito.mock(Builder.class);
SOAPMessage message = Mockito.mock(SOAPMessage.class);
doThrow(TransformerException.class).when(transformer).transform(any(Source.class), any(Result.class));
assertSame("parseMessage should return the same builder passed in", builder, xPathSet.parseMessage(builder, message));
}
use of com.google.api.ads.common.lib.client.RequestInfo.Builder in project googleads-java-lib by googleads.
the class RequestInfoXPathSetTest 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, 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.RequestInfo.Builder in project googleads-java-lib by googleads.
the class RequestInfoXPathSetTest method testParseWithNullTransformer.
@Test
public void testParseWithNullTransformer() {
Builder builder = Mockito.mock(Builder.class);
when(transformerSupplier.get()).thenReturn(null);
SOAPMessage message = Mockito.mock(SOAPMessage.class);
when(message.getSOAPPart()).thenReturn(Mockito.mock(SOAPPart.class));
assertSame("parseMessage should return the same builder passed in", builder, xPathSet.parseMessage(builder, message));
// Transformer was null, so no methods should have been called on the builder.
verifyNoMoreInteractions(builder);
}
use of com.google.api.ads.common.lib.client.RequestInfo.Builder in project googleads-java-lib by googleads.
the class RequestInfoXPathSetTest method testParseWithNullSoapPart.
@Test
public void testParseWithNullSoapPart() {
Builder builder = Mockito.mock(Builder.class);
SOAPMessage message = Mockito.mock(SOAPMessage.class);
when(message.getSOAPPart()).thenReturn(null);
assertSame("parseMessage should return the same builder passed in", builder, xPathSet.parseMessage(builder, message));
// SOAPPart was null, so no methods should have been called on the builder.
verifyNoMoreInteractions(builder);
}
use of com.google.api.ads.common.lib.client.RequestInfo.Builder in project googleads-java-lib by googleads.
the class RequestInfoXPathSetTest method testParseActualMessage.
@Test
public void testParseActualMessage() throws SOAPException, IOException, TransformerException {
Builder builder = new Builder();
SOAPMessage message = Mockito.mock(SOAPMessage.class);
SOAPHeader header = Mockito.mock(SOAPHeader.class);
SOAPPart soapPart = Mockito.mock(SOAPPart.class);
when(message.getSOAPHeader()).thenReturn(header);
when(message.getSOAPPart()).thenReturn(soapPart);
final String payload = "<foo><bar>MyBar</bar></foo>";
when(transformerSupplier.get()).thenReturn(transformer);
doAnswer(invocation -> {
StreamResult streamResult = (StreamResult) invocation.getArguments()[1];
streamResult.getOutputStream().write(payload.getBytes(StandardCharsets.UTF_8));
return null;
}).when(transformer).transform(any(), any());
assertSame("parseMessage should return the same builder passed in", builder, xPathSet.parseMessage(builder, message));
RequestInfo requestInfo = builder.build();
assertEquals("Payload doesn't match", payload, requestInfo.getPayload());
assertEquals("Context name doesn't match", "bar", requestInfo.getContextName());
}
Aggregations