Search in sources :

Example 1 with ProvidersInfo

use of org.guvnor.ala.ui.model.ProvidersInfo in project kie-wb-common by kiegroup.

the class ProvisioningManagementBrowserPresenterTest method testOnProviderTypeSelectedWithProviders.

@Test
public void testOnProviderTypeSelectedWithProviders() {
    // pick an arbitrary element as the selected
    ProviderType selectedProviderType = providerTypes.iterator().next();
    ProviderTypeKey selectedProviderTypeKey = selectedProviderType.getKey();
    List<ProviderKey> providerKeys = mockProviderKeyList(selectedProviderType.getKey(), PROVIDER_TYPES_SIZE);
    // pick an arbitrary element as the selected.
    ProviderKey selectedProviderKey = providerKeys.iterator().next();
    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(), selectedProviderKey.getId()));
    verify(providerTypePresenter, times(1)).setup(selectedProviderType, providerKeys, selectedProviderKey);
}
Also used : ProviderKey(org.guvnor.ala.ui.model.ProviderKey) ProviderTypeSelectedEvent(org.guvnor.ala.ui.client.events.ProviderTypeSelectedEvent) 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 2 with ProvidersInfo

use of org.guvnor.ala.ui.model.ProvidersInfo in project kie-wb-common by kiegroup.

the class ProvisioningScreensServiceImplTest method testGetProvidersInfoProviderTypeNotExisting.

@Test
public void testGetProvidersInfoProviderTypeNotExisting() {
    // the provider type not exists.
    when(providerTypeService.getProviderType(providerTypeKey)).thenReturn(null);
    ProvidersInfo providersInfo = service.getProvidersInfo(providerTypeKey);
    assertNull(providersInfo);
    verify(providerTypeService, times(1)).getProviderType(providerTypeKey);
    verify(providerService, never()).getProvidersKey(providerType);
}
Also used : ProvidersInfo(org.guvnor.ala.ui.model.ProvidersInfo) Test(org.junit.Test)

Example 3 with ProvidersInfo

use of org.guvnor.ala.ui.model.ProvidersInfo 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 4 with ProvidersInfo

use of org.guvnor.ala.ui.model.ProvidersInfo in project kie-wb-common by kiegroup.

the class ProvisioningScreensServiceImpl method getProvidersInfo.

@Override
public ProvidersInfo getProvidersInfo(final ProviderTypeKey providerTypeKey) {
    checkNotNull("providerTypeKey", providerTypeKey);
    final ProviderType providerType = providerTypeService.getProviderType(providerTypeKey);
    if (providerType == null) {
        return null;
    }
    final Collection<ProviderKey> providersKey = providerService.getProvidersKey(providerType);
    return new ProvidersInfo(providerType, providersKey);
}
Also used : ProviderKey(org.guvnor.ala.ui.model.ProviderKey) ProviderType(org.guvnor.ala.ui.model.ProviderType) ProvidersInfo(org.guvnor.ala.ui.model.ProvidersInfo)

Example 5 with ProvidersInfo

use of org.guvnor.ala.ui.model.ProvidersInfo in project kie-wb-common by kiegroup.

the class ProvisioningScreensServiceImplTest method testGetProvidersInfoProviderTypeExisting.

@Test
public void testGetProvidersInfoProviderTypeExisting() {
    // the provider type exists.
    when(providerTypeService.getProviderType(providerTypeKey)).thenReturn(providerType);
    when(providerService.getProvidersKey(providerType)).thenReturn(providerKeys);
    ProvidersInfo providersInfo = service.getProvidersInfo(providerTypeKey);
    assertNotNull(providersInfo);
    assertEquals(providerType, providersInfo.getProviderType());
    assertEquals(providerKeys, providersInfo.getProvidersKey());
    verify(providerTypeService, times(1)).getProviderType(providerTypeKey);
    verify(providerService, times(1)).getProvidersKey(providerType);
}
Also used : ProvidersInfo(org.guvnor.ala.ui.model.ProvidersInfo) Test(org.junit.Test)

Aggregations

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