use of io.strimzi.kafka.config.model.ConfigModel in project strimzi-kafka-operator 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);
}
use of io.strimzi.kafka.config.model.ConfigModel in project strimzi-kafka-operator 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")));
}
use of io.strimzi.kafka.config.model.ConfigModel in project strimzi-kafka-operator 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()));
}
use of io.strimzi.kafka.config.model.ConfigModel in project strimzi-kafka-operator by strimzi.
the class ConfigModelTest method testStringValidation.
@Test
public void testStringValidation() {
ConfigModel cm = new ConfigModel();
cm.setType(Type.STRING);
assertThat(cm.validate("test", "dog"), is(emptyList()));
cm.setValues(asList("foo", "bar"));
assertThat(cm.validate("test", "foo"), is(emptyList()));
assertThat(cm.validate("test", "bar"), is(emptyList()));
assertThat(cm.validate("test", "baz"), is(singletonList("test has value 'baz' which is not one of the allowed values: [foo, bar]")));
cm.setValues(null);
cm.setPattern("foo|bar");
assertThat(cm.validate("test", "foo"), is(emptyList()));
assertThat(cm.validate("test", "bar"), is(emptyList()));
assertThat(cm.validate("test", "baz"), is(singletonList("test has value 'baz' which does not match the required pattern: foo|bar")));
}
use of io.strimzi.kafka.config.model.ConfigModel in project strimzi-kafka-operator 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")));
}
Aggregations