diff options
author | Jim Hahn <jrh3@att.com> | 2021-08-05 10:13:01 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-08-05 11:18:36 -0400 |
commit | 1744dac574fb771301027be74c9257eb070125f7 (patch) | |
tree | b35035a120a2fb5d99114091c89ed8dbfa57cd22 /policy-management/src/test/java/org | |
parent | 43cb6711bbc9b231e904ff3ef5266f0f0df3faec (diff) |
Use lombok in drools-pdp
Updated policy-management thru policy-utils.
Issue-ID: POLICY-3397
Change-Id: Ie9498fe912e8338ddc32a40774c3cb63d84f079a
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-management/src/test/java/org')
9 files changed, 27 insertions, 40 deletions
diff --git a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java index 521666e9..1384501c 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java +++ b/policy-management/src/test/java/org/onap/policy/drools/controller/internal/MavenDroolsController2Test.java @@ -431,7 +431,7 @@ public class MavenDroolsController2Test { // validate parameters EventProtocolParams params = dec.getAllValues().get(0); assertEquals(ARTIFACT, params.getArtifactId()); - assertEquals(gson1, params.getCustomCoder()); + assertEquals(gson1, params.getCustomGsonCoder()); assertEquals(Object.class.getName(), params.getEventClass()); assertEquals(GROUP, params.getGroupId()); assertEquals(CLASS_LOADER_HASHCODE, params.getModelClassLoaderHash()); @@ -440,7 +440,7 @@ public class MavenDroolsController2Test { params = dec.getAllValues().get(1); assertEquals(ARTIFACT, params.getArtifactId()); - assertEquals(gson1, params.getCustomCoder()); + assertEquals(gson1, params.getCustomGsonCoder()); assertEquals(String.class.getName(), params.getEventClass()); assertEquals(GROUP, params.getGroupId()); assertEquals(CLASS_LOADER_HASHCODE, params.getModelClassLoaderHash()); @@ -449,7 +449,7 @@ public class MavenDroolsController2Test { params = enc.getAllValues().get(0); assertEquals(ARTIFACT, params.getArtifactId()); - assertEquals(gson2, params.getCustomCoder()); + assertEquals(gson2, params.getCustomGsonCoder()); assertEquals(Integer.class.getName(), params.getEventClass()); assertEquals(GROUP, params.getGroupId()); assertEquals(CLASS_LOADER_HASHCODE, params.getModelClassLoaderHash()); diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java index 2fc1467b..b6168a2e 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/EventProtocolCoderTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,8 @@ package org.onap.policy.drools.protocol.coders; import static org.junit.Assert.assertTrue; import java.util.Properties; +import lombok.AllArgsConstructor; +import lombok.Getter; import org.junit.Test; import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; @@ -57,22 +59,10 @@ public class EventProtocolCoderTest { /** * Event Test Class. */ + @Getter + @AllArgsConstructor public static class EventTest { - private String field; - - public EventTest(String field) { - super(); - this.field = field; - } - - public String getField() { - return this.field; - } - - public void setField(String field) { - this.field = field; - } } @Test @@ -87,7 +77,7 @@ public class EventProtocolCoderTest { EventProtocolParams.builder().groupId(ENCODER_GROUP).artifactId(ENCODER_ARTIFACT) .topic(NOOP_TOPIC).eventClass(DroolsConfiguration.class.getName()) .protocolFilter(new JsonProtocolFilter()).customGsonCoder(null) - .modelClassLoaderHash(DroolsConfiguration.class.getName().hashCode())); + .modelClassLoaderHash(DroolsConfiguration.class.getName().hashCode()).build()); final String json = EventProtocolCoderConstants.getManager().encode(NOOP_TOPIC, new DroolsConfiguration(ENCODER_ARTIFACT, ENCODER_GROUP, ENCODER_VERSION)); diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java index abf9b387..7920723e 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/coders/ProtocolCoderToolsetTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -108,7 +108,7 @@ public class ProtocolCoderToolsetTest { new GsonProtocolCoderToolset(EventProtocolParams.builder().topic(JUNIT_PROTOCOL_CODER_TOPIC) .groupId(releaseId.getGroupId()).artifactId(releaseId.getArtifactId()) .eventClass(ThreeStrings.class.getName()).protocolFilter(protocolFilter) - .customGsonCoder(null).modelClassLoaderHash(12345678), CONTROLLER_ID); + .customGsonCoder(null).modelClassLoaderHash(12345678).build(), CONTROLLER_ID); Assert.assertNotNull(gsonToolset.getEncoder()); Assert.assertNotNull(gsonToolset.getDecoder()); @@ -155,7 +155,7 @@ public class ProtocolCoderToolsetTest { } CoderFilters coderFilters = coderToolset.getCoder(ThreeStrings.class.getName()); - Assert.assertSame(coderFilters.getCodedClass(), ThreeStrings.class.getName()); + Assert.assertSame(coderFilters.getFactClass(), ThreeStrings.class.getName()); Assert.assertSame(coderFilters.getFilter(), protocolFilter); Assert.assertNotNull(coderFilters.getFilter().getRule()); diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java index 3560671a..7248f11e 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/ControllerConfigurationTest.java @@ -1,7 +1,8 @@ /*- * ============LICENSE_START======================================================= - * Configuration Test * ================================================================================ - * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * ONAP + * ================================================================================ + * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,13 +20,13 @@ package org.onap.policy.drools.protocol.configuration; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; import java.util.Properties; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.junit.Test; import org.onap.policy.common.utils.gson.GsonTestUtils; @@ -99,9 +100,7 @@ public class ControllerConfigurationTest { assertEquals(DROOLS_CONFIG2, controllerConfig2.declaredPropertyOrNotFound(DROOLS_STRING, DROOLS_CONFIG2)); assertEquals(NAME, controllerConfig2.declaredPropertyOrNotFound("dummy", NAME)); - int hashCode = new HashCodeBuilder().append(NAME2).append(OPERATION2).append(DROOLS_CONFIG2) - .append(additionalProperties).toHashCode(); - assertEquals(controllerConfig2.hashCode(), hashCode); + assertThat(controllerConfig2.hashCode()).isNotZero(); } @Test diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java index a18a20b4..2d1ed7e2 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/DroolsConfigurationTest.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * Configuration Test + * ONAP * ================================================================================ - * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,12 @@ package org.onap.policy.drools.protocol.configuration; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import java.util.Properties; -import org.apache.commons.lang3.builder.HashCodeBuilder; import org.junit.Test; import org.onap.policy.common.utils.gson.GsonTestUtils; @@ -92,9 +92,7 @@ public class DroolsConfigurationTest { assertEquals(VERSION2, droolsConfig2.declaredPropertyOrNotFound(VERSION_STRING, VERSION2)); assertEquals(ARTIFACT2, droolsConfig2.declaredPropertyOrNotFound("dummy", ARTIFACT2)); - final int hashCode = new HashCodeBuilder().append(ARTIFACT2).append(GROUPID2).append(VERSION2) - .append(additionalProperties).toHashCode(); - assertEquals(droolsConfig2.hashCode(), hashCode); + assertThat(droolsConfig2.hashCode()).isNotZero(); } @Test diff --git a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java index b02090b4..a8a0a2ac 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/protocol/configuration/PdpdConfigurationTest.java @@ -1,8 +1,8 @@ /*- * ============LICENSE_START======================================================= - * Configuration Test + * ONAP * ================================================================================ - * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java index 1930dfb8..4be25d1a 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineManagerTest.java @@ -1783,7 +1783,7 @@ public class PolicyEngineManagerTest { @Test public void testToString() { - assertTrue(mgr.toString().startsWith("PolicyEngineManager [")); + assertTrue(mgr.toString().startsWith("PolicyEngineManager(")); } /** diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java index 30d38ce1..0fdc00a6 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/system/PolicyEngineTest.java @@ -222,7 +222,7 @@ public class PolicyEngineTest { EventProtocolParams.builder().groupId(ENCODER_GROUP).artifactId(ENCODER_ARTIFACT) .topic(NOOP_TOPIC).eventClass(DroolsConfiguration.class.getName()) .protocolFilter(new JsonProtocolFilter()).customGsonCoder(null) - .modelClassLoaderHash(DroolsConfiguration.class.getName().hashCode())); + .modelClassLoaderHash(DroolsConfiguration.class.getName().hashCode()).build()); assertTrue(PolicyEngineConstants.getManager().deliver(NOOP_TOPIC, new DroolsConfiguration(ENCODER_ARTIFACT, ENCODER_GROUP, ENCODER_VERSION))); diff --git a/policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java b/policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java index 6b669a2d..a6aa9d9d 100644 --- a/policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java +++ b/policy-management/src/test/java/org/onap/policy/drools/system/internal/AggregatedPolicyControllerTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP * ================================================================================ - * Copyright (C) 2018-2020 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -782,7 +782,7 @@ public class AggregatedPolicyControllerTest { @Test public void testToString() { - assertTrue(apc.toString().startsWith("AggregatedPolicyController [")); + assertTrue(apc.toString().startsWith("AggregatedPolicyController(")); } private void validateDeliverFailure(String topic, String event) { |