добавил тест на случай неправильного ввода

This commit is contained in:
swayfarer 2025-05-27 17:19:10 +03:00
parent 2d6e471c14
commit 84c9bc4c7c

View File

@ -20,7 +20,7 @@ import static org.mockito.Mockito.*;
public class WeatherProviderCLISelectorTest { public class WeatherProviderCLISelectorTest {
@Test @Test
void testSelectWeatherProviderFromCLI(){ void testSelectWeatherProviderFromCLI_T(){
WeatherProviderRegistry weatherProviderRegistry = mock(WeatherProviderRegistry.class); WeatherProviderRegistry weatherProviderRegistry = mock(WeatherProviderRegistry.class);
WeatherProvider provider = Mockito.mock("open-weather-map"); WeatherProvider provider = Mockito.mock("open-weather-map");
List<WeatherProvider> providers = Arrays.asList(provider); List<WeatherProvider> providers = Arrays.asList(provider);
@ -32,4 +32,18 @@ public class WeatherProviderCLISelectorTest {
WeatherProviderCLISelector t = new WeatherProviderCLISelector(inputReader, weatherProviderRegistry); WeatherProviderCLISelector t = new WeatherProviderCLISelector(inputReader, weatherProviderRegistry);
assertEquals("open-weather-map" , t.selectWeatherProviderFromCLI()); 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());
}
} }