class UnsignedNumberUtil {

    public static byte[] toBytes(int ushortValue) {
        if (!isWithinUnsignedShort(ushortValue)) {
            throw new IllegalArgumentException(OUT_OF_RANGE_ERROR);
        }
        byte[] bytes = new byte[2];
        bytes[1] = (byte) (0x00ff & (ushortValue));
        bytes[0] = (byte) (0x00ff & (ushortValue >>> 8));
        return bytes;
    }

}

class UnsignedNumberUtilTest {

    @Test
    void toBytes_long_1_test1() {

        byte[] bytes = UnsignedNumberUtil.toBytes(0x00000001L);
        assertAll(
                () -> assertThat(bytes).hasSize(4),
                () -> assertThat(bytes).isEqualTo(new byte[]{(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01})
        );
    }

}