Search in sources :

Example 6 with QueryReturnValue

use of org.ovirt.engine.core.common.queries.QueryReturnValue 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);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Example 7 with QueryReturnValue

use of org.ovirt.engine.core.common.queries.QueryReturnValue 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);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Example 8 with QueryReturnValue

use of org.ovirt.engine.core.common.queries.QueryReturnValue 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);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) ArrayList(java.util.ArrayList) QueryParametersBase(org.ovirt.engine.core.common.queries.QueryParametersBase) QueryType(org.ovirt.engine.core.common.queries.QueryType) Test(org.junit.Test)

Example 9 with QueryReturnValue

use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.

the class AbstractGwtDynamicHostPageServletTest method stubGetConfigurationValuePublicQuery.

void stubGetConfigurationValuePublicQuery() {
    QueryReturnValue returnValue = new QueryReturnValue();
    returnValue.setSucceeded(true);
    // $NON-NLS-1$
    returnValue.setReturnValue("1.2.3");
    when(mockBackend.runPublicQuery(eq(QueryType.GetConfigurationValue), argThat(configValueParams(ConfigValues.ProductRPMVersion)))).thenReturn(returnValue);
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue)

Example 10 with QueryReturnValue

use of org.ovirt.engine.core.common.queries.QueryReturnValue in project ovirt-engine by oVirt.

the class ClusterListModel method fetchAndImportClusterHosts.

private void fetchAndImportClusterHosts(final ClusterModel clusterModel) {
    getWindow().startProgress();
    AsyncQuery<QueryReturnValue> aQuery = new AsyncQuery<>(result -> {
        getWindow().stopProgress();
        QueryReturnValue returnValue = result;
        if (returnValue == null) {
            onEmptyGlusterHosts(clusterModel);
            return;
        } else if (!returnValue.getSucceeded()) {
            clusterModel.setMessage(Frontend.getInstance().getAppErrorsTranslator().translateErrorTextSingle(returnValue.getExceptionString()));
            return;
        }
        Map<String, String> hostMap = returnValue.getReturnValue();
        if (hostMap == null) {
            onEmptyGlusterHosts(clusterModel);
            return;
        }
        if (hostMap.containsValue(null) || hostMap.containsValue("")) {
            // $NON-NLS-1$
            onGlusterHostsWithoutFingerprint(hostMap, clusterModel);
            return;
        }
        ArrayList<EntityModel<HostDetailModel>> list = new ArrayList<>();
        for (Map.Entry<String, String> host : hostMap.entrySet()) {
            HostDetailModel hostModel = new HostDetailModel(host.getKey(), host.getValue());
            hostModel.setName(host.getKey());
            // $NON-NLS-1$
            hostModel.setPassword("");
            EntityModel<HostDetailModel> entityModel = new EntityModel<>(hostModel);
            list.add(entityModel);
        }
        importClusterHosts(clusterModel, list);
    });
    aQuery.setHandleFailure(true);
    AsyncDataProvider.getInstance().getGlusterHosts(aQuery, clusterModel.getGlusterHostAddress().getEntity(), clusterModel.getGlusterHostPassword().getEntity(), clusterModel.getGlusterHostFingerprint().getEntity());
}
Also used : QueryReturnValue(org.ovirt.engine.core.common.queries.QueryReturnValue) HostDetailModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) Map(java.util.Map)

Aggregations

QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)265 ArrayList (java.util.ArrayList)123 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)97 QueryType (org.ovirt.engine.core.common.queries.QueryType)85 List (java.util.List)74 Guid (org.ovirt.engine.core.compat.Guid)66 Frontend (org.ovirt.engine.ui.frontend.Frontend)64 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)54 VM (org.ovirt.engine.core.common.businessentities.VM)49 QueryParametersBase (org.ovirt.engine.core.common.queries.QueryParametersBase)47 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)42 HashMap (java.util.HashMap)40 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)39 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)39 Test (org.junit.Test)38 Collection (java.util.Collection)34 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)33 Map (java.util.Map)31 ActionType (org.ovirt.engine.core.common.action.ActionType)31 VDS (org.ovirt.engine.core.common.businessentities.VDS)31