diff options
author | 2025-01-09 10:18:33 +0000 | |
---|---|---|
committer | 2025-01-09 10:19:40 +0000 | |
commit | 6c92566dd754a7b54e3ee34b5bac5c041c799c72 (patch) | |
tree | dd6e144cb94b170b6c10481823624c9418089fd3 /gson | |
parent | 2d2f5489c70e1334df2779390b67a53bd47a13c3 (diff) |
Fix sonar issues
- fixing sonar issues on code to generate a new common artifact
with parent new dependencies.
Issue-ID: POLICY-5240
Change-Id: I47b2ace072708e576d5fc5a82c2419925cbed7ed
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'gson')
-rw-r--r-- | gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java | 4 | ||||
-rw-r--r-- | gson/src/test/java/org/onap/policy/common/gson/JacksonExclusionStrategyTest.java | 32 |
2 files changed, 15 insertions, 21 deletions
diff --git a/gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java b/gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java index 00e1caf0..579b9fda 100644 --- a/gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java +++ b/gson/src/test/java/org/onap/policy/common/gson/GsonMessageBodyHandlerTest.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2023-2024 Nordix Foundation. + * Modifications Copyright (C) 2023-2025 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -137,7 +137,7 @@ class GsonMessageBodyHandlerTest { // use a derived type, but specify the base type when reading @SuppressWarnings("rawtypes") - Class clazz = new MyObject() {}.getClass(); + Class clazz = MyObject.class; @SuppressWarnings("unchecked") Class<Object> objclazz = clazz; diff --git a/gson/src/test/java/org/onap/policy/common/gson/JacksonExclusionStrategyTest.java b/gson/src/test/java/org/onap/policy/common/gson/JacksonExclusionStrategyTest.java index 38f2f32a..fc3c6675 100644 --- a/gson/src/test/java/org/onap/policy/common/gson/JacksonExclusionStrategyTest.java +++ b/gson/src/test/java/org/onap/policy/common/gson/JacksonExclusionStrategyTest.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modificaitons Copyright (C) 2023-2024 Nordix Foundation. + * Modificaitons Copyright (C) 2023-2025 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,9 +29,12 @@ import com.google.gson.FieldAttributes; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonElement; +import java.io.Serial; import java.lang.reflect.GenericArrayType; import java.util.LinkedList; import java.util.TreeMap; +import lombok.Getter; +import lombok.Setter; import lombok.ToString; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -91,7 +94,7 @@ class JacksonExclusionStrategyTest { // generic classes should NOT be managed Class<?>[] unmanaged = { - new Data[0].getClass(), Enum.class, boolean.class, byte.class, short.class, int.class, + Data[].class, Enum.class, boolean.class, byte.class, short.class, int.class, long.class, float.class, double.class, char.class, Boolean.class, Byte.class, Short.class, Integer.class, Long.class, Float.class, Double.class, Character.class, String.class, MyMap.class, MyList.class, MyJson.class, GenericArrayType.class}; @@ -104,36 +107,27 @@ class JacksonExclusionStrategyTest { /** * Used to verify that no fields are exposed. */ + @Getter + @Setter @ToString public static class Data { private int id; public String text; - public int getId() { - return id; - } - void setId(int id) { this.id = id; } - public String getText() { - return text; - } - void setText(String text) { this.text = text; } } + @Getter @ToString(callSuper = true) public static class Derived extends Data { protected String value; - public String getValue() { - return value; - } - void setValue(String value) { this.value = value; } @@ -142,34 +136,34 @@ class JacksonExclusionStrategyTest { /** * Used to verify that enums are not managed. */ - public static enum Enum { + public enum Enum { UP, DOWN, } /** * Used to verify that interfaces <i>are</i> managed. */ - public static interface Intfc { + public interface Intfc { int getId(); } /** * Used to verify that Maps are not managed. */ + @Getter public static class MyMap extends TreeMap<String, Data> { + @Serial private static final long serialVersionUID = 1L; private int mapId; - public int getMapId() { - return mapId; - } } /** * Used to verify that Collections are not managed. */ public static class MyList extends LinkedList<Data> { + @Serial private static final long serialVersionUID = 1L; } |