### Question:
NormalizationRestService extends RestServiceBase { public Map<String, Object> runPreprocessors(List<StructuredContentPreprocessor> preprocessors, String id) throws SettingsException { Map<String, Object> content = new HashMap<>(); content.put(OUTKEY_INPUT_ID, id); if (preprocessors != null && !preprocessors.isEmpty()) { PreprocessChainContextImpl context = new PreprocessChainContextImpl(); for (StructuredContentPreprocessor preprocessor : preprocessors) { content = preprocessor.preprocessData(content, context); } if (context.warnings != null && !context.warnings.isEmpty()) content.put(OUTKEY_WARNINGS, context.warnings); } return content; }  @SuppressWarnings("unchecked") @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) Map<String, Object> availableNormalizations(); @GET @Path("/{normalizationName}/{id}") @Produces(MediaType.APPLICATION_JSON) Object normalizeOne(@PathParam("normalizationName") String normalizationName, @PathParam(INKEY_ID) String id); @GET @Path("/{normalizationName}") @Produces(MediaType.APPLICATION_JSON) Object normalizeBulk(@PathParam("normalizationName") String normalizationName, @Context UriInfo uriInfo); @SuppressWarnings("unchecked") List<StructuredContentPreprocessor> getPreprocessors(String normalizationName); Map<String, Object> runPreprocessors(List<StructuredContentPreprocessor> preprocessors, String id); static final String INKEY_ID; static final String CFG_PREPROCESSORS; static final String CFG_DESCRIPTION; static final String OUTKEY_WARNINGS; static final String OUTKEY_INPUT_ID; }### Answer:
@SuppressWarnings("rawtypes") @Test public void runPreprocessors() { NormalizationRestService tested = new NormalizationRestService(); { Map<String, Object> ret = tested.runPreprocessors(null, "id1"); Assert.assertNotNull(ret); Assert.assertEquals(1, ret.size()); Assert.assertEquals("id1", ret.get(NormalizationRestService.OUTKEY_INPUT_ID)); } { List<StructuredContentPreprocessor> pl = new ArrayList<>(); Map<String, Object> ret = tested.runPreprocessors(pl, "id1"); Assert.assertNotNull(ret); Assert.assertEquals(1, ret.size()); Assert.assertEquals("id1", ret.get(NormalizationRestService.OUTKEY_INPUT_ID)); } { List<StructuredContentPreprocessor> pl = new ArrayList<>(); WarningMockPreprocessor wp = new WarningMockPreprocessor(); wp.init("pp1", null, null); wp.warnAlways = true; pl.add(wp); WarningMockPreprocessor wp2 = new WarningMockPreprocessor(); wp2.init("pp2", null, null); wp2.addValue = true; pl.add(wp2); Map<String, Object> ret = tested.runPreprocessors(pl, "id1"); Assert.assertNotNull(ret); Assert.assertEquals(3, ret.size()); Assert.assertEquals("id1", ret.get(NormalizationRestService.OUTKEY_INPUT_ID)); Assert.assertEquals(1, ((List) ret.get(NormalizationRestService.OUTKEY_WARNINGS)).size()); Assert.assertEquals("value", ret.get("key")); } }