Search in sources :

Example 11 with RemoteCallReturn

use of com.google.api.ads.common.lib.client.RemoteCallReturn in project googleads-java-lib by googleads.

the class JaxWsHandlerTest method testInvokeSoapCall.

@Test
public void testInvokeSoapCall() throws SecurityException, NoSuchMethodException {
    CampaignServiceInterface soapClient = new CampaignServiceInterfaceImpl();
    Method soapCallMethod = CampaignServiceInterface.class.getMethod("getTestMessage", new Class<?>[0]);
    SoapCall<BindingProvider> soapCall = new SoapCall<BindingProvider>(soapCallMethod, soapClient, new Object[0]);
    RemoteCallReturn returnedValue = jaxWsHandler.invokeSoapCall(soapCall);
    assertEquals("Here!", returnedValue.getReturnValue());
    assertEquals(null, returnedValue.getException());
    assertEquals(CampaignServiceInterfaceImpl.endpointAddress, returnedValue.getRequestInfo().getUrl());
}
Also used : CampaignServiceInterface(com.google.api.ads.common.lib.soap.jaxws.testing.mocks.CampaignServiceInterface) Method(java.lang.reflect.Method) BindingProvider(javax.xml.ws.BindingProvider) SoapCall(com.google.api.ads.common.lib.soap.SoapCall) CampaignServiceInterfaceImpl(com.google.api.ads.common.lib.soap.jaxws.testing.mocks.CampaignServiceInterfaceImpl) RemoteCallReturn(com.google.api.ads.common.lib.client.RemoteCallReturn) Test(org.junit.Test)

Example 12 with RemoteCallReturn

use of com.google.api.ads.common.lib.client.RemoteCallReturn in project googleads-java-lib by googleads.

the class SoapServiceClientTest method testUnwrapRemoteCallReturn_successful.

@Test
public void testUnwrapRemoteCallReturn_successful() throws Throwable {
    Object expectedReturnValue = "return";
    RemoteCallReturn remoteCallReturn = new RemoteCallReturn.Builder().withReturnValue(expectedReturnValue).build();
    assertEquals(expectedReturnValue, soapServiceClient.unwrapRemoteCallReturn(remoteCallReturn));
}
Also used : RemoteCallReturn(com.google.api.ads.common.lib.client.RemoteCallReturn) Test(org.junit.Test)

Example 13 with RemoteCallReturn

use of com.google.api.ads.common.lib.client.RemoteCallReturn in project googleads-java-lib by googleads.

the class SoapServiceClientTest method testCallSoapClient_exception.

@Test
@SuppressWarnings("unchecked")
public void testCallSoapClient_exception() {
    RemoteCallReturn expectedRemoteCallReturn = new RemoteCallReturn.Builder().withException(MockSoapClient.EXCEPTION).build();
    SoapCall<Object> soapCall = Mockito.mock(SoapCall.class);
    when(soapClientHandler.invokeSoapCall(soapCall)).thenReturn(expectedRemoteCallReturn);
    RemoteCallReturn testRemoteCallReturn = soapServiceClient.callSoapClient(soapCall);
    assertSame(MockSoapClient.EXCEPTION, testRemoteCallReturn.getException());
}
Also used : RemoteCallReturn(com.google.api.ads.common.lib.client.RemoteCallReturn) Test(org.junit.Test)

Example 14 with RemoteCallReturn

use of com.google.api.ads.common.lib.client.RemoteCallReturn in project googleads-java-lib by googleads.

the class SoapServiceClientTest method testInvoke_soapClientMethod.

@Test
public void testInvoke_soapClientMethod() throws Throwable {
    Object returnValue = new Object();
    RemoteCallReturn callReturn = new RemoteCallReturn.Builder().withReturnValue(returnValue).build();
    Method identityCallMethod = MockSoapClient.class.getMethod("identityCall", Object[].class);
    Object[] arg = new String[] { "arg1", "arg2" };
    Object[] args = new Object[] { arg };
    SoapCall<Object> soapCall = new SoapCall<Object>(identityCallMethod, soapClient, args);
    when(soapClientHandler.getSoapClientMethod(soapClient, identityCallMethod)).thenReturn(identityCallMethod);
    when(soapClientHandler.invokeSoapCall(soapCall)).thenReturn(callReturn);
    Object result = soapServiceClient.invoke(null, identityCallMethod, args);
    assertEquals(returnValue, result);
}
Also used : Method(java.lang.reflect.Method) RemoteCallReturn(com.google.api.ads.common.lib.client.RemoteCallReturn) Test(org.junit.Test)

Example 15 with RemoteCallReturn

use of com.google.api.ads.common.lib.client.RemoteCallReturn in project googleads-java-lib by googleads.

the class SoapServiceClientTest method testUnwrapRemoteCallReturn_exception.

@Test
public void testUnwrapRemoteCallReturn_exception() throws Throwable {
    RemoteCallReturn remoteCallReturn = new RemoteCallReturn.Builder().withException(new NoSuchMethodException()).build();
    thrown.expect(NoSuchMethodException.class);
    soapServiceClient.unwrapRemoteCallReturn(remoteCallReturn);
}
Also used : RemoteCallReturn(com.google.api.ads.common.lib.client.RemoteCallReturn) Test(org.junit.Test)

Aggregations

RemoteCallReturn (com.google.api.ads.common.lib.client.RemoteCallReturn)17 Test (org.junit.Test)11 ResponseInfo (com.google.api.ads.common.lib.client.ResponseInfo)8 RequestInfo (com.google.api.ads.common.lib.client.RequestInfo)7 Matchers.containsString (org.hamcrest.Matchers.containsString)3 ServiceException (com.google.api.ads.common.lib.exception.ServiceException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 SOAPException (javax.xml.soap.SOAPException)2 BindingProvider (javax.xml.ws.BindingProvider)2 BatchJobMutateResultInterface (com.google.api.ads.adwords.lib.utils.BatchJobMutateResultInterface)1 BatchJobUploadResponse (com.google.api.ads.adwords.lib.utils.BatchJobUploadResponse)1 ReportException (com.google.api.ads.adwords.lib.utils.ReportException)1 SoapCall (com.google.api.ads.common.lib.soap.SoapCall)1 CampaignServiceInterface (com.google.api.ads.common.lib.soap.jaxws.testing.mocks.CampaignServiceInterface)1 CampaignServiceInterfaceImpl (com.google.api.ads.common.lib.soap.jaxws.testing.mocks.CampaignServiceInterfaceImpl)1 InputStream (java.io.InputStream)1 MessageContext (org.apache.axis.MessageContext)1 Stub (org.apache.axis.client.Stub)1