@Test public void testCityDMARegion() { CityDMARegionKey key1 = new CityDMARegionKey(1, "a"); CityDMARegionKey key2 = new CityDMARegionKey(1, "a"); CityDMARegionKey key3 = new CityDMARegionKey(1, "b"); TestUtil.testCommonMethods(key1, key2, key3); assertThat(key1.criteriaId()).isEqualTo(1); assertThat(key1.regionName()).isEqualTo("a"); CityDMARegionValue value1 = new CityDMARegionValue(1, "a", "b"); CityDMARegionValue value2 = new CityDMARegionValue(1, "a", "b"); CityDMARegionValue value3 = new CityDMARegionValue(1, "a", "c"); assertThat(value1.regionCode()).isEqualTo(1); assertThat(value1.city()).isEqualTo("a"); assertThat(value1.state()).isEqualTo("b"); TestUtil.testCommonMethods(value1, value2, value3); }
@Test public void test() { DoubleClickMetadata metadata = new DoubleClickMetadata(new DoubleClickMetadata.ResourceTransport()); assertThat(metadata.toString()).isNotNull(); assertThat(DoubleClickMetadata.toString(metadata.publisherExcludableCreativeAttributes(), 1)) .isEqualTo("1: CreativeAttribute1"); assertThat(DoubleClickMetadata.toString(metadata.buyerDeclarableCreativeAttributes(), 1)) .isEqualTo("1: CreativeAttribute1"); assertThat(DoubleClickMetadata.toString(metadata.allCreativeAttributes(), 1)) .isEqualTo("1: CreativeAttribute1"); assertThat(DoubleClickMetadata.toString(metadata.creativeStatusCodes(), 1)) .isEqualTo("1: Creative won the auction"); assertThat(DoubleClickMetadata.toString(metadata.sensitiveCategories(), 1)) .isEqualTo("1: SensitiveCategory1"); assertThat(DoubleClickMetadata.toString(metadata.restrictedCategories(), 1)) .isEqualTo("1: RestrictedCategory1"); assertThat(DoubleClickMetadata.toString(metadata.productCategories(), 1)) .isEqualTo("1: ProductCategory1"); assertThat(DoubleClickMetadata.toString(metadata.agencies(), 1)).isEqualTo("1: NONE"); assertThat(DoubleClickMetadata.toString(metadata.vendors(), 1)).isEqualTo("1: Vendor1"); assertThat(DoubleClickMetadata.toString(metadata.gdnVendors(), 1)).isEqualTo("1: GDNVendor1"); assertThat(DoubleClickMetadata.toString(metadata.sellerNetworks(), 1)).isEqualTo("1: GDN"); assertThat(DoubleClickMetadata.toString(metadata.siteLists(), 31)) .isEqualTo("31: Brand Select"); assertThat(DoubleClickMetadata.toString(metadata.contentLabels(), 1)) .isEqualTo("1: ContentLabel1"); assertThat(DoubleClickMetadata.toString(metadata.publisherVerticals(), 1)) .isEqualTo("1: /Vertical1"); assertThat(DoubleClickMetadata.toString(metadata.sensitiveCategories(), 9999)) .isEqualTo("9999: <invalid>"); assertThat(metadata.geoTargetFor(1023191).canonParent().canonParent().name()) .isEqualTo("United States"); assertThat(metadata.geoTargets().isEmpty()).isFalse(); assertThat(metadata.dmaRegions().get(new CityDMARegionKey(1016100, "Sioux City, IA"))) .isEqualTo(new CityDMARegionValue(624, "West Bend", "Iowa")); assertThat(metadata.mobileCarriers().get(70092)).isEqualTo("Verizon"); GeoTarget geoTarget1 = metadata.geoTargetFor(GeoTarget.Type.COUNTRY, "United States"); GeoTarget geoTarget2 = new GeoTarget(2840, GeoTarget.Type.COUNTRY, "United States", "United States", "US"); GeoTarget geoTarget3 = metadata.geoTargetFor(GeoTarget.Type.COUNTRY, "France"); TestUtil.testCommonMethods(geoTarget1, geoTarget2, geoTarget3); assertThat(geoTarget1.criteriaId()).isEqualTo(2840); assertThat(geoTarget1.name()).isEqualTo("United States"); assertThat(geoTarget1.canonicalName()).isEqualTo("United States"); assertThat(geoTarget1.countryCode()).isEqualTo("US"); assertThat(geoTarget1.type()).isEqualTo(GeoTarget.Type.COUNTRY); assertThat(geoTarget1.getCanonAncestor(GeoTarget.Type.COUNTRY)).isSameAs(geoTarget1); assertThat(geoTarget1.getCanonAncestor(GeoTarget.Type.CITY)).isNull(); assertThat(geoTarget1.getIdAncestor(GeoTarget.Type.COUNTRY)).isSameAs(geoTarget1); assertThat(geoTarget1.getIdAncestor(GeoTarget.Type.CITY)).isNull(); TestUtil.testCommonEnum(GeoTarget.Type.values()); CountryCodes country1 = metadata.countryCodes().get("US"); CountryCodes country2 = new CountryCodes(840, "US", "USA"); CountryCodes country3 = new CountryCodes(840, "US", "USB"); TestUtil.testCommonMethods(country1, country2, country3); assertThat(metadata.countryCodes().get("USA")).isSameAs(country1); assertThat(metadata.countryCodes().get(840)).isSameAs(country1); assertThat(country1.numeric()).isEqualTo(840); assertThat(country1.alpha2()).isEqualTo("US"); assertThat(country1.alpha3()).isEqualTo("USA"); // https://github.com/google/openrtb-doubleclick/issues/28 GeoTarget postalTarget = metadata.geoTargetFor(9012102); assertThat(postalTarget.getCanonAncestor(GeoTarget.Type.CITY)).isNull(); assertThat(postalTarget.getIdAncestor(GeoTarget.Type.CITY).name()).isEqualTo("Tampa"); GeoTarget.CanonicalKey canKey1 = new GeoTarget.CanonicalKey(GeoTarget.Type.CITY, "A"); GeoTarget.CanonicalKey canKey2 = new GeoTarget.CanonicalKey(GeoTarget.Type.CITY, "A"); GeoTarget.CanonicalKey canKey3 = new GeoTarget.CanonicalKey(GeoTarget.Type.CITY, "B"); TestUtil.testCommonMethods(canKey1, canKey2, canKey3); }