Search in sources :

Example 1 with ConfigModel

use of io.strimzi.kafka.config.model.ConfigModel in project strimzi by strimzi.

the class KafkaConfigModelGenerator method main.

public static void main(String[] args) throws Exception {
    String version = kafkaVersion();
    Map<String, ConfigModel> configs = configs();
    ObjectMapper mapper = new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT).enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY);
    ConfigModels root = new ConfigModels();
    root.setVersion(version);
    root.setConfigs(configs);
    mapper.writeValue(new File(args[0]), root);
}
Also used : ConfigModel(io.strimzi.kafka.config.model.ConfigModel) ConfigModels(io.strimzi.kafka.config.model.ConfigModels) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with ConfigModel

use of io.strimzi.kafka.config.model.ConfigModel in project strimzi by strimzi.

the class ConfigModelTest method testBooleanValidation.

@Test
public void testBooleanValidation() {
    ConfigModel cm = new ConfigModel();
    cm.setType(Type.BOOLEAN);
    assertThat(cm.validate("test", "true"), is(emptyList()));
    assertThat(cm.validate("test", "false"), is(emptyList()));
    assertThat(cm.validate("test", "dog"), is(singletonList("test has value 'dog' which is not a boolean")));
}
Also used : ConfigModel(io.strimzi.kafka.config.model.ConfigModel) Test(org.junit.jupiter.api.Test)

Example 3 with ConfigModel

use of io.strimzi.kafka.config.model.ConfigModel in project strimzi by strimzi.

the class ConfigModelTest method testDoubleValidation.

@Test
public void testDoubleValidation() {
    ConfigModel cm = new ConfigModel();
    cm.setType(Type.DOUBLE);
    assertThat(cm.validate("test", "1"), is(emptyList()));
    assertThat(cm.validate("test", "dog"), is(singletonList("test has value 'dog' which is not a double")));
    cm.setMinimum(0.0);
    assertThat(cm.validate("test", "-0.1"), is(singletonList("test has value -0.1 which less than the minimum value 0.0")));
    cm.setMaximum(1.0);
    assertThat(cm.validate("test", "1.1"), is(singletonList("test has value 1.1 which greater than the maximum value 1.0")));
}
Also used : ConfigModel(io.strimzi.kafka.config.model.ConfigModel) Test(org.junit.jupiter.api.Test)

Example 4 with ConfigModel

use of io.strimzi.kafka.config.model.ConfigModel in project strimzi by strimzi.

the class ConfigModelTest method testIntValidation.

@Test
public void testIntValidation() {
    ConfigModel cm = new ConfigModel();
    cm.setType(Type.INT);
    assertThat(cm.validate("test", "1"), is(emptyList()));
    assertThat(cm.validate("test", Integer.valueOf(Integer.MAX_VALUE).toString()), is(emptyList()));
    assertThat(cm.validate("test", Integer.valueOf(Integer.MIN_VALUE).toString()), is(emptyList()));
    assertThat(cm.validate("test", Long.valueOf((long) Integer.MAX_VALUE + 1L).toString()), is(singletonList("test has value '2147483648' which is not an int")));
    assertThat(cm.validate("test", Long.valueOf((long) Integer.MIN_VALUE - 1L).toString()), is(singletonList("test has value '-2147483649' which is not an int")));
    cm.setMinimum(0);
    assertThat(cm.validate("test", "-1"), is(singletonList("test has value -1 which less than the minimum value 0")));
    cm.setMaximum(1);
    assertThat(cm.validate("test", "2"), is(singletonList("test has value 2 which greater than the maximum value 1")));
}
Also used : ConfigModel(io.strimzi.kafka.config.model.ConfigModel) Test(org.junit.jupiter.api.Test)

Example 5 with ConfigModel

use of io.strimzi.kafka.config.model.ConfigModel in project strimzi by strimzi.

the class ConfigModelTest method testClassValidation.

@Test
public void testClassValidation() {
    ConfigModel cm = new ConfigModel();
    cm.setType(Type.CLASS);
    assertThat(cm.validate("test", "org.example.Whatever"), is(emptyList()));
}
Also used : ConfigModel(io.strimzi.kafka.config.model.ConfigModel) Test(org.junit.jupiter.api.Test)

Aggregations

ConfigModel (io.strimzi.kafka.config.model.ConfigModel)28 Test (org.junit.jupiter.api.Test)18 Scope (io.strimzi.kafka.config.model.Scope)4 Type (io.strimzi.kafka.config.model.Type)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 SerializationFeature (com.fasterxml.jackson.databind.SerializationFeature)2 PatchUtils.patchMapper (io.fabric8.kubernetes.client.internal.PatchUtils.patchMapper)2 JsonDiff (io.fabric8.zjsonpatch.JsonDiff)2 ConfigModels (io.strimzi.kafka.config.model.ConfigModels)2 KafkaConfiguration (io.strimzi.operator.cluster.model.KafkaConfiguration)2 KafkaVersion (io.strimzi.operator.cluster.model.KafkaVersion)2 Reconciliation (io.strimzi.operator.common.Reconciliation)2 ReconciliationLogger (io.strimzi.operator.common.ReconciliationLogger)2 OrderedProperties (io.strimzi.operator.common.model.OrderedProperties)2 AbstractJsonDiff (io.strimzi.operator.common.operator.resource.AbstractJsonDiff)2 File (java.io.File)2 Method (java.lang.reflect.Method)2