MLEnvironmentFactory { public static synchronized void setDefault(MLEnvironment env) { if (map.containsKey(DEFAULT_ML_ENVIRONMENT_ID)) { throw new IllegalArgumentException("The default MLEnvironment should be set only once."); } map.put(DEFAULT_ML_ENVIRONMENT_ID, env); }  static synchronized MLEnvironment get(Long mlEnvId); static synchronized MLEnvironment getDefault(); static synchronized void setDefault(MLEnvironment env); static synchronized Long getNewMLEnvironmentId(); static synchronized Long registerMLEnvironment(MLEnvironment env); static synchronized MLEnvironment remove(Long mlEnvId); static final Long DEFAULT_ML_ENVIRONMENT_ID; }
@Test(expected = IllegalArgumentException.class) public void testSetDefault() { MLEnvironment mlEnvironment = MLEnvironmentFactory.getDefault(); MLEnvironmentFactory.setDefault(mlEnvironment); }