大家好,又见面了,我是你们的朋友全栈君。
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import lombok.val;
@RunWith(PowerMockRunner.class)
@SpringBootTest(classes = ExpenseServiceApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Transactional
@Rollback(true)
@val
@PrepareForTest({ HighExpenseService.class, WorkFlowClient.class })
@PowerMockRunnerDelegate(SpringRunner.class)
@PowerMockIgnore({ "javax.management.*", "javax.net.*" })
public class HighExpenseServiceTest {
@Autowired
HighExpenseService service;
@Test
public void testSubmitHighFlow() {
PowerMockito.mockStatic(WorkFlowClient.class);
SubmitFlowRequest sfr = new SubmitFlowRequest();
sfr.setWorkId("201812061846019");
Mockito.when(WorkFlowClient.submitFlow(sfr)).thenReturn(ResponseMessage2.Success());
service.submitHighFlow(sfr);
}
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/135408.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...