2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.ccsdk.apps.ms.neng.core.policy;
23 import static org.junit.Assert.assertEquals;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.mockito.InjectMocks;
28 import org.mockito.Mock;
29 import org.mockito.Mockito;
30 import org.mockito.runners.MockitoJUnitRunner;
31 import org.onap.ccsdk.apps.ms.neng.persistence.entity.IdentifierMap;
32 import org.onap.ccsdk.apps.ms.neng.persistence.entity.ServiceParameter;
33 import org.onap.ccsdk.apps.ms.neng.persistence.repository.IdentifierMapRespository;
34 import org.onap.ccsdk.apps.ms.neng.persistence.repository.ServiceParameterRepository;
36 @RunWith(MockitoJUnitRunner.class)
37 public class PolicyParametersImplTest {
39 IdentifierMapRespository identifierMapRepository;
41 ServiceParameterRepository serviceParameterRepository;
43 IdentifierMap identifierMap;
45 PolicyParametersImpl policyParametersImpl;
49 static final String RECIPE_SEPERATOR_PARAM = "recipe_separator";
50 static final String MAX_GEN_ATTEMPT_PARAM = "max_gen_attempt";
53 public void policyParameterTest() throws Exception {
54 Mockito.when(serviceParameterRepository.findByName(RECIPE_SEPERATOR_PARAM)).thenReturn(sp);
55 Mockito.when(sp.getValue()).thenReturn("value");
56 assertEquals("value", policyParametersImpl.getRecipeSeparator());
58 Mockito.when(identifierMapRepository.findByPolicyFnName("name")).thenReturn(identifierMap);
59 Mockito.when(identifierMap.getJsFnName()).thenReturn("jsFnName");
60 assertEquals("jsFnName", policyParametersImpl.mapFunction("name"));
62 Mockito.when(sp.getValue()).thenReturn("1");
63 Mockito.when(serviceParameterRepository.findByName(MAX_GEN_ATTEMPT_PARAM)).thenReturn(sp);
64 assertEquals(1, policyParametersImpl.getMaxGenAttempt());