Example #1
0
  @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());
    }
  }