|
12 | 12 | import io.hyperfoil.tools.h5m.entity.ValueEntity; |
13 | 13 | import io.hyperfoil.tools.h5m.entity.mapper.ApiMapper; |
14 | 14 | import io.hyperfoil.tools.h5m.entity.mapper.CycleAvoidingContext; |
| 15 | +import io.hyperfoil.tools.h5m.entity.node.FingerprintNode; |
15 | 16 | import io.hyperfoil.tools.h5m.entity.node.JqNode; |
16 | 17 | import io.hyperfoil.tools.h5m.entity.node.RootNode; |
17 | 18 | import io.quarkus.test.junit.QuarkusTest; |
@@ -672,57 +673,106 @@ public void findMatchingFingerprint_sibling() throws SystemException, NotSupport |
672 | 673 |
|
673 | 674 | } |
674 | 675 | @Test |
675 | | - public void findMatchingFingerprint_sorting_cousin() throws SystemException, NotSupportedException, JsonProcessingException, HeuristicRollbackException, HeuristicMixedException, RollbackException { |
| 676 | + public void findMatchingFingerprint_sorting_cousin_reverse() throws SystemException, NotSupportedException, HeuristicRollbackException, HeuristicMixedException, RollbackException, JsonProcessingException { |
676 | 677 | tm.begin(); |
677 | 678 | NodeEntity rootNode = new RootNode(); |
678 | | - rootNode.persist(rootNode); |
679 | | - NodeEntity aNode = new JqNode("a"); |
680 | | - aNode.sources=List.of(rootNode); |
681 | | - aNode.persist(aNode); |
682 | | - NodeEntity bNode = new JqNode("b"); |
683 | | - bNode.sources=List.of(rootNode); |
| 679 | + rootNode.persist(); |
| 680 | + NodeEntity aNode = new JqNode("a",".a",rootNode); |
| 681 | + aNode.persist(); |
| 682 | + NodeEntity bNode = new JqNode("b",".b",rootNode); |
684 | 683 | bNode.persist(); |
685 | | - NodeEntity cNode = new JqNode("c"); |
686 | | - cNode.sources=List.of(rootNode); |
| 684 | + NodeEntity cNode = new JqNode("c",".c",rootNode); |
687 | 685 | cNode.persist(); |
688 | | - NodeEntity caNode = new JqNode("ca"); |
689 | | - caNode.sources=List.of(cNode); |
| 686 | + NodeEntity caNode = new JqNode("c",".ca",List.of(cNode,aNode)); |
690 | 687 | caNode.persist(); |
691 | | - ObjectMapper objectMapper = new ObjectMapper(); |
692 | 688 |
|
693 | | - ValueEntity rootValue01 = new ValueEntity(null,rootNode,new TextNode("root1")); |
| 689 | + ObjectMapper objectMapper = new ObjectMapper(); |
| 690 | + ValueEntity rootValue01 = new ValueEntity(null,rootNode, |
| 691 | + objectMapper.readTree(""" |
| 692 | + { "a" : "a", "b" : "b1", "c" : "c1", "ca" : "ca1" } |
| 693 | + """)); |
| 694 | + ValueEntity rootValue02 = new ValueEntity(null,rootNode, |
| 695 | + objectMapper.readTree(""" |
| 696 | + { "a" : "a", "b" : "b2", "c" : "c1", "ca" : "ca2" } |
| 697 | + """)); |
694 | 698 | rootValue01.persist(); |
695 | | - ValueEntity rootValue02 = new ValueEntity(null,rootNode,new TextNode("root2")); |
696 | | - rootValue02.persist(); |
697 | | - |
698 | | - ValueEntity aValue01 = new ValueEntity(null,aNode,new TextNode("a")); |
699 | | - aValue01.sources=List.of(rootValue01); |
| 699 | + // a values |
| 700 | + ValueEntity aValue01 = new ValueEntity(null,aNode,rootValue01.data.get("a"),List.of(rootValue01)); |
700 | 701 | aValue01.persist(); |
701 | | - |
702 | | - ValueEntity aValue02 = new ValueEntity(null,aNode,new TextNode("a")); |
703 | | - aValue02.sources=List.of(rootValue02); |
| 702 | + ValueEntity aValue02 = new ValueEntity(null,aNode,rootValue02.data.get("a"),List.of(rootValue02)); |
704 | 703 | aValue02.persist(); |
705 | | - |
706 | | - ValueEntity bValue01 = new ValueEntity(null,bNode,new TextNode("b1")); |
707 | | - bValue01.sources=List.of(rootValue01); |
| 704 | + // b values |
| 705 | + ValueEntity bValue01 = new ValueEntity(null,bNode,rootValue01.data.get("b"),List.of(rootValue01)); |
708 | 706 | bValue01.persist(); |
709 | | - ValueEntity bValue02 = new ValueEntity(null,bNode,new TextNode("b2")); |
710 | | - bValue02.sources=List.of(rootValue02); |
| 707 | + ValueEntity bValue02 = new ValueEntity(null,bNode,rootValue02.data.get("b"),List.of(rootValue02)); |
711 | 708 | bValue02.persist(); |
| 709 | + // c values |
| 710 | + ValueEntity cValue01 = new ValueEntity(null,cNode,rootValue01.data.get("c"),List.of(rootValue01)); |
| 711 | + cValue01.persist(); |
| 712 | + ValueEntity cValue02 = new ValueEntity(null,cNode,rootValue02.data.get("c"),List.of(rootValue02)); |
| 713 | + cValue02.persist(); |
| 714 | + // ca values |
| 715 | + ValueEntity caValue01 = new ValueEntity(null,caNode,rootValue01.data.get("ca"),List.of(rootValue01)); |
| 716 | + caValue01.persist(); |
| 717 | + ValueEntity caValue02 = new ValueEntity(null,caNode,rootValue02.data.get("ca"),List.of(rootValue02)); |
| 718 | + caValue02.persist(); |
712 | 719 |
|
| 720 | + tm.commit(); |
713 | 721 |
|
714 | | - ValueEntity cValue01 = new ValueEntity(null,cNode,new TextNode("c1")); |
715 | | - cValue01.sources=List.of(rootValue01); |
| 722 | + List<ValueEntity> found = valueService.findMatchingFingerprint(caNode,rootNode,aValue01,bNode,null,-1,-1,false); |
| 723 | + |
| 724 | + assertNotNull(found); |
| 725 | + assertEquals(2,found.size(),found.toString()); |
| 726 | + assertTrue(found.contains(caValue01),found.toString()); |
| 727 | + assertTrue(found.contains(caValue02),found.toString()); |
| 728 | + |
| 729 | + assertEquals(caValue01,found.get(0),found.toString()); |
| 730 | + assertEquals(caValue02,found.get(1),found.toString()); |
| 731 | + |
| 732 | + } |
| 733 | + @Test |
| 734 | + public void findMatchingFingerprint_sorting_cousin() throws SystemException, NotSupportedException, JsonProcessingException, HeuristicRollbackException, HeuristicMixedException, RollbackException { |
| 735 | + tm.begin(); |
| 736 | + NodeEntity rootNode = new RootNode(); |
| 737 | + rootNode.persist(); |
| 738 | + NodeEntity aNode = new JqNode("a",".a",rootNode); |
| 739 | + aNode.persist(); |
| 740 | + NodeEntity bNode = new JqNode("b",".b",rootNode); |
| 741 | + bNode.persist(); |
| 742 | + NodeEntity cNode = new JqNode("c",".c",rootNode); |
| 743 | + cNode.persist(); |
| 744 | + NodeEntity caNode = new JqNode("c",".ca",List.of(cNode,aNode)); |
| 745 | + caNode.persist(); |
| 746 | + |
| 747 | + ObjectMapper objectMapper = new ObjectMapper(); |
| 748 | + ValueEntity rootValue01 = new ValueEntity(null,rootNode, |
| 749 | + objectMapper.readTree(""" |
| 750 | + { "a" : "a", "b" : "b1", "c" : "c1", "ca" : "ca1" } |
| 751 | + """)); |
| 752 | + ValueEntity rootValue02 = new ValueEntity(null,rootNode, |
| 753 | + objectMapper.readTree(""" |
| 754 | + { "a" : "a", "b" : "b2", "c" : "c1", "ca" : "ca2" } |
| 755 | + """)); |
| 756 | + rootValue01.persist(); |
| 757 | + // a values |
| 758 | + ValueEntity aValue01 = new ValueEntity(null,aNode,rootValue01.data.get("a"),List.of(rootValue01)); |
| 759 | + aValue01.persist(); |
| 760 | + ValueEntity aValue02 = new ValueEntity(null,aNode,rootValue02.data.get("a"),List.of(rootValue02)); |
| 761 | + aValue02.persist(); |
| 762 | + // b values |
| 763 | + ValueEntity bValue01 = new ValueEntity(null,bNode,rootValue01.data.get("b"),List.of(rootValue01)); |
| 764 | + bValue01.persist(); |
| 765 | + ValueEntity bValue02 = new ValueEntity(null,bNode,rootValue02.data.get("b"),List.of(rootValue02)); |
| 766 | + bValue02.persist(); |
| 767 | + // c values |
| 768 | + ValueEntity cValue01 = new ValueEntity(null,cNode,rootValue01.data.get("c"),List.of(rootValue01)); |
716 | 769 | cValue01.persist(); |
717 | | - ValueEntity cValue02 = new ValueEntity(null,cNode,new TextNode("c2")); |
718 | | - cValue02.sources=List.of(rootValue02); |
| 770 | + ValueEntity cValue02 = new ValueEntity(null,cNode,rootValue02.data.get("c"),List.of(rootValue02)); |
719 | 771 | cValue02.persist(); |
720 | | - |
721 | | - ValueEntity caValue01 = new ValueEntity(null,caNode,new TextNode("ca1")); |
722 | | - caValue01.sources=List.of(cValue01); |
| 772 | + // ca values |
| 773 | + ValueEntity caValue01 = new ValueEntity(null,caNode,rootValue01.data.get("ca"),List.of(rootValue01)); |
723 | 774 | caValue01.persist(); |
724 | | - ValueEntity caValue02 = new ValueEntity(null,caNode,new TextNode("ca2")); |
725 | | - caValue02.sources=List.of(cValue02); |
| 775 | + ValueEntity caValue02 = new ValueEntity(null,caNode,rootValue02.data.get("ca"),List.of(rootValue02)); |
726 | 776 | caValue02.persist(); |
727 | 777 |
|
728 | 778 | tm.commit(); |
|
0 commit comments