String maybeTruncated(String note) throws UnsupportedOperationException {
        byte[] stringBytes = note.getBytes(UTF_8);

        if (note.length() != stringBytes.length) {
            throw new UnsupportedOperationException("Truncating messages containing multibyte characters isn't implemented");
        } else if (stringBytes.length <= MAX_MESSAGE_LENGTH) {
            return note;
        } else {
            return new String(stringBytes, 0, 997, UTF_8) + ELLIPSIS;
        }
    }
@Test
    void testTruncation() {
        String underOneThousandBytes = "1".repeat(999);
        String oneThousandBytes = "2".repeat(1000);
        String twoThousandBytes = "3".repeat(2000);
            
        assertThat(publisher.maybeTruncated(underOneThousandBytes).getBytes(UTF_8).length, is(999));
        assertThat(publisher.maybeTruncated(underOneThousandBytes), is(underOneThousandBytes));

        assertThat(publisher.maybeTruncated(oneThousandBytes).getBytes(UTF_8).length, is(1000));
        assertThat(publisher.maybeTruncated(oneThousandBytes), is(oneThousandBytes));

        assertThat(publisher.maybeTruncated(twoThousandBytes).getBytes(UTF_8).length, is(1000));
        assertThat(publisher.maybeTruncated(twoThousandBytes), is("3".repeat(997) + "..."));
    }