import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
* @author Raviteja Karumuri (raviteja.karumuri@est.tech)
*/
@RunWith(MockitoJUnitRunner.class)
-public class MonitorCnfmCreateJobTaskTest {
+public class MonitorCnfmJobTaskTest {
private final BuildingBlockExecution stubbedExecution = new StubbedBuildingBlockExecution();
public static final String CREATE_CNF_STATUS_RESPONSE_PARAM_NAME = "createCnfStatusResponse";
private final String CNFM_REQUEST_STATUS_CHECK_URL = "CnfmStatusCheckUrl";
public static final String OPERATION_STATUS_PARAM_NAME = "operationStatus";
- private MonitorCnfmCreateJobTask monitorCnfmCreateJobTask;
+ private MonitorCnfmJobTask monitorCnfmCreateJobTask;
@Mock
private CnfmHttpServiceProvider mockedCnfmHttpServiceProvider;
@Mock
@Before
public void setup() {
- monitorCnfmCreateJobTask = new MonitorCnfmCreateJobTask(mockedCnfmHttpServiceProvider, exceptionUtil);
+ monitorCnfmCreateJobTask = new MonitorCnfmJobTask(mockedCnfmHttpServiceProvider, exceptionUtil);
}
@Test
- public void getCurrentOperationStatus_completed() {
+ public void test_getCurrentOperationStatus_completed() {
stubbedExecution.setVariable(CNFM_REQUEST_STATUS_CHECK_URL, URI.create("sampleURL"));
- when(mockedCnfmHttpServiceProvider.getInstantiateOperationJobStatus(Mockito.anyString()))
- .thenReturn(getAsLcmOpOcc());
+ when(mockedCnfmHttpServiceProvider.getOperationJobStatus(Mockito.anyString())).thenReturn(getAsLcmOpOcc());
monitorCnfmCreateJobTask.getCurrentOperationStatus(stubbedExecution);
assertEquals(AsLcmOpOcc.OperationStateEnum.COMPLETED,
stubbedExecution.getVariable(OPERATION_STATUS_PARAM_NAME));
@Test
public void test_getCurrentOperationStatus_Exception() {
stubbedExecution.setVariable(CNFM_REQUEST_STATUS_CHECK_URL, URI.create("sampleURL"));
- when(mockedCnfmHttpServiceProvider.getInstantiateOperationJobStatus(Mockito.anyString()))
+ when(mockedCnfmHttpServiceProvider.getOperationJobStatus(Mockito.anyString()))
.thenThrow(new RuntimeException());
monitorCnfmCreateJobTask.getCurrentOperationStatus(stubbedExecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1209), anyString(),
- any());
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1209),
+ any(Exception.class));
}
@Test
public void test_checkIfOperationWasSuccessful_status_completed() {
- final MonitorCnfmCreateJobTask mockedMonitorCnfmCreateJobTask = Mockito.spy(monitorCnfmCreateJobTask);
+ stubbedExecution.setVariable(OPERATION_STATUS_PARAM_NAME, AsLcmOpOcc.OperationStateEnum.COMPLETED);
+ final MonitorCnfmJobTask mockedMonitorCnfmCreateJobTask = Mockito.spy(monitorCnfmCreateJobTask);
mockedMonitorCnfmCreateJobTask.checkIfOperationWasSuccessful(stubbedExecution);
verify(mockedMonitorCnfmCreateJobTask, times(1)).checkIfOperationWasSuccessful(stubbedExecution);
}
stubbedExecution.setVariable(OPERATION_STATUS_PARAM_NAME, AsLcmOpOcc.OperationStateEnum.FAILED);
stubbedExecution.setVariable(CREATE_CNF_STATUS_RESPONSE_PARAM_NAME, mockedAsLcmOpOcc.orElseThrow());
monitorCnfmCreateJobTask.checkIfOperationWasSuccessful(stubbedExecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1207), anyString(),
- any());
- }
-
- @Test
- public void test_checkIfOperationWasSuccessful_status_Null() {
- stubbedExecution.setVariable(OPERATION_STATUS_PARAM_NAME, null);
- monitorCnfmCreateJobTask.checkIfOperationWasSuccessful(stubbedExecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1206), anyString(),
- any());
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1206),
+ any(Exception.class));
}
@Test
@Test
public void test_timeOutLogFailure() {
- monitorCnfmCreateJobTask.timeOutLogFailue(stubbedExecution);
- verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1205), anyString(),
- any());
+ monitorCnfmCreateJobTask.timeOutLogFailure(stubbedExecution);
+ verify(exceptionUtil).buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(1205),
+ any(Exception.class));
}
private Optional<AsLcmOpOcc> getAsLcmOpOcc() {