File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
src/test/java/org/typesense/api Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 55import java .util .Arrays ;
66import java .util .HashMap ;
77import java .util .List ;
8+ import java .util .Map ;
89
910import org .typesense .model .AnalyticsRuleParameters ;
1011import org .typesense .model .AnalyticsRuleParametersDestination ;
3435public class Helper {
3536 private final Client client ;
3637
38+ public static boolean isV30OrAbove (Client client ) {
39+ try {
40+ Map <String , Object > debugResponse = client .debug .retrieve ();
41+ if (debugResponse == null ) {
42+ return false ;
43+ }
44+
45+ Object version = debugResponse .get ("version" );
46+ if (version == null ) {
47+ return false ;
48+ }
49+
50+ String versionStr = version .toString ();
51+ if ("nightly" .equals (versionStr )) {
52+ return true ;
53+ }
54+
55+ if (!versionStr .startsWith ("v" )) {
56+ return false ;
57+ }
58+
59+ String numberedVersion = versionStr .substring (1 );
60+ String [] parts = numberedVersion .split ("\\ ." );
61+ if (parts .length == 0 ) {
62+ return false ;
63+ }
64+
65+ int majorVersion = Integer .parseInt (parts [0 ]);
66+ return majorVersion >= 30 ;
67+
68+ } catch (Exception e ) {
69+ return false ;
70+ }
71+ }
72+
3773 Helper () {
3874 List <Node > nodes = new ArrayList <>();
3975 nodes .add (new Node ("http" , "localhost" , "8108" ));
You can’t perform that action at this time.
0 commit comments