### Question:
LocalizationBundleJaxrsService { @GET @Produces(MediaType.APPLICATION_JSON) public Response getBundles(@QueryParam(RestConstants.QUERY_PARAM_EXPANDED) Boolean expanded, @Context HttpHeaders headers, @Context Request request, @Context HttpServletRequest httpRequest) { if (httpRequest != null && expanded == null) { Map<String, String[]> forwardedParameters = (Map<String, String[]>)httpRequest .getAttribute(FORWARDED_PARAMETERS); if (forwardedParameters != null && forwardedParameters.get(RestConstants.QUERY_PARAM_EXPANDED) != null) { expanded = Boolean.valueOf(forwardedParameters.get(RestConstants.QUERY_PARAM_EXPANDED)[0]); } } if (Boolean.TRUE.equals(expanded)) { Locale locale = headers.getAcceptableLanguages().get(0); ObjectNode json = JsonNodeFactory.instance.objectNode(); for (String currentBundle : bundleNames) { final Map<String, String> messages = messageSource.getAllMessagesForBaseName(currentBundle, locale); ObjectNode currentMessages = JsonNodeFactory.instance.objectNode(); for (String key : messages.keySet()) { currentMessages.put(key, messages.get(key)); } json.put(currentBundle, currentMessages); } EntityTag etag = generateETag(json); Response.ResponseBuilder response = request.evaluatePreconditions(etag); if (response == null) { response = Response.ok(json).tag(etag); } return response.build(); } else { return Response.ok(bundleNames).build(); } }  @Resource(name = "bundlePathsList") void setBundleNames(List<String> bundlePathsList); @GET @Produces(MediaType.APPLICATION_JSON) Response getBundles(@QueryParam(RestConstants.QUERY_PARAM_EXPANDED) Boolean expanded,
                               @Context HttpHeaders headers, @Context Request request, @Context HttpServletRequest httpRequest); @GET @Path("/{name}") @Produces(MediaType.APPLICATION_JSON) Response getBundle(@PathParam("name") String bundleName, @Context HttpHeaders headers, @Context Request request); byte[] toJson(Map<String, String> messages);  }### Answer:
@Test(dependsOnMethods = "setBundleNames") public void getBundles_expandedFalse() { final Response response = service.getBundles(false, httpHeaders, request, httpServletRequest); assertNotNull(response); final Object entity = response.getEntity(); assertSame(entity, service.bundleNames); }
@Test(dependsOnMethods = "setBundleNames") public void getBundles_expandedTrue() { final Response response = service.getBundles(true, httpHeaders, request, httpServletRequest); assertNotNull(response); assertTrue(response.getEntity() instanceof ObjectNode); ObjectNode json = (ObjectNode) response.getEntity(); assertEquals(json.size(), 4); assertBundle((ObjectNode) json.get(BUNDLE1_NAME), bundle1); assertBundle((ObjectNode) json.get(BUNDLE2_NAME), bundle2); assertBundle((ObjectNode) json.get(BUNDLE3_NAME), bundle3); assertBundle((ObjectNode) json.get(BUNDLE4_NAME), bundle4); }