### Question:
DatastoreSynonymCatalog extends AbstractReferenceData implements SynonymCatalog { @Override public String getMasterTerm(String term) { if (StringUtils.isNullOrEmpty(term)) { return null; } final Cache<String, String> cache = getMasterTermCache(); String result; synchronized (cache) { result = cache.getIfPresent(term); if (result == null) { final Datastore datastore = getDatastore(); try (final DatastoreConnection datastoreConnection = datastore.openConnection()) { final SchemaNavigator schemaNavigator = datastoreConnection.getSchemaNavigator(); final Column masterTermColumn = schemaNavigator.convertToColumn(_masterTermColumnPath); final Column[] columns = schemaNavigator.convertToColumns(_synonymColumnPaths); final DataContext dataContext = datastoreConnection.getDataContext(); final Table table = masterTermColumn.getTable(); final Query query = dataContext.query().from(table.getName()).select(masterTermColumn).toQuery(); final List<FilterItem> filterItems = new ArrayList<FilterItem>(); for (int i = 0; i < columns.length; i++) { final Column column = columns[i]; if (column.getType().isNumber()) { final Number numberValue = ConvertToNumberTransformer.transformValue(term); if (numberValue != null) { filterItems.add(new FilterItem(new SelectItem(column), OperatorType.EQUALS_TO, numberValue)); } } else { filterItems.add(new FilterItem(new SelectItem(column), OperatorType.EQUALS_TO, term)); } } if (filterItems.isEmpty()) { result = ""; } else { query.where(new FilterItem(filterItems.toArray(new FilterItem[0]))); try (final DataSet dataSet = dataContext.executeQuery(query)) { if (dataSet.next()) { final Row row = dataSet.getRow(); result = getMasterTerm(row, masterTermColumn); } else { result = ""; } } } } cache.put(term, result); } } if ("".equals(result)) { result = null; } return result; } DatastoreSynonymCatalog(String name, String datastoreName, String masterTermColumnPath,
            String[] synonymColumnPaths); @Initialize void init(); @Close void close(); String getDatastoreName(); String getMasterTermColumnPath(); String[] getSynonymColumnPaths(); @Override Collection<Synonym> getSynonyms(); @Override String getMasterTerm(String term);  }### Answer:
@Test public void shouldReturnCorrectMasterTerm() { assertEquals(null, _dataStoreBasedSynonymCatalog.getMasterTerm("region")); assertEquals("DNK", _dataStoreBasedSynonymCatalog.getMasterTerm("Denmark")); assertEquals("GBR", _dataStoreBasedSynonymCatalog.getMasterTerm("Great Britain")); assertEquals("DNK", _dataStoreBasedSynonymCatalog.getMasterTerm("DK")); }