Prevent obscure NPE when mocks aren't properly configured 47/94247/2
authorebo <eliezio.oliveira@est.tech>
Thu, 22 Aug 2019 14:20:39 +0000 (15:20 +0100)
committerebo <eliezio.oliveira@est.tech>
Fri, 23 Aug 2019 08:06:28 +0000 (09:06 +0100)
Change-Id: Ibccc712e9ff6b022a55b1ffaaf284d203c8b0dfb
Issue-ID: CCSDK-1638
Signed-off-by: ebo <eliezio.oliveira@est.tech>
ms/blueprintsprocessor/application/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/BlueprintsAcceptanceTest.kt

index ad4173c..adb6de1 100644 (file)
@@ -35,6 +35,7 @@ import org.junit.ClassRule
 import org.junit.Rule
 import org.junit.runner.RunWith
 import org.junit.runners.Parameterized
+import org.mockito.Answers
 import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestLibConstants
 import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService
 import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService
@@ -105,7 +106,7 @@ class BlueprintsAcceptanceTest(private val blueprintName: String, private val fi
     @JvmField
     val springMethodRule = SpringMethodRule()
 
-    @MockBean(name = RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY)
+    @MockBean(name = RestLibConstants.SERVICE_BLUEPRINT_REST_LIB_PROPERTY, answer = Answers.RETURNS_SMART_NULLS)
     lateinit var restClientFactory: BluePrintRestLibPropertyService
 
     @Autowired
@@ -160,7 +161,8 @@ class BlueprintsAcceptanceTest(private val blueprintName: String, private val fi
 
     private fun createRestClientMock(selector: String, restExpectations: List<ExpectationDefinition>)
             : BlueprintWebClientService {
-        val restClient = mock<BlueprintWebClientService>(verboseLogging = true)
+        val restClient = mock<BlueprintWebClientService>(verboseLogging = true,
+                defaultAnswer = Answers.RETURNS_SMART_NULLS)
 
         // Delegates to overloaded exchangeResource(String, String, String, Map<String, String>)
         whenever(restClient.exchangeResource(any(), any(), any()))