1+ package org .typesense .api ;
2+
3+ import org .junit .jupiter .api .AfterEach ;
4+ import org .junit .jupiter .api .BeforeEach ;
5+ import org .junit .jupiter .api .Test ;
6+ import org .typesense .resources .Node ;
7+
8+ import java .time .Duration ;
9+ import java .util .ArrayList ;
10+ import java .util .List ;
11+
12+ import static org .junit .jupiter .api .Assertions .assertEquals ;
13+
14+ class APICallTest {
15+
16+ private ApiCall apiCall ;
17+
18+ @ BeforeEach
19+ void setUp () throws Exception {
20+ List <Node > nodes = new ArrayList <>();
21+ nodes .add (new Node ("http" ,"localhost" ,"8108" ));
22+ nodes .add (new Node ("http" ,"localhost" ,"7108" ));
23+ nodes .add (new Node ("http" ,"localhost" ,"6108" ));
24+ apiCall = new ApiCall (new Configuration (nodes , Duration .ofSeconds (3 ),"xyz" ));
25+ }
26+
27+ @ AfterEach
28+ void tearDown () throws Exception {
29+
30+ }
31+
32+ @ Test
33+ void testRoundRobin () throws Exception {
34+ assertEquals ("7108" , apiCall .getNode ().port );
35+ assertEquals ("6108" , apiCall .getNode ().port );
36+ assertEquals ("8108" , apiCall .getNode ().port );
37+
38+ assertEquals ("7108" , apiCall .getNode ().port );
39+ assertEquals ("6108" , apiCall .getNode ().port );
40+ assertEquals ("8108" , apiCall .getNode ().port );
41+ }
42+ }
0 commit comments