use of com.google.api.ads.adwords.lib.client.AdWordsSession.Builder in project googleads-java-lib by googleads.
the class AdWordsSessionTest method testReadPropertiesFromConfiguration.
/**
* Tests that the builder correctly reads properties from a configuration.
*/
@Test
public void testReadPropertiesFromConfiguration() throws ValidationException {
PropertiesConfiguration config = new PropertiesConfiguration();
config.setProperty("api.adwords.clientCustomerId", "1234567890");
config.setProperty("api.adwords.userAgent", "FooBar");
config.setProperty("api.adwords.developerToken", "devTokendevTokendevTok");
config.setProperty("api.adwords.isPartialFailure", "false");
AdWordsSession session = build(new AdWordsSession.Builder().from(config).withOAuth2Credential(credential));
assertEquals("1234567890", session.getClientCustomerId());
assertEquals("FooBar", session.getUserAgent());
assertEquals("devTokendevTokendevTok", session.getDeveloperToken());
assertFalse(session.isPartialFailure());
ReportingConfiguration reportingConfig = session.getReportingConfiguration();
assertNotNull("reporting configuration is null", reportingConfig);
// Verify that the ReportingConfiguration's attributes are set to the expected default value
// (null).
assertNull("include zero impressions is not null when no reporting options in config", reportingConfig.isIncludeZeroImpressions());
assertNull("skip column header is not null, but no reporting options in config", reportingConfig.isSkipColumnHeader());
assertNull("skip report header is not null, but no reporting options in config", reportingConfig.isSkipReportHeader());
assertNull("skip report summary is not null, but no reporting options in config", reportingConfig.isSkipReportSummary());
assertNull("use raw enum values is not null, but no reporting options in config", reportingConfig.isUseRawEnumValues());
assertNull("download timeout is not null, but no reporting options in config", reportingConfig.getReportDownloadTimeout());
}
use of com.google.api.ads.adwords.lib.client.AdWordsSession.Builder in project googleads-java-lib by googleads.
the class AdWordsSessionTest method testReadPropertiesFromConfiguration_badEndpoint.
/**
* Tests that the builder correctly reads properties from a configuration.
*/
@Test
public void testReadPropertiesFromConfiguration_badEndpoint() throws ValidationException {
String badEndpoint = "3efsdafasd";
PropertiesConfiguration config = new PropertiesConfiguration();
config.setProperty("api.adwords.clientCustomerId", "1234567890");
config.setProperty("api.adwords.userAgent", "FooBar");
config.setProperty("api.adwords.developerToken", "devTokendevTokendevTok");
config.setProperty("api.adwords.isPartialFailure", "false");
config.setProperty("api.adwords.endpoint", badEndpoint);
thrown.expect(ValidationException.class);
thrown.expect(createTriggerMatcher(Matchers.<String>equalTo("endpoint")));
thrown.expectMessage(badEndpoint);
build(new AdWordsSession.Builder().from(config).withOAuth2Credential(credential));
}
use of com.google.api.ads.adwords.lib.client.AdWordsSession.Builder in project googleads-java-lib by googleads.
the class AdWordsSessionTest method testReadPropertiesFromConfiguration_defaultUserAgent.
/**
* Tests that the builder correctly reads properties from a configuration.
*/
@Test
public void testReadPropertiesFromConfiguration_defaultUserAgent() throws ValidationException {
PropertiesConfiguration config = new PropertiesConfiguration();
config.setProperty("api.adwords.userAgent", "INSERT_USERAGENT_HERE");
AdWordsSession adWordsSession = build(new AdWordsSession.Builder().from(config).withDeveloperToken("devTokendevTokendevTok").withOAuth2Credential(credential));
assertEquals(AdWordsSession.UNKNOWN_USER_AGENT, adWordsSession.getUserAgent());
}
use of com.google.api.ads.adwords.lib.client.AdWordsSession.Builder in project googleads-java-lib by googleads.
the class AdWordsSessionTest method testBuilder_noUserAgent.
/**
* Tests that the builder builds with the 'unknown' user agent if none specified.
*/
@Test
public void testBuilder_noUserAgent() throws Exception {
AdWordsSession adWordsSession = build(new AdWordsSession.Builder().withOAuth2Credential(credential).withEndpoint("https://www.google.com").withDeveloperToken("developerToken"));
assertEquals(AdWordsSession.UNKNOWN_USER_AGENT, adWordsSession.getUserAgent());
}
use of com.google.api.ads.adwords.lib.client.AdWordsSession.Builder in project googleads-java-lib by googleads.
the class AdWordsSessionTest method testReadPropertiesFromConfigurationWithReportingConfig.
/**
* Tests that the builder correctly reads properties from a configuration when reporting options
* are included in the configuration.
*/
@Test
public void testReadPropertiesFromConfigurationWithReportingConfig() throws ValidationException {
PropertiesConfiguration config = new PropertiesConfiguration();
config.setProperty("api.adwords.clientCustomerId", "1234567890");
config.setProperty("api.adwords.userAgent", "FooBar");
config.setProperty("api.adwords.developerToken", "devTokendevTokendevTok");
config.setProperty("api.adwords.isPartialFailure", "false");
config.setProperty("api.adwords.reporting.skipHeader", "true");
config.setProperty("api.adwords.reporting.skipColumnHeader", "true");
config.setProperty("api.adwords.reporting.skipSummary", "false");
config.setProperty("api.adwords.reporting.useRawEnumValues", "false");
config.setProperty("api.adwords.reportDownloadTimeout", 9999999);
AdWordsSession session = build(new AdWordsSession.Builder().from(config).withOAuth2Credential(credential));
assertEquals("1234567890", session.getClientCustomerId());
assertEquals("FooBar", session.getUserAgent());
assertEquals("devTokendevTokendevTok", session.getDeveloperToken());
assertFalse(session.isPartialFailure());
assertNotNull("reporting configuration should not be null", session.getReportingConfiguration());
assertTrue(session.getReportingConfiguration().isSkipReportHeader());
assertTrue(session.getReportingConfiguration().isSkipColumnHeader());
assertFalse(session.getReportingConfiguration().isSkipReportSummary());
assertFalse(session.getReportingConfiguration().isUseRawEnumValues());
assertEquals(9999999, session.getReportingConfiguration().getReportDownloadTimeout().intValue());
assertNull("includeZeroImpressions is not settable from ads.properties, so should be null", session.getReportingConfiguration().isIncludeZeroImpressions());
}
Aggregations