use of com.google.api.ads.common.lib.useragent.UserAgentCombiner in project googleads-java-lib by googleads.
the class UserAgentCombinerTest method testUserAgent.
/**
* Tests that the user agent is generated correctly.
*/
@Test
public void testUserAgent() throws Exception {
Injector injector = Guice.createInjector(new AdManagerJaxWsModule());
String userAgent = USER_AGENT;
UserAgentCombiner userAgentCombiner = injector.getInstance(UserAgentCombiner.class);
assertEquals(userAgent, userAgentCombiner.getUserAgent("userAgent"));
}
use of com.google.api.ads.common.lib.useragent.UserAgentCombiner in project googleads-java-lib by googleads.
the class UserAgentCombinerTest method testUserAgent.
/**
* Tests that the user agent is generated correctly.
*/
@Test
public void testUserAgent() throws Exception {
Injector injector = Guice.createInjector(new AdWordsAxisModule());
String userAgent = USER_AGENT;
UserAgentCombiner userAgentCombiner = injector.getInstance(UserAgentCombiner.class);
assertEquals(userAgent, userAgentCombiner.getUserAgent("userAgent"));
}
use of com.google.api.ads.common.lib.useragent.UserAgentCombiner in project googleads-java-lib by googleads.
the class UserAgentCombinerTest method testUserAgent.
/**
* Tests that the user agent is generated correctly.
*/
@Test
public void testUserAgent() throws Exception {
Injector injector = Guice.createInjector(new AdWordsJaxWsModule());
String userAgent = USER_AGENT;
UserAgentCombiner userAgentCombiner = injector.getInstance(UserAgentCombiner.class);
assertEquals(userAgent, userAgentCombiner.getUserAgent("userAgent"));
}
use of com.google.api.ads.common.lib.useragent.UserAgentCombiner in project googleads-java-lib by googleads.
the class UserAgentCombinerTest method testUserAgent.
/**
* Tests that the user agent is generated correctly.
*/
@Test
public void testUserAgent() throws Exception {
Injector injector = Guice.createInjector(new AdManagerAxisModule());
String userAgent = USER_AGENT;
UserAgentCombiner userAgentCombiner = injector.getInstance(UserAgentCombiner.class);
assertEquals(userAgent, userAgentCombiner.getUserAgent("userAgent"));
}
use of com.google.api.ads.common.lib.useragent.UserAgentCombiner in project googleads-java-lib by googleads.
the class AdWordsPluginModuleTest method testCombinedUserAgentBehavior.
/**
* Verifies that {@link UserAgentCombiner} instances behave as expected when an {@link
* AdWordsPluginModule} is or is not provided to the injector.
*/
@Test
public void testCombinedUserAgentBehavior() {
// Create a mock ExtensionUserAgentProvider that returns a specific string from getUserAgent.
String pluginUserAgentSnippet = "MyCustomExtension";
when(extensionUserAgentProvider.getUserAgent()).thenReturn(pluginUserAgentSnippet);
// Create an AdWordsServicesInterface using an AdWordsPluginModule configured with the
// ExtensionUserAgentProvider.
GenericAdWordsServices genericAdWordsServices = (GenericAdWordsServices) new GenericAdWordsServices().withPluginModule(new AdWordsPluginModule(extensionUserAgentProvider));
// Get the combined user agent from the UserAgentCombiner provided by the
// AdWordsServicesInterface, and confirm the combined user agent it returns includes the
// string from the mock ExtensionUserAgentProvider.
UserAgentCombiner userAgentCombiner = genericAdWordsServices.getBootstrapper().getInstanceOf(session, UserAgentCombiner.class);
String combinedUserAgent = userAgentCombiner.getUserAgent("foo");
assertThat("Combined user agent does not contain the string from the plugin", combinedUserAgent, Matchers.containsString(pluginUserAgentSnippet));
// Get a UserAgentCombiner from an AdWordsServicesInterface without a plugin and confirm the
// combined user agent it returns does not contain the string from the mock
// ExtensionUserAgentProvider.
genericAdWordsServices = new GenericAdWordsServices();
userAgentCombiner = genericAdWordsServices.getBootstrapper().getInstanceOf(session, UserAgentCombiner.class);
combinedUserAgent = userAgentCombiner.getUserAgent("foo");
assertThat("Combined user agent contains string from the plugin, but plugin was not provided", combinedUserAgent, Matchers.not(Matchers.containsString(pluginUserAgentSnippet)));
}
Aggregations