use of io.aklivity.zilla.runtime.engine.config.OptionsConfig in project zilla by aklivity.
the class BindingConfigsAdapter method adaptFromJson.
@Override
public BindingConfig[] adaptFromJson(JsonObject object) {
List<BindingConfig> bindings = new LinkedList<>();
for (String entry : object.keySet()) {
JsonObject item = object.getJsonObject(entry);
String type = item.getString(TYPE_NAME);
route.adaptType(type);
options.adaptType(type);
NamespacedRef vault = item.containsKey(VAULT_NAME) ? NamespacedRef.of(item.getString(VAULT_NAME)) : null;
KindConfig kind = this.kind.adaptFromJson(item.getJsonString(KIND_NAME));
OptionsConfig opts = item.containsKey(OPTIONS_NAME) ? options.adaptFromJson(item.getJsonObject(OPTIONS_NAME)) : null;
MutableInteger order = new MutableInteger();
List<RouteConfig> routes = item.containsKey(ROUTES_NAME) ? item.getJsonArray(ROUTES_NAME).stream().map(JsonValue::asJsonObject).peek(o -> route.adaptFromJsonIndex(order.value++)).map(route::adaptFromJson).collect(toList()) : ROUTES_DEFAULT;
RouteConfig exit = item.containsKey(EXIT_NAME) ? new RouteConfig(routes.size(), item.getString(EXIT_NAME)) : null;
bindings.add(new BindingConfig(vault, entry, type, kind, opts, routes, exit));
}
return bindings.toArray(BindingConfig[]::new);
}
use of io.aklivity.zilla.runtime.engine.config.OptionsConfig in project zilla by aklivity.
the class VaultAdapter method adaptFromJson.
public VaultConfig adaptFromJson(String name, JsonObject object) {
String type = object.getString(TYPE_NAME);
options.adaptType(type);
OptionsConfig opts = object.containsKey(OPTIONS_NAME) ? options.adaptFromJson(object.getJsonObject(OPTIONS_NAME)) : null;
return new VaultConfig(name, type, opts);
}
use of io.aklivity.zilla.runtime.engine.config.OptionsConfig in project zilla by aklivity.
the class OptionsConfigAdapterTest method shouldWriteOptions.
@Test
public void shouldWriteOptions() {
OptionsConfig options = new TestOptionsConfig("test");
String text = jsonb.toJson(options);
assertThat(text, not(nullValue()));
assertThat(text, equalTo("{\"mode\":\"test\"}"));
}
use of io.aklivity.zilla.runtime.engine.config.OptionsConfig in project zilla by aklivity.
the class OptionsConfigAdapterTest method shouldWriteNullWhenNotAdapting.
@Test
public void shouldWriteNullWhenNotAdapting() {
OptionsConfig options = new TestOptionsConfig("test");
adapter.adaptType(null);
String text = jsonb.toJson(options);
assertThat(text, not(nullValue()));
assertThat(text, equalTo("null"));
}
Aggregations