summaryrefslogtreecommitdiffstats
path: root/services/services-engine/src/test/java
diff options
context:
space:
mode:
authorlapentafd <francesco.lapenta@est.tech>2021-06-16 12:23:23 +0100
committerlapentafd <francesco.lapenta@est.tech>2021-06-18 10:27:44 +0100
commit782b1a82328a1ba95d370a014c587e1ba13ca464 (patch)
tree9a5482251e6c995285ba8e2f7320ad78baf2d883 /services/services-engine/src/test/java
parent12f634160f11d03265fac84c8d10cb8765e16187 (diff)
Fix Sonar Issues in apex-pdp-services-engine
Test refactoring and local-variable type inference replaced Issue-ID: POLICY-3093 Change-Id: I0c5506f27ea53da7740acce87a25060ba2bce7f4 Signed-off-by: lapentafd <francesco.lapenta@est.tech>
Diffstat (limited to 'services/services-engine/src/test/java')
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParametersTest.java2
-rw-r--r--services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java34
2 files changed, 22 insertions, 14 deletions
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParametersTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParametersTest.java
index 609dc31c9..26445c1fb 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParametersTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FileCarrierTechnologyParametersTest.java
@@ -101,7 +101,7 @@ public class FileCarrierTechnologyParametersTest {
@Test
public void getStartDelay() {
- assertThat(parameters.getStartDelay()).isEqualTo(0L);
+ assertThat(parameters.getStartDelay()).isZero();
}
@Test
diff --git a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
index e9a1a858e..3fe96a64f 100644
--- a/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
+++ b/services/services-engine/src/test/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImplTest.java
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -142,20 +142,27 @@ public class EngineServiceImplTest {
ModelService.clear();
}
- @Test
- public void testEngineServiceImplSanity() throws ApexException {
- assertThatThrownBy(() -> EngineServiceImpl.create(null)).isInstanceOf(ApexException.class)
- .hasMessage("engine service configuration parameters are null");
+ private EngineServiceParameters makeConfig() {
EngineServiceParameters config = new EngineServiceParameters();
config.setInstanceCount(0);
- assertThatThrownBy(() -> EngineServiceImpl.create(config)).isInstanceOf(ApexException.class)
- .hasMessageContaining("Invalid engine service configuration parameters");
-
config.setId(123);
config.setEngineKey(new AxArtifactKey("Engine", "0.0.1"));
config.setInstanceCount(1);
config.setPolicyModel("policyModelContent");
+ return config;
+ }
+
+ @Test
+ public void testEngineServiceImplSanity() throws ApexException {
+ assertThatThrownBy(() -> EngineServiceImpl.create(null)).isInstanceOf(ApexException.class)
+ .hasMessage("engine service configuration parameters are null");
+
+ EngineServiceParameters invalidConfig = new EngineServiceParameters();
+ invalidConfig.setInstanceCount(0);
+ assertThatThrownBy(() -> EngineServiceImpl.create(invalidConfig)).isInstanceOf(ApexException.class)
+ .hasMessageContaining("Invalid engine service configuration parameters");
+ EngineServiceParameters config = makeConfig();
EngineServiceImpl esImpl = EngineServiceImpl.create(config);
assertEquals("Engine:0.0.1", esImpl.getKey().getId());
@@ -201,7 +208,12 @@ public class EngineServiceImplTest {
assertTrue(esImpl.isStopped(null));
assertTrue(esImpl.isStopped(new AxArtifactKey("DummyKey", "0.0.1")));
assertTrue(esImpl.isStopped(esImpl.getEngineKeys().iterator().next()));
+ }
+ @Test
+ public void testEngineServiceExceptions() throws ApexException {
+ EngineServiceParameters config = makeConfig();
+ EngineServiceImpl esImpl = EngineServiceImpl.create(config);
assertThatThrownBy(() -> esImpl.start(null)).isInstanceOf(ApexException.class)
.hasMessage("engine key must be specified and may not be null");
@@ -284,11 +296,7 @@ public class EngineServiceImplTest {
@Test
public void testApexImplModelWIthModel() throws ApexException {
- EngineServiceParameters config = new EngineServiceParameters();
- config.setId(123);
- config.setEngineKey(new AxArtifactKey("Engine", "0.0.1"));
- config.setInstanceCount(1);
- config.setPolicyModel("policyModelContent");
+ EngineServiceParameters config = makeConfig();
EngineServiceImpl esImpl = EngineServiceImpl.create(config);
assertEquals("Engine:0.0.1", esImpl.getKey().getId());