Env { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Env env = (Env) o; if(getName().equals(env.getName())) { throw new RuntimeException(getName() + " is same environment name, but their Env not same"); } else { return false; } } 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 public void testEquals() { assertEquals(Env.DEV, Env.valueOf("dEv")); String name = "someEEEE"; Env.addEnvironment(name); assertFalse(Env.valueOf(name).equals(Env.DEV)); }