Search in sources :

Example 1 with WithConfig

use of io.aklivity.zilla.runtime.engine.config.WithConfig in project zilla by aklivity.

the class RouteAdapter method adaptFromJson.

@Override
public RouteConfig adaptFromJson(JsonObject object) {
    String exit = object.getString(EXIT_NAME);
    List<ConditionConfig> when = object.containsKey(WHEN_NAME) ? object.getJsonArray(WHEN_NAME).stream().map(JsonValue::asJsonObject).map(condition::adaptFromJson).collect(Collectors.toList()) : WHEN_DEFAULT;
    WithConfig wth = object.containsKey(WITH_NAME) ? with.adaptFromJson(object.getJsonObject(WITH_NAME)) : null;
    return new RouteConfig(index, exit, when, wth);
}
Also used : WithConfig(io.aklivity.zilla.runtime.engine.config.WithConfig) RouteConfig(io.aklivity.zilla.runtime.engine.config.RouteConfig) ConditionConfig(io.aklivity.zilla.runtime.engine.config.ConditionConfig)

Example 2 with WithConfig

use of io.aklivity.zilla.runtime.engine.config.WithConfig in project zilla by aklivity.

the class WithConfigAdapterTest method shouldWriteNullWhenNotAdapting.

@Test
public void shouldWriteNullWhenNotAdapting() {
    WithConfig with = new TestWithConfig("test");
    adapter.adaptType(null);
    String text = jsonb.toJson(with);
    assertThat(text, not(nullValue()));
    assertThat(text, equalTo("null"));
}
Also used : WithConfig(io.aklivity.zilla.runtime.engine.config.WithConfig) Test(org.junit.Test)

Example 3 with WithConfig

use of io.aklivity.zilla.runtime.engine.config.WithConfig in project zilla by aklivity.

the class WithConfigAdapterTest method shouldReadWith.

@Test
public void shouldReadWith() {
    String text = "{" + "\"name\": \"test\"" + "}";
    WithConfig with = jsonb.fromJson(text, WithConfig.class);
    assertThat(with, not(nullValue()));
    assertThat(((TestWithConfig) with).name, equalTo("test"));
}
Also used : WithConfig(io.aklivity.zilla.runtime.engine.config.WithConfig) Test(org.junit.Test)

Example 4 with WithConfig

use of io.aklivity.zilla.runtime.engine.config.WithConfig in project zilla by aklivity.

the class WithConfigAdapterTest method shouldReadNullWhenNotAdapting.

@Test
public void shouldReadNullWhenNotAdapting() {
    String text = "{" + "\"name\": \"test\"" + "}";
    adapter.adaptType(null);
    WithConfig with = jsonb.fromJson(text, WithConfig.class);
    assertThat(with, nullValue());
}
Also used : WithConfig(io.aklivity.zilla.runtime.engine.config.WithConfig) Test(org.junit.Test)

Aggregations

WithConfig (io.aklivity.zilla.runtime.engine.config.WithConfig)4 Test (org.junit.Test)3 ConditionConfig (io.aklivity.zilla.runtime.engine.config.ConditionConfig)1 RouteConfig (io.aklivity.zilla.runtime.engine.config.RouteConfig)1