use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitOperationList_oneQuery_success.
@Test
public void testTransmitOperationList_oneQuery_success() {
List<VdcOperation<?, ?>> testList = new ArrayList<>();
QueryParametersBase testParameters = new QueryParametersBase();
VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testParameters, mockOperationCallbackSingle1);
testList.add(testOperation1);
testProvider.transmitOperationList(testList);
verify(mockService).runQuery(eq(QueryType.Search), eq(testParameters), queryCallback.capture());
QueryReturnValue testResult = new QueryReturnValue();
queryCallback.getValue().onSuccess(testResult);
verify(mockOperationCallbackSingle1).onSuccess(testOperation1, testResult);
}
use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitPublicOperationList_success.
@Test
public void testTransmitPublicOperationList_success() {
QueryParametersBase testQueryParameters = new QueryParametersBase();
VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testQueryParameters, true, false, mockOperationCallbackSingle1);
List<VdcOperation<?, ?>> operationList = new ArrayList<>();
operationList.add(testOperation1);
testProvider.transmitOperationList(operationList);
verify(mockService).runPublicQuery(eq(QueryType.Search), eq(testQueryParameters), queryCallback.capture());
QueryReturnValue testQueryResult = new QueryReturnValue();
queryCallback.getValue().onSuccess(testQueryResult);
verify(mockOperationCallbackSingle1).onSuccess(testOperation1, testQueryResult);
}
use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitPublicOperationList_two_public_success.
@Test
public void testTransmitPublicOperationList_two_public_success() {
QueryParametersBase testQueryParameters = new QueryParametersBase();
VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testQueryParameters, true, false, mockOperationCallbackSingle1);
VdcOperation<QueryType, QueryParametersBase> testOperation2 = new VdcOperation<>(QueryType.GetConfigurationValues, testQueryParameters, true, false, mockOperationCallbackSingle2);
List<VdcOperation<?, ?>> operationList = new ArrayList<>();
operationList.add(testOperation1);
operationList.add(testOperation2);
testProvider.transmitOperationList(operationList);
verify(mockService).runPublicQuery(eq(QueryType.Search), eq(testQueryParameters), queryCallback.capture());
QueryReturnValue testQueryResult = new QueryReturnValue();
queryCallback.getValue().onSuccess(testQueryResult);
verify(mockOperationCallbackSingle1).onSuccess(testOperation1, testQueryResult);
verify(mockService).runPublicQuery(eq(QueryType.GetConfigurationValues), eq(testQueryParameters), queryCallback.capture());
testQueryResult = new QueryReturnValue();
queryCallback.getValue().onSuccess(testQueryResult);
verify(mockOperationCallbackSingle2).onSuccess(testOperation2, testQueryResult);
}
use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class OperationProcessorTest method testOnOperationAvailableSingle_failure_with_retry.
@Test
public void testOnOperationAvailableSingle_failure_with_retry() {
QueryParametersBase testParameter = new QueryParametersBase();
VdcOperation<QueryType, QueryParametersBase> testOperation = new VdcOperation<>(QueryType.Search, testParameter, mockCallback1);
when(mockOperationManager.pollOperation()).thenReturn((VdcOperation) testOperation).thenReturn(null);
testProcessor.processAvailableOperations(mockOperationManager);
verify(mockProvider).transmitOperationList(operationListCaptor.capture());
// $NON-NLS-1$
Exception testException = new Exception("This is an exception");
operationListCaptor.getValue().get(0).getCallback().onFailure(operationListCaptor.getValue().get(0), testException);
// Verify that the original callback is never called.
verify(mockCallback1, never()).onFailure(operationListCaptor.getValue().get(0), testException);
// Verify that the operation is put back in the queue.
verify(mockOperationManager).addOperation(operationListCaptor.getValue().get(0));
// Verify that the callback on the operation is no longer the original.
assertFalse(// $NON-NLS-1$
"callbacks should not match", operationListCaptor.getValue().get(0).getCallback().equals(mockCallback1));
}
use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class OperationProcessorTest method testOnOperationAvailableMultiple_same_success.
@Test
public void testOnOperationAvailableMultiple_same_success() {
QueryParametersBase testParameter = new QueryParametersBase();
List<VdcOperation<?, ?>> testOperation1List = new ArrayList<>();
VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testParameter, mockCallbackList1);
testOperation1List.add(testOperation1);
VdcOperation<QueryType, QueryParametersBase> testOperation2 = new VdcOperation<>(QueryType.GetDirectoryGroupById, testParameter, mockCallbackList2);
when(mockOperationManager.pollOperation()).thenReturn((VdcOperation) testOperation1).thenReturn((VdcOperation) testOperation1).thenReturn((VdcOperation) testOperation2).thenReturn(null);
testProcessor.processAvailableOperations(mockOperationManager);
verify(mockProvider).transmitOperationList(operationListCaptor.capture());
// Check to make sure it inserted its own callback.
assertFalse(// $NON-NLS-1$
"The callbacks should NOT match", operationListCaptor.getValue().get(0).getCallback().equals(mockCallbackList1));
assertFalse(// $NON-NLS-1$
"The callbacks should NOT match", operationListCaptor.getValue().get(1).getCallback().equals(mockCallbackList2));
// There should be only be two items in the list.
// $NON-NLS-1$
assertEquals("There should be two items", 2, operationListCaptor.getValue().size());
List<ActionReturnValue> resultList1 = new ArrayList<>();
List<ActionReturnValue> resultList2 = new ArrayList<>();
ActionReturnValue result1 = new ActionReturnValue();
ActionReturnValue result2 = new ActionReturnValue();
resultList1.add(result1);
resultList2.add(result2);
List<VdcOperation> captured1List = new ArrayList<>();
captured1List.add(operationListCaptor.getValue().get(0));
List<VdcOperation> captured2List = new ArrayList<>();
captured2List.add(operationListCaptor.getValue().get(1));
operationListCaptor.getValue().get(0).getCallback().onSuccess(captured1List, resultList1);
verify(mockCallbackList1).onSuccess(testOperation1List, resultList1);
operationListCaptor.getValue().get(1).getCallback().onSuccess(captured2List, resultList2);
}
Aggregations