public void testSelectVariant() {
final ClientInfo clientInfo = new ClientInfo();
final List<Preference<Language>> accLangs = clientInfo
.getAcceptedLanguages();
accLangs.add(new Preference<Language>(Language.SPANISH, 1f));
accLangs.add(new Preference<Language>(new Language("de"), 0.8f));
clientInfo.getAcceptedMediaTypes().add(
new Preference<MediaType>(MediaType.TEXT_HTML, 0.5f));
Response response = get("selectVariants", clientInfo);
assertEquals(Status.SUCCESS_OK, response.getStatus());
assertEqualMediaType(MediaType.TEXT_HTML, response.getEntity()
.getMediaType());
assertEquals(new Language("de"), TestUtils.getOnlyElement(response
.getEntity().getLanguages()));
assertTrue("dimensions must contain " + Dimension.MEDIA_TYPE, response
.getDimensions().contains(Dimension.MEDIA_TYPE));
assertTrue("dimensions must contain " + Dimension.LANGUAGE, response
.getDimensions().contains(Dimension.LANGUAGE));
clientInfo.getAcceptedMediaTypes().add(
new Preference<MediaType>(MediaType.TEXT_PLAIN, 1f));
response = get("selectVariants", clientInfo);
assertEqualMediaType(MediaType.TEXT_PLAIN, response.getEntity()
.getMediaType());
assertEquals(new Language("de"), TestUtils.getOnlyElement(response
.getEntity().getLanguages()));
accLangs.add(new Preference<Language>(Language.ENGLISH, 0.9f));
response = get("selectVariants", clientInfo);
assertEqualMediaType(MediaType.TEXT_PLAIN, response.getEntity()