Added country to invalid city ID search.
This commit is contained in:
parent
351f117d38
commit
34c7adddff
2 changed files with 3 additions and 3 deletions
|
@ -169,14 +169,14 @@ public class Weather2 extends ThreadedModule {
|
|||
}
|
||||
}
|
||||
|
||||
if (cwd.getCityId() != null) {
|
||||
if (cwd.hasCityId() && cwd.getCityId() != null) {
|
||||
if (cwd.getCityId() > 0) {
|
||||
messages.add(new NoticeMessage("https://openweathermap.org/city/" + cwd.getCityId(),
|
||||
Colors.GREEN));
|
||||
} else {
|
||||
final HttpUrl url =
|
||||
HttpUrl.parse("https://openweathermap.org/find").newBuilder().addQueryParameter(
|
||||
"q", city).build();
|
||||
"q", city + ',' + country).build();
|
||||
messages.add(
|
||||
new NoticeMessage(url.toString(), Colors.GREEN));
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ public class Weather2Test extends LocalProperties {
|
|||
public void testWeather() throws ModuleException {
|
||||
List<Message> messages = Weather2.getWeather("98204", LocalProperties.getProperty(Weather2.OWM_API_KEY_PROP));
|
||||
assertThat(messages.get(0).getMessage()).as("is Everett").contains("Everett");
|
||||
assertThat(messages.get(messages.size() - 1).getMessage()).as("is City Search").endsWith("98204");
|
||||
assertThat(messages.get(messages.size() - 1).getMessage()).as("is City Search").endsWith("98204%2CUS");
|
||||
|
||||
messages = Weather2.getWeather("London, UK", LocalProperties.getProperty(Weather2.OWM_API_KEY_PROP));
|
||||
assertThat(messages.get(0).getMessage()).as("is UK").contains("UK");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue