forked from folio-org/mod-camunda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from folio-org/sprint5-staging
Sprint5 staging
- Loading branch information
Showing
12 changed files
with
157 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/org/folio/rest/camunda/exception/ScriptTaskDeserializeCodeFailure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.folio.rest.camunda.exception; | ||
|
||
public class ScriptTaskDeserializeCodeFailure extends Exception { | ||
|
||
private static final long serialVersionUID = -6270663785866339965L; | ||
|
||
private static final String MESSAGE = "Failed to De-serialize code for ScriptTask %s."; | ||
|
||
public ScriptTaskDeserializeCodeFailure(String scriptTaskUuid) { | ||
super(String.format(MESSAGE, scriptTaskUuid)); | ||
} | ||
|
||
public ScriptTaskDeserializeCodeFailure(String scriptTaskUuid, Exception e) { | ||
super(String.format(MESSAGE, scriptTaskUuid), e); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/org/folio/rest/camunda/utility/ScriptEngineUtility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.folio.rest.camunda.utility; | ||
|
||
import org.graalvm.shadowed.org.json.JSONObject; | ||
|
||
/** | ||
* Provide utility functions specifically needed for scripting engines. | ||
*/ | ||
public class ScriptEngineUtility { | ||
|
||
/** | ||
* Decode a JSON string into a JSONObject. | ||
* | ||
* This is required by several of the scripting engines, such as engine.py. | ||
* | ||
* @param json | ||
* The JSON string to decode. | ||
* | ||
* @return | ||
* A generated JSON object, containing the decoded JSON string. | ||
*/ | ||
public JSONObject decodeJson(String json) { | ||
return new JSONObject(json); | ||
} | ||
|
||
/** | ||
* Encode a JSONObject into a JSON string. | ||
* | ||
* @param json | ||
* The JSONObject to encode. | ||
* | ||
* @return | ||
* A String containing the encoded JSON data. | ||
*/ | ||
public String encodeJson(JSONObject json) { | ||
return json.toString(2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/test/java/org/folio/rest/camunda/exception/ScriptTaskDeserializeCodeFailureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.folio.rest.camunda.exception; | ||
|
||
import static org.folio.spring.test.mock.MockMvcConstant.UUID; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.io.IOException; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class ScriptTaskDeserializeCodeFailureTest { | ||
|
||
@Test | ||
void scriptEngineLoadFailedWorksTest() throws IOException { | ||
ScriptTaskDeserializeCodeFailure exception = Assertions.assertThrows(ScriptTaskDeserializeCodeFailure.class, () -> { | ||
throw new ScriptTaskDeserializeCodeFailure(UUID); | ||
}); | ||
|
||
assertNotNull(exception); | ||
assertTrue(exception.getMessage().contains(UUID)); | ||
} | ||
|
||
@Test | ||
void scriptEngineLoadFailedWorksWithParameterTest() throws IOException { | ||
ScriptTaskDeserializeCodeFailure exception = Assertions.assertThrows(ScriptTaskDeserializeCodeFailure.class, () -> { | ||
throw new ScriptTaskDeserializeCodeFailure(UUID, new RuntimeException()); | ||
}); | ||
|
||
assertNotNull(exception); | ||
assertTrue(exception.getMessage().contains(UUID)); | ||
} | ||
} |