Added additional validation to be sure that the value cannot be set to 0 which means unlimited level
This commit is contained in:
parent
43b07c242f
commit
ed70a1e690
@ -45,6 +45,9 @@ public class RelationQueryDynamicSourceConfiguration implements CfArgumentDynami
|
||||
|
||||
@Override
|
||||
public void validate() {
|
||||
if (maxLevel < 1) {
|
||||
throw new IllegalArgumentException("Relation query dynamic source configuration max relation level can't be less than 1!");
|
||||
}
|
||||
if (maxLevel > 2) {
|
||||
throw new IllegalArgumentException("Relation query dynamic source configuration max relation level can't be greater than 2!");
|
||||
}
|
||||
|
||||
@ -54,6 +54,18 @@ public class RelationQueryDynamicSourceConfigurationTest {
|
||||
assertThat(cfg.getType()).isEqualTo(CFArgumentDynamicSourceType.RELATION_QUERY);
|
||||
}
|
||||
|
||||
@Test
|
||||
void validateShouldThrowWhenMaxLevelLessThanOne() {
|
||||
var cfg = new RelationQueryDynamicSourceConfiguration();
|
||||
cfg.setMaxLevel(0);
|
||||
cfg.setDirection(EntitySearchDirection.FROM);
|
||||
cfg.setRelationType(EntityRelation.CONTAINS_TYPE);
|
||||
|
||||
assertThatThrownBy(cfg::validate)
|
||||
.isInstanceOf(IllegalArgumentException.class)
|
||||
.hasMessage("Relation query dynamic source configuration max relation level can't be less than 1!");
|
||||
}
|
||||
|
||||
@Test
|
||||
void validateShouldThrowWhenMaxLevelGreaterThanTwo() {
|
||||
var cfg = new RelationQueryDynamicSourceConfiguration();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user