Support 7.2.1 VES in TCAGEN2
[dcaegen2/analytics/tca-gen2.git] / dcae-analytics / dcae-analytics-tca-web / src / test / java / org / onap / dcae / analytics / tca / web / validation / TcaPolicyValidateTest.java
1 /*
2  * ===========LICENSE_START=====================================================================
3  * Copyright (c) 2020 ChinaMobile. All rights reserved.
4  * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved.
5  * ================================================================================
6  * Copyright (c) 2019 IBM
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  */
22 package org.onap.dcae.analytics.tca.web.validation;
23
24 import java.util.List;
25
26 import org.junit.jupiter.api.Assertions;
27 import org.junit.jupiter.api.Test;
28 import org.mockito.Mockito;
29 import org.onap.dcae.analytics.model.AnalyticsProfile;
30 import org.onap.dcae.analytics.tca.model.policy.TcaPolicy;
31 import org.onap.dcae.analytics.tca.web.TcaAppProperties;
32 import org.onap.dcae.analytics.tca.web.domain.TcaPolicyWrapper;
33 import org.onap.dcae.analytics.test.BaseAnalyticsSpringBootIT;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.core.env.Environment;
36 import org.springframework.test.context.ActiveProfiles;
37 import org.springframework.validation.Errors;
38
39 @ActiveProfiles({AnalyticsProfile.DEV_PROFILE_NAME})
40 public class TcaPolicyValidateTest extends BaseAnalyticsSpringBootIT {
41
42     @Autowired
43     Environment environment;
44     
45     @Test
46     void TestTcaAppPropertiesValidator() {
47         TcaAppProperties properties = new TcaAppProperties(environment);
48         TcaPolicyValidator validate = new TcaPolicyValidator();
49         Errors errors = Mockito.mock(Errors.class);
50         TcaPolicyWrapper tcaPolicyWrapper = new TcaPolicyWrapper(properties);
51         tcaPolicyWrapper.getConfigSource();
52         List<TcaPolicy> tcaPolicy = tcaPolicyWrapper.getTcaPolicy();
53         validate.validate(tcaPolicy, errors);        
54         validate.apply(tcaPolicy);
55         Assertions.assertEquals("version-0", tcaPolicyWrapper.getPolicyVersion());
56     }
57 }