RangerValidator { int getEnumDefaultIndex(RangerEnumDef enumDef) { int index; if (enumDef == null) { index = -1; } else if (enumDef.getDefaultIndex() == null) { index = 0; } else { index = enumDef.getDefaultIndex(); } return index; } protected  RangerValidator(ServiceStore store); protected  RangerValidator(RoleStore roleStore); void validate(Long id, Action action); void validate(String name, Action action); static String serializeFailures(List<ValidationFailureDetails> failures);  }
@Test public void test_getEnumDefaultIndex() { RangerEnumDef enumDef = mock(RangerEnumDef.class); Assert.assertEquals(-1, _validator.getEnumDefaultIndex(null)); when(enumDef.getDefaultIndex()).thenReturn(null); Assert.assertEquals(0, _validator.getEnumDefaultIndex(enumDef)); when(enumDef.getDefaultIndex()).thenReturn(-5); Assert.assertEquals(-5, _validator.getEnumDefaultIndex(enumDef)); }