@SuppressWarnings("rawtypes")
@Test
public void filter404NoParameter() {
final ContainerRequestContext requestContext = Mockito.mock(ContainerRequestContext.class);
final ContainerResponseContext responseContext = Mockito.mock(ContainerResponseContext.class);
Mockito.when(responseContext.getStatus()).thenReturn(204);
final Annotation anno1 = Mockito.mock(Annotation.class);
final Annotation anno2 = Mockito.mock(Annotation.class);
final Annotation[] annotations = new Annotation[] { anno1, anno2 };
Mockito.when((Class) anno2.annotationType()).thenReturn(OnNullReturn404.class);
Mockito.when(responseContext.getEntityAnnotations()).thenReturn(annotations);
final UriInfo uriInfo = Mockito.mock(UriInfo.class);
final MultivaluedMap<String, String> parameters = new MultivaluedHashMap<>();
Mockito.when(uriInfo.getPathParameters()).thenReturn(parameters);
Mockito.when(requestContext.getUriInfo()).thenReturn(uriInfo);
filter.filter(requestContext, responseContext);
Mockito.verify(responseContext, VerificationModeFactory.atLeastOnce()).setStatus(404);
Mockito.verify(responseContext, VerificationModeFactory.atLeastOnce())
.setEntity("{\"code\":\"data\",\"message\":null,\"parameters\":null,\"cause\":null}", annotations, MediaType.APPLICATION_JSON_TYPE);
}
NotFoundResponseFilterTest.java 文件源码
java
阅读 35
收藏 0
点赞 0
评论 0
项目:bootstrap
作者:
评论列表
文章目录