### Question:
SchedulerNGFactoryFactory { static SchedulerNGFactory createSchedulerNGFactory( final Configuration configuration, final RestartStrategyFactory restartStrategyFactory) { final String schedulerName = configuration.getString(JobManagerOptions.SCHEDULER); switch (schedulerName) { case "legacy": return new LegacySchedulerFactory(restartStrategyFactory); case "ng": return new DefaultSchedulerFactory(); default: throw new IllegalArgumentException(String.format( "Illegal value [%s] for config option [%s]", schedulerName, JobManagerOptions.SCHEDULER.key())); } } private  SchedulerNGFactoryFactory();   }### Answer:
@Test public void createLegacySchedulerFactoryByDefault() { final SchedulerNGFactory schedulerNGFactory = createSchedulerNGFactory(new Configuration()); assertThat(schedulerNGFactory, is(instanceOf(LegacySchedulerFactory.class))); }
@Test public void createSchedulerNGFactoryIfConfigured() { final Configuration configuration = new Configuration(); configuration.setString(JobManagerOptions.SCHEDULER, "ng"); final SchedulerNGFactory schedulerNGFactory = createSchedulerNGFactory(configuration); assertThat(schedulerNGFactory, is(instanceOf(DefaultSchedulerFactory.class))); }
@Test public void throwsExceptionIfSchedulerNameIsInvalid() { final Configuration configuration = new Configuration(); configuration.setString(JobManagerOptions.SCHEDULER, "invalid-scheduler-name"); try { createSchedulerNGFactory(configuration); } catch (IllegalArgumentException e) { assertThat(e.getMessage(), containsString("Illegal value [invalid-scheduler-name]")); } }