@Before
public void test() throws IOException {
Mockito.when(objectMapper.writeValueAsString(Mockito.any())).thenReturn("JSON");
Mockito.when(objectMapper.getTypeFactory()).thenReturn(typeFactory);
Mockito.when(objectMapper.readValue(Mockito.<InputStream>any(), Mockito.<JavaType>any())).thenReturn(Collections.singletonList(new LockedExternalTaskDto()));
Mockito.when(httpClient.execute(Mockito.any())).thenReturn(response);
Mockito.when(response.getEntity()).thenReturn(httpEntity);
Mockito.when(response.getStatusLine()).thenReturn(statusLine);
Mockito.when(statusLine.getStatusCode()).thenReturn(HttpStatus.SC_OK);
Mockito.when(httpEntity.getContent()).thenReturn(new StringBufferInputStream("http response"));
service = new ExternalTaskRestServiceImpl();
JavaUtils.setFieldWithoutCheckedException(
ReflectionUtils.findField(ExternalTaskRestServiceImpl.class, "objectMapper")
, service
, objectMapper
);
JavaUtils.setFieldWithoutCheckedException(
ReflectionUtils.findField(ExternalTaskRestServiceImpl.class, "httpClient")
, service
, httpClient
);
JavaUtils.setFieldWithoutCheckedException(
ReflectionUtils.findField(ExternalTaskRestServiceImpl.class, "engineUrl")
, service
, "someurl"
);
}
ExternalTaskRestServiceImplTest.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:camunda-task-dispatcher
作者:
评论列表
文章目录