Skip to content

Commit 38d95da

Browse files
committed
Small cleanup of version PR
1 parent 588130d commit 38d95da

File tree

4 files changed

+8
-15
lines changed

4 files changed

+8
-15
lines changed

marklogic-junit5/src/main/java/com/marklogic/junit5/AbstractMarkLogicTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* This class depends on a DatabaseClient, and how that is provided must be defined by the subclass.
3232
* </p>
3333
*/
34-
public abstract class AbstractMarkLogicTest extends LoggingObject implements HasMarkLogicVersion {
34+
public abstract class AbstractMarkLogicTest extends LoggingObject implements MarkLogicVersionSupplier {
3535

3636
/**
3737
* Subclass must define how a connection is made to (presumably) the test database.
@@ -46,7 +46,8 @@ public abstract class AbstractMarkLogicTest extends LoggingObject implements Has
4646
*/
4747
@Override
4848
public MarkLogicVersion getMarkLogicVersion() {
49-
return MarkLogicVersion.getVersion(getDatabaseClient());
49+
String version = getDatabaseClient().newServerEval().javascript("xdmp.version()").evalAs(String.class);
50+
return new MarkLogicVersion(version);
5051
}
5152

5253
/**

marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersion.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
*/
44
package com.marklogic.junit5;
55

6-
import com.marklogic.client.DatabaseClient;
7-
86
/**
97
* Parses a MarkLogic version string - i.e. from xdmp.version() - into its major, minor, and patch values.
108
*/
@@ -14,21 +12,15 @@ public class MarkLogicVersion {
1412
private final static String SEMVER_PATTERN = "^[0-9]+\\.[0-9]+\\.[0-9]+";
1513
private final static String NIGHTLY_SEMVER_PATTERN = "^[0-9]+\\.[0-9]+\\.[0-9]{8}";
1614

17-
// For non-semver releases.
15+
// For non-semver releases, such as MarkLogic 10 and earlier..
1816
private final static String MAJOR_WITH_MINOR_PATTERN = "^.*-(.+)$";
19-
2017
private final static String VERSION_WITH_PATCH_PATTERN = "^.*-(.+)\\..*";
2118
private final static String NIGHTLY_BUILD_PATTERN = "[^-]+-(\\d{4})(\\d{2})(\\d{2})";
2219

2320
private final int major;
2421
private final Integer minor;
2522
private final Integer patch;
2623
private final boolean nightly;
27-
28-
public static MarkLogicVersion getVersion(DatabaseClient client) {
29-
String version = client.newServerEval().javascript("xdmp.version()").evalAs(String.class);
30-
return new MarkLogicVersion(version);
31-
}
3224

3325
public MarkLogicVersion(String version) {
3426
if (version.matches(NIGHTLY_SEMVER_PATTERN)) {

marklogic-junit5/src/main/java/com/marklogic/junit5/HasMarkLogicVersion.java renamed to marklogic-junit5/src/main/java/com/marklogic/junit5/MarkLogicVersionSupplier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/**
77
* @since 1.5.0
88
*/
9-
public interface HasMarkLogicVersion {
9+
public interface MarkLogicVersionSupplier {
1010

1111
MarkLogicVersion getMarkLogicVersion();
1212
}

marklogic-junit5/src/main/java/com/marklogic/junit5/VersionExecutionCondition.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext con
2626
if (!testInstance.isPresent()) {
2727
throw new RuntimeException(getClass() + " can only be used when a test instance is present.");
2828
}
29-
if (!(testInstance.get() instanceof HasMarkLogicVersion)) {
30-
throw new RuntimeException(testInstance.getClass() + " must implement " + HasMarkLogicVersion.class.getName());
29+
if (!(testInstance.get() instanceof MarkLogicVersionSupplier)) {
30+
throw new RuntimeException(testInstance.getClass() + " must implement " + MarkLogicVersionSupplier.class.getName());
3131
}
32-
markLogicVersion = ((HasMarkLogicVersion) context.getTestInstance().get()).getMarkLogicVersion();
32+
markLogicVersion = ((MarkLogicVersionSupplier) context.getTestInstance().get()).getMarkLogicVersion();
3333
}
3434
return evaluateVersion(markLogicVersion);
3535
}

0 commit comments

Comments
 (0)