CoAP { public static String formatCode(final int code) { return formatCode(getCodeClass(code), getCodeDetail(code)); } 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 testFormatCode() { assertThat(CoAP.formatCode(Code.GET.value), is("0.01")); assertThat(CoAP.formatCode(Code.POST.value), is("0.02")); assertThat(CoAP.formatCode(Code.FETCH.value), is("0.05")); assertThat(CoAP.formatCode(Code.PATCH.value), is("0.06")); assertThat(CoAP.formatCode(ResponseCode.CREATED.value), is("2.01")); assertThat(CoAP.formatCode(ResponseCode.CHANGED.value), is("2.04")); assertThat(CoAP.formatCode(ResponseCode.CONTENT.value), is("2.05")); assertThat(CoAP.formatCode(ResponseCode.BAD_REQUEST.value), is("4.00")); assertThat(CoAP.formatCode(ResponseCode.REQUEST_ENTITY_INCOMPLETE.value), is("4.08")); assertThat(CoAP.formatCode(ResponseCode.CONFLICT.value), is("4.09")); assertThat(CoAP.formatCode(ResponseCode.REQUEST_ENTITY_TOO_LARGE.value), is("4.13")); assertThat(CoAP.formatCode(ResponseCode.UNSUPPORTED_CONTENT_FORMAT.value), is("4.15")); assertThat(CoAP.formatCode(ResponseCode.UNPROCESSABLE_ENTITY.value), is("4.22")); assertThat(CoAP.formatCode(ResponseCode.INTERNAL_SERVER_ERROR.value), is("5.00")); assertThat(CoAP.formatCode(ResponseCode.NOT_IMPLEMENTED.value), is("5.01")); assertThat(CoAP.formatCode(ResponseCode.SERVICE_UNAVAILABLE.value), is("5.03")); }