diff options
Diffstat (limited to 'gson')
3 files changed, 19 insertions, 11 deletions
diff --git a/gson/pom.xml b/gson/pom.xml index 068e19ec..be8ef286 100644 --- a/gson/pom.xml +++ b/gson/pom.xml @@ -3,7 +3,7 @@ ONAP Policy Engine - Common Modules ================================================================================ Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved. - Modifications Copyright (C) 2019 Nordix Foundation. + Modifications Copyright (C) 2019,2023 Nordix Foundation. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -61,8 +61,13 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-api-mockito2</artifactId> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-test</artifactId> <scope>test</scope> </dependency> <dependency> 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 41933bc5..9d8d3495 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,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. + * Modificaitons Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -175,6 +176,7 @@ public class JacksonExclusionStrategyTest { /** * Used to verify that JsonElements are not managed. */ + @SuppressWarnings("deprecation") public static class MyJson extends JsonElement { @Override public JsonElement deepCopy() { diff --git a/gson/src/test/java/org/onap/policy/common/gson/internal/AdapterTest.java b/gson/src/test/java/org/onap/policy/common/gson/internal/AdapterTest.java index 9d80c860..fd999951 100644 --- a/gson/src/test/java/org/onap/policy/common/gson/internal/AdapterTest.java +++ b/gson/src/test/java/org/onap/policy/common/gson/internal/AdapterTest.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +43,7 @@ import org.onap.policy.common.gson.annotation.GsonJsonProperty; import org.onap.policy.common.gson.internal.Adapter.Factory; import org.onap.policy.common.gson.internal.DataAdapterFactory.Data; import org.onap.policy.common.gson.internal.DataAdapterFactory.DerivedData; -import org.powermock.reflect.Whitebox; +import org.springframework.test.util.ReflectionTestUtils; public class AdapterTest { private static final String GET_INVALID_NAME = "get$InvalidName"; @@ -83,12 +84,12 @@ public class AdapterTest { @BeforeClass public static void setUpBeforeClass() { - saveFactory = Whitebox.getInternalState(Adapter.class, FACTORY_FIELD); + saveFactory = (Factory) ReflectionTestUtils.getField(Adapter.class, FACTORY_FIELD); } @After public void tearDown() { - Whitebox.setInternalState(Adapter.class, FACTORY_FIELD, saveFactory); + ReflectionTestUtils.setField(Adapter.class, FACTORY_FIELD, saveFactory); } @Test @@ -98,7 +99,7 @@ public class AdapterTest { // return an invalid field name Factory factory = mock(Factory.class); when(factory.getName(any(Field.class))).thenReturn("$invalidFieldName"); - Whitebox.setInternalState(Adapter.class, FACTORY_FIELD, factory); + ReflectionTestUtils.setField(Adapter.class, FACTORY_FIELD, factory); assertFalse(Adapter.isManaged(field(VALUE_NAME))); } @@ -108,7 +109,7 @@ public class AdapterTest { // return an invalid method name Factory factory = mock(Factory.class); - Whitebox.setInternalState(Adapter.class, FACTORY_FIELD, factory); + ReflectionTestUtils.setField(Adapter.class, FACTORY_FIELD, factory); when(factory.getName(any(Method.class))).thenReturn(GET_INVALID_NAME); assertFalse(Adapter.isManaged(mget(GET_VALUE_NAME))); @@ -240,7 +241,7 @@ public class AdapterTest { // return an invalid field name Factory factory = mock(Factory.class); when(factory.getName(any(Field.class))).thenReturn("$invalidFieldName"); - Whitebox.setInternalState(Adapter.class, FACTORY_FIELD, factory); + ReflectionTestUtils.setField(Adapter.class, FACTORY_FIELD, factory); assertEquals(null, Adapter.detmPropName(field(VALUE_NAME))); } @@ -257,7 +258,7 @@ public class AdapterTest { // return an invalid method name Factory factory = mock(Factory.class); - Whitebox.setInternalState(Adapter.class, FACTORY_FIELD, factory); + ReflectionTestUtils.setField(Adapter.class, FACTORY_FIELD, factory); when(factory.getName(any(Method.class))).thenReturn(GET_INVALID_NAME); assertEquals(null, Adapter.detmGetterPropName(mget(GET_VALUE_NAME))); @@ -273,7 +274,7 @@ public class AdapterTest { // return an invalid method name Factory factory = mock(Factory.class); - Whitebox.setInternalState(Adapter.class, FACTORY_FIELD, factory); + ReflectionTestUtils.setField(Adapter.class, FACTORY_FIELD, factory); when(factory.getName(any(Method.class))).thenReturn(SET_INVALID_NAME); assertEquals(null, Adapter.detmSetterPropName(mset(SET_VALUE_NAME))); |