06f2f9088e1629bb22553c6c91f082f39e58d17c
[ccsdk/cds.git] /
1 /*
2  * Copyright © 2017-2018 AT&T Intellectual Property.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.ccsdk.apps.controllerblueprints.service.enhancer;
18
19 import org.junit.Assert;
20 import org.junit.Before;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23 import org.onap.ccsdk.apps.controllerblueprints.TestApplication;
24 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintEnhancerService;
25 import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintValidatorService;
26 import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext;
27 import org.onap.ccsdk.apps.controllerblueprints.service.load.ModelTypeLoadService;
28 import org.onap.ccsdk.apps.controllerblueprints.service.load.ResourceDictionaryLoadService;
29 import org.springframework.beans.factory.annotation.Autowired;
30 import org.springframework.test.context.ContextConfiguration;
31 import org.springframework.test.context.TestPropertySource;
32 import org.springframework.test.context.junit4.SpringRunner;
33
34 import java.nio.file.Paths;
35
36 @RunWith(SpringRunner.class)
37 @ContextConfiguration(classes = {TestApplication.class})
38 @TestPropertySource(locations = {"classpath:application.properties"})
39 public class BluePrintEnhancerServiceImplTest {
40
41     @Autowired
42     private ModelTypeLoadService modelTypeLoadService;
43
44     @Autowired
45     private ResourceDictionaryLoadService resourceDictionaryLoadService;
46
47     @Autowired
48     private BluePrintEnhancerService bluePrintEnhancerService;
49
50     @Autowired
51     private BluePrintValidatorService bluePrintValidatorService;
52
53     @Before
54     public void init() {
55         modelTypeLoadService.loadModelType("./../../../../components/model-catalog/definition-type/starter-type");
56         resourceDictionaryLoadService.loadResourceDictionary("./../../../../components/model-catalog/resource-dictionary/starter-dictionary");
57     }
58
59     @Test
60     public void testEnhancementAndValidation() throws Exception {
61
62         String basePath = "./../../../../components/model-catalog/blueprint-model/starter-blueprint/baseconfiguration";
63
64         String targetPath = Paths.get("target", "bp-enhance").toUri().getPath();
65
66         BluePrintContext bluePrintContext = bluePrintEnhancerService.enhance(basePath, targetPath);
67         Assert.assertNotNull("failed to get blueprintContext ", bluePrintContext);
68
69         // Validate the Generated BluePrints
70         Boolean valid = bluePrintValidatorService.validateBluePrints(targetPath);
71         Assert.assertTrue("blueprint validation failed ", valid);
72     }
73 }