Search in sources :

Example 6 with ProviderTypeSelectedEvent

use of org.guvnor.ala.ui.client.events.ProviderTypeSelectedEvent in project kie-wb-common by kiegroup.

the class ProvisioningManagementBrowserPresenterTest method testOnProviderTypeSelectedWithNOProviders.

@Test
public void testOnProviderTypeSelectedWithNOProviders() {
    // pick an arbitrary element as the selected
    ProviderType selectedProviderType = providerTypes.iterator().next();
    ProviderTypeKey selectedProviderTypeKey = selectedProviderType.getKey();
    // the selected provider type don't have providers.
    List<ProviderKey> providerKeys = new ArrayList<>();
    ProvidersInfo providersInfo = mock(ProvidersInfo.class);
    when(providersInfo.getProviderType()).thenReturn(selectedProviderType);
    when(providersInfo.getProvidersKey()).thenReturn(providerKeys);
    when(providerTypeService.getProviderType(selectedProviderTypeKey)).thenReturn(selectedProviderType);
    when(provisioningScreensService.getProvidersInfo(selectedProviderTypeKey)).thenReturn(providersInfo);
    presenter.onProviderTypeSelected(new ProviderTypeSelectedEvent(selectedProviderType.getKey()));
    verify(providerEmptyPresenter, times(1)).setProviderType(selectedProviderType);
    verify(view, times(1)).setContent(providerEmptyPresenterView);
    verify(providerTypePresenter, times(1)).setup(any(ProviderType.class), anyCollectionOf(ProviderKey.class), any(ProviderKey.class));
}
Also used : ProviderKey(org.guvnor.ala.ui.model.ProviderKey) ProviderTypeSelectedEvent(org.guvnor.ala.ui.client.events.ProviderTypeSelectedEvent) ArrayList(java.util.ArrayList) ProviderType(org.guvnor.ala.ui.model.ProviderType) ProviderTypeKey(org.guvnor.ala.ui.model.ProviderTypeKey) ProvidersInfo(org.guvnor.ala.ui.model.ProvidersInfo) Test(org.junit.Test)

Example 7 with ProviderTypeSelectedEvent

use of org.guvnor.ala.ui.client.events.ProviderTypeSelectedEvent in project kie-wb-common by kiegroup.

the class ProviderTypeNavigationPresenterTest method testOnSelect.

@Test
public void testOnSelect() {
    presenter.setup(providerType, providerTypes);
    // test the selection of whatever of the elements.
    providerTypes.forEach(currentProviderType -> {
        presenter.onSelect(new ProviderTypeSelectedEvent(currentProviderType.getKey()));
        if (!currentProviderType.equals(providerType)) {
            verify(view, times(1)).select(currentProviderType.getKey());
        }
    });
    verify(view, times(2)).select(providerType.getKey());
}
Also used : ProviderTypeSelectedEvent(org.guvnor.ala.ui.client.events.ProviderTypeSelectedEvent) Test(org.junit.Test)

Example 8 with ProviderTypeSelectedEvent

use of org.guvnor.ala.ui.client.events.ProviderTypeSelectedEvent in project kie-wb-common by kiegroup.

the class ProvisioningManagementBrowserPresenter method setupProviderTypes.

private void setupProviderTypes(final Collection<ProviderType> providerTypes, final ProviderTypeKey selectProviderTypeKey) {
    if (providerTypes.isEmpty()) {
        this.view.setEmptyView(providerTypeEmptyPresenter.getView());
        providerTypeNavigationPresenter.clear();
    } else {
        ProviderType providerType2BeSelected = null;
        if (selectProviderTypeKey != null) {
            for (final ProviderType providerType : providerTypes) {
                if (providerType.getKey().equals(selectProviderTypeKey)) {
                    providerType2BeSelected = providerType;
                    break;
                }
            }
        }
        if (providerType2BeSelected == null) {
            providerType2BeSelected = providerTypes.iterator().next();
        }
        providerTypeNavigationPresenter.setup(providerType2BeSelected, providerTypes);
        providerTypeSelectedEvent.fire(new ProviderTypeSelectedEvent(providerType2BeSelected.getKey()));
    }
}
Also used : ProviderTypeSelectedEvent(org.guvnor.ala.ui.client.events.ProviderTypeSelectedEvent) ProviderType(org.guvnor.ala.ui.model.ProviderType)

Aggregations

ProviderTypeSelectedEvent (org.guvnor.ala.ui.client.events.ProviderTypeSelectedEvent)8 Test (org.junit.Test)5 ProviderType (org.guvnor.ala.ui.model.ProviderType)4 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)3 ProviderKey (org.guvnor.ala.ui.model.ProviderKey)2 ProviderTypeKey (org.guvnor.ala.ui.model.ProviderTypeKey)2 ProvidersInfo (org.guvnor.ala.ui.model.ProvidersInfo)2 ArrayList (java.util.ArrayList)1 ProviderSelectedEvent (org.guvnor.ala.ui.client.events.ProviderSelectedEvent)1 ProviderTypeListRefreshEvent (org.guvnor.ala.ui.client.events.ProviderTypeListRefreshEvent)1