Skip to content

Commit 0df26d3

Browse files
committed
Now NuixVersion has static getCurrent which is eagerly populated upon utilities acquisition
1 parent 416212c commit 0df26d3

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

IntelliJ/src/main/java/com/nuix/innovation/enginewrapper/NuixEngine.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ public Utilities getUtilities() throws Exception {
326326
}
327327
}
328328

329+
// Set NuixVersion.current to right value
330+
NuixVersion.setCurrent(NuixVersion.parse(engine.getVersion()));
329331
return utilities;
330332
}
331333

@@ -597,7 +599,7 @@ public String getNuixVersionString() {
597599
* Engine has not yet been initialized.
598600
*/
599601
public NuixVersion getNuixVersion() {
600-
return NuixVersion.parse(getNuixVersionString());
602+
return NuixVersion.getCurrent();
601603
}
602604

603605
/***

IntelliJ/src/main/java/com/nuix/innovation/enginewrapper/NuixVersion.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.nuix.innovation.enginewrapper;
22

3+
import lombok.AccessLevel;
4+
import lombok.Getter;
5+
import lombok.Setter;
6+
37
import java.util.regex.Pattern;
48

59
/***
@@ -9,6 +13,10 @@
913
public class NuixVersion implements Comparable<NuixVersion> {
1014
private static Pattern previewVersionInfoRemovalPattern = Pattern.compile("[^0-9\\.].*$");
1115

16+
@Getter
17+
@Setter(AccessLevel.PACKAGE)
18+
private static NuixVersion current = NuixVersion.parse("0.0.0.0");
19+
1220
private int major = 0;
1321
private int minor = 0;
1422
private int bugfix = 0;
@@ -67,7 +75,7 @@ public NuixVersion(int majorVersion, int minorVersion, int bugfixVersion, int bu
6775
* When providing a version string such as "6.2.1-preview6", "-preview6" will be trimmed off before parsing.
6876
* @param versionString The version string to parse.
6977
* @return A NuixVersion instance representing the supplied version string, if there is an error parsing the provided value will return
70-
* an instance representing 100.0.0
78+
* an instance representing 999.0.0
7179
*/
7280
public static NuixVersion parse(String versionString) {
7381
try {
@@ -90,7 +98,7 @@ public static NuixVersion parse(String versionString) {
9098
}
9199
} catch (Exception exc) {
92100
System.out.println("Error while parsing version: " + versionString);
93-
System.out.println("Pretending version is 100.0.0.0");
101+
System.out.println("Pretending version is 999.0.0.0");
94102
return new NuixVersion(100, 0, 0, 0);
95103
}
96104
}

IntelliJ/src/test/java/BasicTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import com.nuix.innovation.enginewrapper.NuixEngine;
2+
import com.nuix.innovation.enginewrapper.NuixVersion;
23
import nuix.*;
34
import org.junit.jupiter.api.Test;
45

@@ -22,6 +23,7 @@ public void GetLicenseAutomaticCleanup() throws Exception {
2223
// run method will call close before returning
2324
nuixEngine.run((utilities -> {
2425
licenseWasObtained.set(true);
26+
log.info("Nuix v{}", NuixVersion.getCurrent());
2527
}));
2628
assertTrue(licenseWasObtained.get());
2729
}

0 commit comments

Comments
 (0)