PluralFormServiceImpl implements PluralFormService { @Override public String getPluralForm(final String lang, final int num, final String[] form) { int index = 0; if ("RU".equalsIgnoreCase(lang)) { index = (num % 10 == 1 && num % 100 != 11 ? 0 : num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? 1 : 2); } else { if (num > 1) { index = 1; } } return form[index]; }  @Override String getPluralForm(final String lang, final int num, final String[] form);  }
@Test public void testGetPluralForm() { PluralFormService pluralFormService = new PluralFormServiceImpl(); assertEquals("item", pluralFormService.getPluralForm("EN", 1, new String[]{"item", "items"})); assertEquals("items", pluralFormService.getPluralForm("EN", 2, new String[]{"item", "items"})); String[] arr = new String[]{"продукт", "продукта", "продуктов"}; assertEquals("продукт", pluralFormService.getPluralForm("ru", 1, arr)); assertEquals("продукта", pluralFormService.getPluralForm("ru", 2, arr)); assertEquals("продукта", pluralFormService.getPluralForm("ru", 3, arr)); assertEquals("продукта", pluralFormService.getPluralForm("ru", 4, arr)); assertEquals("продуктов", pluralFormService.getPluralForm("ru", 10, arr)); assertEquals("продуктов", pluralFormService.getPluralForm("ru", 11, arr)); assertEquals("продукт", pluralFormService.getPluralForm("ru", 21, arr)); assertEquals("продуктов", pluralFormService.getPluralForm("ru", 111, arr)); assertEquals("продукта", pluralFormService.getPluralForm("ru", 142, arr)); }