fix fake data service creating invalid projects

This commit is contained in:
Jake Potrebic 2023-01-28 11:36:12 -08:00
parent d82d0abbc4
commit 743dea6ad8
No known key found for this signature in database
GPG Key ID: 27CC63F7CBC866C7
2 changed files with 3 additions and 1 deletions

View File

@ -26,6 +26,8 @@ public enum Category {
MISC(9, "mdi-asterisk", "misc"), MISC(9, "mdi-asterisk", "misc"),
UNDEFINED(10, "", "undefined", false); UNDEFINED(10, "", "undefined", false);
public static final List<Category> VALID_CATEGORIES = Arrays.stream(Category.values()).filter(c -> c != UNDEFINED).toList();
private final int value; private final int value;
private final String icon; private final String icon;
private final boolean isVisible; private final boolean isVisible;

View File

@ -101,7 +101,7 @@ public class FakeDataService extends HangarComponent {
final String projectName = this.normalize(this.faker.funnyName().name() + "_" + this.faker.minecraft().animalName()); final String projectName = this.normalize(this.faker.funnyName().name() + "_" + this.faker.minecraft().animalName());
final String quote = this.faker.theItCrowd().quotes(); final String quote = this.faker.theItCrowd().quotes();
final NewProjectForm newProject = new NewProjectForm(settings, final NewProjectForm newProject = new NewProjectForm(settings,
Category.values()[this.faker.random().nextInt(Category.values().length)], Category.VALID_CATEGORIES.get(this.faker.random().nextInt(Category.VALID_CATEGORIES.size())),
quote.substring(0, Math.min(quote.length(), 254)), quote.substring(0, Math.min(quote.length(), 254)),
ownerId, ownerId,
projectName.substring(0, Math.min(projectName.length(), 24)), projectName.substring(0, Math.min(projectName.length(), 24)),