From 02847bc3889fe3c3a419612ea7a94eca8794bdc6 Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Fri, 8 Sep 2017 17:48:10 +0200 Subject: Rework some sonar critical and major bugs Class renamed to AbstractModelELement, exceptions reworked and IT tests as well Change-Id: Ief2b09b0e36776519338834e2af61aa6e638ee91 Issue-Id: CLAMP-43 Signed-off-by: Determe, Sebastien (sd378r) --- .../java/org/onap/clamp/clds/client/req/SdcReqTest.java | 4 ++-- src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java | 2 +- .../java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java | 14 +++++++++----- .../org/onap/clamp/clds/model/prop/CustomModelElement.java | 2 +- 4 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/test/java/org') diff --git a/src/test/java/org/onap/clamp/clds/client/req/SdcReqTest.java b/src/test/java/org/onap/clamp/clds/client/req/SdcReqTest.java index 20b85d6f..a283f43d 100644 --- a/src/test/java/org/onap/clamp/clds/client/req/SdcReqTest.java +++ b/src/test/java/org/onap/clamp/clds/client/req/SdcReqTest.java @@ -40,11 +40,11 @@ import org.onap.clamp.clds.model.prop.ModelProperties; public class SdcReqTest { - String baseUrl = "AYBABTU"; + String baseUrl = "AYBABTU"; String serviceInvariantUUID = "serviceInvariantUUID"; @Test - public void getSdcReqUrlsListNoGlobalPropTest() throws Exception { + public void getSdcReqUrlsListNoGlobalPropTest() { ModelProperties prop = mock(ModelProperties.class); SdcCatalogServices sdcCatalogServices = mock(SdcCatalogServices.class); DelegateExecution delegateExecution = mock(DelegateExecution.class); diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java index 19fad480..69df9721 100644 --- a/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java +++ b/src/test/java/org/onap/clamp/clds/it/PolicyClientIT.java @@ -119,7 +119,7 @@ public class PolicyClientIT extends AbstractIT { try { responseMessage = policyClient.sendMicroServiceInJson(policyJson, prop, tcaPolicyRequestUuid); } catch (Exception e) { - assertTrue(e.getMessage().contains("Policy send failed: PE500 ")); + assertTrue(e.getMessage().contains("Exception while communicating with Policy")); } System.out.println(responseMessage); } diff --git a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java index 5d08e5ec..a12d6b7d 100644 --- a/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java +++ b/src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesIT.java @@ -202,9 +202,10 @@ public class SdcCatalogServicesIT extends AbstractIT { @Test public void getServiceUuidFromServiceInvariantIdTest() throws Exception { SdcCatalogServices spy = Mockito.spy(sdcCatalogWired); - Mockito.when(spy.getSdcServicesInformation(null)).thenReturn(IOUtils.toString( - SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8")); + Mockito.doReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8")) + .when(spy).getSdcServicesInformation(null); // Try the vcts4 version 1.0, this one should be replaced by 1.1 so it // should not exist, returning empty string String resUuidVcts4Null = spy.getServiceUuidFromServiceInvariantId("a33ed748-3477-4434-b3f3-b5560f5e7d9b"); @@ -228,8 +229,10 @@ public class SdcCatalogServicesIT extends AbstractIT { @Test public void getCldsServiceDataWithAlarmConditionsTest() throws Exception { SdcCatalogServices spy = Mockito.spy(sdcCatalogWired); - Mockito.when(spy.getSdcServicesInformation(null)).thenReturn(IOUtils.toString( - SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8")); + + Mockito.doReturn(IOUtils.toString( + SdcCatalogServicesIT.class.getResourceAsStream("/example/sdc/sdcServicesListExample.json"), "UTF-8")) + .when(spy).getSdcServicesInformation(null); // This invariant uuid is the one from vcts4 v1.1 String serviceResourceDetailUrl = refProp.getStringValue("sdc.serviceUrl") @@ -286,7 +289,8 @@ public class SdcCatalogServicesIT extends AbstractIT { assertTrue("29018914-966c-442d-9d08-251b9dc45b8f".equals(cldsServiceData.getServiceUUID())); assertTrue(cldsServiceData.getCldsVfs().size() == 1); - List alarmsList = spy.getAllAlarmConditionsFromCldsServiceData(cldsServiceData, "alarmCondition"); + List alarmsList = spy.getAllAlarmConditionsFromCldsServiceData(cldsServiceData, + "alarmCondition"); assertTrue(alarmsList.size() == 6); } diff --git a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java index c6b19d0f..03d7d65d 100644 --- a/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java +++ b/src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java @@ -28,7 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode; /** * A CustomModelElement to test the capability to add new elements on the fly. */ -public class CustomModelElement extends ModelElement { +public class CustomModelElement extends AbstractModelElement { private static final String CUSTOM_TYPE = "customType"; -- cgit 1.2.3-korg