2 * Copyright (c) 2019 Vodafone Group
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js';
17 import Configuration from 'sdc-app/config/Configuration.js';
18 import { actionTypes } from './SoftwareProductValidationResultsViewConstants.js';
20 function encodeResultQueryData(requestId, endPoints) {
22 query.push('requestId=' + requestId);
23 endPoints.forEach(endPoint => {
24 query.push('endPoint=' + encodeURIComponent(endPoint));
27 return query.join('&');
29 function fetchVspValidationResults(requestId, endPoints) {
30 const restPrefix = Configuration.get('restPrefix');
31 const requestQuery = encodeResultQueryData(requestId, endPoints);
32 return RestAPIUtil.fetch(
33 `${restPrefix}/v1.0/externaltesting/executions?${requestQuery}`
36 function fetchVspChecks() {
37 const restPrefix = Configuration.get('restPrefix');
38 return RestAPIUtil.fetch(`${restPrefix}/v1.0/externaltesting/testcasetree`);
40 const SoftwareProductValidationResultsViewActionHelper = {
41 refreshValidationResults(dispatch, { requestId, endPoints }) {
42 return new Promise((resolve, reject) => {
43 fetchVspValidationResults(requestId, endPoints)
46 type: actionTypes.FETCH_VSP_RESULT,
47 vspTestResults: response
56 fetchVspChecks(dispatch) {
57 return new Promise((resolve, reject) => {
61 type: actionTypes.FETCH_VSP_CHECKS,
71 updateDisplayTestResultData(dispatch, { testResultToDisplay }) {
73 type: actionTypes.UPDATE_DISPLAY_TEST_RESULT_DATA,
74 testResultToDisplay: testResultToDisplay
79 export default SoftwareProductValidationResultsViewActionHelper;