2 * Copyright 2017 ZTE Corporation.
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 package org.onap.workflow.activitiext.restservicetask;
18 import static org.hamcrest.CoreMatchers.is;
19 import static org.hamcrest.MatcherAssert.assertThat;
20 import static org.powermock.api.mockito.PowerMockito.mock;
22 import java.util.ArrayList;
24 import org.activiti.engine.delegate.DelegateExecution;
25 import org.activiti.engine.impl.context.Context;
26 import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.mockito.Mockito;
31 import org.powermock.api.mockito.PowerMockito;
32 import org.powermock.core.classloader.annotations.PrepareForTest;
33 import org.powermock.modules.junit4.PowerMockRunner;
35 @PrepareForTest({HighLevelRestApi.class})
36 @RunWith(PowerMockRunner.class)
37 public class HttpUtilTest {
39 private HttpUtil httpUtil;
43 httpUtil = new HttpUtil();
47 public void testExecute() {
50 DelegateExecution executionEntity = mock(ExecutionEntity.class);
52 PowerMockito.when(executionEntity.getCurrentActivityId()).thenReturn("1111");
54 HttpResponseMessage msg = new HttpResponseMessage();
55 msg.setStatusCode(200);
56 msg.setResponseBody("success");
57 PowerMockito.mockStatic(HighLevelRestApi.class);
58 PowerMockito.when(HighLevelRestApi.invoke(Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString(), Mockito.anyString())).thenReturn(msg);
60 assertThat(httpUtil.executeMethod(executionEntity), is(true));
61 } catch (Exception e) {