Ejemplo n.º 1
0
  /** test a complete unmarshal from the json */
  @Test
  public void testGeoCoordinates() throws Exception {
    final InputStream is =
        getClass()
            .getClassLoader()
            .getResourceAsStream("com/zaubersoftware/gnip4j/payload/payload-example-geo.json");
    try {
      final JsonParser parser = mapper.getJsonFactory().createJsonParser(is);
      final Activity activity = parser.readValueAs(Activity.class);

      assertNotNull(activity.getGeo());
      assertNotNull(activity.getGeo().getCoordinates());
      assertEquals(-34.58501869, activity.getGeo().getCoordinates()[0], 0.001);
      assertEquals(-58.43946468, activity.getGeo().getCoordinates()[1], 0.001);
    } finally {
      is.close();
    }
  }
Ejemplo n.º 2
0
  /** test a complete unmarshal from the json */
  @Test
  public void testGetGnip() throws Exception {
    final InputStream is =
        getClass()
            .getClassLoader()
            .getResourceAsStream("com/zaubersoftware/gnip4j/payload/payload-example.js");
    try {
      final JsonParser parser = mapper.getJsonFactory().createJsonParser(is);
      final Activity activity = parser.readValueAs(Activity.class);

      assertNotNull(activity.getGnip());
      assertNotNull(activity.getGnip().getLanguage());
      assertEquals("en", activity.getGnip().getLanguage().getValue());
      final List<MatchingRules> matchingRules = activity.getGnip().getMatchingRules();
      assertNotNull(matchingRules);
      assertEquals(1, matchingRules.size());
      assertEquals("coke", matchingRules.get(0).getValue());
      assertEquals(null, matchingRules.get(0).getTag());
    } finally {
      is.close();
    }
  }