@Test public void assertGetAllJobsBriefInfo() { when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job_1", "test_job_2")); when(regCenter.get("/test_job_1/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job_1", "desc1")); when(regCenter.get("/test_job_2/config")).thenReturn(LifecycleYamlConstants.getSimpleJobYaml("test_job_2", "desc2")); when(regCenter.getChildrenKeys("/test_job_1/servers")).thenReturn(Arrays.asList("ip1", "ip2")); when(regCenter.getChildrenKeys("/test_job_2/servers")).thenReturn(Arrays.asList("ip3", "ip4")); when(regCenter.getChildrenKeys("/test_job_1/sharding")).thenReturn(Arrays.asList("0", "1")); when(regCenter.get("/test_job_1/sharding/0/instance")).thenReturn("ip1@-@defaultInstance"); when(regCenter.get("/test_job_1/sharding/1/instance")).thenReturn("ip2@-@defaultInstance"); when(regCenter.getChildrenKeys("/test_job_2/sharding")).thenReturn(Arrays.asList("0", "1")); when(regCenter.get("/test_job_2/sharding/0/instance")).thenReturn("ip3@-@defaultInstance"); when(regCenter.get("/test_job_2/sharding/1/instance")).thenReturn("ip4@-@defaultInstance"); when(regCenter.getChildrenKeys("/test_job_1/instances")).thenReturn(Arrays.asList("ip1@-@defaultInstance", "ip2@-@defaultInstance")); when(regCenter.getChildrenKeys("/test_job_2/instances")).thenReturn(Arrays.asList("ip3@-@defaultInstance", "ip4@-@defaultInstance")); int i = 0; for (JobBriefInfo each : jobStatisticsAPI.getAllJobsBriefInfo()) { i++; assertThat(each.getJobName(), is("test_job_" + i)); assertThat(each.getDescription(), is("desc" + i)); assertThat(each.getCron(), is("0/1 * * * * ?")); assertThat(each.getInstanceCount(), is(2)); assertThat(each.getShardingTotalCount(), is(3)); assertThat(each.getStatus(), is(JobBriefInfo.JobStatus.OK)); } }
@Override public Collection<JobBriefInfo> getAllJobsBriefInfo() { List<String> jobNames = regCenter.getChildrenKeys("/"); List<JobBriefInfo> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { JobBriefInfo jobBriefInfo = getJobBriefInfo(each); if (null != jobBriefInfo) { result.add(jobBriefInfo); } } Collections.sort(result); return result; }
JobStatisticsAPIImpl implements JobStatisticsAPI { @Override public Collection<JobBriefInfo> getAllJobsBriefInfo() { List<String> jobNames = regCenter.getChildrenKeys("/"); List<JobBriefInfo> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { JobBriefInfo jobBriefInfo = getJobBriefInfo(each); if (null != jobBriefInfo) { result.add(jobBriefInfo); } } Collections.sort(result); return result; } }
JobStatisticsAPIImpl implements JobStatisticsAPI { @Override public Collection<JobBriefInfo> getAllJobsBriefInfo() { List<String> jobNames = regCenter.getChildrenKeys("/"); List<JobBriefInfo> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { JobBriefInfo jobBriefInfo = getJobBriefInfo(each); if (null != jobBriefInfo) { result.add(jobBriefInfo); } } Collections.sort(result); return result; }  }
JobStatisticsAPIImpl implements JobStatisticsAPI { @Override public Collection<JobBriefInfo> getAllJobsBriefInfo() { List<String> jobNames = regCenter.getChildrenKeys("/"); List<JobBriefInfo> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { JobBriefInfo jobBriefInfo = getJobBriefInfo(each); if (null != jobBriefInfo) { result.add(jobBriefInfo); } } Collections.sort(result); return result; }  @Override int getJobsTotalCount(); @Override Collection<JobBriefInfo> getAllJobsBriefInfo(); @Override JobBriefInfo getJobBriefInfo(final String jobName); @Override Collection<JobBriefInfo> getJobsBriefInfo(final String ip); }
JobStatisticsAPIImpl implements JobStatisticsAPI { @Override public Collection<JobBriefInfo> getAllJobsBriefInfo() { List<String> jobNames = regCenter.getChildrenKeys("/"); List<JobBriefInfo> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { JobBriefInfo jobBriefInfo = getJobBriefInfo(each); if (null != jobBriefInfo) { result.add(jobBriefInfo); } } Collections.sort(result); return result; }  @Override int getJobsTotalCount(); @Override Collection<JobBriefInfo> getAllJobsBriefInfo(); @Override JobBriefInfo getJobBriefInfo(final String jobName); @Override Collection<JobBriefInfo> getJobsBriefInfo(final String ip);  }