src/main/java/org/edgegallery/appstore/application/external/atp/AtpUtil.java
public AtpTestDto sendCreateTask2Atp(String filePath, String token) {
        if (filePath == null || token == null) {
            LOGGER.error("Failed to validate input parameters of ATP task creation {}",
                ResponseConst.RET_PARAM_INVALID);
            return new AtpTestDto();
        }
        MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
        LOGGER.info("filePath: {}", filePath);
        body.add("file", new FileSystemResource(filePath));

        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.MULTIPART_FORM_DATA);
        headers.set(Consts.ACCESS_TOKEN_STR, token);

        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers);
        String url = createTaskUrl;
        LOGGER.info("url: {}", url);
        try {
            ResponseEntity<String> response = REST_TEMPLATE.exchange(url, HttpMethod.POST, requestEntity, String.class);
            if (HttpStatus.OK.equals(response.getStatusCode()) || HttpStatus.ACCEPTED.equals(
                response.getStatusCode())) {
                JsonObject jsonObject = new JsonParser().parse(response.getBody()).getAsJsonObject();
                String id = jsonObject.get("id").getAsString();
                String status = jsonObject.get(ATP_STATUS).getAsString();
                LOGGER.info("Successfully created test task {}, status is {}", id, status);
                return new AtpTestDto(id, status);
            }
            LOGGER.error("Failed to create instance from atp,  status is {}", response.getStatusCode());
        } catch (RestClientException e) {
            LOGGER.error("Failed to create instance from atp,  exception {}", e.getMessage());
        }

        throw new AppException("Failed to create instance from atp.", ResponseConst.RET_CREATE_TEST_TASK_FAILED);
    }
/**
     * send request to atp to create test task.
     *
     * @param filePath csar file path
     * @param token request token
     * @return response from atp
     */
send request to atp to create test task.
@param filePath csar file path
@param token request token
@return response from atp
send request to atp to create test task . @param filePath csar file path @param token request token @return response from atp
public AtpTestDto sendCreateTask2Atp(String filePath, String token) {
        if (filePath == null || token == null) {
            LOGGER.error("Failed to validate input parameters of ATP task creation {}",
                ResponseConst.RET_PARAM_INVALID);
            return new AtpTestDto();
        }
        MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
        LOGGER.info("filePath: {}", filePath);
        body.add("file", new FileSystemResource(filePath));
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.MULTIPART_FORM_DATA);
        headers.set(Consts.ACCESS_TOKEN_STR, token);
        HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers);
        String url = createTaskUrl;
        LOGGER.info("url: {}", url);
        try {
            ResponseEntity<String> response = REST_TEMPLATE.exchange(url, HttpMethod.POST, requestEntity, String.class);
            if (HttpStatus.OK.equals(response.getStatusCode()) || HttpStatus.ACCEPTED.equals(
                response.getStatusCode())) {
                JsonObject jsonObject = new JsonParser().parse(response.getBody()).getAsJsonObject();
                String id = jsonObject.get("id").getAsString();
                String status = jsonObject.get(ATP_STATUS).getAsString();
                LOGGER.info("Successfully created test task {}, status is {}", id, status);
                return new AtpTestDto(id, status);
            }
            LOGGER.error("Failed to create instance from atp,  status is {}", response.getStatusCode());
        } catch (RestClientException e) {
            LOGGER.error("Failed to create instance from atp,  exception {}", e.getMessage());
        }
        throw new AppException("Failed to create instance from atp.", ResponseConst.RET_CREATE_TEST_TASK_FAILED);
    }
public AtpTestDto sendCreateTask2Atp ( String filePath , String token ) { if ( filePath == null || token == null ) { LOGGER . error ( "Failed to validate input parameters of ATP task creation {}" , ResponseConst . RET_PARAM_INVALID ) ; return new AtpTestDto ( ) ; } MultiValueMap < String , Object > body = new LinkedMultiValueMap < > ( ) ; LOGGER . info ( "filePath: {}" , filePath ) ; body . add ( "file" , new FileSystemResource ( filePath ) ) ; HttpHeaders headers = new HttpHeaders ( ) ; headers . setContentType ( MediaType . MULTIPART_FORM_DATA ) ; headers . set ( Consts . ACCESS_TOKEN_STR , token ) ; HttpEntity < MultiValueMap < String , Object > > requestEntity = new HttpEntity < > ( body , headers ) ; String url = createTaskUrl ; LOGGER . info ( "url: {}" , url ) ; try { ResponseEntity < String > response = REST_TEMPLATE . exchange ( url , HttpMethod . POST , requestEntity , String . class ) ; if ( HttpStatus . OK . equals ( response . getStatusCode ( ) ) || HttpStatus . ACCEPTED . equals ( response . getStatusCode ( ) ) ) { JsonObject jsonObject = new JsonParser ( ) . parse ( response . getBody ( ) ) . getAsJsonObject ( ) ; String id = jsonObject . get ( "id" ) . getAsString ( ) ; String status = jsonObject . get ( ATP_STATUS ) . getAsString ( ) ; LOGGER . info ( "Successfully created test task {}, status is {}" , id , status ) ; return new AtpTestDto ( id , status ) ; } LOGGER . error ( "Failed to create instance from atp,  status is {}" , response . getStatusCode ( ) ) ; } catch ( RestClientException e ) { LOGGER . error ( "Failed to create instance from atp,  exception {}" , e . getMessage ( ) ) ; } throw new AppException ( "Failed to create instance from atp." , ResponseConst . RET_CREATE_TEST_TASK_FAILED ) ; }
send request to atp to create test task.
send request to atp to create test task .