@@ -443,4 +443,120 @@ private List<String> getWarningStrings(Results results) {
443
443
private List <String > getErrorStrings (Results results ) {
444
444
return results .find ().errors ().list ().stream ().map (w -> w .getMessage (Locale .US )).collect (Collectors .toList ());
445
445
}
446
+
447
+ @ Test
448
+ @ Classpath (
449
+ "data.metamodel.ValidDocumentNumericIndexedComplex"
450
+ )
451
+ void testValidDocumentNumericIndexedComplex (Results results ) throws IOException {
452
+ List <String > warnings = getWarningStrings (results );
453
+ assertThat (warnings ).isEmpty ();
454
+
455
+ List <String > errors = getErrorStrings (results );
456
+ assertThat (errors ).isEmpty ();
457
+
458
+ assertThat (results .generated ).hasSize (1 );
459
+ JavaFileObject metamodel = results .generated .get (0 );
460
+ assertThat (metamodel .getName ()).isEqualTo ("/SOURCE_OUTPUT/valid/ValidDocumentNumericIndexedComplex$.java" );
461
+
462
+ var fileContents = metamodel .getCharContent (true );
463
+
464
+ assertAll ( //
465
+ // Test the exact case from the GitHub issue
466
+ () -> assertThat (fileContents ).contains (
467
+ "public static NumericField<ValidDocumentNumericIndexedComplex, Double> ISSUE_REPORTED_FIELD;" ),
468
+ () -> assertThat (fileContents ).contains (
469
+ "public static NumericField<ValidDocumentNumericIndexedComplex, Double> INDEXED_FIELD;" ),
470
+
471
+ // Test all numeric types work with @NumericIndexed
472
+ () -> assertThat (fileContents ).contains (
473
+ "public static NumericField<ValidDocumentNumericIndexedComplex, Integer> INTEGER_FIELD;" ),
474
+ () -> assertThat (fileContents ).contains (
475
+ "public static NumericField<ValidDocumentNumericIndexedComplex, Long> LONG_FIELD;" ),
476
+ () -> assertThat (fileContents ).contains (
477
+ "public static NumericField<ValidDocumentNumericIndexedComplex, Float> FLOAT_FIELD;" ),
478
+ () -> assertThat (fileContents ).contains (
479
+ "public static NumericField<ValidDocumentNumericIndexedComplex, BigDecimal> BIG_DECIMAL_FIELD;" ),
480
+ () -> assertThat (fileContents ).contains (
481
+ "public static NumericField<ValidDocumentNumericIndexedComplex, BigInteger> BIG_INTEGER_FIELD;" ),
482
+
483
+ // Test primitive types
484
+ () -> assertThat (fileContents ).contains (
485
+ "public static NumericField<ValidDocumentNumericIndexedComplex, Integer> PRIMITIVE_INT;" ),
486
+ () -> assertThat (fileContents ).contains (
487
+ "public static NumericField<ValidDocumentNumericIndexedComplex, Long> PRIMITIVE_LONG;" ),
488
+ () -> assertThat (fileContents ).contains (
489
+ "public static NumericField<ValidDocumentNumericIndexedComplex, Double> PRIMITIVE_DOUBLE;" ),
490
+ () -> assertThat (fileContents ).contains (
491
+ "public static NumericField<ValidDocumentNumericIndexedComplex, Float> PRIMITIVE_FLOAT;" )
492
+ );
493
+ }
494
+
495
+ @ Test
496
+ @ Classpath (
497
+ "data.metamodel.ValidDocumentNumericIndexed"
498
+ )
499
+ void testValidDocumentNumericIndexed (Results results ) throws IOException {
500
+ List <String > warnings = getWarningStrings (results );
501
+ assertThat (warnings ).isEmpty ();
502
+
503
+ List <String > errors = getErrorStrings (results );
504
+ assertThat (errors ).isEmpty ();
505
+
506
+ assertThat (results .generated ).hasSize (1 );
507
+ JavaFileObject metamodel = results .generated .get (0 );
508
+ assertThat (metamodel .getName ()).isEqualTo ("/SOURCE_OUTPUT/valid/ValidDocumentNumericIndexed$.java" );
509
+
510
+ var fileContents = metamodel .getCharContent (true );
511
+
512
+ assertAll ( //
513
+
514
+ // test package matches source package
515
+ () -> assertThat (fileContents ).contains ("package valid;" ), //
516
+
517
+ // test Fields generation
518
+ () -> assertThat (fileContents ).contains ("public static Field id;" ), //
519
+ () -> assertThat (fileContents ).contains ("public static Field price;" ), //
520
+ () -> assertThat (fileContents ).contains ("public static Field quantity;" ), //
521
+ () -> assertThat (fileContents ).contains ("public static Field rating;" ), //
522
+
523
+ // test fields initialization
524
+ () -> assertThat (fileContents ).contains (
525
+ "id = com.redis.om.spring.util.ObjectUtils.getDeclaredFieldTransitively(ValidDocumentNumericIndexed.class, \" id\" );" ),
526
+ //
527
+ () -> assertThat (fileContents ).contains (
528
+ "price = com.redis.om.spring.util.ObjectUtils.getDeclaredFieldTransitively(ValidDocumentNumericIndexed.class, \" price\" );" ),
529
+ //
530
+ () -> assertThat (fileContents ).contains (
531
+ "quantity = com.redis.om.spring.util.ObjectUtils.getDeclaredFieldTransitively(ValidDocumentNumericIndexed.class, \" quantity\" );" ),
532
+ //
533
+ () -> assertThat (fileContents ).contains (
534
+ "rating = com.redis.om.spring.util.ObjectUtils.getDeclaredFieldTransitively(ValidDocumentNumericIndexed.class, \" rating\" );" ),
535
+ //
536
+
537
+ // test Metamodel Field generation
538
+ () -> assertThat (fileContents ).contains ("public static TextTagField<ValidDocumentNumericIndexed, String> ID;" ), //
539
+ () -> assertThat (fileContents ).contains (
540
+ "public static NumericField<ValidDocumentNumericIndexed, Double> PRICE;" ), //
541
+ () -> assertThat (fileContents ).contains (
542
+ "public static NumericField<ValidDocumentNumericIndexed, Integer> QUANTITY;" ), //
543
+ () -> assertThat (fileContents ).contains (
544
+ "public static NumericField<ValidDocumentNumericIndexed, Float> RATING;" ), //
545
+
546
+ // test Metamodel Field initialization - verify aliases are used
547
+ () -> assertThat (fileContents ).contains (
548
+ "ID = new TextTagField<ValidDocumentNumericIndexed, String>(new SearchFieldAccessor(\" id\" , \" $.id\" , id),true);" ),
549
+ //
550
+ () -> assertThat (fileContents ).contains (
551
+ "PRICE = new NumericField<ValidDocumentNumericIndexed, Double>(new SearchFieldAccessor(\" price\" , \" $.price\" , price),true);" ),
552
+ //
553
+ () -> assertThat (fileContents ).contains (
554
+ "QUANTITY = new NumericField<ValidDocumentNumericIndexed, Integer>(new SearchFieldAccessor(\" qty\" , \" $.quantity\" , quantity),true);" ),
555
+ //
556
+ () -> assertThat (fileContents ).contains (
557
+ "RATING = new NumericField<ValidDocumentNumericIndexed, Float>(new SearchFieldAccessor(\" rating\" , \" $.rating\" , rating),true);" ),
558
+ //
559
+ () -> assertThat (fileContents ).contains (
560
+ "_KEY = new MetamodelField<ValidDocumentNumericIndexed, String>(\" __key\" , String.class, true);" ));
561
+ }
446
562
}
0 commit comments