2 * Copyright © 2020 IBM, Bell Canada.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.cds.blueprintsprocessor.uat.error
19 import org.junit.runner.RunWith
20 import org.onap.ccsdk.cds.blueprintsprocessor.uat.ErrorCatalogTestConfiguration
21 import org.onap.ccsdk.cds.controllerblueprints.core.grpcProcessorException
22 import org.onap.ccsdk.cds.controllerblueprints.core.httpProcessorException
23 import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalog
24 import org.onap.ccsdk.cds.error.catalog.core.ErrorCatalogCodes
25 import org.onap.ccsdk.cds.error.catalog.core.ErrorMessage
26 import org.onap.ccsdk.cds.error.catalog.core.ErrorPayload
27 import org.onap.ccsdk.cds.error.catalog.services.ErrorCatalogService
28 import org.springframework.beans.factory.annotation.Autowired
29 import org.springframework.test.context.ContextConfiguration
30 import org.springframework.test.context.TestPropertySource
31 import org.springframework.test.context.junit4.SpringRunner
32 import kotlin.test.BeforeTest
33 import kotlin.test.Test
34 import kotlin.test.assertTrue
36 @RunWith(SpringRunner::class)
37 @ContextConfiguration(
38 classes = [ErrorCatalogTestConfiguration::class]
40 @TestPropertySource(locations = ["classpath:application-test.properties"])
41 class ErrorCatalogServiceTest {
43 lateinit var errorCatalogService: ErrorCatalogService
45 private val domain = "org.onap.ccsdk.cds.blueprintsprocessor"
46 private lateinit var errorType: String
47 private lateinit var errorCatalogHttp: ErrorCatalog
48 private lateinit var errorCatalogGrpc: ErrorCatalog
49 private lateinit var errorPayloadHttp: ErrorPayload
50 private lateinit var errorPayloadGrpc: ErrorPayload
54 errorType = ErrorCatalogCodes.GENERIC_FAILURE
55 errorCatalogHttp = ErrorCatalog(errorType, domain, 500,
56 "Contact CDS administrator team.", "Internal error in Blueprint Processor run time.")
57 errorCatalogGrpc = ErrorCatalog(errorType, domain, 2,
58 "Contact CDS administrator team.", "Internal error in Blueprint Processor run time.")
60 errorPayloadHttp = ErrorPayload(500, ErrorCatalogCodes.GENERIC_FAILURE,
61 "Cause: Internal error in Blueprint Processor run time. \n Action : Contact CDS administrator team.",
62 errorMessage = ErrorMessage("org.onap.ccsdk.cds.blueprintsprocessor",
63 "Internal error in Blueprint Processor run time.", ""))
64 errorPayloadGrpc = ErrorPayload(2, ErrorCatalogCodes.GENERIC_FAILURE,
65 "Cause: Internal error in Blueprint Processor run time. \n Action : Contact CDS administrator team.",
66 errorMessage = ErrorMessage("org.onap.ccsdk.cds.blueprintsprocessor",
67 "Internal error in Blueprint Processor run time.", ""))
71 fun errorPayloadHttp() {
72 val errorPayload = errorCatalogService.errorPayload(httpProcessorException(errorType, domain,
73 "Internal error in Blueprint Processor run time."))
74 assertTrue { errorPayload.isEqualTo(errorPayloadHttp) }
78 fun errorPayloadGrpc() {
79 val errorPayload = errorCatalogService.errorPayload(grpcProcessorException(errorType, domain,
80 "Internal error in Blueprint Processor run time."))
81 assertTrue { errorPayload.isEqualTo(errorPayloadGrpc) }
85 fun getErrorCatalogHttp() {
86 val errorCatalog = errorCatalogService.getErrorCatalog(httpProcessorException(errorType, domain,
87 "Internal error in Blueprint Processor run time."))
88 assertTrue { errorCatalog == errorCatalogHttp }
92 fun getErrorCatalogGrpc() {
93 val errorCatalog = errorCatalogService.getErrorCatalog(grpcProcessorException(errorType, domain,
94 "Internal error in Blueprint Processor run time."))
95 assertTrue { errorCatalog == errorCatalogGrpc }