|
7 | 7 | import static org.junit.Assert.assertFalse; |
8 | 8 | import static org.junit.Assert.assertTrue; |
9 | 9 |
|
10 | | -import com.fasterxml.jackson.core.JsonProcessingException; |
11 | | -import com.fasterxml.jackson.databind.ObjectMapper; |
12 | | -import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; |
13 | 10 | import hudson.ExtensionList; |
14 | 11 | import io.jenkins.plugins.casc.ConfigurationAsCode; |
15 | 12 | import io.jenkins.plugins.casc.ConfigurationContext; |
|
40 | 37 | import org.jvnet.hudson.test.LogRecorder; |
41 | 38 | import org.jvnet.hudson.test.LoggerRule; |
42 | 39 | import org.yaml.snakeyaml.nodes.Node; |
| 40 | +import tools.jackson.databind.ObjectMapper; |
| 41 | +import tools.jackson.dataformat.yaml.YAMLMapper; |
43 | 42 |
|
44 | 43 | public class Util { |
45 | 44 |
|
@@ -252,15 +251,11 @@ public static void assertLogContains(LogRecorder logging, String expectedText) { |
252 | 251 | * @return the json conversion of the yaml string. |
253 | 252 | */ |
254 | 253 | public static String convertToJson(String yamlString) { |
255 | | - try { |
256 | | - ObjectMapper yamlReader = new ObjectMapper(new YAMLFactory()); |
257 | | - Object obj = yamlReader.readValue(yamlString, Object.class); |
| 254 | + ObjectMapper yamlReader = new YAMLMapper(); |
| 255 | + Object obj = yamlReader.readValue(yamlString, Object.class); |
258 | 256 |
|
259 | | - ObjectMapper jsonWriter = new ObjectMapper(); |
260 | | - return jsonWriter.writeValueAsString(obj); |
261 | | - } catch (JsonProcessingException e) { |
262 | | - throw new UncheckedIOException(e); |
263 | | - } |
| 257 | + ObjectMapper jsonWriter = new ObjectMapper(); |
| 258 | + return jsonWriter.writeValueAsString(obj); |
264 | 259 | } |
265 | 260 |
|
266 | 261 | /** |
|
0 commit comments