1
1
package org .myrobotlab .service ;
2
2
3
3
import static org .junit .Assert .assertEquals ;
4
- import static org .junit .Assert .assertFalse ;
5
4
import static org .junit .Assert .assertTrue ;
6
5
7
- import java .util .Date ;
8
6
import java .util .List ;
9
7
import java .util .Map ;
10
8
@@ -101,7 +99,6 @@ public void testRuntimeLocale() {
101
99
assertEquals ("fr-FR" , l .toString ());
102
100
103
101
}
104
-
105
102
106
103
@ Test
107
104
public void testGetDescribeMessage () {
@@ -113,4 +110,33 @@ public void testGetDescribeMessage() {
113
110
assertEquals ("Incorrect UUID in describe query" , "testUUID" , ((DescribeQuery ) msg .data [1 ]).uuid );
114
111
}
115
112
113
+ @ Test
114
+ public void testGetLatestVersion () {
115
+ if (hasInternet ()) {
116
+ try {
117
+ String latestVersion = Runtime .getLatestVersion ();
118
+ Assert .assertNotNull ("Latest version should not be null" , latestVersion );
119
+ Assert .assertFalse ("Latest version should not be empty" , latestVersion .isEmpty ());
120
+
121
+ // The version should not contain the leading 'v' since getLatestVersion
122
+ // removes it
123
+ Assert .assertFalse ("Version should not start with 'v'" , latestVersion .startsWith ("v" ));
124
+
125
+ // Version should follow semantic versioning pattern (x.y.z)
126
+ String [] versionParts = latestVersion .split ("\\ ." );
127
+ Assert .assertTrue ("Version should have at least 2 parts (major.minor)" , versionParts .length >= 2 );
128
+
129
+ log .info ("Latest version retrieved: {}" , latestVersion );
130
+ } catch (Exception e ) {
131
+ // If remote service is unavailable, the method should still return
132
+ // "unknown"
133
+ // rather than throwing an exception
134
+ log .error ("testGetLatestVersion failed" , e );
135
+ Assert .fail ("getLatestVersion should not throw exceptions, but return 'unknown' on failure" );
136
+ }
137
+ } else {
138
+ log .info ("Skipping testGetLatestVersion - no internet connection" );
139
+ }
140
+ }
141
+
116
142
}
0 commit comments