Skip to content

Commit

Permalink
Add get current job #592 improve TCs
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielwEriksson committed Feb 22, 2024
1 parent 12df881 commit 8464b21
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,27 @@ public void testGetCurrentJobStatus() throws InterruptedException
latch);
myScheduler.schedule(testJob);
new Thread(() -> myScheduler.run()).start();
Thread.sleep(100);
Thread.sleep(50);
assertThat(myScheduler.getCurrentJobStatus()).isEqualTo("Job ID: " + jobId.toString() + ", Status: Running");
latch.countDown();
}

@Test
public void testGetCurrentJobStatusNoRunning() throws InterruptedException
{
CountDownLatch latch = new CountDownLatch(1);
UUID jobId = UUID.randomUUID();
ScheduledJob testJob = new TestScheduledJob(
new ScheduledJob.ConfigurationBuilder()
.withPriority(ScheduledJob.Priority.LOW)
.withRunInterval(1, TimeUnit.SECONDS)
.build(),
jobId,
latch);
myScheduler.schedule(testJob);
new Thread(() -> myScheduler.run()).start();
assertThat(myScheduler.getCurrentJobStatus()).isNotEqualTo("Job ID: " + jobId.toString() + ", Status: Running");
latch.countDown();
}
private void waitForJobStarted(TestJob job) throws InterruptedException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import static org.mockito.Mockito.when;
import static org.springframework.http.HttpStatus.NOT_FOUND;


@RunWith(MockitoJUnitRunner.Silent.class)
public class TestScheduleRepairManagementRESTImpl
{
Expand All @@ -64,23 +65,6 @@ public void setupMocks()
ScheduleREST = new ScheduleRepairManagementRESTImpl(myRepairScheduler);
}

@Test
public void testGetCurrentJobOneExist()
{
UUID jobId = UUID.randomUUID();
String t = "Job ID: " + jobId + ", Status: Running";
when(myRepairScheduler.getCurrentJobStatus()).thenReturn(t);
assertThat(myRepairScheduler.getCurrentJobStatus()).isEqualTo(t);
}

@Test
public void testGetCurrentJobNoneExist()
{
String t = "No job is currently running";
when(myRepairScheduler.getCurrentJobStatus()).thenReturn(t);
assertThat(myRepairScheduler.getCurrentJobStatus()).isEqualTo(t);
}

@Test
public void testGetNoSchedules()
{
Expand Down

0 comments on commit 8464b21

Please sign in to comment.