5f4125780835cdaae50aa77a60613d2d8b6aafe0
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.onap.so.apihandlerinfra;
21
22 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
23 import static com.github.tomakehurst.wiremock.client.WireMock.get;
24 import javax.ws.rs.core.MediaType;
25 import org.junit.Rule;
26 import org.junit.Test;
27 import org.junit.rules.ExpectedException;
28 import org.springframework.beans.factory.annotation.Autowired;
29 import org.springframework.beans.factory.annotation.Value;
30 import org.springframework.http.HttpHeaders;
31 import org.springframework.web.client.ResourceAccessException;
32
33 public class CamundaRequestHandlerTest extends BaseTest {
34
35     @Autowired
36     private CamundaRequestHandler camundaRequestHandler;
37
38     @Value("${wiremock.server.port}")
39     private String wiremockPort;
40
41     @Rule
42     public ExpectedException thrown = ExpectedException.none();
43
44     @Test
45     public void timeoutTest() {
46         wireMockServer.stubFor(get(
47                 ("/sobpmnengine/history/process-instance?processInstanceBusinessKey=6718de35-b9a5-4670-b19f-a0f4ac22bfaf&active=true&maxResults=1"))
48                         .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
49                                 .withBodyFile("Camunda/HistoryCheckResponse.json")
50                                 .withStatus(org.apache.http.HttpStatus.SC_OK).withFixedDelay(40000)));
51
52         thrown.expect(ResourceAccessException.class);
53         camundaRequestHandler.getCamundaProcessInstanceHistory("6718de35-b9a5-4670-b19f-a0f4ac22bfaf", false, true,
54                 false);
55     }
56 }