### Question:
RussianLetterDecoderEncoder implements LetterDecoderEncoder { public Integer encode(String string) { if (string.length() > WORD_PART_LENGHT) throw new SuffixToLongException("Suffix length should not be greater then " + WORD_PART_LENGHT + " " + string); int result = 0; for (int i = 0; i < string.length(); i++) { int c = 0 + string.charAt(i) - RUSSIAN_SMALL_LETTER_OFFSET; if (c == 45 - RUSSIAN_SMALL_LETTER_OFFSET) { c = DASH_CODE; } if (c == EE_CHAR) c = E_CHAR; if (c < 0 || c > 33) throw new WrongCharaterException("Symbol " + string.charAt(i) + " is not small cirillic letter"); result = result * 34 + c; } for (int i = string.length(); i < WORD_PART_LENGHT; i++) { result *= 34; } return result; }  Integer encode(String string); int[] encodeToArray(String s); String decodeArray(int[] array); String decode(Integer suffixN); boolean checkCharacter(char c); boolean checkString(String word); String cleanString(String s); static final int RUSSIAN_SMALL_LETTER_OFFSET; static final int WORD_PART_LENGHT; static final int EE_CHAR; static final int E_CHAR; static final int DASH_CHAR; static final int DASH_CODE; }### Answer:
@Test public void testShouldPreserverStringComporision() throws IOException { InputStream stream = this.getClass().getResourceAsStream("/org/apache/lucene/morphology/russian/decoder-test-monotonic.txt"); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(stream, "UTF-8")); String s = bufferedReader.readLine(); while (s != null) { String[] qa = s.trim().split(" "); if (qa[0].length() <= RussianLetterDecoderEncoder.WORD_PART_LENGHT && qa[1].length() <= RussianLetterDecoderEncoder.WORD_PART_LENGHT) { assertThat(decoderEncoder.encode(qa[1]) > decoderEncoder.encode(qa[0]), equalTo(true)); } s = bufferedReader.readLine(); } }
@Test(expected = SuffixToLongException.class) public void shouldThrownExeptionIfSuffixToLong() { decoderEncoder.encode("1234567890123"); }
@Test(expected = WrongCharaterException.class) public void shouldThrownExceptionIfSuffixContainWrongCharater() { decoderEncoder.encode("1"); }