From 12f634160f11d03265fac84c8d10cb8765e16187 Mon Sep 17 00:00:00 2001 From: lapentafd Date: Tue, 15 Jun 2021 11:09:52 +0100 Subject: Fix Sonar issues in apex-pdp Issue-ID: POLICY-3093 Change-Id: I4def597b054a9ab2f3cc9a4665df04dd1d515ebf Signed-off-by: lapentafd --- .../contextmodel/concepts/AxContextAlbum.java | 10 ++--- .../contextmodel/concepts/AxContextAlbums.java | 8 ++-- .../contextmodel/concepts/AxContextModel.java | 8 ++-- .../contextmodel/concepts/AxContextSchema.java | 10 ++--- .../contextmodel/concepts/AxContextSchemas.java | 8 ++-- .../contextmodel/concepts/ContextAlbumsTest.java | 50 ++++++++++++++++++++-- .../contextmodel/concepts/ContextSchemasTest.java | 46 ++++++++++++++++++-- 7 files changed, 111 insertions(+), 29 deletions(-) (limited to 'model/context-model/src') diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java index 629e2556c..85a6ab803 100644 --- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java +++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbum.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -264,7 +264,7 @@ public class AxContextAlbum extends AxConcept { "scope is not defined")); } - String stringCheckResult = Assertions.getStringParameterValidationMessage(SCOPE_STRING, scope, SCOPE_REGEXP); + var stringCheckResult = Assertions.getStringParameterValidationMessage(SCOPE_STRING, scope, SCOPE_REGEXP); if (stringCheckResult != null) { result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, "scope invalid-" + stringCheckResult)); @@ -294,7 +294,7 @@ public class AxContextAlbum extends AxConcept { */ @Override public String toString() { - final StringBuilder builder = new StringBuilder(); + final var builder = new StringBuilder(); builder.append(this.getClass().getSimpleName()); builder.append(":("); builder.append("key="); @@ -333,8 +333,8 @@ public class AxContextAlbum extends AxConcept { */ @Override public int hashCode() { - final int prime = 31; - int result = 1; + final var prime = 31; + var result = 1; result = prime * result + key.hashCode(); result = prime * result + scope.hashCode(); result = prime * result + (isWritable ? HASH_PRIME_0 : HASH_PRIME_1); diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java index 99e5300dc..616599653 100644 --- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java +++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextAlbums.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -213,7 +213,7 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter< */ @Override public String toString() { - final StringBuilder builder = new StringBuilder(); + final var builder = new StringBuilder(); builder.append(this.getClass().getSimpleName()); builder.append(":("); builder.append(this.getClass().getSimpleName()); @@ -300,8 +300,8 @@ public final class AxContextAlbums extends AxConcept implements AxConceptGetter< */ @Override public int hashCode() { - final int prime = 31; - int result = 1; + final var prime = 31; + var result = 1; result = prime * result + key.hashCode(); result = prime * result + albums.hashCode(); return result; diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java index 9fbcc81cb..c5919c030 100644 --- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java +++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextModel.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019-2021 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -224,7 +224,7 @@ public class AxContextModel extends AxModel { */ @Override public String toString() { - final StringBuilder builder = new StringBuilder(); + final var builder = new StringBuilder(); builder.append(this.getClass().getSimpleName()); builder.append(":("); builder.append(super.toString()); @@ -259,8 +259,8 @@ public class AxContextModel extends AxModel { */ @Override public int hashCode() { - final int prime = 31; - int result = 1; + final var prime = 31; + var result = 1; result = prime * result + super.hashCode(); result = prime * result + schemas.hashCode(); result = prime * result + albums.hashCode(); diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java index 00baebeab..bca369157 100644 --- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java +++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchema.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -226,7 +226,7 @@ public class AxContextSchema extends AxConcept { "schema flavour is not defined")); } - String flavourValidationResult = Assertions.getStringParameterValidationMessage(SCHEMA_FLAVOUR, schemaFlavour, + var flavourValidationResult = Assertions.getStringParameterValidationMessage(SCHEMA_FLAVOUR, schemaFlavour, SCHEMA_FLAVOUR_REGEXP); if (flavourValidationResult != null) { result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID, @@ -256,7 +256,7 @@ public class AxContextSchema extends AxConcept { */ @Override public String toString() { - final StringBuilder builder = new StringBuilder(); + final var builder = new StringBuilder(); builder.append(this.getClass().getSimpleName()); builder.append(":("); builder.append("key="); @@ -292,8 +292,8 @@ public class AxContextSchema extends AxConcept { */ @Override public int hashCode() { - final int prime = 31; - int result = 1; + final var prime = 31; + var result = 1; result = prime * result + key.hashCode(); result = prime * result + schemaFlavour.hashCode(); result = prime * result + schemaDefinition.hashCode(); diff --git a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java index 8c4110b62..705691c22 100644 --- a/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java +++ b/model/context-model/src/main/java/org/onap/policy/apex/model/contextmodel/concepts/AxContextSchemas.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2016-2018 Ericsson. All rights reserved. - * Modifications Copyright (C) 2019-2020 Nordix Foundation. + * Modifications Copyright (C) 2019-2021 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -253,7 +253,7 @@ public class AxContextSchemas extends AxConcept implements AxConceptGetter