0df95d2d307d184815bd387ea2a5f2edecf3f1e2
[ccsdk/cds.git] /
1 /*\r
2  *  Copyright © 2017-2018 AT&T Intellectual Property.\r
3  *\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
7  *\r
8  *      http://www.apache.org/licenses/LICENSE-2.0\r
9  *\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
15  */\r
16 \r
17 package org.onap.ccsdk.apps.blueprintsprocessor.services.execution;\r
18 \r
19 import com.fasterxml.jackson.databind.node.ObjectNode;\r
20 import org.apache.commons.io.FileUtils;\r
21 import org.junit.Assert;\r
22 import org.junit.Test;\r
23 import org.junit.runner.RunWith;\r
24 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput;\r
25 import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceOutput;\r
26 import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils;\r
27 import org.slf4j.Logger;\r
28 import org.slf4j.LoggerFactory;\r
29 import org.springframework.beans.factory.annotation.Autowired;\r
30 import org.springframework.test.context.ContextConfiguration;\r
31 import org.springframework.test.context.junit4.SpringRunner;\r
32 \r
33 import java.io.File;\r
34 import java.nio.charset.Charset;\r
35 \r
36 \r
37 /**\r
38  * ExecutionServiceTest\r
39  *\r
40  * @author Brinda Santh\r
41  * DATE : 8/15/2018\r
42  */\r
43 @RunWith(SpringRunner.class)\r
44 @ContextConfiguration(classes = ExecutionService.class)\r
45 public class ExecutionServiceTest {\r
46     private static Logger log = LoggerFactory.getLogger(ExecutionServiceTest.class);\r
47 \r
48     @Autowired\r
49     private ExecutionService executionService;\r
50 \r
51     @Test\r
52     public void testExecutionService() throws Exception {\r
53 \r
54         Assert.assertNotNull("failed to create ResourceResolutionService", executionService);\r
55 \r
56         String resourceResolutionInputContent = FileUtils.readFileToString(\r
57                 new File("src/test/resources/payload/requests/sample-execution-request.json"), Charset.defaultCharset());\r
58 \r
59         ExecutionServiceInput executionServiceInput = JacksonUtils.readValue(resourceResolutionInputContent, ExecutionServiceInput.class );\r
60         Assert.assertNotNull("failed to populate executionServiceInput request ",executionServiceInput);\r
61 \r
62         ObjectNode inputContent = (ObjectNode)JacksonUtils.jsonNodeFromFile("src/test/resources/payload/inputs/input.json");\r
63         Assert.assertNotNull("failed to populate input payload ",inputContent);\r
64         executionServiceInput.setPayload(inputContent);\r
65 \r
66         ExecutionServiceOutput executionServiceOutput = executionService.process(executionServiceInput);\r
67         Assert.assertNotNull("failed to populate output",executionServiceOutput);\r
68 \r
69     }\r
70 }