CloudJobConfigurationService { public Optional<CloudJobConfigurationPOJO> load(final String jobName) { String configContent = regCenter.get(CloudJobConfigurationNode.getRootNodePath(jobName)); return Strings.isNullOrEmpty(configContent) ? Optional.empty() : Optional.of(YamlEngine.unmarshal(configContent, CloudJobConfigurationPOJO.class)); }  void add(final CloudJobConfigurationPOJO cloudJobConfig); void update(final CloudJobConfigurationPOJO cloudJobConfig); Collection<CloudJobConfigurationPOJO> loadAll(); Optional<CloudJobConfigurationPOJO> load(final String jobName); void remove(final String jobName);  }
@Test public void assertLoadWithoutConfig() { assertFalse(configService.load("test_job").isPresent()); }
@Test public void assertLoadWithConfig() { when(regCenter.get("/config/job/test_job")).thenReturn(CloudJsonConstants.getJobJson()); Optional<CloudJobConfigurationPOJO> actual = configService.load("test_job"); assertTrue(actual.isPresent()); assertThat(actual.get().getJobName(), is("test_job")); }
@Test public void assertLoadWithSpringConfig() { when(regCenter.get("/config/job/test_spring_job")).thenReturn(CloudJsonConstants.getSpringJobJson()); Optional<CloudJobConfigurationPOJO> actual = configService.load("test_spring_job"); assertTrue(actual.isPresent()); }