Add tests
[clamp.git] / src / test / java / org / onap / clamp / policy / downloader / PolicyEngineControllerTestItCase.java
1 package org.onap.clamp.policy.downloader;
2 /*-
3  * ============LICENSE_START=======================================================
4  * ONAP CLAMP
5  * ================================================================================
6  * Copyright (C) 2020 AT&T Intellectual Property. All rights
7  *                             reserved.
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END============================================
21  * ===================================================================
22  *
23  */
24
25 import static org.assertj.core.api.Assertions.assertThat;
26
27 import com.google.gson.JsonSyntaxException;
28
29 import java.io.IOException;
30 import java.util.List;
31
32 import javax.transaction.Transactional;
33
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.onap.clamp.clds.Application;
37 import org.onap.clamp.loop.template.PolicyModel;
38 import org.onap.clamp.loop.template.PolicyModelsRepository;
39 import org.springframework.beans.factory.annotation.Autowired;
40 import org.springframework.boot.test.context.SpringBootTest;
41 import org.springframework.test.context.ActiveProfiles;
42 import org.springframework.test.context.junit4.SpringRunner;
43
44 @RunWith(SpringRunner.class)
45 @SpringBootTest(classes = Application.class)
46 @ActiveProfiles(profiles = "clamp-default,clamp-policy-controller")
47 public class PolicyEngineControllerTestItCase {
48
49     @Autowired
50     PolicyEngineController policyController;
51
52     @Autowired
53     PolicyModelsRepository policyModelsRepository;
54
55     @Test
56     @Transactional
57     public void synchronizeAllPoliciesTest() throws JsonSyntaxException, IOException, InterruptedException {
58         policyController.synchronizeAllPolicies();
59         List<PolicyModel> policyModelsList = policyModelsRepository.findAll();
60         assertThat(policyModelsList.size()).isGreaterThanOrEqualTo(8);
61         assertThat(policyModelsList).contains(new PolicyModel("onap.policies.Monitoring", null, "1.0.0"));
62         assertThat(policyModelsList).contains(new PolicyModel("onap.policies.controlloop.Operational", null, "1.0.0"));
63     }
64
65 }