### Question:
NormalizationRestService extends RestServiceBase { @GET @Path("/{normalizationName}") @Produces(MediaType.APPLICATION_JSON) public Object normalizeBulk(@PathParam("normalizationName") String normalizationName, @Context UriInfo uriInfo) throws ObjectNotFoundException { if (SearchUtils.isBlank(normalizationName)) { throw new RequiredFieldException("normalizationName"); } if (uriInfo == null || uriInfo.getQueryParameters().isEmpty() || !uriInfo.getQueryParameters().containsKey(INKEY_ID)) { return Response.status(Status.BAD_REQUEST) .entity("Request content must contain 'id' field with array of strings with content identifiers to delete") .build(); } List<String> ids = uriInfo.getQueryParameters().get(INKEY_ID); Map<String, Object> ret = new LinkedHashMap<>(); if (!ids.isEmpty()) { List<StructuredContentPreprocessor> preprocessors = getPreprocessors(normalizationName); for (String id : ids) { ret.put(id, runPreprocessors(preprocessors, id)); } } return ret; }  @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({ "unchecked", "rawtypes" }) @Test public void normalizeBulk() throws Exception { NormalizationRestService tested = Mockito.mock(NormalizationRestService.class); Mockito.when(tested.normalizeBulk(Mockito.anyString(), Mockito.any(UriInfo.class))).thenCallRealMethod(); List<StructuredContentPreprocessor> pl = new ArrayList<>(); Mockito.when(tested.getPreprocessors(TEST_NORM_NAME)).thenReturn(pl); UriInfo reqContent = new UriInfoImpl(new URI("http: new ArrayList()); try { tested.normalizeBulk(null, reqContent); Assert.fail("RequiredFieldException expected"); } catch (RequiredFieldException e) { } try { tested.normalizeBulk(" ", reqContent); Assert.fail("RequiredFieldException expected"); } catch (RequiredFieldException e) { } TestUtils.assertResponseStatus(tested.normalizeBulk(TEST_NORM_NAME, null), Status.BAD_REQUEST); reqContent = new UriInfoImpl(new URI("http: TestUtils.assertResponseStatus(tested.normalizeBulk(TEST_NORM_NAME, reqContent), Status.BAD_REQUEST); reqContent = new UriInfoImpl(new URI("http: new ArrayList()); TestUtils.assertResponseStatus(tested.normalizeBulk(TEST_NORM_NAME, reqContent), Status.BAD_REQUEST); Map<String, Object> sret = new HashMap<>(); Mockito.when(tested.runPreprocessors(pl, "myid")).thenReturn(sret); Map<String, Object> sret2 = new HashMap<>(); Mockito.when(tested.runPreprocessors(pl, "myid2")).thenReturn(sret2); reqContent = new UriInfoImpl(new URI("http: new ArrayList()); Object ret = tested.normalizeBulk(TEST_NORM_NAME, reqContent); Assert.assertTrue(ret instanceof Map); Map r = (Map) ret; Assert.assertEquals(2, r.size()); Assert.assertEquals(sret, r.get("myid")); Assert.assertEquals(sret2, r.get("myid2")); }