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);
}
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"));
}
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"));
}
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());
}
Aggregations