Search in sources :

Example 1 with ConditionConfig

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

the class ConditionConfigAdapterTest method shouldWriteNullWhenNotAdapting.

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

Example 2 with ConditionConfig

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

the class ConditionConfigAdapterTest method shouldWriteCondition.

@Test
public void shouldWriteCondition() {
    ConditionConfig condition = new TestConditionConfig("test");
    String text = jsonb.toJson(condition);
    assertThat(text, not(nullValue()));
    assertThat(text, equalTo("{\"match\":\"test\"}"));
}
Also used : ConditionConfig(io.aklivity.zilla.runtime.engine.config.ConditionConfig) Test(org.junit.Test)

Example 3 with ConditionConfig

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

the class WithConfigAdapterTest method shouldWriteWith.

@Test
public void shouldWriteWith() {
    ConditionConfig condition = new TestCondition("test");
    String text = jsonb.toJson(condition);
    assertThat(text, not(nullValue()));
    assertThat(text, equalTo("{\"match\":\"test\"}"));
}
Also used : ConditionConfig(io.aklivity.zilla.runtime.engine.config.ConditionConfig) Test(org.junit.Test)

Example 4 with ConditionConfig

use of io.aklivity.zilla.runtime.engine.config.ConditionConfig 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 5 with ConditionConfig

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

the class ConditionConfigAdapterTest method shouldReadNullWhenNotAdapting.

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

Aggregations

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