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.*; class ConfigurationPolicyTest { @TempDir Path root; @Test void oldConfigKeepsDefaultsAndNewFieldsAreValidated() throws Exception { Path file = root.resolve("cauldron.json"); Files.writeString( file, "{\"servingsPerBrew\":2,\"ingredientCount\":2,\"requireHeat\":false,\"soupStackSize\":8}"); var config = SoupConfig.load(file); assertEquals(2, config.servingsPerBrew); assertEquals(2, config.ingredientCount); assertEquals(8, config.soupStackSize); assertFalse(config.requireHeat); assertTrue(config.tipArrows); config.ingredientCount = 5; assertThrows(IllegalArgumentException.class, config::validate); } @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(), List.of(), 3)); } }