2 * Copyright © 2017-2018 AT&T Intellectual Property.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 package org.onap.ccsdk.apps.controllerblueprints.service.rs;
\r
20 import org.junit.runner.RunWith;
\r
21 import org.junit.runners.MethodSorters;
\r
22 import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
\r
23 import org.onap.ccsdk.apps.controllerblueprints.service.domain.ConfigModel;
\r
24 import org.onap.ccsdk.apps.controllerblueprints.service.utils.ConfigModelUtils;
\r
25 import com.att.eelf.configuration.EELFLogger;
\r
26 import com.att.eelf.configuration.EELFManager;
\r
27 import org.springframework.beans.factory.annotation.Autowired;
\r
28 import org.springframework.boot.test.context.SpringBootTest;
\r
29 import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
\r
30 import org.springframework.test.context.ContextConfiguration;
\r
31 import org.springframework.test.context.junit4.SpringRunner;
\r
33 import java.util.List;
\r
35 @RunWith(SpringRunner.class)
\r
36 @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
\r
37 @ContextConfiguration(classes = {TestApplication.class})
\r
38 @FixMethodOrder(MethodSorters.NAME_ASCENDING)
\r
39 public class ConfigModelRestTest {
\r
41 private static EELFLogger log = EELFManager.getInstance().getLogger(ConfigModelRestTest.class);
\r
44 ConfigModelRest configModelRest;
\r
46 ConfigModel configModel;
\r
48 String name = "vrr-test";
\r
49 String version = "1.0.0";
\r
52 public void setUp() {
\r
58 public void tearDown() {
\r
63 public void test01getInitialConfigModel() throws Exception {
\r
64 log.info("** test01getInitialConfigModel *****************");
\r
66 String name = "default_netconf";
\r
67 ConfigModel configModel = configModelRest.getInitialConfigModel(name);
\r
68 Assert.assertNotNull("Failed to get Initial Config Model , Return object is Null", configModel);
\r
69 Assert.assertNotNull("Failed to get Service Template Content ", configModel.getConfigModelContents());
\r
75 public void test02SaveServiceTemplate() throws Exception {
\r
76 log.info("************************ test02SaveServiceTemplate ******************");
\r
79 configModel = ConfigModelUtils.getConfigModel("load/blueprints/vrr-test");
\r
81 configModel = configModelRest.saveConfigModel(configModel);
\r
82 Assert.assertNotNull("Failed to ConfigModel, Return object is Null", configModel);
\r
83 Assert.assertNotNull("Failed to ConfigModel Id , Return ID object is Null", configModel.getId());
\r
84 Assert.assertNotNull("Failed to ConfigModel Content, Return object is Null",
\r
85 configModel.getConfigModelContents());
\r
86 Assert.assertEquals("Failed in validation of ConfigModel Content count,", 3,
\r
87 configModel.getConfigModelContents().size());
\r
89 ConfigModel dbconfigModel = configModelRest.getConfigModel(configModel.getId());
\r
91 log.info("************************ test02SaveServiceTemplate-2 ******************");
\r
93 dbconfigModel.getConfigModelContents().remove(2);
\r
94 dbconfigModel = configModelRest.saveConfigModel(dbconfigModel);
\r
95 log.info("Saved Config Model " + configModel.getId());
\r
96 Assert.assertNotNull("Failed to ConfigModel, Return object is Null", dbconfigModel);
\r
97 Assert.assertNotNull("Failed to ConfigModel Id ", dbconfigModel.getId());
\r
98 Assert.assertNotNull("Failed to ConfigModel Content",
\r
99 dbconfigModel.getConfigModelContents());
\r
100 Assert.assertEquals("Failed to Remove the ConfigModel Content,", 2,
\r
101 dbconfigModel.getConfigModelContents().size());
\r
108 public void test03PublishServiceTemplate() throws Exception {
\r
109 log.info("** test03PublishServiceTemplate *****************");
\r
111 ConfigModel configModel = configModelRest.getConfigModelByNameAndVersion(name, version);
\r
112 log.info("Publishing Config Model " + configModel.getId());
\r
113 configModel = configModelRest.publishConfigModel(configModel.getId());
\r
114 Assert.assertNotNull("Failed to ConfigModel, Return object is Null", configModel);
\r
115 Assert.assertNotNull("Failed to ConfigModel Id ", configModel.getId());
\r
116 Assert.assertNotNull("Failed to ConfigModel Content", configModel.getConfigModelContents());
\r
117 Assert.assertEquals("Failed to update the publish indicator", "Y", configModel.getPublished());
\r
123 public void test04GetConfigModel() throws Exception {
\r
124 log.info("** test04GetConfigModel *****************");
\r
126 ConfigModel configModel = configModelRest.getConfigModelByNameAndVersion(name, version);
\r
127 Assert.assertNotNull("Failed to get ConfigModel for the Name (" + configModel.getArtifactName() + ") and ("
\r
128 + configModel.getArtifactVersion() + ")", configModel);
\r
129 Assert.assertNotNull("Failed to get ConfigModel Id", configModel.getId());
\r
131 configModel = configModelRest.getConfigModel(configModel.getId());
\r
132 Assert.assertNotNull("Failed to get ConfigModel for the Id (" + configModel.getId() + ") ", configModel);
\r
138 public void test05GetCloneConfigModel() throws Exception {
\r
139 log.info("** test05GetCloneConfigModel *****************");
\r
141 ConfigModel configModel = configModelRest.getConfigModelByNameAndVersion(name, version);
\r
143 Assert.assertNotNull("Failed to get ConfigModel for the Name (" + configModel.getArtifactName() + ") and ("
\r
144 + configModel.getArtifactVersion() + ")", configModel);
\r
145 Assert.assertNotNull("Failed to get ConfigModel Id", configModel.getId());
\r
147 configModel = configModelRest.getCloneConfigModel(configModel.getId());
\r
148 Assert.assertNotNull("Failed to get ConfigModel for the Id (" + configModel.getId() + ") ", configModel);
\r
153 public void test07SearchConfigModels() throws Exception {
\r
154 log.info("** test07SearchConfigModels *****************");
\r
156 List<ConfigModel> configModels = configModelRest.searchConfigModels("vrr-test");
\r
157 Assert.assertNotNull("Failed to search ConfigModel", configModels);
\r
158 Assert.assertTrue("Failed to search ConfigModel with count", configModels.size() > 0);
\r
159 // update the ServiceModelContent
\r
164 public void test08DeleteConfigModels() throws Exception {
\r
165 log.info("** test08DeleteConfigModels *****************");
\r
167 ConfigModel configModel = configModelRest.getConfigModelByNameAndVersion(name, version);
\r
168 configModelRest.deleteConfigModel(configModel.getId());
\r