Simplify ingredient handling and remove generated verification files

This commit is contained in:
2026-09-13 21:55:44 +03:00
parent fcd84c7024
commit ce5a37e139
31 changed files with 1596 additions and 914 deletions
@@ -1,16 +1,22 @@
package online.astradev.cauldron;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.nio.file.*;
import java.util.*;
import static org.junit.jupiter.api.Assertions.*;
class ConfigurationPolicyTest {
@TempDir Path root;
@Test void oldConfigKeepsDefaultsAndNewFieldsAreValidated() throws Exception {
@Test
void oldConfigKeepsDefaultsAndNewFieldsAreValidated() throws Exception {
Path file = root.resolve("cauldron.json");
Files.writeString(file, "{\"servingsPerBrew\":2,\"ingredientCount\":2,\"requireHeat\":false,\"soupStackSize\":8}");
Files.writeString(
file,
"{\"servingsPerBrew\":2,\"ingredientCount\":2,\"requireHeat\":false,\"soupStackSize\":8}");
var config = SoupConfig.load(file);
assertEquals(2, config.servingsPerBrew);
assertEquals(2, config.ingredientCount);
@@ -20,11 +26,19 @@ class ConfigurationPolicyTest {
config.ingredientCount = 5;
assertThrows(IllegalArgumentException.class, config::validate);
}
@Test void ingredientCountStillChecksForbiddenCombinations() {
@Test
void ingredientCountStillChecksForbiddenCombinations() {
var ingredients = List.of(Set.of("material:carrot"), Set.of("material:potato"));
assertNull(CombinationRules.rejection(ingredients, List.of(), List.of(), 2));
assertNotNull(CombinationRules.rejection(ingredients, List.of("material:carrot"), List.of(), 2));
assertNotNull(CombinationRules.rejection(ingredients, List.of(), List.of(List.of("material:carrot", "material:potato")), 2));
assertNotNull(
CombinationRules.rejection(ingredients, List.of("material:carrot"), List.of(), 2));
assertNotNull(
CombinationRules.rejection(
ingredients,
List.of(),
List.of(List.of("material:carrot", "material:potato")),
2));
assertNotNull(CombinationRules.rejection(ingredients, List.of(), List.of(), 3));
}
}