说明
java traits示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。
编程语言: Java
命名空间/包名称: com.maxmind.geoip2.record
示例#1文件:
NullTest.java项目:
uservidya/GeoIP2-java
@Test
public void testDefaults() throws IOException, GeoIp2Exception {
OmniResponse omni = this.client.omni(InetAddress.getByName("1.2.3.13"));
assertTrue(omni.toString().startsWith("Omni"));
City city = omni.getCity();
assertNotNull(city);
assertNull(city.getConfidence());
Continent continent = omni.getContinent();
assertNotNull(continent);
assertNull(continent.getCode());
Country country = omni.getCountry();
assertNotNull(country);
Location location = omni.getLocation();
assertNotNull(location);
assertNull(location.getAccuracyRadius());
assertNull(location.getLatitude());
assertNull(location.getLongitude());
assertNull(location.getMetroCode());
assertNull(location.getTimeZone());
assertEquals("Location []", location.toString());
MaxMind maxmind = omni.getMaxMind();
assertNotNull(maxmind);
assertNull(maxmind.getQueriesRemaining());
assertNotNull(omni.getPostal());
Country registeredCountry = omni.getRegisteredCountry();
assertNotNull(registeredCountry);
RepresentedCountry representedCountry = omni.getRepresentedCountry();
assertNotNull(representedCountry);
assertNull(representedCountry.getType());
List<Subdivision> subdivisions = omni.getSubdivisions();
assertNotNull(subdivisions);
assertTrue(subdivisions.isEmpty());
Subdivision subdiv = omni.getMostSpecificSubdivision();
assertNotNull(subdiv);
assertNull(subdiv.getIsoCode());
assertNull(subdiv.getConfidence());
Traits traits = omni.getTraits();
assertNotNull(traits);
assertNull(traits.getAutonomousSystemNumber());
assertNull(traits.getAutonomousSystemOrganization());
assertNull(traits.getDomain());
assertNull(traits.getIpAddress());
assertNull(traits.getIsp());
assertNull(traits.getOrganization());
assertNull(traits.getUserType());
assertFalse(traits.isAnonymousProxy());
assertFalse(traits.isSatelliteProvider());
assertEquals("Traits [anonymousProxy=false, satelliteProvider=false, ]", traits.toString());
for (Country c : new Country[] {country, registeredCountry, representedCountry}) {
assertNull(c.getConfidence());
assertNull(c.getIsoCode());
}
for (AbstractNamedRecord r :
new AbstractNamedRecord[] {
city, continent, country, registeredCountry, representedCountry, subdiv
}) {
assertNull(r.getGeoNameId());
assertNull(r.getName());
assertTrue(r.getNames().isEmpty());
assertEquals("", r.toString());
}
}