@Before public void setUp() { service = new ProvisioningScreensServiceImpl(providerTypeService, providerService, runtimeService); }
@Test public void testHasRuntimesTrue() { Collection<RuntimeListItem> runtimes = mock(Collection.class); when(runtimeService.getRuntimeItems(providerKey)).thenReturn(runtimes); when(runtimes.isEmpty()).thenReturn(false); assertTrue(service.hasRuntimes(providerKey)); verify(runtimeService, times(1)).getRuntimeItems(providerKey); }
@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); }
@Test public void testGetRuntimesInfoProviderNotExisting() { //the provider not exists. when(providerService.getProvider(providerKey)).thenReturn(null); RuntimesInfo info = service.getRuntimesInfo(providerKey); assertNull(info); verify(providerService, times(1)).getProvider(providerKey); verify(runtimeService, never()).getRuntimeItems(providerKey); }
@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); }
@Test public void testGetRuntimesInfoProviderNotExisting() { //the provider not exists. when(providerService.getProvider(providerKey)).thenReturn(null); RuntimesInfo info = service.getRuntimesInfo(providerKey); assertNull(info); verify(providerService, times(1)).getProvider(providerKey); verify(runtimeService, never()).getRuntimeItems(providerKey); }
@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); }
@Test public void testHasRuntimesFalse() { Collection<RuntimeListItem> runtimes = mock(Collection.class); when(runtimeService.getRuntimeItems(providerKey)).thenReturn(runtimes); when(runtimes.isEmpty()).thenReturn(true); assertFalse(service.hasRuntimes(providerKey)); verify(runtimeService, times(1)).getRuntimeItems(providerKey); } }
@Test public void testGetRuntimesInfoProviderExisting() { //the provider exists. when(providerService.getProvider(providerKey)).thenReturn(provider); when(runtimeService.getRuntimeItems(providerKey)).thenReturn(runtimeListItems); RuntimesInfo info = service.getRuntimesInfo(providerKey); assertNotNull(info); assertEquals(provider, info.getProvider()); assertEquals(runtimeListItems, info.getRuntimeItems()); verify(providerService, times(1)).getProvider(providerKey); verify(runtimeService, times(1)).getRuntimeItems(providerKey); }
@Before public void setUp() { service = new ProvisioningScreensServiceImpl(providerTypeService, providerService, runtimeService); }
@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); }
@Test public void testHasRuntimesTrue() { Collection<RuntimeListItem> runtimes = mock(Collection.class); when(runtimeService.getRuntimeItems(providerKey)).thenReturn(runtimes); when(runtimes.isEmpty()).thenReturn(false); assertTrue(service.hasRuntimes(providerKey)); verify(runtimeService, times(1)).getRuntimeItems(providerKey); }
@Test public void testGetRuntimesInfoProviderExisting() { //the provider exists. when(providerService.getProvider(providerKey)).thenReturn(provider); when(runtimeService.getRuntimeItems(providerKey)).thenReturn(runtimeListItems); RuntimesInfo info = service.getRuntimesInfo(providerKey); assertNotNull(info); assertEquals(provider, info.getProvider()); assertEquals(runtimeListItems, info.getRuntimeItems()); verify(providerService, times(1)).getProvider(providerKey); verify(runtimeService, times(1)).getRuntimeItems(providerKey); }
@Test public void testHasRuntimesFalse() { Collection<RuntimeListItem> runtimes = mock(Collection.class); when(runtimeService.getRuntimeItems(providerKey)).thenReturn(runtimes); when(runtimes.isEmpty()).thenReturn(true); assertFalse(service.hasRuntimes(providerKey)); verify(runtimeService, times(1)).getRuntimeItems(providerKey); } }