diff options
Diffstat (limited to 'utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java')
-rw-r--r-- | utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java | 45 |
1 files changed, 14 insertions, 31 deletions
diff --git a/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java b/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java index 35fea577..51522ec0 100644 --- a/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java +++ b/utils-test/src/test/java/org/onap/policy/common/utils/gson/GsonTestUtilsTest.java @@ -2,7 +2,8 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +35,9 @@ import com.google.gson.JsonParseException; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; -import javax.script.ScriptException; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; import org.junit.Before; import org.junit.Test; @@ -76,10 +79,11 @@ public class GsonTestUtilsTest { utils.compareGson(data, GsonTestUtilsTest.class); // file not found - assertThatThrownBy(() -> utils.compareGson(data, - new File(GsonTestUtilsTest.class.getSimpleName() + "-NotFound.json"))) - .isInstanceOf(JsonParseException.class) - .hasCauseInstanceOf(FileNotFoundException.class); + File file = new File(GsonTestUtilsTest.class.getSimpleName() + "-NotFound.json"); + + assertThatThrownBy(() -> utils.compareGson(data, file)) + .isInstanceOf(JsonParseException.class) + .hasCauseInstanceOf(FileNotFoundException.class); // force I/O error while reading file GsonTestUtils utils2 = new GsonTestUtils() { @@ -136,11 +140,7 @@ public class GsonTestUtilsTest { data.setText(null); result = utils.applyScripts("use ${obj.text} this", data); assertEquals("use null this", result); - - assertThatThrownBy(() -> utils.applyScripts("use ${obj.text} this", null)) - .isInstanceOf(JsonParseException.class) - .hasCauseInstanceOf(ScriptException.class) - .hasMessage("cannot expand element: ${obj.text}"); + assertEquals("use null this", utils.applyScripts("use ${obj.text} this", null)); } @Test @@ -224,29 +224,12 @@ public class GsonTestUtilsTest { assertEquals("[300,{'objE':true,'objEStr':'obj-e-string'},false]".replace('\'', '"'), jsonEl.toString()); } + @Setter + @Getter + @ToString public static class Data { private int id; private String text; - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - @Override - public String toString() { - return "Data [id=" + id + ", text=" + text + "]"; - } } } |