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