Skip to content

Commit 9902cd3

Browse files
rjrudinMarkLogic Builder
authored andcommitted
DHFPROD-7009: Fixing bug with saving step definition
The logic for checking on "default-" isn't needed because OOTB DHF step definitions are loaded via /v1/documents, not the artifacts endpoint.
1 parent cd243b8 commit 9902cd3

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/5/artifacts/stepDefinition.sjs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,13 @@ function getArtifactNode(artifactName, artifactVersion) {
5353
function getDirectory(artifactName, artifact) {
5454
let doc = getArtifactNode(artifactName, null);
5555
let dir = "/step-definitions/";
56-
let type;
5756
if(!doc && artifact && artifactName) {
5857
dir = dir + artifact.type.toLowerCase() + "/" + artifact.name +"/"
5958
}
6059
else if (doc) {
61-
let mutableArtifact = doc.toObject();
62-
if(mutableArtifact.name.startsWith("default-") || mutableArtifact.name == 'entity-services-mapping'){
63-
dir = dir + mutableArtifact.toLowerCase() + "/" + "/marklogic/";
64-
}
65-
else {
66-
dir = dir + mutableArtifact.type.toLowerCase() + "/" + mutableArtifact.name + "/";
60+
let stepDefinition = doc.toObject();
61+
if (stepDefinition.type && stepDefinition.name) {
62+
dir = dir + stepDefinition.type.toLowerCase() + "/" + stepDefinition.name + "/";
6763
}
6864
}
6965
return dir;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const test = require("/test/test-helper.xqy");
2+
const ArtifactService = require('../lib/artifactService.sjs');
3+
4+
const stepDef = {
5+
name: "default-myStepDef",
6+
type: "custom"
7+
};
8+
9+
const firstResponse = ArtifactService.invokeSetService('stepDefinition', stepDef.name, stepDef);
10+
const secondResponse = ArtifactService.invokeSetService('stepDefinition', stepDef.name, stepDef);
11+
12+
const assertions = [
13+
test.assertEqual("default-myStepDef", firstResponse.name,
14+
"Verifying that a user can create a custom step def whose name starts with 'default-', which was a problem in 5.4.0"),
15+
test.assertEqual("default-myStepDef", secondResponse.name,
16+
"Verifying that the step def was updated successfully")
17+
];
18+
19+
assertions

0 commit comments

Comments
 (0)