int getDictionaryId(String word) throws LongWordException {
        requireNonNull(word);
        if (word.length() > MAX_WORD_LENGTH) {
            throw new LongWordException("Too long value in the metric descriptor found, maximum is "
                    + MAX_WORD_LENGTH + ": " + word);
        }

        int nextWordId = orderedDictionary.size();
        return orderedDictionary
                .computeIfAbsent(word, key -> new Word(word, nextWordId))
                .id;
    }
@Test
    public void when_tooLongWord_then_fails() {
        String longWord = Stream.generate(() -> "a")
                                .limit(MetricsDictionary.MAX_WORD_LENGTH + 1)
                                .collect(Collectors.joining());
        assertThrows(LongWordException.class, () -> dictionary.getDictionaryId(longWord));
    }