Revert "Renaming Files having BluePrint to have Blueprint"
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / blueprints / blueprint-core / src / test / kotlin / org / onap / ccsdk / cds / controllerblueprints / core / utils / PropertyDefinitionUtilsTest.kt
1 /*
2  * Copyright © 2019 Bell Canada.
3  *
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 package org.onap.ccsdk.cds.controllerblueprints.core.utils
18
19 import org.junit.Test
20 import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants.LOG_PROTECT
21 import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition
22 import org.onap.ccsdk.cds.controllerblueprints.core.utils.PropertyDefinitionUtils.Companion.hasLogProtect
23 import kotlin.test.assertFalse
24 import kotlin.test.assertTrue
25
26 class PropertyDefinitionUtilsTest {
27
28     @Test
29     fun testLogProtectMetadata() {
30         val metadata = mutableMapOf<String, String>()
31
32         assertFalse { hasLogProtect(metadata) }
33
34         metadata[LOG_PROTECT] = "true"
35         assertTrue { hasLogProtect(metadata) }
36         metadata.clear()
37
38         metadata[LOG_PROTECT] = "yes"
39         assertTrue { hasLogProtect(metadata) }
40         metadata.clear()
41
42         metadata[LOG_PROTECT] = "y"
43         assertTrue { hasLogProtect(metadata) }
44         metadata.clear()
45
46         metadata[LOG_PROTECT] = "false"
47         assertFalse { hasLogProtect(metadata) }
48         metadata.clear()
49
50         val nullMetadata: MutableMap<String, String>? = null
51         assertFalse { hasLogProtect(nullMetadata) }
52     }
53
54     @Test
55     fun testHasLogProtectPropertyDefinition() {
56         var propertyDefinition: PropertyDefinition? = null
57         assertFalse { hasLogProtect(propertyDefinition) }
58
59         propertyDefinition = PropertyDefinition()
60         assertFalse { hasLogProtect(propertyDefinition) }
61
62         val metadata = mutableMapOf<String, String>()
63         metadata[LOG_PROTECT] = "TRUE"
64         propertyDefinition.metadata = metadata
65
66         assertTrue { hasLogProtect(propertyDefinition) }
67     }
68 }