diff options
Diffstat (limited to 'runtime')
48 files changed, 142 insertions, 155 deletions
diff --git a/runtime/pom.xml b/runtime/pom.xml index 3a8ece35b..ef15198dc 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -662,6 +662,9 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> + <includes> + <include>**/*Test.java</include> + </includes> <forkCount>1C</forkCount> <reuseForks>true</reuseForks> <useSystemClassLoader>false</useSystemClassLoader> @@ -685,7 +688,7 @@ </additionalClasspathElement> </additionalClasspathElements> <includes> - <include>**/*ItCase.java</include> + <include>**/*ItTestCase.java</include> </includes> <forkCount>1C</forkCount> <reuseForks>true</reuseForks> diff --git a/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java b/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java index 62614e729..cf639a35d 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java +++ b/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java @@ -35,7 +35,6 @@ import org.onap.policy.common.utils.logging.LoggerUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java b/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java index 0e520dec1..1e5b003f1 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java @@ -26,7 +26,6 @@ package org.onap.policy.clamp.clds; import java.io.IOException; -import java.security.Principal; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -48,7 +47,6 @@ import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.User; -import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; public class ClampServlet extends CamelHttpTransportServlet { diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java b/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java index 27f706d77..8f492c761 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java @@ -34,7 +34,6 @@ import java.util.Date; import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; -import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.ExchangeBuilder; import org.onap.policy.clamp.clds.exception.cds.CdsParametersException; import org.onap.policy.clamp.clds.model.cds.CdsBpWorkFlowListResponse; diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java index 34f0662c7..0ac58fc80 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java @@ -24,7 +24,6 @@ package org.onap.policy.clamp.clds.config; import java.io.IOException; -import java.net.URL; import java.nio.charset.StandardCharsets; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Autowired; diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java b/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java index eb9de056c..7224493b5 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java @@ -26,7 +26,6 @@ package org.onap.policy.clamp.clds.filter; import java.io.ByteArrayInputStream; import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.net.URLDecoder; import java.nio.charset.StandardCharsets; import java.nio.file.StandardCopyOption; diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java b/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java index 9f5300a9f..9862728df 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java @@ -1,13 +1,10 @@ - /*- * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ - * 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. * You may obtain a copy of the License at diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java index 89046afd1..2ca463ede 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java @@ -24,11 +24,8 @@ package org.onap.policy.clamp.clds.sdc.controller.installer; import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.Path; import java.nio.file.Paths; import java.util.Enumeration; import java.util.HashMap; diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplate.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplate.java index 5c96f2c4a..8e619969d 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplate.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplate.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -148,9 +148,9 @@ public class JsonTemplate { * @return a boolean */ public boolean checkFields(JsonTemplate jsonTemplate) { - boolean duplicateFields = false; + var duplicateFields = false; if (jsonTemplate.getJsonTemplateFields().size() == this.getJsonTemplateFields().size()) { - int countMatchingFields = 0; + var countMatchingFields = 0; //loop each component of first for (JsonTemplateField jsonTemplateFieldToCheck : jsonTemplate.getJsonTemplateFields()) { for (JsonTemplateField jsonTemplateField : this.getJsonTemplateFields()) { diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java b/runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java index 5d09c065a..fcd375ad3 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java +++ b/runtime/src/main/java/org/onap/policy/clamp/clds/util/LoggingUtils.java @@ -292,7 +292,7 @@ public class LoggingUtils { * @param targetServiceName The target service name */ public void invoke(String targetEntity, String targetServiceName) { - final String invocationId = UUID.randomUUID().toString(); + final var invocationId = UUID.randomUUID().toString(); invokeContext(targetEntity, targetServiceName, invocationId); @@ -396,7 +396,7 @@ public class LoggingUtils { private <T extends URLConnection> T invokeGeneric(final T con, String targetEntity, String targetServiceName) { - final String invocationId = UUID.randomUUID().toString(); + final var invocationId = UUID.randomUUID().toString(); // Set standard HTTP headers on (southbound request) builder. con.setRequestProperty(OnapLogConstants.Headers.REQUEST_ID, diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java b/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java index 946edd767..9449c25eb 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java +++ b/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java @@ -26,13 +26,11 @@ package org.onap.policy.clamp.loop; import com.google.gson.JsonObject; -import java.io.IOException; import java.util.List; import java.util.Set; import javax.persistence.EntityNotFoundException; import org.onap.policy.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport; import org.onap.policy.clamp.loop.template.LoopTemplatesService; -import org.onap.policy.clamp.loop.template.PolicyModel; import org.onap.policy.clamp.loop.template.PolicyModelsService; import org.onap.policy.clamp.policy.microservice.MicroServicePolicy; import org.onap.policy.clamp.policy.microservice.MicroServicePolicyService; diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java b/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java index 53365806b..10d98e362 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java +++ b/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java @@ -120,7 +120,7 @@ public class CsarServiceInstaller { * @throws SdcArtifactInstallerException The SdcArtifactInstallerException */ public boolean isServiceAlreadyDeployed(CsarHandler csar) throws SdcArtifactInstallerException { - boolean alreadyInstalled = true; + var alreadyInstalled = true; var serviceDetails = JsonUtils.GSON.fromJson( JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class); alreadyInstalled = serviceRepository.existsById(serviceDetails.get("UUID").getAsString()); diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java b/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java index cc4e4c2fc..c955d2696 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java +++ b/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java @@ -33,7 +33,6 @@ import javax.persistence.Table; import javax.persistence.Transient; import org.hibernate.annotations.Type; import org.hibernate.annotations.TypeDef; -import org.hibernate.annotations.TypeDefs; import org.onap.policy.clamp.clds.util.JsonUtils; import org.onap.policy.clamp.dao.model.jsontype.StringJsonUserType; import org.slf4j.Logger; diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java index 7477ae31f..e15731fc7 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java +++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java @@ -163,8 +163,8 @@ public class LoopElementModel extends AuditEntity implements Serializable { @Override public int hashCode() { - final int prime = 31; - int result = 1; + final var prime = 31; + var result = 1; result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java index 0d57caada..741530e99 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java +++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java @@ -37,7 +37,6 @@ import javax.persistence.ManyToMany; import javax.persistence.Table; import org.hibernate.annotations.Type; import org.hibernate.annotations.TypeDef; -import org.hibernate.annotations.TypeDefs; import org.onap.policy.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.policy.clamp.loop.common.AuditEntity; import org.onap.policy.clamp.util.SemanticVersioning; diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java b/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java index 96edfa190..3f0f4e7b9 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java +++ b/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java @@ -37,7 +37,6 @@ import javax.persistence.ManyToMany; import javax.persistence.Table; import org.apache.commons.lang3.RandomStringUtils; import org.hibernate.annotations.TypeDef; -import org.hibernate.annotations.TypeDefs; import org.onap.policy.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport; import org.onap.policy.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.policy.clamp.loop.Loop; diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java index c7d67bd4e..203f2771e 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java +++ b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java @@ -40,7 +40,6 @@ import javax.persistence.Table; import javax.persistence.Transient; import org.apache.commons.lang3.RandomStringUtils; import org.hibernate.annotations.TypeDef; -import org.hibernate.annotations.TypeDefs; import org.onap.policy.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport; import org.onap.policy.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.policy.clamp.loop.Loop; diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java index 63df3a7b0..84bf72b62 100644 --- a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java +++ b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java @@ -32,8 +32,6 @@ import org.onap.policy.clamp.clds.tosca.update.ToscaConverterWithDictionarySuppo import org.onap.policy.clamp.loop.Loop; import org.onap.policy.clamp.loop.template.PolicyModelsRepository; import org.onap.policy.clamp.policy.PolicyService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/config/CldsUserJsonDecoderTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/config/CldsUserJsonDecoderTest.java index 605ab99ae..59d9e7320 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/config/CldsUserJsonDecoderTest.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/config/CldsUserJsonDecoderTest.java @@ -6,6 +6,7 @@ * reserved. * ================================================================================ * Modifications Copyright (c) 2019 Samsung + * 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. @@ -71,7 +72,7 @@ public class CldsUserJsonDecoderTest { assertThat(usersArray).hasSize(1); CldsUser user = usersArray[0]; assertThat(user.getUser()).isEqualTo(user1); - assertThat(user.getPassword()).isEqualTo(null); + assertThat(user.getPassword()).isNull(); assertThat(user.getPermissionsString()).isEmpty(); } diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java index 7390b65ba..eed3f4edb 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java @@ -74,8 +74,8 @@ public class SdcSingleControllerConfigurationTest { assertEquals(10, sdcConfig.getPollingInterval()); assertEquals(30, sdcConfig.getPollingTimeout()); - assertThat(SdcSingleControllerConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST) - .hasSameSizeAs(sdcConfig.getRelevantArtifactTypes()); + assertThat(sdcConfig.getRelevantArtifactTypes()) + .hasSameSizeAs(SdcSingleControllerConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST); assertEquals("ThePassword", sdcConfig.getKeyStorePassword()); assertTrue(sdcConfig.activateServerTLSAuth()); assertThat(sdcConfig.getMsgBusAddress()).contains("localhost"); @@ -103,6 +103,6 @@ public class SdcSingleControllerConfigurationTest { public final void testConsumerGroupWithNull() throws IOException { SdcSingleControllerConfiguration sdcConfig = loadControllerConfiguration("clds/sdc-controller-config-NULL.json", "sdc-controller1"); - assertTrue(sdcConfig.getConsumerGroup() == null); + assertNull(sdcConfig.getConsumerGroup()); } } diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItTestCase.java index 45d4d64b1..746b8381a 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItTestCase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights + * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Modifications Copyright (c) 2019 Samsung @@ -56,7 +56,7 @@ import org.springframework.test.context.junit4.SpringRunner; */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -public class AuthorizationControllerItCase { +public class AuthorizationControllerItTestCase { @Autowired private AuthorizationController auth; diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/CldsHealthcheckServiceItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/CldsHealthcheckServiceItTestCase.java index 52da63952..da2007e07 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/CldsHealthcheckServiceItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/CldsHealthcheckServiceItTestCase.java @@ -2,19 +2,19 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * Copyright (C) 2017-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. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ * =================================================================== @@ -39,7 +39,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; */ @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -public class CldsHealthcheckServiceItCase { +public class CldsHealthcheckServiceItTestCase { @Autowired private CldsHealthcheckService cldsHealthcheckService; diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/HttpsItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/HttpsItTestCase.java index 180c3094d..06f0c1310 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/HttpsItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/HttpsItTestCase.java @@ -59,7 +59,7 @@ import org.springframework.web.client.RestTemplate; @SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) @TestPropertySource(locations = "classpath:https/https-test.properties") @DirtiesContext -public class HttpsItCase { +public class HttpsItTestCase { @Value("${server.port}") private String httpsPort; diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItTestCase.java index 66c7f3589..367bd4109 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItTestCase.java @@ -56,12 +56,12 @@ import org.springframework.test.context.junit4.SpringRunner; @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @TestPropertySource(locations = "classpath:robotframework/robotframework-test.properties") @DirtiesContext -public class RobotItCase { +public class RobotItTestCase { @Value("${server.port}") private String httpPort; private static final int TIMEOUT_S = 150; - protected static final Logger logger = LoggerFactory.getLogger(RobotItCase.class); + protected static final Logger logger = LoggerFactory.getLogger(RobotItTestCase.class); @Test public void robotTests() throws Exception { diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/config/CldsReferencePropertiesItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/config/CldsReferencePropertiesItTestCase.java index c8b9932cc..eeed51c12 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/config/CldsReferencePropertiesItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/config/CldsReferencePropertiesItTestCase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights + * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,7 +36,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest -public class CldsReferencePropertiesItCase { +public class CldsReferencePropertiesItTestCase { @Autowired private ClampProperties refProp; diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/config/SdcControllersConfigurationItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/config/SdcControllersConfigurationItTestCase.java index 70aeccf59..cf4987fa8 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/config/SdcControllersConfigurationItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/config/SdcControllersConfigurationItTestCase.java @@ -20,8 +20,8 @@ package org.onap.policy.clamp.clds.it.config; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.google.gson.JsonSyntaxException; @@ -44,7 +44,7 @@ import org.springframework.test.util.ReflectionTestUtils; @RunWith(SpringRunner.class) @SpringBootTest @ActiveProfiles({"clamp-default", "clamp-default-user", "clamp-sdc-controller"}) -public class SdcControllersConfigurationItCase { +public class SdcControllersConfigurationItTestCase { @Autowired private SdcControllersConfiguration sdcControllersConfiguration; @@ -59,7 +59,7 @@ public class SdcControllersConfigurationItCase { loadFile("classpath:clds/sdc-controllers-config.json"); Map<String, SdcSingleControllerConfiguration> mapResult = sdcControllersConfiguration .getAllDefinedControllers(); - assertTrue(mapResult.size() == 2); + assertThat(mapResult).hasSize(2); assertEquals("sdc-controller1", mapResult.get("sdc-controller1").getSdcControllerName()); assertEquals("sdc-controller2", mapResult.get("sdc-controller2").getSdcControllerName()); } diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/sdc/controller/SdcSingleControllerItTestCase.java index 787118902..2201d1a2e 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/sdc/controller/SdcSingleControllerItTestCase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights + * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Modifications Copyright (c) 2019 Samsung @@ -58,7 +58,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest @ActiveProfiles({"clamp-default", "clamp-default-user", "clamp-sdc-controller"}) -public class SdcSingleControllerItCase { +public class SdcSingleControllerItTestCase { private static final String CSAR_ARTIFACT_NAME = "testArtifact.csar"; private static final String SERVICE_UUID = "serviceUUID"; @@ -115,7 +115,7 @@ public class SdcSingleControllerItCase { // when sdcSingleController.treatNotification(buildFakeSdcNotification()); // then - Assertions.assertThat(sdcSingleController.getNbOfNotificationsOngoing()).isEqualTo(0); + Assertions.assertThat(sdcSingleController.getNbOfNotificationsOngoing()).isZero(); } @Test diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponseCacheTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponseCacheItTestCase.java index f406e5ed2..71d5f2dab 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponseCacheTestItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponseCacheItTestCase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,7 +42,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -public class DcaeInventoryResponseCacheTestItCase { +public class DcaeInventoryResponseCacheItTestCase { public static DcaeInventoryCache inventoryCache = new DcaeInventoryCache(); diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponseTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponseTest.java index a246e0efa..25b3b92c9 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponseTest.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponseTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -53,7 +53,7 @@ public class DcaeInventoryResponseTest { int value = 0; for (DcaeInventoryResponse inventoryResponse : responseSet) { - assertThat(Integer.valueOf(inventoryResponse.getAsdcResourceId()) == value++).isTrue(); + assertThat(Integer.valueOf(inventoryResponse.getAsdcResourceId())).isSameAs(value++); } } } diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/DictionaryRepositoriesTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/DictionaryRepositoriesTestItTestCase.java index f70e74cd6..5880bad0b 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/DictionaryRepositoriesTestItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/DictionaryRepositoriesTestItTestCase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,7 +39,7 @@ import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = Application.class) -public class DictionaryRepositoriesTestItCase { +public class DictionaryRepositoriesTestItTestCase { @Autowired private DictionaryRepository dictionaryRepository; @@ -76,13 +76,13 @@ public class DictionaryRepositoriesTestItCase { dictionaryRepository.save(dictionaryTest1); List<String> res1 = dictionaryRepository.getAllDictionaryNames(); - assertThat(res1.size()).isGreaterThanOrEqualTo(1); + assertThat(res1.size()).isPositive(); assertThat(res1).contains("testDictionary1"); dictionaryRepository.save(dictionaryTest2); List<String> res2 = dictionaryRepository.getAllDictionaryNames(); assertThat(res2.size()).isGreaterThanOrEqualTo(2); - assertThat(res2).contains("testDictionary1"); - assertThat(res2).contains("testDictionary2"); + assertThat(res2).contains("testDictionary1") + .contains("testDictionary2"); } } diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/JsonTemplateFieldTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/JsonTemplateFieldTest.java index 3eaa0ce51..ad8593787 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/JsonTemplateFieldTest.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/JsonTemplateFieldTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -49,11 +49,11 @@ public class JsonTemplateFieldTest extends TestCase { * Test equals method. */ public void testEqualsMethod() { - assertTrue(field1.equals(field2)); - assertTrue(field1.equals(field3)); - assertTrue(field1.equals(field4)); - assertTrue(field1.equals(field5)); - assertTrue(field1.equals(field6)); + assertEquals(field1, field2); + assertEquals(field1, field3); + assertEquals(field1, field4); + assertEquals(field1, field5); + assertEquals(field1, field6); } /** @@ -64,6 +64,6 @@ public class JsonTemplateFieldTest extends TestCase { assertFalse(field1.compareWithField(field3)); assertFalse(field1.compareWithField(field4)); assertFalse(field1.compareWithField(field5)); - assertTrue(field1.equals(field6)); + assertEquals(field1, field6); } -}
\ No newline at end of file +} diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/JsonTemplateTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/JsonTemplateTest.java index dc27d8aaa..63bc36321 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/JsonTemplateTest.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/JsonTemplateTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -58,12 +58,11 @@ public class JsonTemplateTest extends TestCase { toTest.setVisibility("moreField", true); toTest.setStatic("moreField", true); toTest.updateValueField("moreField", "testValue"); - + assertTrue(toTest.isVisible("moreField")); - assertTrue(toTest.getSpecificField("moreField").getValue().equals("testValue")); + assertEquals("testValue", toTest.getSpecificField("moreField").getValue()); assertTrue(toTest.fieldStaticStatus("moreField")); - assertTrue(toTest.toString() - .equals(" templateFields : [type null null null, description null null null, " - + "enum null null null, moreField testValue true true]")); + assertEquals(" templateFields : [type null null null, description null null null, " + + "enum null null null, moreField testValue true true]", toTest.toString()); } -}
\ No newline at end of file +} diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItTestCase.java index 658419d4c..1d78d6ce1 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaConverterWithDictionarySupportItTestCase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,7 +47,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = Application.class) @ActiveProfiles({"clamp-default", "clamp-default-user", "default-dictionary-elements"}) -public class ToscaConverterWithDictionarySupportItCase { +public class ToscaConverterWithDictionarySupportItTestCase { @Autowired private DictionaryService dictionaryService; diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/CsarInstallerItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/CsarInstallerItTestCase.java index b0abf832b..661696e55 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/loop/CsarInstallerItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/loop/CsarInstallerItTestCase.java @@ -75,7 +75,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) @ActiveProfiles({"clamp-default", "clamp-default-user", "clamp-sdc-controller"}) -public class CsarInstallerItCase { +public class CsarInstallerItTestCase { private static final String CSAR_ARTIFACT_NAME_CDS = "example/sdc/service_Vloadbalancerms_cds.csar"; private static final String CSAR_ARTIFACT_NAME_NO_CDS = "example/sdc/service_Vloadbalancerms_no_cds.csar"; @@ -312,7 +312,7 @@ public class CsarInstallerItCase { assertThat(((LoopTemplateLoopElementModel) (loopTemplate.getLoopElementModelsUsed().toArray()[0])) .getLoopElementModel().getName()).isNotEmpty(); - assertThat(policyModelsRepository.findAll().size()).isGreaterThanOrEqualTo(1); + assertThat(policyModelsRepository.findAll().size()).isPositive(); assertThat(policyModelsRepository .existsById(new PolicyModelId("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0"))).isTrue(); assertThat(policyModelsRepository diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/DeployFlowTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/DeployFlowItTestCase.java index 4d02b10dc..bfd5b0377 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/loop/DeployFlowTestItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/loop/DeployFlowItTestCase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,7 +47,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -public class DeployFlowTestItCase { +public class DeployFlowItTestCase { private Gson gson = new Gson(); @Autowired @@ -159,7 +159,7 @@ public class DeployFlowTestItCase { camelContext.createProducerTemplate().send("direct:undeploy-loop", myCamelExchange); Loop loopAfterTest = loopService.getLoop("ControlLoopTest"); - assertThat(loopAfterTest.getDcaeDeploymentStatusUrl().contains("/uninstall")).isTrue(); + assertThat(loopAfterTest.getDcaeDeploymentStatusUrl()).contains("/uninstall"); assertThat(loopAfterTest.getDcaeDeploymentId()).isNull(); } @@ -196,9 +196,8 @@ public class DeployFlowTestItCase { Loop loopAfterTest = loopService.getLoop("ControlLoopTest2"); Set<MicroServicePolicy> policyList = loopAfterTest.getMicroServicePolicies(); for (MicroServicePolicy policy : policyList) { - assertThat(policy.getDcaeDeploymentStatusUrl().contains("/uninstall")).isTrue(); + assertThat(policy.getDcaeDeploymentStatusUrl()).contains("/uninstall"); assertThat(policy.getDcaeDeploymentId()).isNull(); - } assertThat(loopAfterTest.getDcaeDeploymentStatusUrl()).isNull(); assertThat(loopAfterTest.getDcaeDeploymentId()).isNull(); @@ -224,7 +223,7 @@ public class DeployFlowTestItCase { "{\"param1\":\"value1\"}", true); loopTest.addMicroServicePolicy(microServicePolicy); loopService.saveOrUpdateLoop(loopTest); - assertThat(loopTest.getComponents().size()).isEqualTo(2); + assertThat(loopTest.getComponents()).hasSize(2); assertThat(loopTest.getComponent("DCAE")).isNotNull(); assertThat(loopTest.getComponent("POLICY")).isNotNull(); Exchange myCamelExchange = ExchangeBuilder.anExchange(camelContext).withProperty("loopObject", loopTest) @@ -235,7 +234,7 @@ public class DeployFlowTestItCase { assertThat(loopTest.getComponent("DCAE").getState().getStateName()).isEqualTo("BLUEPRINT_DEPLOYED"); Loop loopAfterTest = loopService.getLoop("ControlLoopTest"); - assertThat(loopAfterTest.getComponents().size()).isEqualTo(2); + assertThat(loopAfterTest.getComponents()).hasSize(2); assertThat(loopAfterTest.getComponent("DCAE")).isNotNull(); assertThat(loopAfterTest.getComponent("POLICY")).isNotNull(); } @@ -263,7 +262,7 @@ public class DeployFlowTestItCase { loopTest.addMicroServicePolicy(microServicePolicy); loopTest.addMicroServicePolicy(microServicePolicy2); loopService.saveOrUpdateLoop(loopTest); - assertThat(loopTest.getComponents().size()).isEqualTo(3); + assertThat(loopTest.getComponents()).hasSize(3); assertThat(loopTest.getComponent("DCAE")).isNull(); assertThat(loopTest.getComponent("DCAE_configPolicyTest")).isNotNull(); assertThat(loopTest.getComponent("DCAE_configPolicyTest2")).isNotNull(); @@ -279,7 +278,7 @@ public class DeployFlowTestItCase { .isEqualTo("BLUEPRINT_DEPLOYED"); Loop loopAfterTest = loopService.getLoop("ControlLoopTest"); - assertThat(loopAfterTest.getComponents().size()).isEqualTo(3); + assertThat(loopAfterTest.getComponents()).hasSize(3); assertThat(loopAfterTest.getComponent("DCAE")).isNull(); assertThat(loopAfterTest.getComponent("POLICY")).isNotNull(); assertThat(loopTest.getComponent("DCAE_configPolicyTest")).isNotNull(); diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/ExternalComponentStateTest.java b/runtime/src/test/java/org/onap/policy/clamp/loop/ExternalComponentStateTest.java index a73b2784b..567cad69d 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/loop/ExternalComponentStateTest.java +++ b/runtime/src/test/java/org/onap/policy/clamp/loop/ExternalComponentStateTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,34 +34,34 @@ public class ExternalComponentStateTest { @Test public void generalTest() { - assertThat(state.toString()).isEqualTo("NOT_SENT"); + assertThat(state).hasToString("NOT_SENT"); state.setLevel(70); assertThat(state.getLevel()).isEqualTo(70); } @Test public void equalsTest() { - assertThat(state.equals(null)).isEqualTo(false); + assertThat(state.equals(null)).isFalse(); ExternalComponentState state2 = new ExternalComponentState("NOT_SENT", "The policies defined have NOT yet been created on the policy engine", 90); - assertThat(state.equals(state2)).isEqualTo(true); + assertThat(state.equals(state2)).isTrue(); - assertThat(state.equals(12)).isEqualTo(false); + assertThat(state.equals(12)).isFalse(); state2.setLevel(70); - assertThat(state.equals(state2)).isEqualTo(true); + assertThat(state.equals(state2)).isTrue(); ExternalComponentState state3 = new ExternalComponentState("SENT", "The policies defined have NOT yet been created on the policy engine", 90); - assertThat(state.equals(state3)).isEqualTo(false); + assertThat(state.equals(state3)).isFalse(); ExternalComponentState state4 = new ExternalComponentState(null, "The policies defined have NOT yet been created on the policy engine", 90); ExternalComponentState state5 = new ExternalComponentState(null, "The policies defined have NOT yet been", 50); - assertThat(state4.equals(state3)).isEqualTo(false); - assertThat(state4.equals(state5)).isEqualTo(true); + assertThat(state4.equals(state3)).isFalse(); + assertThat(state4.equals(state5)).isTrue(); } @Test @@ -79,4 +79,4 @@ public class ExternalComponentStateTest { assertThat(state.compareTo(state4)).isEqualTo(-1); } -}
\ No newline at end of file +} diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerItTestCase.java index 54ecaa639..865c83a8b 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerItTestCase.java @@ -4,7 +4,9 @@ * ================================================================================ * Copyright (C) 2019 Nokia Intellectual Property. All rights * reserved. + * ================================================================================ * Modifications Copyright (C) 2019 Huawei Technologies Co., Ltd. + * 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. @@ -52,7 +54,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -public class LoopControllerTestItCase { +public class LoopControllerItTestCase { private static final String EXAMPLE_LOOP_NAME = "ClosedLoopTest"; private static final String EXAMPLE_JSON = "{\"testName\":\"testValue\"}"; @@ -161,7 +163,7 @@ public class LoopControllerTestItCase { Set<OperationalPolicy> opPolicyList = newLoop.getOperationalPolicies(); assertThat(opPolicyList.size()).isEqualTo(1); for (OperationalPolicy policy : opPolicyList) { - assertThat(policy.getName().contains("OPERATIONAL_serviceName")).isTrue(); + assertThat(policy.getName()).contains("OPERATIONAL_serviceName"); Assertions.assertThat(policy.getPolicyModel().getPolicyModelType()).isEqualTo("testPolicyModel"); Assertions.assertThat(policy.getPolicyModel().getVersion()).isEqualTo("1.0.0"); } diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceItTestCase.java index ab256eafb..1dac230fe 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceItTestCase.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2019 Huawei Technologies Co., Ltd. * ================================================================================ + * 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. * You may obtain a copy of the License at @@ -41,7 +43,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -public class LoopLogServiceTestItCase { +public class LoopLogServiceItTestCase { private static final String EXAMPLE_LOOP_NAME = "ClosedLoopTest"; private static final String EXAMPLE_JSON = "{\"testName\":\"testValue\"}"; diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopRepositoriesItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopRepositoriesItTestCase.java index e18dd2475..24dd92909 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopRepositoriesItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopRepositoriesItTestCase.java @@ -58,7 +58,7 @@ import org.springframework.transaction.annotation.Transactional; @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = Application.class) -public class LoopRepositoriesItCase { +public class LoopRepositoriesItTestCase { private Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); @@ -177,21 +177,21 @@ public class LoopRepositoriesItCase { assertThat(loopInDb).isEqualToIgnoringGivenFields(loopTest, "components", "createdDate", "updatedDate", "createdBy", "updatedBy"); - assertThat(loopRepository.existsById(loopTest.getName())).isEqualTo(true); - assertThat(operationalPolicyService.isExisting(opPolicy.getName())).isEqualTo(true); - assertThat(microServicePolicyService.isExisting(microServicePolicy.getName())).isEqualTo(true); + assertThat(loopRepository.existsById(loopTest.getName())).isTrue(); + assertThat(operationalPolicyService.isExisting(opPolicy.getName())).isTrue(); + assertThat(microServicePolicyService.isExisting(microServicePolicy.getName())).isTrue(); assertThat(loopLogRepository.existsById(loopLog.getId())).isEqualTo(true); - assertThat(loopTemplateRepository.existsById(loopInDb.getLoopTemplate().getName())).isEqualTo(true); - assertThat(loopTemplateRepository.existsById(loopInDb.getLoopTemplate().getName())).isEqualTo(true); - assertThat(servicesRepository.existsById(loopInDb.getModelService().getServiceUuid())).isEqualTo(true); + assertThat(loopTemplateRepository.existsById(loopInDb.getLoopTemplate().getName())).isTrue(); + assertThat(loopTemplateRepository.existsById(loopInDb.getLoopTemplate().getName())).isTrue(); + assertThat(servicesRepository.existsById(loopInDb.getModelService().getServiceUuid())).isTrue(); assertThat(microServiceModelsRepository.existsById( loopInDb.getLoopTemplate().getLoopElementModelsUsed().first().getLoopElementModel().getName())) - .isEqualTo(true); + .isTrue(); assertThat(policyModelsRepository.existsById(new PolicyModelId( loopInDb.getLoopTemplate().getLoopElementModelsUsed().first().getLoopElementModel().getPolicyModels() .first().getPolicyModelType(), loopInDb.getLoopTemplate().getLoopElementModelsUsed().first().getLoopElementModel().getPolicyModels() - .first().getVersion()))).isEqualTo(true); + .first().getVersion()))).isTrue(); // Now attempt to read from database Loop loopInDbRetrieved = loopRepository.findById(loopTest.getName()).get(); @@ -238,21 +238,21 @@ public class LoopRepositoriesItCase { // Attempt to delete the object and check it has well been cascaded loopRepository.delete(loopInDbRetrieved); - assertThat(loopRepository.existsById(loopTest.getName())).isEqualTo(false); - assertThat(operationalPolicyService.isExisting(opPolicy.getName())).isEqualTo(false); - assertThat(microServicePolicyService.isExisting(microServicePolicy.getName())).isEqualTo(true); - assertThat(loopLogRepository.existsById(loopLog.getId())).isEqualTo(false); - assertThat(loopTemplateRepository.existsById(loopInDb.getLoopTemplate().getName())).isEqualTo(true); - assertThat(servicesRepository.existsById(loopInDb.getModelService().getServiceUuid())).isEqualTo(true); + assertThat(loopRepository.existsById(loopTest.getName())).isFalse(); + assertThat(operationalPolicyService.isExisting(opPolicy.getName())).isFalse(); + assertThat(microServicePolicyService.isExisting(microServicePolicy.getName())).isTrue(); + assertThat(loopLogRepository.existsById(loopLog.getId())).isFalse(); + assertThat(loopTemplateRepository.existsById(loopInDb.getLoopTemplate().getName())).isTrue(); + assertThat(servicesRepository.existsById(loopInDb.getModelService().getServiceUuid())).isTrue(); assertThat(microServiceModelsRepository.existsById( loopInDb.getLoopTemplate().getLoopElementModelsUsed().first().getLoopElementModel().getName())) - .isEqualTo(true); + .isTrue(); assertThat(policyModelsRepository.existsById(new PolicyModelId( loopInDb.getLoopTemplate().getLoopElementModelsUsed().first().getLoopElementModel().getPolicyModels() .first().getPolicyModelType(), loopInDb.getLoopTemplate().getLoopElementModelsUsed().first().getLoopElementModel().getPolicyModels() - .first().getVersion()))).isEqualTo(true); + .first().getVersion()))).isTrue(); } } diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopServiceTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopServiceItTestCase.java index 74092727c..e38dee552 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopServiceTestItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopServiceItTestCase.java @@ -51,7 +51,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -public class LoopServiceTestItCase { +public class LoopServiceItTestCase { private static final String EXAMPLE_LOOP_NAME = "ClosedLoopTest"; private static final String EXAMPLE_JSON = "{\"testName\":\"testValue\"}"; @@ -330,10 +330,10 @@ public class LoopServiceTestItCase { loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(microServicePolicy)); // Verify it's there - assertThat(loopsRepository.findById(EXAMPLE_LOOP_NAME).orElse(null)).isNotNull(); + assertThat(loopsRepository.findById(EXAMPLE_LOOP_NAME)).isPresent(); loopService.deleteLoop(EXAMPLE_LOOP_NAME); // Verify it's well deleted and has been cascaded, except for Microservice - assertThat(loopsRepository.findById(EXAMPLE_LOOP_NAME).orElse(null)).isNull(); + assertThat(loopsRepository.findById(EXAMPLE_LOOP_NAME)).isNotPresent(); assertThat(microServicePolicyService.isExisting("microPolicy")).isTrue(); assertThat(operationalPolicyService.isExisting("opPolicy")).isFalse(); assertThat(loopLogService.isExisting(((LoopLog) loop.getLoopLogs().toArray()[0]).getId())).isFalse(); @@ -378,4 +378,4 @@ public class LoopServiceTestItCase { private Loop createTestLoop(String loopName, String loopBlueprint) { return new Loop(loopName); } -}
\ No newline at end of file +} diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopTemplatesServiceItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopTemplatesServiceItTestCase.java index dba7c39a9..26ab9b37c 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopTemplatesServiceItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopTemplatesServiceItTestCase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,7 +46,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -public class LoopTemplatesServiceItCase { +public class LoopTemplatesServiceItTestCase { @Autowired LoopTemplatesService loopTemplatesService; diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/PolicyModelServiceItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/PolicyModelServiceItTestCase.java index a2563b8d3..c47c55495 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/loop/PolicyModelServiceItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/loop/PolicyModelServiceItTestCase.java @@ -55,7 +55,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -public class PolicyModelServiceItCase { +public class PolicyModelServiceItTestCase { @Autowired PolicyModelsService policyModelsService; @@ -98,8 +98,7 @@ public class PolicyModelServiceItCase { PolicyModel actualPolicyModel = policyModelsService.saveOrUpdatePolicyModel(policyModel); // then - assertThat(actualPolicyModel).isNotNull(); - assertThat(actualPolicyModel).isEqualTo(policyModelsRepository + assertThat(actualPolicyModel).isNotNull().isEqualTo(policyModelsRepository .findById(new PolicyModelId(actualPolicyModel.getPolicyModelType(), actualPolicyModel.getVersion())) .get()); diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/ServiceTest.java b/runtime/src/test/java/org/onap/policy/clamp/loop/ServiceTest.java index 8f28299fd..41fa61152 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/loop/ServiceTest.java +++ b/runtime/src/test/java/org/onap/policy/clamp/loop/ServiceTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights + * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -44,11 +44,11 @@ public class ServiceTest { Service service2 = new Service(JsonUtils.GSON.fromJson(serviceStr2, JsonObject.class), null, "1.0"); - Service service3 = new Service(JsonUtils.GSON.fromJson(serviceStr3, JsonObject.class), + Service service3 = new Service(JsonUtils.GSON.fromJson(serviceStr3, JsonObject.class), JsonUtils.GSON.fromJson(resourceStr, JsonObject.class), "1.0"); - assertThat(service1.equals(service2)).isEqualTo(true); - assertThat(service1.equals(service3)).isEqualTo(false); + assertThat(service2).isEqualTo(service1); + assertThat(service3).isNotEqualTo(service1); } } diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/downloader/PolicyEngineControllerTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/policy/downloader/PolicyEngineControllerItTestCase.java index 8fbd2712b..81eba487c 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/policy/downloader/PolicyEngineControllerTestItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/policy/downloader/PolicyEngineControllerItTestCase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. * Modifications Copyright (C) 2021 Nordix Foundation. * ================================================================================ @@ -48,7 +48,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) @ActiveProfiles({"clamp-default", "clamp-policy-controller"}) -public class PolicyEngineControllerTestItCase { +public class PolicyEngineControllerItTestCase { @Autowired PolicyEngineController policyController; @@ -72,9 +72,8 @@ public class PolicyEngineControllerTestItCase { List<PolicyModel> policyModelsList = policyModelsRepository.findAll(); assertThat(policyModelsList.size()).isGreaterThanOrEqualTo(5); assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.operational.common.Drools", - null, "1.0.0")); - assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.operational.common.Apex", - null, "1.0.0")); + null, "1.0.0")) + .contains(new PolicyModel("onap.policies.controlloop.operational.common.Apex", null, "1.0.0")); assertThat(policyModelsList) .contains(new PolicyModel("onap.policies.controlloop.guard.common.FrequencyLimiter", null, "1.0.0")); assertThat(policyModelsList) diff --git a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseItTestCase.java index f4e171174..7824be460 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseTestItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/runtime/RuntimeCommissioningResponseItTestCase.java @@ -2,6 +2,8 @@ * ============LICENSE_START======================================================= * Copyright (C) 2021 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. * You may obtain a copy of the License at @@ -36,7 +38,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -public class RuntimeCommissioningResponseTestItCase { +public class RuntimeCommissioningResponseItTestCase { @Autowired CamelContext camelContext; @@ -86,7 +88,7 @@ public class RuntimeCommissioningResponseTestItCase { .withProperty("raiseHttpExceptionFlag", "true") .build()); - assertThat(exchangeResponse.getIn().getBody().toString()).isEqualTo(SAMPLE_TOSCA_TEMPLATE); + assertThat(exchangeResponse.getIn().getBody()).hasToString(SAMPLE_TOSCA_TEMPLATE); } @Test diff --git a/runtime/src/test/java/org/onap/policy/clamp/tosca/DictionaryServiceItCase.java b/runtime/src/test/java/org/onap/policy/clamp/tosca/DictionaryServiceItTestCase.java index fdde53a21..382d5cd44 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/tosca/DictionaryServiceItCase.java +++ b/runtime/src/test/java/org/onap/policy/clamp/tosca/DictionaryServiceItTestCase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,6 +24,7 @@ package org.onap.policy.clamp.tosca; import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -39,7 +40,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -public class DictionaryServiceItCase { +public class DictionaryServiceItTestCase { @Autowired private DictionaryService dictionaryService; @@ -124,7 +125,7 @@ public class DictionaryServiceItCase { assertTrue(updatedDictionary2.getDictionaryElements().contains(dictionaryElement)); updatedDictionary2.getDictionaryElements().forEach(element -> { if (element.equals(dictionaryElement)) { - assertTrue(element.getDescription().equals(dictionaryElement.getDescription())); + assertEquals(dictionaryElement.getDescription(), element.getDescription()); } }); @@ -172,7 +173,7 @@ public class DictionaryServiceItCase { dictionaryService.getDictionary("Test"); } catch (Exception e) { assertThat(e).isInstanceOf(EntityNotFoundException.class); - assertTrue(e.getMessage().equals("Couldn't find Dictionary named: Test")); + assertEquals("Couldn't find Dictionary named: Test", e.getMessage()); } } @@ -189,7 +190,7 @@ public class DictionaryServiceItCase { try { dictionaryService.getDictionary("Dictionary1"); } catch (EntityNotFoundException e) { - assertTrue(e.getMessage().equals("Couldn't find Dictionary named: Dictionary1")); + assertEquals("Couldn't find Dictionary named: Dictionary1", e.getMessage()); } } @@ -205,7 +206,7 @@ public class DictionaryServiceItCase { try { dictionaryService.getDictionary("Dictionary1"); } catch (EntityNotFoundException e) { - assertTrue(e.getMessage().equals("Couldn't find Dictionary named: Dictionary1")); + assertEquals("Couldn't find Dictionary named: Dictionary1", e.getMessage()); } } diff --git a/runtime/src/test/java/org/onap/policy/clamp/util/PassDecoderTest.java b/runtime/src/test/java/org/onap/policy/clamp/util/PassDecoderTest.java index 7fd0cb91d..eb5e1d522 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/util/PassDecoderTest.java +++ b/runtime/src/test/java/org/onap/policy/clamp/util/PassDecoderTest.java @@ -47,7 +47,7 @@ public class PassDecoderTest { @Test public final void testDecryption() throws Exception { String decodedPass = PassDecoder.decode(encrypted, "classpath:clds/aaf/org.onap.clamp.keyfile"); - assertEquals(decodedPass, "China in the Spring"); + assertEquals("China in the Spring", decodedPass); assertEquals("Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U", PassDecoder .decode("enc:JPV4p067JlSXt2Fet9bfuI8JpkS4ZGYVcgypcPs98gXjgjCjTze_d3JxqmlKaaakdiOjIcEC_MJh6-5pJTLgdc", "classpath:clds/aaf/org.onap.clamp.keyfile")); diff --git a/runtime/src/test/java/org/onap/policy/clamp/util/SemanticVersioningTest.java b/runtime/src/test/java/org/onap/policy/clamp/util/SemanticVersioningTest.java index 604ce55db..0ef10ae2a 100644 --- a/runtime/src/test/java/org/onap/policy/clamp/util/SemanticVersioningTest.java +++ b/runtime/src/test/java/org/onap/policy/clamp/util/SemanticVersioningTest.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights + * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights * reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -61,9 +61,9 @@ public class SemanticVersioningTest { */ @Test public void compareEqualsTest() { - assertThat(SemanticVersioning.compare("1.0.0", "1.0.0")).isEqualTo(0); + assertThat(SemanticVersioning.compare("1.0.0", "1.0.0")).isZero(); assertThat(SemanticVersioning.compare("1.0.0.0", "1.0.0")).isEqualTo(1); - assertThat(SemanticVersioning.compare("1.2.3", "1.2.3")).isEqualTo(0); + assertThat(SemanticVersioning.compare("1.2.3", "1.2.3")).isZero(); assertThat(SemanticVersioning.compare("1.2.3", "1.2.3.0")).isEqualTo(-1); } @@ -73,7 +73,7 @@ public class SemanticVersioningTest { */ @Test public void compareNullTest() { - assertThat(SemanticVersioning.compare(null, null)).isEqualTo(0); + assertThat(SemanticVersioning.compare(null, null)).isZero(); assertThat(SemanticVersioning.compare(null, "1.0")).isEqualTo(-1); assertThat(SemanticVersioning.compare("1.0", null)).isEqualTo(1); } |