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 testGetDictionaryIdReturnsSameIdForSameWord() {
        int word1Id = dictionary.getDictionaryId("word1");
        dictionary.getDictionaryId("word2");
        dictionary.getDictionaryId("word3");
        dictionary.getDictionaryId("word4");

        assertEquals(word1Id, dictionary.getDictionaryId("word1"));
    }