CoAP { public static int getCodeClass(final int code) { return (code & 0b11100000) >> 5; } private  CoAP(); static int getCodeClass(final int code); static int getCodeDetail(final int code); static String formatCode(final int code); static String getSchemeForProtocol(final String protocol); static String getProtocolForScheme(final String scheme); static boolean isTcpProtocol(final String protocol); static boolean isSecureProtocol(final String protocol); static boolean isTcpScheme(final String uriScheme); static boolean isSecureScheme(final String uriScheme); static boolean isSupportedScheme(final String uriScheme); static int getDefaultPort(final String uriScheme); static String getSchemeFromUri(final String uri); static boolean isRequest(final int code); static boolean isResponse(final int code); static boolean isEmptyMessage(final int code); static boolean isObservable(final Code code); static final int VERSION; static final String PROTOCOL_UDP; static final String PROTOCOL_DTLS; static final String PROTOCOL_TCP; static final String PROTOCOL_TLS; static final String COAP_URI_SCHEME; static final String COAP_TCP_URI_SCHEME; static final String COAP_SECURE_TCP_URI_SCHEME; static final String COAP_SECURE_URI_SCHEME; static final String URI_SCHEME_SEPARATOR; static final int DEFAULT_COAP_PORT; static final int DEFAULT_COAP_SECURE_PORT; static final Charset UTF8_CHARSET; static final InetAddress MULTICAST_IPV4; static final InetAddress MULTICAST_IPV6_LINKLOCAL; static final InetAddress MULTICAST_IPV6_SITELOCAL; }
@Test public void testGetCodeClass() { for (Code code : Code.values()) { assertThat(CoAP.getCodeClass(code.value), is(CodeClass.REQUEST.value)); } assertThat(CoAP.getCodeClass(ResponseCode.CREATED.value), is(CodeClass.SUCCESS_RESPONSE.value)); assertThat(CoAP.getCodeClass(ResponseCode.CHANGED.value), is(CodeClass.SUCCESS_RESPONSE.value)); assertThat(CoAP.getCodeClass(ResponseCode.CONTINUE.value), is(CodeClass.SUCCESS_RESPONSE.value)); assertThat(CoAP.getCodeClass(ResponseCode.BAD_REQUEST.value), is(CodeClass.ERROR_RESPONSE.value)); assertThat(CoAP.getCodeClass(ResponseCode.CONFLICT.value), is(CodeClass.ERROR_RESPONSE.value)); assertThat(CoAP.getCodeClass(ResponseCode.UNSUPPORTED_CONTENT_FORMAT.value), is(CodeClass.ERROR_RESPONSE.value)); assertThat(CoAP.getCodeClass(ResponseCode.UNPROCESSABLE_ENTITY.value), is(CodeClass.ERROR_RESPONSE.value)); assertThat(CoAP.getCodeClass(ResponseCode.INTERNAL_SERVER_ERROR.value), is(CodeClass.SERVER_ERROR_RESPONSE.value)); assertThat(CoAP.getCodeClass(ResponseCode.NOT_IMPLEMENTED.value), is(CodeClass.SERVER_ERROR_RESPONSE.value)); assertThat(CoAP.getCodeClass(ResponseCode.SERVICE_UNAVAILABLE.value), is(CodeClass.SERVER_ERROR_RESPONSE.value)); }