### Question:
Engine implements ContentEngine { @Override public ContentSerializer getBestSerializer(Collection<MediaType> mediaTypes) { if (mediaTypes == null || mediaTypes.isEmpty()) { mediaTypes = ImmutableList.of(MediaType.HTML_UTF_8); } for (MediaType type : mediaTypes) { for (ContentSerializer ser : serializers) { MediaType mt = MediaType.parse(ser.getContentType()); if (mt.is(type.withoutParameters())) { return ser; } } } return null; }  @Override BodyParser getBodyParserEngineForContentType(String contentType); @Override ContentSerializer getContentSerializerForContentType(String contentType); @Override ContentSerializer getBestSerializer(Collection<MediaType> mediaTypes);  }### Answer:
@Test public void testGetBestSerializer() throws Exception { assertThat(engine.getBestSerializer(types)).isEqualTo(json); types = mediaTypes("text*;q=0.5"); assertThat(engine.getBestSerializer(types)).isEqualTo(xml); types = mediaTypes("text*;q=0.5"); assertThat(engine.getBestSerializer(types)).isEqualTo(json); types = mediaTypes(MimeTypes.JSON); assertThat(engine.getBestSerializer(types)).isEqualTo(json); assertThat(engine.getBestSerializer(types)).isEqualTo(json); types = mediaTypes("text*;q=0.5"); assertThat(engine.getBestSerializer(types)).isEqualTo(xml); assertThat(engine.getBestSerializer(null)).isNull(); assertThat(engine.getBestSerializer(Collections.<MediaType>emptyList())).isNull(); }