2727import org .apache .geaflow .ai .index .EntityAttributeIndexStore ;
2828import org .apache .geaflow .ai .index .IndexStore ;
2929import org .apache .geaflow .ai .index .vector .EmbeddingVector ;
30+ import org .apache .geaflow .ai .index .vector .IVector ;
3031import org .apache .geaflow .ai .index .vector .KeywordVector ;
3132import org .apache .geaflow .ai .index .vector .MagnitudeVector ;
3233import org .apache .geaflow .ai .index .vector .TraversalVector ;
34+ import org .apache .geaflow .ai .index .vector .VectorType ;
3335import org .apache .geaflow .ai .search .VectorSearch ;
3436import org .apache .geaflow .ai .verbalization .Context ;
3537import org .apache .geaflow .ai .verbalization .SubgraphSemanticPromptFunction ;
3840import org .slf4j .Logger ;
3941import org .slf4j .LoggerFactory ;
4042
43+ import static org .junit .jupiter .api .Assertions .assertEquals ;
44+ import static org .junit .jupiter .api .Assertions .assertNotEquals ;
45+
4146public class GraphMemoryTest {
4247
4348 private static final Logger LOGGER = LoggerFactory .getLogger (GraphMemoryTest .class );
@@ -52,6 +57,55 @@ public void testVectorSearch() {
5257 LOGGER .info (String .valueOf (search ));
5358 }
5459
60+ // ========== MagnitudeVector Tests ==========
61+
62+ @ Test
63+ public void testMagnitudeVectorConstructorAndGetter () {
64+ MagnitudeVector vector = new MagnitudeVector (0.85 );
65+ assertEquals (vector .getMagnitude (), 0.85 , 0.0001 );
66+ }
67+
68+ @ Test
69+ public void testMagnitudeVectorMatchExactSameValue () {
70+ MagnitudeVector v1 = new MagnitudeVector (5.0 );
71+ MagnitudeVector v2 = new MagnitudeVector (5.0 );
72+
73+ assertEquals (v1 .match (v2 ), 1.0 , 0.0001 );
74+ }
75+
76+ @ Test
77+ public void testMagnitudeVectorMatchDifferentValues () {
78+ MagnitudeVector v1 = new MagnitudeVector (10.0 );
79+ MagnitudeVector v2 = new MagnitudeVector (5.0 );
80+
81+ // Expected: 1 - |10-5|/max(10,5) = 1 - 5/10 = 0.5
82+ assertEquals (v1 .match (v2 ), 0.5 , 0.0001 );
83+ }
84+ @ Test
85+ public void testMagnitudeVectorEqualsAndHashCode () {
86+ MagnitudeVector v1 = new MagnitudeVector (5.0 );
87+ MagnitudeVector v2 = new MagnitudeVector (5.0 );
88+ MagnitudeVector v3 = new MagnitudeVector (10.0 );
89+
90+ assertEquals (v1 , v2 );
91+ assertEquals (v1 .hashCode (), v2 .hashCode ());
92+ assertNotEquals (v1 , v3 );
93+ }
94+
95+ @ Test
96+ public void testMagnitudeVectorToString () {
97+ MagnitudeVector vector = new MagnitudeVector (0.75 );
98+ String str = vector .toString ();
99+
100+ assertEquals (str , "MagnitudeVector{magnitude=0.75}" );
101+ }
102+
103+ @ Test
104+ public void testMagnitudeVectorGetType () {
105+ MagnitudeVector vector = new MagnitudeVector (1.0 );
106+ assertEquals (vector .getType (), VectorType .MagnitudeVector );
107+ }
108+
55109 @ Test
56110 public void testEmptyMainPipeline () {
57111 GraphMemoryServer server = new GraphMemoryServer ();
0 commit comments