2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2020 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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 * ===================================================================
24 package org.onap.clamp.clds.tosca;
26 import static org.assertj.core.api.Assertions.assertThat;
28 import java.util.List;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 import org.onap.clamp.clds.Application;
32 import org.onap.clamp.tosca.Dictionary;
33 import org.onap.clamp.tosca.DictionaryElement;
34 import org.onap.clamp.tosca.DictionaryRepository;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.boot.test.context.SpringBootTest;
37 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
38 import org.springframework.transaction.annotation.Transactional;
40 @RunWith(SpringJUnit4ClassRunner.class)
41 @SpringBootTest(classes = Application.class)
42 public class DictionaryRepositoriesTestItCase {
44 private DictionaryRepository dictionaryRepository;
48 public void crudTest() {
50 Dictionary dictionaryTest1 = new Dictionary();
51 dictionaryTest1.setName("testDictionary1");
52 dictionaryTest1.setSecondLevelDictionary(1);
53 dictionaryTest1.setSubDictionaryType("testType");
55 DictionaryElement element1 = new DictionaryElement();
56 element1.setName("element1");
57 element1.setShortName("shortName1");
58 element1.setType("type1");
59 element1.setDescription("description1");
61 dictionaryTest1.addDictionaryElements(element1);
63 Dictionary dictionaryTest2 = new Dictionary();
64 dictionaryTest2.setName("testDictionary2");
65 dictionaryTest2.setSecondLevelDictionary(1);
66 dictionaryTest2.setSubDictionaryType("testType");
68 DictionaryElement element2 = new DictionaryElement();
69 element2.setName("element2");
70 element2.setShortName("shortName2");
71 element2.setSubDictionary("testDictionary1");
72 element2.setType("type2");
73 element2.setDescription("description2");
75 dictionaryTest2.addDictionaryElements(element2);
77 dictionaryRepository.save(dictionaryTest1);
78 List<String> res1 = dictionaryRepository.getAllDictionaryNames();
79 assertThat(res1.size()).isGreaterThan(1);
80 assertThat(res1).contains("testDictionary1");
82 dictionaryRepository.save(dictionaryTest2);
83 List<String> res2 = dictionaryRepository.getAllDictionaryNames();
84 assertThat(res2.size()).isGreaterThan(2);
85 assertThat(res2).contains("testDictionary1");
86 assertThat(res2).contains("testDictionary2");