11package org .myrobotlab .service ;
22
33import static org .junit .Assert .assertEquals ;
4- import static org .junit .Assert .assertFalse ;
54import static org .junit .Assert .assertTrue ;
65
7- import java .util .Date ;
86import java .util .List ;
97import java .util .Map ;
108
@@ -101,7 +99,6 @@ public void testRuntimeLocale() {
10199 assertEquals ("fr-FR" , l .toString ());
102100
103101 }
104-
105102
106103 @ Test
107104 public void testGetDescribeMessage () {
@@ -113,4 +110,33 @@ public void testGetDescribeMessage() {
113110 assertEquals ("Incorrect UUID in describe query" , "testUUID" , ((DescribeQuery ) msg .data [1 ]).uuid );
114111 }
115112
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+
116142}
0 commit comments