ResponseCodeUtil { public static org.eclipse.californium.core.coap.CoAP.ResponseCode toCoapResponseCode( ResponseCode Lwm2mResponseCode) { Validate.notNull(Lwm2mResponseCode); try { return org.eclipse.californium.core.coap.CoAP.ResponseCode.valueOf(toCoapCode(Lwm2mResponseCode.getCode())); } catch (MessageFormatException e) { throw new IllegalArgumentException("Invalid CoAP code for LWM2M response: " + Lwm2mResponseCode); } }  static int toLwM2mCode(org.eclipse.californium.core.coap.CoAP.ResponseCode coapResponseCode); static ResponseCode toLwM2mResponseCode(
            org.eclipse.californium.core.coap.CoAP.ResponseCode coapResponseCode); static int toLwM2mCode(int coapCode); static ResponseCode toLwM2mResponseCode(int coapCode); static int toCoapCode(int lwm2mCode); static org.eclipse.californium.core.coap.CoAP.ResponseCode toCoapResponseCode(
            ResponseCode Lwm2mResponseCode);  }
@Test public void known_lwm2m_code_to_known_coap_code() { ResponseCode coapResponseCode = ResponseCodeUtil .toCoapResponseCode(org.eclipse.leshan.core.ResponseCode.BAD_REQUEST); Assert.assertEquals(ResponseCode.BAD_REQUEST, coapResponseCode); }
@Test public void unknown_lwm2m_code_to_known_coap_code() { ResponseCode coapResponseCode = ResponseCodeUtil.toCoapResponseCode(new org.eclipse.leshan.core.ResponseCode(503)); Assert.assertEquals(ResponseCode.SERVICE_UNAVAILABLE, coapResponseCode); }
@Test(expected = IllegalArgumentException.class) public void unknown_lwm2m_code_to_invalid_coap_code() { ResponseCodeUtil.toCoapResponseCode(new org.eclipse.leshan.core.ResponseCode(301)); }
@Test(expected = IllegalArgumentException.class) public void unknown_lwm2m_code_to_invalid_coap_code2() { ResponseCodeUtil.toCoapResponseCode(new org.eclipse.leshan.core.ResponseCode(441)); }
@Test public void unknown_lwm2m_code_to_unknown_coap_code() { ResponseCode coapResponseCode = ResponseCodeUtil.toCoapResponseCode(new org.eclipse.leshan.core.ResponseCode(206)); Assert.assertEquals(ResponseCode._UNKNOWN_SUCCESS_CODE, coapResponseCode); coapResponseCode = ResponseCodeUtil.toCoapResponseCode(new org.eclipse.leshan.core.ResponseCode(425)); Assert.assertEquals(ResponseCode.BAD_REQUEST, coapResponseCode); coapResponseCode = ResponseCodeUtil.toCoapResponseCode(new org.eclipse.leshan.core.ResponseCode(509)); Assert.assertEquals(ResponseCode.INTERNAL_SERVER_ERROR, coapResponseCode); }