This repository has been archived by the owner on Dec 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added dedicated methods to serialize/deserialize input/output data
- Loading branch information
1 parent
48a8e9d
commit d045c14
Showing
4 changed files
with
212 additions
and
12 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
66 changes: 66 additions & 0 deletions
66
core/src/test/groovy/com/netflix/conductor/model/TaskModelSpec.groovy
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,66 @@ | ||
/* | ||
* Copyright 2022 Netflix, Inc. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.netflix.conductor.model | ||
|
||
import com.netflix.conductor.common.config.ObjectMapperProvider | ||
|
||
import com.fasterxml.jackson.databind.JsonNode | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import spock.lang.Specification | ||
import spock.lang.Subject | ||
|
||
class TaskModelSpec extends Specification { | ||
|
||
@Subject | ||
TaskModel taskModel | ||
|
||
private static final ObjectMapper objectMapper = new ObjectMapperProvider().getObjectMapper() | ||
|
||
def setup() { | ||
taskModel = new TaskModel() | ||
} | ||
|
||
def "check inputData serialization"() { | ||
given: | ||
String path = "task/input/${UUID.randomUUID()}.json" | ||
taskModel.addInput(['key1': 'value1', 'key2': 'value2']) | ||
taskModel.externalizeInput(path) | ||
|
||
when: | ||
def json = objectMapper.writeValueAsString(taskModel) | ||
println(json) | ||
|
||
then: | ||
json != null | ||
JsonNode node = objectMapper.readTree(json) | ||
node.path("inputData").isEmpty() | ||
node.path("externalInputPayloadStoragePath").isTextual() | ||
} | ||
|
||
def "check outputData serialization"() { | ||
given: | ||
String path = "task/output/${UUID.randomUUID()}.json" | ||
taskModel.addOutput(['key1': 'value1', 'key2': 'value2']) | ||
taskModel.externalizeOutput(path) | ||
|
||
when: | ||
def json = objectMapper.writeValueAsString(taskModel) | ||
println(json) | ||
|
||
then: | ||
json != null | ||
JsonNode node = objectMapper.readTree(json) | ||
node.path("outputData").isEmpty() | ||
node.path("externalOutputPayloadStoragePath").isTextual() | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
core/src/test/groovy/com/netflix/conductor/model/WorkflowModelSpec.groovy
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,68 @@ | ||
/* | ||
* Copyright 2022 Netflix, Inc. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.netflix.conductor.model | ||
|
||
import com.netflix.conductor.common.config.ObjectMapperProvider | ||
import com.netflix.conductor.common.metadata.workflow.WorkflowDef | ||
|
||
import com.fasterxml.jackson.databind.JsonNode | ||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import spock.lang.Specification | ||
import spock.lang.Subject | ||
|
||
class WorkflowModelSpec extends Specification { | ||
|
||
@Subject | ||
WorkflowModel workflowModel | ||
|
||
private static final ObjectMapper objectMapper = new ObjectMapperProvider().getObjectMapper() | ||
|
||
def setup() { | ||
def workflowDef = new WorkflowDef(name: "test def name", version: 1) | ||
workflowModel = new WorkflowModel(workflowDefinition: workflowDef) | ||
} | ||
|
||
def "check input serialization"() { | ||
given: | ||
String path = "task/input/${UUID.randomUUID()}.json" | ||
workflowModel.input = ['key1': 'value1', 'key2': 'value2'] | ||
workflowModel.externalizeInput(path) | ||
|
||
when: | ||
def json = objectMapper.writeValueAsString(workflowModel) | ||
println(json) | ||
|
||
then: | ||
json != null | ||
JsonNode node = objectMapper.readTree(json) | ||
node.path("input").isEmpty() | ||
node.path("externalInputPayloadStoragePath").isTextual() | ||
} | ||
|
||
def "check output serialization"() { | ||
given: | ||
String path = "task/output/${UUID.randomUUID()}.json" | ||
workflowModel.output = ['key1': 'value1', 'key2': 'value2'] | ||
workflowModel.externalizeOutput(path) | ||
|
||
when: | ||
def json = objectMapper.writeValueAsString(workflowModel) | ||
println(json) | ||
|
||
then: | ||
json != null | ||
JsonNode node = objectMapper.readTree(json) | ||
node.path("output").isEmpty() | ||
node.path("externalOutputPayloadStoragePath").isTextual() | ||
} | ||
} |