Skip to content

Commit

Permalink
Formatted the code as per code of conduct and made the changes as men…
Browse files Browse the repository at this point in the history
…tioned in the review comments.
  • Loading branch information
HarshSawarkar committed Oct 31, 2023
1 parent a2877a7 commit b084c16
Showing 1 changed file with 4 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,27 @@ class PipelineJobCenterTest {
void testPipelineJobCenter() {
PipelineJob pipelineJob = mock(PipelineJob.class);
PipelineJobCenter.addJob("Job1", pipelineJob);

assertTrue(PipelineJobCenter.isJobExisting("Job1"));
assertFalse(PipelineJobCenter.isJobExisting("Job2"));
assertNotNull(PipelineJobCenter.getJob("Job1"));
assertEquals(pipelineJob, PipelineJobCenter.getJob("Job1"));
assertNull(PipelineJobCenter.getJob("Job2"));

PipelineJob pipelineJob1 = mock(PipelineJob.class);
PipelineJobCenter.addJob("Job3", pipelineJob1);
assertNotNull(PipelineJobCenter.getJob("Job3"));
assertEquals(pipelineJob1, PipelineJobCenter.getJob("Job3"));
PipelineJobCenter.stop("Job3");
PipelineJobCenter.stop("Job1");
}

@Test
void getJobItemContext() {
PipelineJob pipelineJob = mock(PipelineJob.class);
PipelineTasksRunner pipelineTasksRunner = mock(PipelineTasksRunner.class);
PipelineJobItemContext pipelineJobItemContext = mock(PipelineJobItemContext.class);
Optional<PipelineJobItemContext> pipelineJobItemContext1 = Optional.ofNullable(pipelineJobItemContext);
Optional<PipelineJobItemContext> optionalPipelineJobItemContext = Optional.ofNullable(pipelineJobItemContext);
when(pipelineJob.getTasksRunner(anyInt())).thenReturn(Optional.of(pipelineTasksRunner));
when(pipelineTasksRunner.getJobItemContext()).thenReturn(pipelineJobItemContext);
PipelineJobCenter.addJob("Job1", pipelineJob);
Optional<PipelineJobItemContext> result = PipelineJobCenter.getJobItemContext("Job1", 1);
Optional<PipelineJobItemContext> result1 = PipelineJobCenter.getJobItemContext("Job2", 1);
assertTrue(result.isPresent());
assertEquals(pipelineJobItemContext1, result);
assertFalse(result1.isPresent());
assertNotNull(result1);
assertEquals(Optional.empty(), PipelineJobCenter.getJobItemContext("Job2", 1));
assertEquals(optionalPipelineJobItemContext, result);
PipelineJobCenter.stop("Job1");
}

Expand All @@ -84,7 +76,6 @@ void getShardingItems() {
PipelineJobCenter.addJob("Job1", pipelineJob);
when(pipelineJob.getShardingItems()).thenReturn(Arrays.asList(1, 2, 3));
Collection<Integer> shardingItems = pipelineJob.getShardingItems();

Assertions.assertFalse(shardingItems.isEmpty());
Assertions.assertEquals(Arrays.asList(1, 2, 3), PipelineJobCenter.getShardingItems("Job1"));
assertEquals(Collections.EMPTY_LIST, PipelineJobCenter.getShardingItems("Job2"));
Expand Down

0 comments on commit b084c16

Please sign in to comment.