diff options
author | adheli.tavares <adheli.tavares@est.tech> | 2023-08-30 14:57:10 +0100 |
---|---|---|
committer | adheli.tavares <adheli.tavares@est.tech> | 2023-09-22 16:08:42 +0100 |
commit | fc19178b956f4474ed14e810fd911ac60f3756d0 (patch) | |
tree | 196af66a25ca190af8f2b2199f977a4e58aad8b3 /controlloop/common/coordination | |
parent | d7d54fef032a2ba3118232506a7ed37f24eb4131 (diff) |
Upgrade Java 17 in policy-drools-apps
Issue-ID: POLICY-4816
Change-Id: I61d5c2c0b8bf2cc08416d91bbd84f27f2ed5c5c1
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'controlloop/common/coordination')
4 files changed, 43 insertions, 32 deletions
diff --git a/controlloop/common/coordination/pom.xml b/controlloop/common/coordination/pom.xml index 622d01416..b390c973a 100644 --- a/controlloop/common/coordination/pom.xml +++ b/controlloop/common/coordination/pom.xml @@ -4,6 +4,7 @@ ================================================================================ Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. Modifications Copyright (C) 2020 Bell Canada. + 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. @@ -18,23 +19,24 @@ limitations under the License. ============LICENSE_END========================================================= --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> - <artifactId>drools-applications-common</artifactId> - <version>2.0.0-SNAPSHOT</version> - </parent> + <parent> + <groupId>org.onap.policy.drools-applications.controlloop.common</groupId> + <artifactId>drools-applications-common</artifactId> + <version>2.0.1-SNAPSHOT</version> + </parent> - <artifactId>coordination</artifactId> + <artifactId>coordination</artifactId> - <dependencies> - <dependency> - <groupId>org.onap.policy.drools-pdp</groupId> - <artifactId>policy-management</artifactId> - <version>${version.policy.drools-pdp}</version> - <scope>provided</scope> - </dependency> - </dependencies> + <dependencies> + <dependency> + <groupId>org.onap.policy.drools-pdp</groupId> + <artifactId>policy-management</artifactId> + <version>${version.policy.drools-pdp}</version> + <scope>provided</scope> + </dependency> + </dependencies> </project> diff --git a/controlloop/common/coordination/src/main/java/org/onap/policy/coordination/Util.java b/controlloop/common/coordination/src/main/java/org/onap/policy/coordination/Util.java index af8cc2529..7aba3cce3 100644 --- a/controlloop/common/coordination/src/main/java/org/onap/policy/coordination/Util.java +++ b/controlloop/common/coordination/src/main/java/org/onap/policy/coordination/Util.java @@ -3,6 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2019-2021 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. @@ -32,8 +33,10 @@ import java.util.stream.Stream; import org.apache.commons.io.IOUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.yaml.snakeyaml.LoaderOptions; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; +import org.yaml.snakeyaml.inspector.TagInspector; public final class Util { @@ -51,12 +54,16 @@ public final class Util { * @return the CoordinationDirective */ public static CoordinationDirective loadCoordinationDirectiveFromFile(String directiveFilename) { - try (var is = new FileInputStream(new File(directiveFilename))) { + try (var is = new FileInputStream(directiveFilename)) { + var loaderoptions = new LoaderOptions(); + TagInspector taginspector = tag -> tag.getClassName().equals(CoordinationDirective.class.getName()); + loaderoptions.setTagInspector(taginspector); + var contents = IOUtils.toString(is, StandardCharsets.UTF_8); // // Read the yaml into our Java Object // - var yaml = new Yaml(new Constructor(CoordinationDirective.class)); + var yaml = new Yaml(new Constructor(CoordinationDirective.class, loaderoptions)); Object obj = yaml.load(contents); logger.debug(contents); diff --git a/controlloop/common/coordination/src/test/java/org/onap/policy/coordination/CoordinationDirectiveTest.java b/controlloop/common/coordination/src/test/java/org/onap/policy/coordination/CoordinationDirectiveTest.java index 47d11dd62..96846ecb4 100644 --- a/controlloop/common/coordination/src/test/java/org/onap/policy/coordination/CoordinationDirectiveTest.java +++ b/controlloop/common/coordination/src/test/java/org/onap/policy/coordination/CoordinationDirectiveTest.java @@ -3,6 +3,7 @@ * controlloop * ================================================================================ * Copyright (C) 2019 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. @@ -21,16 +22,16 @@ package org.onap.policy.coordination; import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class CoordinationDirectiveTest { +class CoordinationDirectiveTest { @Test - public void test() { + void test() { CoordinationDirective cd1 = new CoordinationDirective(); diff --git a/controlloop/common/coordination/src/test/java/org/onap/policy/coordination/UtilTest.java b/controlloop/common/coordination/src/test/java/org/onap/policy/coordination/UtilTest.java index 21998a7b4..d1b99ab27 100644 --- a/controlloop/common/coordination/src/test/java/org/onap/policy/coordination/UtilTest.java +++ b/controlloop/common/coordination/src/test/java/org/onap/policy/coordination/UtilTest.java @@ -3,6 +3,7 @@ * controlloop * ================================================================================ * Copyright (C) 2019 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. @@ -21,19 +22,19 @@ package org.onap.policy.coordination; import static org.assertj.core.api.Assertions.assertThatNullPointerException; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class UtilTest { +class UtilTest { @Test - public void test() { + void test() { - String filename = "src/test/resources/test_coordination_directive.yaml"; - CoordinationDirective cd1 = Util.loadCoordinationDirectiveFromFile(filename); + var filename = "src/test/resources/test_coordination_directive.yaml"; + var cd1 = Util.loadCoordinationDirectiveFromFile(filename); assertNotNull(cd1); @@ -46,7 +47,7 @@ public class UtilTest { assertEquals("cf", cd1.getCoordinationFunction()); filename = "src/test/resources/non_existent_coordination_directive.yaml"; - CoordinationDirective cd2 = Util.loadCoordinationDirectiveFromFile(filename); + var cd2 = Util.loadCoordinationDirectiveFromFile(filename); assertNull(cd2); |