ErrorCode { public static String getName(int error) { switch(error) { case UNKNOWN_CONFIG: return "UNKNOWN_CONFIG"; case UNKNOWN_DEFINITION: return "UNKNOWN_DEFINITION"; case UNKNOWN_DEF_MD5: return "UNKNOWN_DEF_MD5"; case ILLEGAL_NAME: return "ILLEGAL_NAME"; case ILLEGAL_VERSION: return "ILLEGAL_VERSION"; case ILLEGAL_CONFIGID: return "ILLEGAL_CONFIGID"; case ILLEGAL_DEF_MD5: return "ILLEGAL_DEF_MD5"; case ILLEGAL_CONFIG_MD5: return "ILLEGAL_CONFIG_MD5"; case ILLEGAL_TIMEOUT: return "ILLEGAL_TIMEOUT"; case ILLEGAL_GENERATION: return "ILLEGAL_GENERATION"; case ILLEGAL_SUB_FLAG: return "ILLEGAL_SUBSCRIBE_FLAG"; case ILLEGAL_NAME_SPACE: return "ILLEGAL_NAME_SPACE"; case ILLEGAL_CLIENT_HOSTNAME: return "ILLEGAL_CLIENT_HOSTNAME"; case OUTDATED_CONFIG: return "OUTDATED_CONFIG"; case INTERNAL_ERROR: return "INTERNAL_ERROR"; case APPLICATION_NOT_LOADED: return "APPLICATION_NOT_LOADED"; case ILLEGAL_PROTOCOL_VERSION: return "ILLEGAL_PROTOCOL_VERSION"; case INCONSISTENT_CONFIG_MD5: return "INCONSISTENT_CONFIG_MD5"; case UNKNOWN_VESPA_VERSION: return "UNKNOWN_VESPA_VERSION"; default: return "Unknown error"; } } private  ErrorCode(); static String getName(int error); static final int UNKNOWN_CONFIG; static final int UNKNOWN_DEFINITION; static final int UNKNOWN_DEF_MD5; static final int UNKNOWN_VESPA_VERSION; static final int ILLEGAL_NAME; static final int ILLEGAL_VERSION; static final int ILLEGAL_CONFIGID; static final int ILLEGAL_DEF_MD5; static final int ILLEGAL_CONFIG_MD5; static final int ILLEGAL_TIMEOUT; static final int ILLEGAL_GENERATION; static final int ILLEGAL_SUB_FLAG; static final int ILLEGAL_NAME_SPACE; static final int ILLEGAL_PROTOCOL_VERSION; static final int ILLEGAL_CLIENT_HOSTNAME; static final int OUTDATED_CONFIG; static final int INTERNAL_ERROR; static final int APPLICATION_NOT_LOADED; static final int INCONSISTENT_CONFIG_MD5; }
@Test public void basic() { assertThat(ErrorCode.getName(ErrorCode.INTERNAL_ERROR), is("INTERNAL_ERROR")); assertThat(ErrorCode.getName(ErrorCode.ILLEGAL_CONFIG_MD5), is("ILLEGAL_CONFIG_MD5")); assertThat(ErrorCode.getName(ErrorCode.ILLEGAL_CONFIGID), is("ILLEGAL_CONFIGID")); assertThat(ErrorCode.getName(ErrorCode.ILLEGAL_DEF_MD5), is("ILLEGAL_DEF_MD5")); assertThat(ErrorCode.getName(ErrorCode.ILLEGAL_GENERATION), is("ILLEGAL_GENERATION")); assertThat(ErrorCode.getName(ErrorCode.ILLEGAL_NAME), is("ILLEGAL_NAME")); assertThat(ErrorCode.getName(ErrorCode.ILLEGAL_SUB_FLAG), is("ILLEGAL_SUBSCRIBE_FLAG")); assertThat(ErrorCode.getName(ErrorCode.ILLEGAL_TIMEOUT), is("ILLEGAL_TIMEOUT")); assertThat(ErrorCode.getName(ErrorCode.ILLEGAL_VERSION), is("ILLEGAL_VERSION")); assertThat(ErrorCode.getName(ErrorCode.OUTDATED_CONFIG), is("OUTDATED_CONFIG")); assertThat(ErrorCode.getName(ErrorCode.UNKNOWN_CONFIG), is("UNKNOWN_CONFIG")); assertThat(ErrorCode.getName(ErrorCode.UNKNOWN_DEF_MD5), is("UNKNOWN_DEF_MD5")); assertThat(ErrorCode.getName(ErrorCode.UNKNOWN_DEFINITION), is("UNKNOWN_DEFINITION")); assertThat(ErrorCode.getName(ErrorCode.UNKNOWN_VESPA_VERSION), is("UNKNOWN_VESPA_VERSION")); assertThat(ErrorCode.getName(ErrorCode.INCONSISTENT_CONFIG_MD5), is("INCONSISTENT_CONFIG_MD5")); assertThat(ErrorCode.getName(ErrorCode.ILLEGAL_CLIENT_HOSTNAME), is("ILLEGAL_CLIENT_HOSTNAME")); assertThat(ErrorCode.getName(12345), is("Unknown error")); }