From 9344ec1396b7151262e9b4ac48c72020e2b03e7e Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 2 Aug 2021 16:36:26 -0400 Subject: Use lombok in apex-pdp #5 Updated examples thru integration-executor-test. Issue-ID: POLICY-3391 Change-Id: Idc707146a646d05720675a787761c199484048e9 Signed-off-by: Jim Hahn --- .../context/entities/ArtifactKeyTestEntity.java | 101 +++------------------ .../context/entities/ReferenceKeyTestEntity.java | 101 +++------------------ .../context/factory/TestContextAlbumFactory.java | 11 +-- .../context/utils/ConfigrationProviderImpl.java | 70 ++------------ .../integration/context/utils/Constants.java | 13 +-- .../integration/context/utils/NetworkUtils.java | 13 +-- 6 files changed, 44 insertions(+), 265 deletions(-) (limited to 'testsuites/integration/integration-context-test/src/test/java') diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java index 19c3d33c5..3b8394dbb 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ArtifactKeyTestEntity.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 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. @@ -27,6 +28,11 @@ import javax.persistence.EmbeddedId; import javax.persistence.Entity; import javax.persistence.Table; import javax.xml.bind.annotation.XmlElement; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; import org.onap.policy.apex.model.basicmodel.concepts.AxConcept; import org.onap.policy.apex.model.basicmodel.concepts.AxKey; @@ -37,6 +43,11 @@ import org.onap.policy.apex.model.basicmodel.concepts.AxValidationResult; */ @Entity @Table(name = "ArtifactKeyTestEntity") +@Getter +@Setter +@ToString +@EqualsAndHashCode(callSuper = false) +@AllArgsConstructor public class ArtifactKeyTestEntity extends AxConcept { private static final long serialVersionUID = -2962570563281067896L; @@ -64,25 +75,6 @@ public class ArtifactKeyTestEntity extends AxConcept { this.doubleValue = doubleValue; } - /** - * Instantiates a new artifact key test entity. - * - * @param key the key - * @param doubleValue the double value - */ - public ArtifactKeyTestEntity(final AxArtifactKey key, final Double doubleValue) { - this.key = key; - this.doubleValue = doubleValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public AxArtifactKey getKey() { - return key; - } - /** * {@inheritDoc}. */ @@ -91,15 +83,6 @@ public class ArtifactKeyTestEntity extends AxConcept { return Arrays.asList((AxKey) getKey()); } - /** - * Sets the key. - * - * @param key the new key - */ - public void setKey(final AxArtifactKey key) { - this.key = key; - } - /** * Check set key. * @@ -109,24 +92,6 @@ public class ArtifactKeyTestEntity extends AxConcept { return (this.key != null); } - /** - * Gets the double value. - * - * @return the double value - */ - public double getDoubleValue() { - return doubleValue; - } - - /** - * Sets the double value. - * - * @param doubleValue the new double value - */ - public void setDoubleValue(final double doubleValue) { - this.doubleValue = doubleValue; - } - /** * {@inheritDoc}. */ @@ -143,14 +108,6 @@ public class ArtifactKeyTestEntity extends AxConcept { key.clean(); } - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "ArtifactKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]"; - } - /** * {@inheritDoc}. */ @@ -171,42 +128,6 @@ public class ArtifactKeyTestEntity extends AxConcept { } } - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((key == null) ? 0 : key.hashCode()); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (obj == null) { - return false; - } - if (this == obj) { - return true; - } - if (getClass() != obj.getClass()) { - return false; - } - final ArtifactKeyTestEntity other = (ArtifactKeyTestEntity) obj; - if (key == null) { - if (other.key != null) { - return false; - } - } else if (!key.equals(other.key)) { - return false; - } - return (Double.compare(doubleValue, other.doubleValue) == 0); - } - /** * {@inheritDoc}. */ diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java index b3256484b..da478f0dd 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/entities/ReferenceKeyTestEntity.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 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. @@ -28,6 +29,11 @@ import javax.persistence.Entity; import javax.persistence.Table; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; import org.onap.policy.apex.model.basicmodel.concepts.AxConcept; import org.onap.policy.apex.model.basicmodel.concepts.AxKey; import org.onap.policy.apex.model.basicmodel.concepts.AxReferenceKey; @@ -39,6 +45,11 @@ import org.onap.policy.apex.model.basicmodel.xml.AxReferenceKeyAdapter; */ @Entity @Table(name = "ReferenceKeyTestEntity") +@Getter +@Setter +@ToString +@EqualsAndHashCode(callSuper = false) +@AllArgsConstructor public class ReferenceKeyTestEntity extends AxConcept { private static final long serialVersionUID = -2962570563281067895L; @@ -67,25 +78,6 @@ public class ReferenceKeyTestEntity extends AxConcept { this.doubleValue = doubleValue; } - /** - * Instantiates a new reference key test entity. - * - * @param key the key - * @param doubleValue the double value - */ - public ReferenceKeyTestEntity(final AxReferenceKey key, final Double doubleValue) { - this.key = key; - this.doubleValue = doubleValue; - } - - /** - * {@inheritDoc}. - */ - @Override - public AxReferenceKey getKey() { - return key; - } - /** * {@inheritDoc}. */ @@ -94,15 +86,6 @@ public class ReferenceKeyTestEntity extends AxConcept { return Arrays.asList((AxKey) getKey()); } - /** - * Sets the key. - * - * @param key the new key - */ - public void setKey(final AxReferenceKey key) { - this.key = key; - } - /** * Check set key. * @@ -112,24 +95,6 @@ public class ReferenceKeyTestEntity extends AxConcept { return (this.key != null); } - /** - * Gets the double value. - * - * @return the double value - */ - public double getDoubleValue() { - return doubleValue; - } - - /** - * Sets the double value. - * - * @param doubleValue the new double value - */ - public void setDoubleValue(final double doubleValue) { - this.doubleValue = doubleValue; - } - /** * {@inheritDoc}. */ @@ -146,14 +111,6 @@ public class ReferenceKeyTestEntity extends AxConcept { key.clean(); } - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "ReferenceKeyTestEntity [key=" + key + ", doubleValue=" + doubleValue + "]"; - } - /** * {@inheritDoc}. */ @@ -174,42 +131,6 @@ public class ReferenceKeyTestEntity extends AxConcept { } } - /** - * {@inheritDoc}. - */ - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((key == null) ? 0 : key.hashCode()); - return result; - } - - /** - * {@inheritDoc}. - */ - @Override - public boolean equals(final Object obj) { - if (obj == null) { - return false; - } - if (this == obj) { - return true; - } - if (getClass() != obj.getClass()) { - return false; - } - final ReferenceKeyTestEntity other = (ReferenceKeyTestEntity) obj; - if (key == null) { - if (other.key != null) { - return false; - } - } else if (!key.equals(other.key)) { - return false; - } - return (Double.compare(doubleValue, other.doubleValue) == 0); - } - /** * {@inheritDoc}. */ diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java index 4abbc2051..be4a379aa 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/factory/TestContextAlbumFactory.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 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. @@ -29,6 +30,8 @@ import static org.onap.policy.apex.testsuites.integration.context.utils.Constant import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.POLICY_CONTEXT_ALBUM; import static org.onap.policy.apex.testsuites.integration.context.utils.Constants.VERSION; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.onap.policy.apex.context.test.concepts.TestContextDateLocaleItem; import org.onap.policy.apex.context.test.concepts.TestContextLongItem; import org.onap.policy.apex.context.test.concepts.TestContextTreeMapItem; @@ -48,6 +51,7 @@ import org.onap.policy.apex.model.contextmodel.concepts.AxContextSchemas; * * @author Liam Fallon (liam.fallon@ericsson.com) */ +@NoArgsConstructor(access = AccessLevel.PRIVATE) public final class TestContextAlbumFactory { // Recurring string constants. private static final String CONTEXT = "context"; @@ -57,13 +61,6 @@ public final class TestContextAlbumFactory { private static final String JAVA_LONG = Long.class.getName(); private static final String JAVA_FLAVOUR = "Java"; - /** - * Default constructor to prevent sub-classing. - */ - private TestContextAlbumFactory() { - // Private constructor to block subclassing - } - /** * Creates the policy context model. * diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java index 608a7fc68..0b3ac82c2 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/ConfigrationProviderImpl.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 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. @@ -25,6 +26,8 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import lombok.Getter; +import lombok.ToString; import org.onap.policy.apex.context.ContextAlbum; import org.onap.policy.apex.context.ContextException; import org.onap.policy.apex.context.ContextRuntimeException; @@ -41,9 +44,11 @@ import org.onap.policy.common.utils.validation.Assertions; /** * The Class ConfigrationProviderImpl provides configuration information for a context test back to the caller. */ +@Getter +@ToString public class ConfigrationProviderImpl implements ConfigrationProvider { - private final String testType; + private final String testName; private final int jvmCount; private final int threadCount; private final int loopSize; @@ -62,7 +67,7 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { */ public ConfigrationProviderImpl(final String testType, final int jvmCount, final int threadCount, final int loopSize, final int albumSize, final int lockType) { - this.testType = testType; + this.testName = testType; this.jvmCount = jvmCount; this.threadCount = threadCount; this.loopSize = loopSize; @@ -70,52 +75,12 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { this.lockType = LockType.getLockType(lockType); } - /** - * {@inheritDoc}. - */ - @Override - public String getTestName() { - return testType; - } - - /** - * {@inheritDoc}. - */ - @Override - public int getLoopSize() { - return loopSize; - } - - /** - * {@inheritDoc}. - */ - @Override - public int getThreadCount() { - return threadCount; - } - - /** - * {@inheritDoc}. - */ - @Override - public int getJvmCount() { - return jvmCount; - } - - /** - * {@inheritDoc}. - */ - @Override - public int getAlbumSize() { - return albumSize; - } - /** * {@inheritDoc}. */ @Override public ExecutorService getExecutorService() { - final String name = getThreadFactoryName(jvmCount, testType); + final String name = getThreadFactoryName(jvmCount, testName); final IntegrationThreadFactory threadFactory = new IntegrationThreadFactory(name); return Executors.newFixedThreadPool(threadCount, threadFactory); } @@ -197,14 +162,6 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { return lockType.getAlbumModifier(); } - /** - * {@inheritDoc}. - */ - @Override - public LockType getLockType() { - return lockType; - } - /** * Gets the thread factory name. * @@ -216,15 +173,4 @@ public class ConfigrationProviderImpl implements ConfigrationProvider { return jvmCount == 1 ? testType + ":TestConcurrentContextThread_0_" : testType + ":TestConcurrentContextJVMThread_"; } - - /** - * {@inheritDoc}. - */ - @Override - public String toString() { - return "ConfigrationProviderImpl [testType=" + testType + ", jvmCount=" + jvmCount + ", threadCount=" - + threadCount + ", loopSize=" + loopSize + ", albumSize=" + albumSize + ", lockType=" + lockType - + "]"; - } - } diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java index e1d8d1a9e..a5eabd753 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/Constants.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 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. @@ -22,13 +23,16 @@ package org.onap.policy.apex.testsuites.integration.context.utils; import java.util.TimeZone; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.onap.policy.apex.context.test.concepts.TestPolicyContextItem; import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey; /** * The Class Constants provides constants for context tests. */ -public class Constants { +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class Constants { public static final String MAP_CONTEXT_ALBUM = "MapContextAlbum"; public static final String LONG_CONTEXT_ALBUM = "LongContextAlbum"; public static final String DATE_CONTEXT_ALBUM = "DateContextAlbum"; @@ -64,13 +68,6 @@ public class Constants { private static final AxArtifactKey[] USED_ARTIFACT_STACK_ARRAY = new AxArtifactKey[] {KEY, KEY2, KEY3}; - /** - * Instantiates a new constants. - */ - private Constants() { - // Private constructor to block subclassing - } - /** * Gets the ax artifact key array. * diff --git a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/NetworkUtils.java b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/NetworkUtils.java index 30bc8d823..a4a110659 100644 --- a/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/NetworkUtils.java +++ b/testsuites/integration/integration-context-test/src/test/java/org/onap/policy/apex/testsuites/integration/context/utils/NetworkUtils.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 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. @@ -28,18 +29,14 @@ import java.util.Collections; import java.util.Enumeration; import java.util.SortedSet; import java.util.TreeSet; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; /** * The Class NetworkUtils contains some utility functions for getting network information for context tests. */ -public class NetworkUtils { - - /** - * Instantiates a new network utils. - */ - private NetworkUtils() { - // Private constructor to block subclassing - } +@NoArgsConstructor(access = AccessLevel.PRIVATE) +public final class NetworkUtils { /** * The JGroups IP address must be set to a real (not loopback) IP address for Infinispan to work. In order to ensure -- cgit 1.2.3-korg