@Test
public void testSchemaTags() throws Exception
{

  List<String> expectedTags = Lists.newArrayList("geo", "bullet");
  List<String> expectedKeyTags = Lists.newArrayList("geo.location");
  List<String> expectedValueTagsLat = Lists.newArrayList("geo.lattitude");
  List<String> expectedValueTagsLong = Lists.newArrayList("geo.longitude");
  String eventSchemaJSON = SchemaUtils.jarResourceFileToString("adsGenericEventSchemaTags.json");
  DimensionalSchema dimensional = new DimensionalSchema(
      new DimensionalConfigurationSchema(eventSchemaJSON, AggregatorRegistry.DEFAULT_AGGREGATOR_REGISTRY));
  String schemaJSON = dimensional.getSchemaJSON();
  JSONObject jo = new JSONObject(schemaJSON);
  List<String> tags = getStringList(jo.getJSONArray(FIELD_TAGS));
  Assert.assertEquals(expectedTags, tags);
  JSONArray keys = jo.getJSONArray(DimensionalConfigurationSchema.FIELD_KEYS);
  List<String> keyTags = null;
  for (int keyIndex = 0; keyIndex < keys.length(); keyIndex++) {
    JSONObject key = keys.getJSONObject(keyIndex);
    if (!key.has(FIELD_TAGS)) {
      continue;
    }
    Assert.assertEquals("location", key.get(DimensionalConfigurationSchema.FIELD_KEYS_NAME));
    keyTags = getStringList(key.getJSONArray(FIELD_TAGS));
  }
  Assert.assertTrue("No tags found for any key", keyTags != null);
  Assert.assertEquals(expectedKeyTags, keyTags);
  JSONArray values = jo.getJSONArray(DimensionalConfigurationSchema.FIELD_VALUES);
  boolean valueTagsLat = false;
  boolean valueTagsLong = false;
  for (int valueIndex = 0; valueIndex < values.length(); valueIndex++) {
    JSONObject value = values.getJSONObject(valueIndex);
    if (!value.has(FIELD_TAGS)) {
      continue;
    }
    String valueName = value.getString(DimensionalConfigurationSchema.FIELD_VALUES_NAME);
    List<String> valueTags = getStringList(value.getJSONArray(FIELD_TAGS));
    LOG.debug("value name: {}", valueName);
    if (valueName.startsWith("impressions")) {
      Assert.assertEquals(expectedValueTagsLat, valueTags);
      valueTagsLat = true;
    } else if (valueName.startsWith("clicks")) {
      Assert.assertEquals(expectedValueTagsLong, valueTags);
      valueTagsLong = true;
    } else {
      Assert.fail("There should be no tags for " + valueName);
    }
  }
  Assert.assertTrue("No tags found for impressions", valueTagsLat);
  Assert.assertTrue("No tags found for clicks", valueTagsLong);
}