RangerEnumUtil { public String getLabel(String enumName, int enumValue) { VEnum vEnum = getEnum(enumName); if (vEnum == null) { logger.error("Enum " + enumName + " not found.", new Throwable()); return ""; } for (VEnumElement vEnumElement : vEnum.getElementList()) { if (vEnumElement.getElementValue() == enumValue) { return vEnumElement.getElementLabel(); } } logger.error("Enum value not found. enum=" + enumName + ", value=" + enumValue, new Throwable()); return ""; }  List<VEnum> getEnums(); VEnum getEnum(String enumName); String getLabel(String enumName, int enumValue); int getValue(String enumName, String elementName); final static String ENUM_CommonEnums_ActiveStatus; final static String ENUM_CommonEnums_ActivationStatus; final static String ENUM_CommonEnums_BooleanValue; final static String ENUM_CommonEnums_DataType; final static String ENUM_CommonEnums_DeviceType; final static String ENUM_CommonEnums_DiffLevel; final static String ENUM_CommonEnums_FileType; final static String ENUM_CommonEnums_FreqType; final static String ENUM_CommonEnums_MimeType; final static String ENUM_CommonEnums_NumberFormat; final static String ENUM_CommonEnums_ObjectStatus; final static String ENUM_CommonEnums_PasswordResetStatus; final static String ENUM_CommonEnums_PriorityType; final static String ENUM_CommonEnums_ProgressStatus; final static String ENUM_CommonEnums_RelationType; final static String ENUM_CommonEnums_UserSource; final static String ENUM_CommonEnums_AssetType; final static String ENUM_CommonEnums_AccessResult; final static String ENUM_CommonEnums_PolicyType; final static String ENUM_CommonEnums_XAAuditType; final static String ENUM_CommonEnums_ResourceType; final static String ENUM_CommonEnums_XAGroupType; final static String ENUM_CommonEnums_XAPermForType; final static String ENUM_CommonEnums_XAPermType; final static String ENUM_CommonEnums_ClassTypes; final static String ENUM_XXAuthSession_AuthStatus; final static String ENUM_XXAuthSession_AuthType; final static String ENUM_XResponse_ResponseStatus; }
@Test public void testGetLabelIsNUll() { String enumName = "CommonEnums.ActiveStatus"; int enumValue = 1; String value = xaEnumUtil.getLabel(enumName, enumValue); boolean checkValue=value.isEmpty(); Assert.assertFalse(checkValue); }
@Test public void testGetLabel() { testGetEnum(); String enumName = "CommonEnums.ActiveStatus"; int enumValue = 1; String value = xaEnumUtil.getLabel(enumName, enumValue); Assert.assertNotNull(value); }