ListGazetteer extends AbstractMultiMapGazetteer<Integer> { @Override @SuppressWarnings("unchecked") public void init(Resource connection, Map<String, Object> config) throws BaleenException { if (config.containsKey(CONFIG_TERM_SEPARATOR)) { termSeparator = config.get(CONFIG_TERM_SEPARATOR).toString(); } terms = ImmutableList.copyOf((Iterable<String>) config.get(CONFIG_TERMS)); super.init(connection, config); }  @Override @SuppressWarnings("unchecked") void init(Resource connection, Map<String, Object> config); @Override void reloadValues(); static final String CONFIG_TERMS; static final String CONFIG_TERM_SEPARATOR; }
@Test public void testGetValues() throws BaleenException { ListGazetteer gaz = new ListGazetteer(); gaz.init(null, config); List<String> values = Arrays.asList(gaz.getValues()); assertEquals(8, values.size()); assertTrue(values.contains("guten tag")); assertTrue(values.contains(HELLO)); gaz.destroy(); }
@Test public void testHasValue() throws BaleenException { ListGazetteer gaz = new ListGazetteer(); gaz.init(null, config); assertTrue(gaz.hasValue("howdy")); assertTrue(gaz.hasValue("hej")); assertTrue(gaz.hasValue("HEJ")); assertFalse(gaz.hasValue("good morning")); gaz.destroy(); }
@Test public void testHasValueCaseSensitive() throws BaleenException { ListGazetteer gaz = new ListGazetteer(); config.put("caseSensitive", true); gaz.init(null, config); assertTrue(gaz.hasValue("hej")); assertFalse(gaz.hasValue("HEJ")); gaz.destroy(); }
@Test public void testGetAliases() throws BaleenException { ListGazetteer gaz = new ListGazetteer(); gaz.init(null, config); String[] helloAliases = gaz.getAliases(HELLO); String[] hiAliases = gaz.getAliases("hi"); assertEquals(0, helloAliases.length); assertEquals(2, hiAliases.length); List<String> hiAliasesList = Arrays.asList(hiAliases); assertTrue(hiAliasesList.contains("heya")); assertTrue(hiAliasesList.contains("howdy")); gaz.destroy(); }
@Test public void testGetAdditionalData() throws BaleenException { ListGazetteer gaz = new ListGazetteer(); gaz.init(null, config); assertEquals(Collections.emptyMap(), gaz.getAdditionalData(HELLO)); gaz.destroy(); }