MLEnvironmentFactory { public static synchronized MLEnvironment get(Long mlEnvId) { if (!map.containsKey(mlEnvId)) { if (mlEnvId.equals(DEFAULT_ML_ENVIRONMENT_ID)) { setDefault(new MLEnvironment()); } else { throw new IllegalArgumentException( String.format("Cannot find MLEnvironment for MLEnvironmentId %s." + " Did you get the MLEnvironmentId by calling getNewMLEnvironmentId?", mlEnvId)); } } return map.get(mlEnvId); }  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 testInvalidMLEnvId() { MLEnvironmentFactory.get(-1L); }