feat: added min size of 12 to validation of characterConfig

This commit is contained in:
Yannik Bretschneider 2021-06-05 16:24:35 +02:00
parent bf2ef23733
commit b9a6308d6b
2 changed files with 4 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package uulm.teamname.marvelous.gamelibrary.config;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.Size;
import java.util.*; import java.util.*;
@ -13,6 +14,7 @@ public class CharacterConfig {
@NotEmpty @NotEmpty
@Valid @Valid
@Size(min = 12, message = "has less than 12 characters")
public CharacterProperties[] characters; public CharacterProperties[] characters;
@JsonIgnore private Map<String, CharacterProperties> propertyMap; @JsonIgnore private Map<String, CharacterProperties> propertyMap;

View File

@ -125,7 +125,8 @@ class MessageValidationUtilityTest {
characterConfig.characters = new CharacterProperties[] {racoon, quicksilver, hulk, loki, silversurfer}; characterConfig.characters = new CharacterProperties[] {racoon, quicksilver, hulk, loki, silversurfer};
assertThat(ValidationUtility.validate(characterConfig).get()) assertThat(ValidationUtility.validate(characterConfig).get())
.contains("characters[4].rangedDamage must be greater than 0", .contains("characters has less than 12 characters",
"characters[4].rangedDamage must be greater than 0",
"characters[4].name must not be empty", "characters[4].name must not be empty",
"characters[4].meleeDamage must be greater than 0"); "characters[4].meleeDamage must be greater than 0");
} }