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.blueprintsprocessor.services.execution;
\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
33 import java.io.File;
\r
34 import java.nio.charset.Charset;
\r
38 * ExecutionServiceTest
\r
40 * @author Brinda Santh
\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
49 private ExecutionService executionService;
\r
52 public void testExecutionService() throws Exception {
\r
54 Assert.assertNotNull("failed to create ResourceResolutionService", executionService);
\r
56 String resourceResolutionInputContent = FileUtils.readFileToString(
\r
57 new File("src/test/resources/payload/requests/sample-execution-request.json"), Charset.defaultCharset());
\r
59 ExecutionServiceInput executionServiceInput = JacksonUtils.readValue(resourceResolutionInputContent, ExecutionServiceInput.class );
\r
60 Assert.assertNotNull("failed to populate executionServiceInput request ",executionServiceInput);
\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
66 ExecutionServiceOutput executionServiceOutput = executionService.process(executionServiceInput);
\r
67 Assert.assertNotNull("failed to populate output",executionServiceOutput);
\r