Search in sources :

Example 11 with Builder

use of com.google.api.ads.adwords.lib.client.AdWordsSession.Builder in project googleads-java-lib by googleads.

the class AdWordsSessionTest method testReadPropertiesFromConfiguration_noUserAgent.

/**
 * Tests that the builder correctly reads properties from a configuration.
 */
@Test
public void testReadPropertiesFromConfiguration_noUserAgent() throws ValidationException {
    PropertiesConfiguration config = new PropertiesConfiguration();
    AdWordsSession adWordsSession = build(new AdWordsSession.Builder().from(config).withDeveloperToken("devTokendevTokendevTok").withOAuth2Credential(credential));
    assertEquals(AdWordsSession.UNKNOWN_USER_AGENT, adWordsSession.getUserAgent());
}
Also used : ImmutableAdWordsSession(com.google.api.ads.adwords.lib.client.AdWordsSession.ImmutableAdWordsSession) Builder(com.google.api.ads.adwords.lib.client.AdWordsSession.Builder) PropertiesConfiguration(org.apache.commons.configuration.PropertiesConfiguration) Test(org.junit.Test)

Example 12 with Builder

use of com.google.api.ads.adwords.lib.client.AdWordsSession.Builder in project googleads-java-lib by googleads.

the class AdWordsSessionTest method testBuilder_defaultUserAgent.

/**
 * Tests that the builder builds with the 'unknown' user agent if the default user agent is
 * specified.
 */
@Test
public void testBuilder_defaultUserAgent() throws Exception {
    AdWordsSession adWordsSession = build(new AdWordsSession.Builder().withOAuth2Credential(credential).withEndpoint("https://www.google.com").withUserAgent("INSERT_USERAGENT_HERE").withDeveloperToken("developerToken"));
    assertEquals(AdWordsSession.UNKNOWN_USER_AGENT, adWordsSession.getUserAgent());
}
Also used : Builder(com.google.api.ads.adwords.lib.client.AdWordsSession.Builder) ImmutableAdWordsSession(com.google.api.ads.adwords.lib.client.AdWordsSession.ImmutableAdWordsSession) Test(org.junit.Test)

Aggregations

Builder (com.google.api.ads.adwords.lib.client.AdWordsSession.Builder)12 ImmutableAdWordsSession (com.google.api.ads.adwords.lib.client.AdWordsSession.ImmutableAdWordsSession)11 Test (org.junit.Test)11 PropertiesConfiguration (org.apache.commons.configuration.PropertiesConfiguration)5 ReportingConfiguration (com.google.api.ads.adwords.lib.client.reporting.ReportingConfiguration)2 ApiError (com.google.api.ads.adwords.axis.v201809.cm.ApiError)1 ApiException (com.google.api.ads.adwords.axis.v201809.cm.ApiException)1 AdWordsSession (com.google.api.ads.adwords.lib.client.AdWordsSession)1 AdWordsServicesInterface (com.google.api.ads.adwords.lib.factory.AdWordsServicesInterface)1 OfflineCredentials (com.google.api.ads.common.lib.auth.OfflineCredentials)1 ConfigurationLoadException (com.google.api.ads.common.lib.conf.ConfigurationLoadException)1 OAuthException (com.google.api.ads.common.lib.exception.OAuthException)1 ValidationException (com.google.api.ads.common.lib.exception.ValidationException)1 Credential (com.google.api.client.auth.oauth2.Credential)1 IOException (java.io.IOException)1 RemoteException (java.rmi.RemoteException)1