2 * Copyright © 2019 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.controllerblueprints.core.utils
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
26 class PropertyDefinitionUtilsTest {
29 fun testLogProtectMetadata() {
30 val metadata = mutableMapOf<String, String>()
32 assertFalse { hasLogProtect(metadata) }
34 metadata[LOG_PROTECT] = "true"
35 assertTrue { hasLogProtect(metadata) }
38 metadata[LOG_PROTECT] = "yes"
39 assertTrue { hasLogProtect(metadata) }
42 metadata[LOG_PROTECT] = "y"
43 assertTrue { hasLogProtect(metadata) }
46 metadata[LOG_PROTECT] = "false"
47 assertFalse { hasLogProtect(metadata) }
50 val nullMetadata: MutableMap<String, String>? = null
51 assertFalse { hasLogProtect(nullMetadata) }
55 fun testHasLogProtectPropertyDefinition() {
56 var propertyDefinition: PropertyDefinition? = null
57 assertFalse { hasLogProtect(propertyDefinition) }
59 propertyDefinition = PropertyDefinition()
60 assertFalse { hasLogProtect(propertyDefinition) }
62 val metadata = mutableMapOf<String, String>()
63 metadata[LOG_PROTECT] = "TRUE"
64 propertyDefinition.metadata = metadata
66 assertTrue { hasLogProtect(propertyDefinition) }