SpanHttpDeriverUtil { public static List<HttpCode> getClientOrServerErrors(List<HttpCode> httpCodes) { return httpCodes.stream() .filter(x -> x.isClientOrServerError()) .collect(Collectors.toList()); } private  SpanHttpDeriverUtil(); static List<HttpCode> getHttpStatusCodes(List<BinaryAnnotation> binaryAnnotations); static List<HttpCode> getClientOrServerErrors(List<HttpCode> httpCodes); static String getHttpMethod(Span span); static boolean isHttp(Span span);  }
@Test public void testGetErrors() { SpanHttpDeriverUtil.HttpCode code200 = new SpanHttpDeriverUtil.HttpCode(200, "Ok"); SpanHttpDeriverUtil.HttpCode code302 = new SpanHttpDeriverUtil.HttpCode(302, "Found"); SpanHttpDeriverUtil.HttpCode code400 = new SpanHttpDeriverUtil.HttpCode(400, "Bad Request"); SpanHttpDeriverUtil.HttpCode code501 = new SpanHttpDeriverUtil.HttpCode(501, "Not Implemented"); List<SpanHttpDeriverUtil.HttpCode> codeList = Arrays.asList(code200, code400, code400, code302, code501); List<SpanHttpDeriverUtil.HttpCode> clientOrServerErrors = SpanHttpDeriverUtil.getClientOrServerErrors(codeList); Assert.assertEquals( Arrays.asList(new SpanHttpDeriverUtil.HttpCode(400, "400"), new SpanHttpDeriverUtil.HttpCode(400, "400"), new SpanHttpDeriverUtil.HttpCode(501, "501")), clientOrServerErrors); Assert.assertEquals(Arrays.asList(code400, code400, code501), clientOrServerErrors); }