Search in sources :

Example 1 with Encoder

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));
}
Also used : Encoder(org.talend.sdk.component.api.service.http.Encoder) Test(org.junit.jupiter.api.Test)

Example 2 with 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));
}
Also used : Encoder(org.talend.sdk.component.api.service.http.Encoder) Test(org.junit.jupiter.api.Test)

Example 3 with Encoder

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());
}
Also used : Encoder(org.talend.sdk.component.api.service.http.Encoder) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)3 Encoder (org.talend.sdk.component.api.service.http.Encoder)3