use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class AsyncDataProvider method initCpuMap.
private void initCpuMap() {
cpuMap = new HashMap<>();
final List<QueryType> queryTypes = new ArrayList<>();
final List<QueryParametersBase> queryParams = new ArrayList<>();
for (Version version : Version.ALL) {
queryTypes.add(QueryType.GetAllServerCpuList);
queryParams.add(new GetAllServerCpuListParameters(version));
}
final IFrontendMultipleQueryAsyncCallback callback = result -> {
for (int i = 0; i < result.getReturnValues().size(); i++) {
final List<ServerCpu> cpus = result.getReturnValues().get(i).getReturnValue();
final Version version = ((GetAllServerCpuListParameters) result.getParameters().get(i)).getVersion();
initCpuMapForVersion(version, cpus);
}
};
Frontend.getInstance().runMultipleQueries(queryTypes, queryParams, callback);
}
use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class AsyncDataProvider method updateVDSInterfaceList.
public void updateVDSInterfaceList(List<VDS> vdsList, Runnable callback) {
if (vdsList != null && !vdsList.isEmpty()) {
List<QueryType> types = new ArrayList<>();
List<QueryParametersBase> ids = new ArrayList<>();
vdsList.stream().forEach(vds -> {
types.add(QueryType.GetVdsInterfacesByVdsId);
ids.add(new IdQueryParameters(vds.getId()));
});
Frontend.getInstance().runMultipleQueries(types, ids, result -> {
List<QueryReturnValue> values = result.getReturnValues();
for (int i = 0; i < vdsList.size(); i++) {
QueryReturnValue interfaceQueryValue = values.get(i);
if (interfaceQueryValue.getReturnValue() != null) {
vdsList.get(i).getInterfaces().addAll(interfaceQueryValue.getReturnValue());
}
}
callback.run();
});
} else {
callback.run();
}
}
use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testMissingXsrfToken.
@SuppressWarnings("unchecked")
@Test
public void testMissingXsrfToken() {
// Remove token so there should be a request for it.
mockXsrfRpcRequestBuilder.setXsrfToken(null);
QueryParametersBase testParameters = new QueryParametersBase();
final List<VdcOperation<QueryType, QueryParametersBase>> operationList = new ArrayList<>();
final VdcOperation<QueryType, QueryParametersBase> testOperation = new VdcOperation<>(QueryType.Search, testParameters, null);
operationList.add(testOperation);
testProvider.transmitOperation(testOperation);
verify(mockXsrfService).getNewXsrfToken((AsyncCallback<XsrfToken>) any());
}
use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitOperationList_multipleQuery_different_callback_failure.
@Test
public void testTransmitOperationList_multipleQuery_different_callback_failure() {
List<VdcOperation<?, ?>> testList = new ArrayList<>();
List<VdcOperation<?, ?>> operation1List = new ArrayList<>();
List<VdcOperation<?, ?>> operation2List = new ArrayList<>();
QueryParametersBase testParameters = new QueryParametersBase();
VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testParameters, mockOperationCallbackList1);
VdcOperation<QueryType, QueryParametersBase> testOperation2 = new VdcOperation<>(QueryType.Search, testParameters, mockOperationCallbackList2);
testList.add(testOperation1);
testList.add(testOperation2);
operation1List.add(testOperation1);
operation2List.add(testOperation2);
List<QueryParametersBase> testParameterList = createQueryParameterList(testParameters, 2);
List<QueryType> testQueryList = createQueryList(QueryType.Search, 2);
testProvider.transmitOperationList(testList);
verify(mockService).runMultipleQueries(eq((ArrayList<QueryType>) testQueryList), (ArrayList<QueryParametersBase>) eq(testParameterList), queryCallbackList.capture());
// $NON-NLS-1$
Exception testException = new Exception("This is an exception");
queryCallbackList.getValue().onFailure(testException);
verify(mockOperationCallbackList1).onFailure(eq(operation1List), eq(testException));
verify(mockOperationCallbackList2).onFailure(eq(operation2List), eq(testException));
}
use of org.ovirt.engine.core.common.queries.QueryType in project ovirt-engine by oVirt.
the class GWTRPCCommunicationProviderTest method testTransmitOperationList_multipleQuery_different_callback_success.
@Test
public void testTransmitOperationList_multipleQuery_different_callback_success() {
List<VdcOperation<?, ?>> testList = new ArrayList<>();
List<VdcOperation<?, ?>> operation1List = new ArrayList<>();
List<VdcOperation<?, ?>> operation2List = new ArrayList<>();
QueryParametersBase testParameters = new QueryParametersBase();
VdcOperation<QueryType, QueryParametersBase> testOperation1 = new VdcOperation<>(QueryType.Search, testParameters, mockOperationCallbackList1);
VdcOperation<QueryType, QueryParametersBase> testOperation2 = new VdcOperation<>(QueryType.Search, testParameters, mockOperationCallbackList2);
testList.add(testOperation1);
testList.add(testOperation2);
operation1List.add(testOperation1);
operation2List.add(testOperation2);
List<QueryParametersBase> testParameterList = createQueryParameterList(testParameters, 2);
List<QueryType> testQueryList = createQueryList(QueryType.Search, 2);
testProvider.transmitOperationList(testList);
QueryReturnValue returnValue = new QueryReturnValue();
List<QueryReturnValue> resultList = createQueryResultList(returnValue, 2);
List<QueryReturnValue> return1List = createQueryResultList(returnValue, 1);
List<QueryReturnValue> return2List = createQueryResultList(returnValue, 1);
verify(mockService).runMultipleQueries(eq((ArrayList<QueryType>) testQueryList), (ArrayList<QueryParametersBase>) eq(testParameterList), queryCallbackList.capture());
queryCallbackList.getValue().onSuccess((ArrayList<QueryReturnValue>) resultList);
verify(mockOperationCallbackList1).onSuccess(eq(operation1List), eq(return1List));
verify(mockOperationCallbackList2).onSuccess(eq(operation2List), eq(return2List));
}
Aggregations