package edu.homework.crawler.command; import edu.homework.crawler.exception.CommandException; import org.junit.jupiter.api.Test; import java.util.List; import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; class CommandRegistryTest { @Test void tokenizesQuotedOutputPath() throws Exception { CommandRegistry registry = new CommandRegistry(); List tokens = registry.tokenize("crawl --site all --out \"data/my news.json\""); assertEquals(List.of("crawl", "--site", "all", "--out", "data/my news.json"), tokens); } @Test void parsesOptionsAsKeyValuePairs() throws Exception { CommandRegistry registry = new CommandRegistry(); Map options = registry.parseOptions(new String[]{"--site", "hnu", "--limit", "5"}); assertEquals("hnu", options.get("site")); assertEquals("5", options.get("limit")); } @Test void rejectsMissingOptionValue() { CommandRegistry registry = new CommandRegistry(); assertThrows(CommandException.class, () -> registry.parseOptions(new String[]{"--site"})); } }