2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2023 Nordix Foundation
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.cps.ncmp.api.impl.trustlevel.dmiavailability
23 import org.onap.cps.ncmp.api.impl.client.DmiRestClient
24 import org.onap.cps.ncmp.api.impl.trustlevel.TrustLevel
25 import spock.lang.Specification
27 class DmiPluginWatchDogSpec extends Specification {
29 def mockDmiRestClient = Mock(DmiRestClient)
30 def trustLevelPerDmiPlugin = [:]
32 def objectUnderTest = new DmiPluginWatchDog(mockDmiRestClient, trustLevelPerDmiPlugin)
34 def 'watch dmi plugin health status for #dmiHealhStatus'() {
35 given: 'the cache has been initialised and "knows" about dmi-1'
36 trustLevelPerDmiPlugin.put('dmi-1',null)
37 and: 'dmi client returns health status #dmiHealhStatus'
38 mockDmiRestClient.getDmiHealthStatus('dmi-1') >> dmiHealhStatus
39 when: 'dmi watch dog method runs'
40 objectUnderTest.watchDmiPluginTrustLevel()
41 then: 'the result is as expected'
42 assert trustLevelPerDmiPlugin.get('dmi-1') == expectedResult
43 where: 'the following health status is used'
44 dmiHealhStatus || expectedResult
45 'UP' || TrustLevel.COMPLETE
46 'Other' || TrustLevel.NONE
47 null || TrustLevel.NONE