### Question:
NormalizationRestService extends RestServiceBase { @SuppressWarnings("unchecked") @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) public Map<String, Object> availableNormalizations() { Map<String, Object> normalizations = configService.get(ConfigService.CFGNAME_NORMALIZATIONS); Map<String, Object> ret = new HashMap<>(); if (normalizations != null) { for (String normalizationName : normalizations.keySet()) { Object o = normalizations.get(normalizationName); if (o instanceof Map) { String descr = ((Map<String, String>) o).get(CFG_DESCRIPTION); if (descr == null) descr = ""; ret.put(normalizationName, descr); } } } 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:
@Test public void availableNormalizations() { NormalizationRestService tested = new NormalizationRestService(); tested.configService = Mockito.mock(ConfigService.class); { Mockito.when(tested.configService.get(ConfigService.CFGNAME_NORMALIZATIONS)).thenReturn(null); Map<String, Object> ret = tested.availableNormalizations(); Assert.assertEquals(0, ret.size()); } { Mockito.when(tested.configService.get(ConfigService.CFGNAME_NORMALIZATIONS)).thenReturn( TestUtils.loadJSONFromClasspathFile("/normalization/normalizations.json")); Map<String, Object> ret = tested.availableNormalizations(); Assert.assertEquals(2, ret.size()); Assert.assertEquals("description 1", ret.get("test_normalization")); Assert.assertEquals("", ret.get("test_normalization_bad")); } }