diff options
author | 2025-01-10 11:50:41 +0000 | |
---|---|---|
committer | 2025-01-10 11:51:51 +0000 | |
commit | b60fb4d0e5ad3603f967029a2682484cbdd81cec (patch) | |
tree | 5918b072b3219512bd8d60c777e7891bddaabbef /models-tosca | |
parent | 7cfbbcb1f16ab8b358c06a1f77fc94a203a53212 (diff) |
Fix sonar issues
- fixing sonar issues on code to generate new models-* artifacts
with parent new dependencies.
Issue-ID: POLICY-5240
Change-Id: I41e01ededbc20c9b389be1167691aeb4e03cd0fb
Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
Diffstat (limited to 'models-tosca')
7 files changed, 63 insertions, 70 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java index eb573ca51..0d71e1d3f 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java @@ -3,7 +3,7 @@ * ONAP Policy Model * ================================================================================ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019-2021, 2023 Nordix Foundation. + * Modifications Copyright (C) 2019-2021, 2023, 2025 Nordix Foundation. * Modifications Copyright (C) 2022 Bell Canada. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -152,10 +152,10 @@ public class JpaToscaPolicy extends JpaToscaWithTypeAndStringProperties<ToscaPol if (getMetadata().containsKey(METADATA_METADATA_SET_NAME_TAG) && getMetadata().containsKey(METADATA_METADATA_SET_VERSION_TAG)) { getMetadata().put(METADATA_METADATA_SET_NAME_TAG, getMetadata().get(METADATA_METADATA_SET_NAME_TAG) - .replaceAll("^\"|\"$", "")); + .replaceAll("^\"|\"$", "")); // NOSONAR operator precedence is explicit getMetadata().put(METADATA_METADATA_SET_VERSION_TAG, getMetadata().get(METADATA_METADATA_SET_VERSION_TAG) - .replaceAll("^\"|\"$", "")); + .replaceAll("^\"|\"$", "")); // NOSONAR operator precedence is explicit } } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilterTest.java index c1c3f4aeb..f2fc60c6f 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilterTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntityFilterTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2021, 2025 Nordix Foundation. * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ @@ -75,7 +75,7 @@ class ToscaEntityFilterTest { }; // @formatter:on - private static List<ToscaPolicyType> typeList = new ArrayList<>(); + private static final List<ToscaPolicyType> typeList = new ArrayList<>(); /** * Set up a Tosca Policy type list for filtering. @@ -90,14 +90,14 @@ class ToscaEntityFilterTest { String yamlAsJsonString = new GsonBuilder().setPrettyPrinting().create().toJson(yamlObject); ToscaServiceTemplate serviceTemplate = - new StandardCoder().decode(yamlAsJsonString, ToscaServiceTemplate.class); + new StandardCoder().decode(yamlAsJsonString, ToscaServiceTemplate.class); assertNotNull(serviceTemplate); addPolicyTypes(serviceTemplate.getPolicyTypes()); } for (ToscaPolicyType type : typeList) { - LOGGER.info("using policy type-" + type.getName() + ":" + type.getVersion()); + LOGGER.info("using policy type-{}:{}", type.getName(), type.getVersion()); } } @@ -136,7 +136,7 @@ class ToscaEntityFilterTest { @Test void testFilterLatestVersion() { ToscaEntityFilter<ToscaPolicyType> filter = - ToscaEntityFilter.<ToscaPolicyType>builder().version(ToscaEntityFilter.LATEST_VERSION).build(); + ToscaEntityFilter.<ToscaPolicyType>builder().version(ToscaEntityFilter.LATEST_VERSION).build(); List<ToscaPolicyType> filteredList = filter.filter(typeList); assertEquals(19, filteredList.size()); @@ -157,7 +157,7 @@ class ToscaEntityFilterTest { @Test void testFilterNameVersion() { ToscaEntityFilter<ToscaPolicyType> filter = - ToscaEntityFilter.<ToscaPolicyType>builder().name("onap.policies.Monitoring").build(); + ToscaEntityFilter.<ToscaPolicyType>builder().name("onap.policies.Monitoring").build(); List<ToscaPolicyType> filteredList = filter.filter(typeList); assertEquals(1, filteredList.size()); @@ -174,12 +174,12 @@ class ToscaEntityFilterTest { assertEquals(19, filteredList.size()); filter = ToscaEntityFilter.<ToscaPolicyType>builder().name("onap.policies.optimization.Vim_fit") - .version(VERSION_000).build(); + .version(VERSION_000).build(); filteredList = filter.filter(typeList); assertEquals(0, filteredList.size()); filter = ToscaEntityFilter.<ToscaPolicyType>builder().name("onap.policies.optimization.Vim_fit") - .version("0.0.1").build(); + .version("0.0.1").build(); filteredList = filter.filter(typeList); assertEquals(0, filteredList.size()); } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilterTest.java index b224a4472..ea9fab728 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilterTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaTypedEntityFilterTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2021, 2025 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ @@ -70,7 +70,7 @@ class ToscaTypedEntityFilterTest { }; // @formatter:on - private static List<ToscaPolicy> policyList = new ArrayList<>(); + private static final List<ToscaPolicy> policyList = new ArrayList<>(); /** * Set up a Tosca Policy type list for filtering. @@ -96,8 +96,8 @@ class ToscaTypedEntityFilterTest { } for (ToscaPolicy policy : policyList) { - LOGGER.info("using policy-" + policy.getName() + ":" + policy.getVersion() + ", type-" + policy.getType() - + ":" + policy.getTypeVersion()); + LOGGER.info("using policy-{}:{}, type-{}:{}", policy.getName(), policy.getVersion(), + policy.getType(), policy.getTypeVersion()); } } @@ -140,7 +140,7 @@ class ToscaTypedEntityFilterTest { @Test void testFilterLatestVersion() { ToscaTypedEntityFilter<ToscaPolicy> filter = - ToscaTypedEntityFilter.<ToscaPolicy>builder().version(ToscaTypedEntityFilter.LATEST_VERSION).build(); + ToscaTypedEntityFilter.<ToscaPolicy>builder().version(ToscaTypedEntityFilter.LATEST_VERSION).build(); List<ToscaPolicy> filteredList = filter.filter(policyList); assertEquals(22, filteredList.size()); @@ -182,9 +182,7 @@ class ToscaTypedEntityFilterTest { // Change versions back // policyList.forEach(policy -> { - if ("onap.vfirewall.tca".equals(policy.getName())) { - policy.setVersion(VERSION_100); - } else if ("operational.modifyconfig".equals(policy.getName())) { + if ("onap.vfirewall.tca".equals(policy.getName()) || "operational.modifyconfig".equals(policy.getName())) { policy.setVersion(VERSION_100); } }); @@ -202,7 +200,7 @@ class ToscaTypedEntityFilterTest { @Test void testFilterNameVersion() { ToscaTypedEntityFilter<ToscaPolicy> filter = - ToscaTypedEntityFilter.<ToscaPolicy>builder().name("operational.modifyconfig").build(); + ToscaTypedEntityFilter.<ToscaPolicy>builder().name("operational.modifyconfig").build(); List<ToscaPolicy> filteredList = filter.filter(policyList); assertEquals(1, filteredList.size()); @@ -219,12 +217,12 @@ class ToscaTypedEntityFilterTest { assertEquals(22, filteredList.size()); filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().name("OSDF_CASABLANCA.SubscriberPolicy_v1") - .version(VERSION_100).build(); + .version(VERSION_100).build(); filteredList = filter.filter(policyList); assertEquals(1, filteredList.size()); filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().name("operational.modifyconfig").version(VERSION_100) - .build(); + .build(); filteredList = filter.filter(policyList); assertEquals(1, filteredList.size()); } @@ -233,7 +231,7 @@ class ToscaTypedEntityFilterTest { void testFilterVersionPrefix() { // null pattern ToscaTypedEntityFilter<ToscaPolicy> filter = - ToscaTypedEntityFilter.<ToscaPolicy>builder().versionPrefix(null).build(); + ToscaTypedEntityFilter.<ToscaPolicy>builder().versionPrefix(null).build(); List<ToscaPolicy> filteredList = filter.filter(policyList); assertEquals(22, filteredList.size()); @@ -249,17 +247,17 @@ class ToscaTypedEntityFilterTest { @Test void testFilterTypeVersion() { ToscaTypedEntityFilter<ToscaPolicy> filter = - ToscaTypedEntityFilter.<ToscaPolicy>builder().type("onap.policies.controlloop.Operational").build(); + ToscaTypedEntityFilter.<ToscaPolicy>builder().type("onap.policies.controlloop.Operational").build(); List<ToscaPolicy> filteredList = filter.filter(policyList); assertEquals(0, filteredList.size()); filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().type("onap.policies.controlloop.operational.common.Apex") - .build(); + .build(); filteredList = filter.filter(policyList); assertEquals(0, filteredList.size()); filter = ToscaTypedEntityFilter.<ToscaPolicy>builder() - .type("onap.policies.controlloop.operational.common.Drools").build(); + .type("onap.policies.controlloop.operational.common.Drools").build(); filteredList = filter.filter(policyList); assertEquals(3, filteredList.size()); @@ -276,12 +274,12 @@ class ToscaTypedEntityFilterTest { assertEquals(0, filteredList.size()); filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().type("onap.policies.optimization.resource.HpaPolicy") - .typeVersion(VERSION_100).build(); + .typeVersion(VERSION_100).build(); filteredList = filter.filter(policyList); assertEquals(2, filteredList.size()); filter = ToscaTypedEntityFilter.<ToscaPolicy>builder().type("onap.policies.controlloop.Operational") - .typeVersion(VERSION_000).build(); + .typeVersion(VERSION_000).build(); filteredList = filter.filter(policyList); assertEquals(0, filteredList.size()); } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java index e79664550..e80d6248c 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021, 2023-2024 Nordix Foundation. + * Copyright (C) 2019-2021, 2023-2025 Nordix Foundation. * Modifications Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -459,9 +459,8 @@ class AuthorativeToscaProviderPolicyTest { ToscaDataType duplDataType = toscaServiceTemplatePolicyType.getDataTypes().values().iterator().next(); toscaServiceTemplatePolicyType.getDataTypes().put("DuplicateDataType", duplDataType); - assertThatThrownBy(() -> { - toscaServiceTemplatePolicyType.getDataTypesAsMap(); - }).hasMessageContaining("list of map of entities contains more than one entity with key"); + assertThatThrownBy(toscaServiceTemplatePolicyType::getDataTypesAsMap) + .hasMessageContaining("list of map of entities contains more than one entity with key"); } private void createPolicyTypes() throws CoderException, PfModelException { diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java index 92a59722f..b275b13b5 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaTimeIntervalTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2021, 2025 Nordix Foundation. * Modifications Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ @@ -143,8 +143,7 @@ class JpaToscaTimeIntervalTest { private JpaToscaTimeInterval setUpJpaToscaTimeInterval(Instant startTime, Instant endTime) { PfConceptKey ttiParentKey = new PfConceptKey("tParentKey", "0.0.1"); PfReferenceKey ttiKey = new PfReferenceKey(ttiParentKey, "trigger0"); - JpaToscaTimeInterval tti = new JpaToscaTimeInterval(ttiKey, startTime, endTime); - return tti; + return new JpaToscaTimeInterval(ttiKey, startTime, endTime); } } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaPropertiesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaPropertiesTest.java index 6defc85de..4bfff20da 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaPropertiesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaWithToscaPropertiesTest.java @@ -3,7 +3,7 @@ * ONAP * ================================================================================ * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2024 Nordix Foundation + * Modifications Copyright (C) 2024-2025 Nordix Foundation * ================================================================================ * 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,7 @@ package org.onap.policy.models.tosca.simple.concepts; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; +import java.io.Serial; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -51,8 +52,8 @@ class JpaToscaWithToscaPropertiesTest { private static final PfReferenceKey REF_KEY2 = new PfReferenceKey(CONCEPT_KEY2); private static final JpaToscaProperty JPA_PROP1 = new JpaToscaProperty(REF_KEY1); private static final JpaToscaProperty JPA_PROP2 = new JpaToscaProperty(REF_KEY2); - private static ToscaProperty PROP1; - private static ToscaProperty PROP2; + private static ToscaProperty toscaPropertyOne; + private static ToscaProperty toscaPropertyTwo; private static final String DESCRIPT1 = "description A"; private static final String DESCRIPT2 = "description B"; @@ -66,8 +67,8 @@ class JpaToscaWithToscaPropertiesTest { JPA_PROP1.setDescription(DESCRIPT1); JPA_PROP2.setDescription(DESCRIPT2); - PROP1 = JPA_PROP1.toAuthorative(); - PROP2 = JPA_PROP2.toAuthorative(); + toscaPropertyOne = JPA_PROP1.toAuthorative(); + toscaPropertyTwo = JPA_PROP2.toAuthorative(); } @BeforeEach @@ -118,7 +119,7 @@ class JpaToscaWithToscaPropertiesTest { MyTosca tosca = jpa.toAuthorative(); assertEquals(SOME_DESCRIPTION, tosca.getDescription()); - assertThat(tosca.getProperties()).isEqualTo(Map.of(KEY1, PROP1, KEY2, PROP2)); + assertThat(tosca.getProperties()).isEqualTo(Map.of(KEY1, toscaPropertyOne, KEY2, toscaPropertyTwo)); } @Test @@ -130,12 +131,12 @@ class JpaToscaWithToscaPropertiesTest { assertEquals(SOME_DESCRIPTION, jpa.getDescription()); assertThat(jpa.getProperties()).isNull(); - tosca.setProperties(Map.of(KEY1, PROP1, KEY2, PROP2)); + tosca.setProperties(Map.of(KEY1, toscaPropertyOne, KEY2, toscaPropertyTwo)); - JpaToscaProperty jpa1 = new JpaToscaProperty(PROP1); + JpaToscaProperty jpa1 = new JpaToscaProperty(toscaPropertyOne); jpa1.setKey(new PfReferenceKey(jpa.getKey(), KEY1)); - JpaToscaProperty jpa2 = new JpaToscaProperty(PROP2); + JpaToscaProperty jpa2 = new JpaToscaProperty(toscaPropertyTwo); jpa2.setKey(new PfReferenceKey(jpa.getKey(), KEY2)); jpa = new MyJpa(); @@ -187,15 +188,15 @@ class JpaToscaWithToscaPropertiesTest { tosca.setName("world"); tosca.setVersion("3.2.1"); tosca.setDescription(SOME_DESCRIPTION); - tosca.setProperties(Map.of(KEY1, PROP1, KEY2, PROP2)); + tosca.setProperties(Map.of(KEY1, toscaPropertyOne, KEY2, toscaPropertyTwo)); jpa = new MyJpa(tosca); assertEquals(SOME_DESCRIPTION, jpa.getDescription()); - JpaToscaProperty jpa1 = new JpaToscaProperty(PROP1); + JpaToscaProperty jpa1 = new JpaToscaProperty(toscaPropertyOne); jpa1.setKey(new PfReferenceKey(jpa.getKey(), KEY1)); - JpaToscaProperty jpa2 = new JpaToscaProperty(PROP2); + JpaToscaProperty jpa2 = new JpaToscaProperty(toscaPropertyTwo); jpa2.setKey(new PfReferenceKey(jpa.getKey(), KEY2)); assertThat(jpa.getProperties()).isEqualTo(Map.of(KEY1, jpa1, KEY2, jpa2)); @@ -244,17 +245,18 @@ class JpaToscaWithToscaPropertiesTest { } - private static class MyTosca extends ToscaWithToscaProperties { + protected static class MyTosca extends ToscaWithToscaProperties { } + @Setter + @Getter @NoArgsConstructor protected static class MyJpa extends JpaToscaWithToscaProperties<MyTosca> { + @Serial private static final long serialVersionUID = 1L; @NotNull - @Getter - @Setter private String text; public MyJpa(MyJpa jpa) { @@ -277,6 +279,7 @@ class JpaToscaWithToscaPropertiesTest { } private static class MyJpa2 extends MyJpa { + @Serial private static final long serialVersionUID = 1L; } } diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java index 9e655909b..6cb929802 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaUtilsTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019-2021 Nordix Foundation. + * Copyright (C) 2019-2021, 2025 Nordix Foundation. * Modifications Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. * Modifications Copyright (C) 2024 Nordix Foundation * ================================================================================ @@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -72,10 +73,8 @@ class ToscaUtilsTest { jpaToscaServiceTemplate.getDataTypes().getConceptMap().put(new PfConceptKey(), null); assertTrue(ToscaUtils.doDataTypesExist(jpaToscaServiceTemplate)); - assertEquals(null, ToscaUtils.checkDataTypesExist(jpaToscaServiceTemplate)); - assertThatCode(() -> { - ToscaUtils.assertDataTypesExist(jpaToscaServiceTemplate); - }).doesNotThrowAnyException(); + assertNull(ToscaUtils.checkDataTypesExist(jpaToscaServiceTemplate)); + assertThatCode(() -> ToscaUtils.assertDataTypesExist(jpaToscaServiceTemplate)).doesNotThrowAnyException(); } @@ -102,10 +101,8 @@ class ToscaUtilsTest { jpaToscaServiceTemplate.getPolicyTypes().getConceptMap().put(new PfConceptKey(), null); assertTrue(ToscaUtils.doPolicyTypesExist(jpaToscaServiceTemplate)); - assertEquals(null, ToscaUtils.checkPolicyTypesExist(jpaToscaServiceTemplate)); - assertThatCode(() -> { - ToscaUtils.assertPolicyTypesExist(jpaToscaServiceTemplate); - }).doesNotThrowAnyException(); + assertNull(ToscaUtils.checkPolicyTypesExist(jpaToscaServiceTemplate)); + assertThatCode(() -> ToscaUtils.assertPolicyTypesExist(jpaToscaServiceTemplate)).doesNotThrowAnyException(); } @Test @@ -140,14 +137,12 @@ class ToscaUtilsTest { jpaToscaServiceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(new PfConceptKey(), null); assertTrue(ToscaUtils.doPoliciesExist(jpaToscaServiceTemplate)); - assertEquals(null, ToscaUtils.checkPoliciesExist(jpaToscaServiceTemplate)); - assertThatCode(() -> { - ToscaUtils.assertPoliciesExist(jpaToscaServiceTemplate); - }).doesNotThrowAnyException(); + assertNull(ToscaUtils.checkPoliciesExist(jpaToscaServiceTemplate)); + assertThatCode(() -> ToscaUtils.assertPoliciesExist(jpaToscaServiceTemplate)).doesNotThrowAnyException(); } @Test - void testGetentityTypeAncestors() { + void testGetEntityTypeAncestors() { assertThatThrownBy(() -> { ToscaUtils.getEntityTypeAncestors(null, null, null); }).hasMessageMatching("entityTypes is marked .*on.*ull but is null"); @@ -236,7 +231,7 @@ class ToscaUtilsTest { dt1.setDerivedFrom(new PfConceptKey("tosca.datatyps.Root", PfKey.NULL_KEY_VERSION)); checkSingleEmptyEntityTypeAncestor(dataTypes, dt0, result); - checkMultipleEmptyEntityTypeAncestors(dataTypes, dt1, dt2, result, 1, 0); + checkMultipleEmptyEntityTypeAncestors(dataTypes, dt1, dt2, result); dataTypes.getConceptMap().remove(dt1.getKey()); assertThat(ToscaUtils.getEntityTypeAncestors(dataTypes, dt2, result)).isEmpty(); @@ -259,11 +254,11 @@ class ToscaUtilsTest { } private void checkMultipleEmptyEntityTypeAncestors(JpaToscaDataTypes dataTypes, JpaToscaDataType emptydt, - JpaToscaDataType notemptydt, BeanValidationResult result, int size1, int size2) { + JpaToscaDataType notemptydt, BeanValidationResult result) { assertThat(ToscaUtils.getEntityTypeAncestors(dataTypes, emptydt, result)).isEmpty(); assertFalse(ToscaUtils.getEntityTypeAncestors(dataTypes, notemptydt, result).isEmpty()); - assertEquals(size1, ToscaUtils.getEntityTypeAncestors(dataTypes, notemptydt, result).size()); - assertEquals(size2, ToscaUtils.getEntityTypeAncestors(dataTypes, emptydt, result).size()); + assertEquals(1, ToscaUtils.getEntityTypeAncestors(dataTypes, notemptydt, result).size()); + assertEquals(0, ToscaUtils.getEntityTypeAncestors(dataTypes, emptydt, result).size()); assertTrue(result.isValid()); } @@ -273,7 +268,7 @@ class ToscaUtilsTest { } @Test - void testgetEntityTree() { + void testGetEntityTree() { assertThatThrownBy(() -> { ToscaUtils.getEntityTree(null, null, null); }).hasMessageMatching("entityTypes is marked .*on.*ull but is null"); @@ -378,7 +373,6 @@ class ToscaUtilsTest { assertEquals(3, filteredDataTypes.getConceptMap().size()); dt9.setDerivedFrom(new PfConceptKey("i.dont.Exist", "0.0.0")); - filteredDataTypes = new JpaToscaDataTypes(dataTypes); assertThatThrownBy(() -> { final JpaToscaDataTypes badDataTypes = new JpaToscaDataTypes(dataTypes); |