@@ -357,4 +357,102 @@ void testCreateConfig_withWhitespaceImageDir() throws ParseException {
357357
358358 assertNull (config .getImageDir ()); // whitespace-only treated as null (use default)
359359 }
360+
361+ // ===== Hybrid Mode Option Tests =====
362+
363+ @ Test
364+ void testDefineOptions_containsHybridModeOption () {
365+ assertTrue (options .hasOption ("hybrid-mode" ));
366+ }
367+
368+ @ Test
369+ void testDefineOptions_containsHybridOcrOption () {
370+ assertTrue (options .hasOption ("hybrid-ocr" ));
371+ }
372+
373+ @ Test
374+ void testCreateConfig_withHybridModeAuto () throws ParseException {
375+ String [] args = {"--hybrid" , "docling" , "--hybrid-mode" , "auto" , testPdf .getAbsolutePath ()};
376+ CommandLine cmd = parser .parse (options , args );
377+
378+ Config config = CLIOptions .createConfigFromCommandLine (cmd );
379+
380+ assertEquals ("auto" , config .getHybridConfig ().getMode ());
381+ assertFalse (config .getHybridConfig ().isFullMode ());
382+ }
383+
384+ @ Test
385+ void testCreateConfig_withHybridModeFull () throws ParseException {
386+ String [] args = {"--hybrid" , "docling" , "--hybrid-mode" , "full" , testPdf .getAbsolutePath ()};
387+ CommandLine cmd = parser .parse (options , args );
388+
389+ Config config = CLIOptions .createConfigFromCommandLine (cmd );
390+
391+ assertEquals ("full" , config .getHybridConfig ().getMode ());
392+ assertTrue (config .getHybridConfig ().isFullMode ());
393+ }
394+
395+ @ Test
396+ void testCreateConfig_withInvalidHybridMode () throws ParseException {
397+ String [] args = {"--hybrid-mode" , "invalid" , testPdf .getAbsolutePath ()};
398+ CommandLine cmd = parser .parse (options , args );
399+
400+ assertThrows (IllegalArgumentException .class , () -> {
401+ CLIOptions .createConfigFromCommandLine (cmd );
402+ });
403+ }
404+
405+ @ Test
406+ void testCreateConfig_withHybridOcrAuto () throws ParseException {
407+ String [] args = {"--hybrid" , "docling" , "--hybrid-ocr" , "auto" , testPdf .getAbsolutePath ()};
408+ CommandLine cmd = parser .parse (options , args );
409+
410+ Config config = CLIOptions .createConfigFromCommandLine (cmd );
411+
412+ assertEquals ("auto" , config .getHybridConfig ().getOcrMode ());
413+ assertFalse (config .getHybridConfig ().isForceOcr ());
414+ }
415+
416+ @ Test
417+ void testCreateConfig_withHybridOcrForce () throws ParseException {
418+ String [] args = {"--hybrid" , "docling" , "--hybrid-ocr" , "force" , testPdf .getAbsolutePath ()};
419+ CommandLine cmd = parser .parse (options , args );
420+
421+ Config config = CLIOptions .createConfigFromCommandLine (cmd );
422+
423+ assertEquals ("force" , config .getHybridConfig ().getOcrMode ());
424+ assertTrue (config .getHybridConfig ().isForceOcr ());
425+ }
426+
427+ @ Test
428+ void testCreateConfig_withInvalidHybridOcr () throws ParseException {
429+ String [] args = {"--hybrid-ocr" , "invalid" , testPdf .getAbsolutePath ()};
430+ CommandLine cmd = parser .parse (options , args );
431+
432+ assertThrows (IllegalArgumentException .class , () -> {
433+ CLIOptions .createConfigFromCommandLine (cmd );
434+ });
435+ }
436+
437+ @ Test
438+ void testCreateConfig_defaultHybridModeAndOcr () throws ParseException {
439+ String [] args = {"--hybrid" , "docling" , testPdf .getAbsolutePath ()};
440+ CommandLine cmd = parser .parse (options , args );
441+
442+ Config config = CLIOptions .createConfigFromCommandLine (cmd );
443+
444+ assertEquals ("auto" , config .getHybridConfig ().getMode ());
445+ assertEquals ("auto" , config .getHybridConfig ().getOcrMode ());
446+ }
447+
448+ @ Test
449+ void testCreateConfig_withDoclingBackend () throws ParseException {
450+ String [] args = {"--hybrid" , "docling" , testPdf .getAbsolutePath ()};
451+ CommandLine cmd = parser .parse (options , args );
452+
453+ Config config = CLIOptions .createConfigFromCommandLine (cmd );
454+
455+ assertEquals ("docling" , config .getHybrid ());
456+ assertTrue (config .isHybridEnabled ());
457+ }
360458}
0 commit comments