### Question:
ProjectMappingPreprocessor extends ESLookupValuePreprocessor { @Override public void init(String name, Client client, Map<String, Object> settings) throws SettingsException { settings.put(CFG_index_name, ProjectService.SEARCH_INDEX_NAME); settings.put(CFG_index_type, ProjectService.SEARCH_INDEX_TYPE); if (!settings.containsKey(CFG_result_mapping)) { settings.put(CFG_result_mapping, resultMapping); } super.init(name, client, settings); }  @Override void init(String name, Client client, Map<String, Object> settings);  }### Answer:
@Test public void init_defaults() { ProjectMappingPreprocessor tested = new ProjectMappingPreprocessor(); Client clientMock = Mockito.mock(Client.class); Map<String, Object> settings = new HashMap<>(); settings.put("source_field", "sf"); settings.put("idx_search_field", "if"); tested.init("Project mapper", clientMock, settings); Assert.assertTrue(tested instanceof ESLookupValuePreprocessor); Assert.assertEquals("Project mapper", tested.getName()); Assert.assertEquals(ProjectService.SEARCH_INDEX_NAME, tested.getIndexName()); Assert.assertEquals(ProjectService.SEARCH_INDEX_TYPE, tested.getIndexType()); Assert.assertEquals(1, tested.getIdxSearchField().size()); Assert.assertTrue(tested.getIdxSearchField().contains("if")); Assert.assertEquals("sf", tested.getSourceField()); Assert.assertEquals(null, tested.getSourceValuePattern()); List<Map<String, String>> mr = tested.getResultMapping(); Assert.assertEquals(2, mr.size()); }
@Test public void init_resultMappingOverwrite() { ProjectMappingPreprocessor tested = new ProjectMappingPreprocessor(); Client clientMock = Mockito.mock(Client.class); Map<String, Object> settings = new HashMap<>(); settings.put("source_value", "sv"); settings.put("idx_search_field", "if"); List<Map<String, String>> rmMock = new ArrayList<>(); settings.put("result_mapping", rmMock); Map<String, String> rm_code = new HashMap<>(); rm_code.put("idx_result_field", ProjectService.FIELD_CODE); rm_code.put("target_field", ContentObjectFields.SYS_PROJECT); rmMock.add(rm_code); tested.init("Project mapper", clientMock, settings); Assert.assertTrue(tested instanceof ESLookupValuePreprocessor); Assert.assertEquals("Project mapper", tested.getName()); Assert.assertEquals(ProjectService.SEARCH_INDEX_NAME, tested.getIndexName()); Assert.assertEquals(ProjectService.SEARCH_INDEX_TYPE, tested.getIndexType()); Assert.assertEquals(1, tested.getIdxSearchField().size()); Assert.assertTrue(tested.getIdxSearchField().contains("if")); Assert.assertEquals(null, tested.getSourceField()); Assert.assertEquals("sv", tested.getSourceValuePattern()); List<Map<String, String>> mr = tested.getResultMapping(); Assert.assertEquals(rmMock, mr); }