добавил тест на случай неправильного ввода
This commit is contained in:
parent
2d6e471c14
commit
84c9bc4c7c
@ -20,7 +20,7 @@ import static org.mockito.Mockito.*;
|
||||
public class WeatherProviderCLISelectorTest {
|
||||
|
||||
@Test
|
||||
void testSelectWeatherProviderFromCLI(){
|
||||
void testSelectWeatherProviderFromCLI_T(){
|
||||
WeatherProviderRegistry weatherProviderRegistry = mock(WeatherProviderRegistry.class);
|
||||
WeatherProvider provider = Mockito.mock("open-weather-map");
|
||||
List<WeatherProvider> providers = Arrays.asList(provider);
|
||||
@ -32,4 +32,18 @@ public class WeatherProviderCLISelectorTest {
|
||||
WeatherProviderCLISelector t = new WeatherProviderCLISelector(inputReader, weatherProviderRegistry);
|
||||
assertEquals("open-weather-map" , t.selectWeatherProviderFromCLI());
|
||||
}
|
||||
@Test
|
||||
void testSelectWeatherProviderFromCLI_F(){
|
||||
WeatherProviderRegistry weatherProviderRegistry = mock(WeatherProviderRegistry.class);
|
||||
WeatherProvider provider = Mockito.mock("open-weather-map");
|
||||
List<WeatherProvider> providers = Arrays.asList(provider);
|
||||
when(weatherProviderRegistry.getAllWeatherProviders()).thenReturn(providers);
|
||||
var j = "3";
|
||||
InputStream inputStream = new ByteArrayInputStream(j.getBytes());
|
||||
CLIInputReader inputReader = new CLIInputReader(inputStream);
|
||||
|
||||
WeatherProviderCLISelector t = new WeatherProviderCLISelector(inputReader, weatherProviderRegistry);
|
||||
assertEquals("open-weather-map" , t.selectWeatherProviderFromCLI());
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user