Search in sources :

Example 1 with Polling

use of com.dyngr.Polling in project cloudbreak by hortonworks.

the class SdxWaitTaskServiceTest method testWaitFor.

@Test
void testWaitFor() {
    try (MockedStatic<Polling> polling = mockStatic(Polling.class)) {
        SdxWaitTask<?> sdxWaitTask = new TestWaitTask(new SdxCluster(), POLLING_CONFIG, "My Sdx task");
        setupPolling(polling);
        underTest.waitFor(sdxWaitTask);
        verify(pollingOptions).stopAfterDelay(DURATION, DURATION_TIME_UNIT);
        verify(pollingOptions).stopIfException(Boolean.TRUE);
        verify(pollingOptions).run(sdxWaitTask);
    }
}
Also used : Polling(com.dyngr.Polling) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Test(org.junit.jupiter.api.Test)

Example 2 with Polling

use of com.dyngr.Polling in project cloudbreak by hortonworks.

the class SdxWaitTaskServiceTest method testWaitForWithPollerException.

@Test
void testWaitForWithPollerException() {
    try (MockedStatic<Polling> polling = mockStatic(Polling.class)) {
        SdxWaitTask<?> sdxWaitTask = new TestWaitTask(new SdxCluster(), POLLING_CONFIG, "My Sdx task");
        setupPolling(polling);
        doThrow(new PollerException()).when(pollingOptions).run(sdxWaitTask);
        Assertions.assertThrows(SdxWaitException.class, () -> {
            underTest.waitFor(sdxWaitTask);
        });
        verify(pollingOptions).stopAfterDelay(DURATION, DURATION_TIME_UNIT);
        verify(pollingOptions).stopIfException(Boolean.TRUE);
        verify(pollingOptions).run(sdxWaitTask);
    }
}
Also used : Polling(com.dyngr.Polling) PollerException(com.dyngr.exception.PollerException) SdxCluster(com.sequenceiq.datalake.entity.SdxCluster) Test(org.junit.jupiter.api.Test)

Aggregations

Polling (com.dyngr.Polling)2 SdxCluster (com.sequenceiq.datalake.entity.SdxCluster)2 Test (org.junit.jupiter.api.Test)2 PollerException (com.dyngr.exception.PollerException)1