use of org.talend.sdk.component.api.service.http.Encoder in project component-runtime by Talend.
the class CodecMatcherTest method selectWithNoType.
@Test
void selectWithNoType() {
final Encoder encoder = matcher.select(codecMap, null);
assertTrue(DefaultEncoder.class.isInstance(encoder));
}
use of org.talend.sdk.component.api.service.http.Encoder in project component-runtime by Talend.
the class CodecMatcherTest method selectWithExactMatch.
@Test
void selectWithExactMatch() {
final Encoder jsonEncoder = matcher.select(codecMap, "application/json");
assertTrue(JsonEncoder.class.isInstance(jsonEncoder));
assertEquals("application/json", jsonEncoder.getClass().getAnnotation(ContentType.class).value());
final Encoder talendEncoder = matcher.select(codecMap, "application/talend+json");
assertTrue(TalendJsonEncoder.class.isInstance(talendEncoder));
assertEquals("application/talend+json", talendEncoder.getClass().getAnnotation(ContentType.class).value());
final Encoder defaultEncoder = matcher.select(codecMap, "*/*");
assertTrue(DefaultEncoder.class.isInstance(defaultEncoder));
}
use of org.talend.sdk.component.api.service.http.Encoder in project component-runtime by Talend.
the class CodecMatcherTest method selectWithtRegex.
@Test
void selectWithtRegex() {
final Encoder jsonEncoder = matcher.select(codecMap, "foo/json");
assertTrue(JsonEncoder.class.isInstance(jsonEncoder));
assertEquals("application/json", jsonEncoder.getClass().getAnnotation(ContentType.class).value());
final Encoder talendEncoder = matcher.select(codecMap, "application/foo+json");
assertTrue(TalendJsonEncoder.class.isInstance(talendEncoder));
assertEquals("application/talend+json", talendEncoder.getClass().getAnnotation(ContentType.class).value());
}