2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (C) 2018 IBM.
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.apihandler.common;
26 import java.io.IOException;
27 import org.junit.Rule;
28 import org.junit.Test;
29 import org.junit.rules.ExpectedException;
30 import org.junit.runner.RunWith;
31 import org.mockito.InjectMocks;
32 import org.mockito.Spy;
33 import org.mockito.junit.MockitoJUnitRunner;
34 import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException;
35 import org.springframework.http.ResponseEntity;
37 @RunWith(MockitoJUnitRunner.class)
38 public class ResponseHandlerTest {
42 private ResponseHandler responseHandler;
45 public ExpectedException thrown = ExpectedException.none();
48 public void acceptedResponseTest() throws IOException, BPMNFailureException {
49 ResponseEntity<String> camundaResponse = ResponseEntity.noContent().build();
50 thrown.expect(BPMNFailureException.class);
51 thrown.expectMessage("Request Failed due to BPEL error with HTTP Status = 204");
52 responseHandler.acceptedResponse(camundaResponse);
56 public void acceptedOrNoContentResponseTest() throws IOException, BPMNFailureException {
57 ResponseEntity<String> camundaResponse = ResponseEntity.badRequest().build();
58 thrown.expect(BPMNFailureException.class);
59 thrown.expectMessage("Request Failed due to BPEL error with HTTP Status = 400");
60 responseHandler.acceptedOrNoContentResponse(camundaResponse);