Skip to content

Commit f68d69b

Browse files
authored
[ZEPPELIN-6281] Add Unit Tests for LivyVersion Class
### What is this PR for? This PR adds a comprehensive suite of unit tests for the LivyVersion class. The LivyVersion class is critical for ensuring Zeppelin's compatibility with various versions of the Livy server. ### What type of PR is it? Test ### Todos * [x] Add LivyVersionTest.java with comprehensive test cases. * [x] Ensure all tests pass with the existing LivyVersion implementation. ### What is the Jira issue? [ZEPPELIN-6281](https://issues.apache.org/jira/browse/ZEPPELIN-6281) ### How should this be tested? ### Screenshots (if appropriate) ### Questions: * Does the license files need to update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Closes #5029 from celinayk/ZEPPELIN-6281. Signed-off-by: ParkGyeongTae <[email protected]>
1 parent 31f7d56 commit f68d69b

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.zeppelin.livy;
19+
20+
import org.junit.jupiter.api.Test;
21+
22+
import static org.junit.jupiter.api.Assertions.assertEquals;
23+
import static org.junit.jupiter.api.Assertions.assertTrue;
24+
import static org.junit.jupiter.api.Assertions.assertFalse;
25+
26+
class LivyVersionTest {
27+
28+
@Test
29+
void testVersionParsing() {
30+
LivyVersion v = new LivyVersion("1.6.2");
31+
assertEquals(10602, v.toNumber());
32+
assertEquals("1.6.2", v.toString());
33+
}
34+
35+
@Test
36+
void testPreReleaseVersionParsing() {
37+
LivyVersion v = new LivyVersion("0.6.0-SNAPSHOT");
38+
assertEquals(600, v.toNumber());
39+
assertEquals("0.6.0-SNAPSHOT", v.toString());
40+
}
41+
42+
@Test
43+
void testComparisonLogic() {
44+
LivyVersion v1 = new LivyVersion("0.5.0");
45+
LivyVersion v2 = new LivyVersion("0.4.0");
46+
assertTrue(v1.newerThan(v2));
47+
assertTrue(v2.olderThan(v1));
48+
assertFalse(v2.newerThan(v1));
49+
assertFalse(v1.olderThan(v2));
50+
}
51+
52+
@Test
53+
void testInvalidVersionString() {
54+
LivyVersion v1 = new LivyVersion("invalid");
55+
assertEquals(99999, v1.toNumber());
56+
57+
LivyVersion v2 = new LivyVersion(null);
58+
assertEquals(99999, v2.toNumber());
59+
}
60+
61+
@Test
62+
void isCancelSupported() {
63+
assertTrue(new LivyVersion("0.3.0").isCancelSupported());
64+
assertFalse(new LivyVersion("0.2.0").isCancelSupported());
65+
}
66+
67+
@Test
68+
void isSharedSupported() {
69+
assertTrue(new LivyVersion("0.5.0").isSharedSupported());
70+
assertFalse(new LivyVersion("0.4.0").isSharedSupported());
71+
}
72+
73+
@Test
74+
void isGetProgressSupported() {
75+
assertTrue(new LivyVersion("0.4.0").isGetProgressSupported());
76+
assertFalse(new LivyVersion("0.3.0").isGetProgressSupported());
77+
}
78+
}
79+

0 commit comments

Comments
 (0)