Env { public static Env valueOf(String name) { name = getWellFormName(name); if(exists(name)) { return STRING_ENV_MAP.get(name); } else { throw new IllegalArgumentException(name + " not exist"); } } private  Env(String name); static Env transformEnv(String envName); static boolean exists(String name); static Env addEnvironment(String name); static Env valueOf(String name); @Deprecated static Env fromString(String env); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Deprecated String name(); String getName(); static final Env LOCAL; static final Env DEV; static final Env FWS; static final Env FAT; static final Env UAT; static final Env LPT; static final Env PRO; static final Env TOOLS; static final Env UNKNOWN; }
@Test(expected = IllegalArgumentException.class) public void valueOf() { String name = "notexist"; assertFalse(Env.exists(name)); assertEquals(Env.valueOf(name), Env.UNKNOWN); assertEquals(Env.valueOf("dev"), Env.DEV); assertEquals(Env.valueOf("UAT"), Env.UAT); }