df848e6d87f95e3a26baed6230c851029e9cd3ff
[policy/models.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * Copyright (C) 2022 AT&T Intellectual Property. All rights reserved.
4  * Modifications Copyright (C) 2024 Nordix Foundation
5  * ================================================================================
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  * ============LICENSE_END=========================================================
18  */
19
20 package org.onap.policy.controlloop.actor.cds.properties;
21
22 import static org.junit.jupiter.api.Assertions.assertEquals;
23
24 import java.util.HashMap;
25 import java.util.Map;
26 import org.junit.jupiter.api.Test;
27 import org.onap.policy.controlloop.actorserviceprovider.TargetType;
28 import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
29
30 class GrpcOperationPropertiesTest {
31
32     @Test
33      void build() {
34         ControlLoopOperationParams params = ControlLoopOperationParams.builder().targetType(TargetType.VNF).build();
35         assertEquals(GrpcOperationTargetVnfProperties.VNF_PROPERTY_NAMES,
36                 GrpcOperationProperties.build(params).getPropertyNames());
37
38         Map<String, String> targetEntityIds = new HashMap<>();
39         targetEntityIds.put(ControlLoopOperationParams.PARAMS_ENTITY_RESOURCEID, "R");
40
41         params = ControlLoopOperationParams.builder()
42                          .targetType(TargetType.VNF)
43                          .targetEntityIds(targetEntityIds)
44                          .build();
45         assertEquals(GrcpOperationResourceVnfProperties.VNF_PROPERTY_NAMES,
46                 GrpcOperationProperties.build(params).getPropertyNames());
47
48         params = ControlLoopOperationParams.builder().targetType(TargetType.PNF).build();
49         assertEquals(GrpcOperationPnfProperties.PNF_PROPERTY_NAMES,
50                 GrpcOperationProperties.build(params).getPropertyNames());
51
52         params = ControlLoopOperationParams.builder()
53                          .targetType(TargetType.VFC)
54                          .targetEntityIds(targetEntityIds)
55                          .build();
56         assertEquals(GrcpOperationResourceVnfProperties.VNF_PROPERTY_NAMES,
57                 GrpcOperationProperties.build(params).getPropertyNames());
58     }
59 }