Skip to content

Commit 858a88f

Browse files
authored
Updating OWM to update Kotlin (#317)
The OWM library brings in a version of Kotlin with a CVE, this updates the version without the CVE. Signed-off-by: Jason Porter <lightguard.jp@gmail.com>
1 parent 5fe14c8 commit 858a88f

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

openweathermap-workitem/src/main/java/org/jbpm/process/workitem/owm/DailyForecastWorkitemHandler.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22-
import net.aksingh.owmjapis.core.OWM;
22+
import net.aksingh.owmjapis.core.OWMPro;
2323
import net.aksingh.owmjapis.core.OWM.Country;
2424
import net.aksingh.owmjapis.model.DailyWeatherForecast;
2525
import net.aksingh.owmjapis.model.param.ForecastData;
@@ -67,7 +67,7 @@ public class DailyForecastWorkitemHandler extends AbstractLogOrThrowWorkItemHand
6767
private static final String RESULTS_VALUES = "DailyForecastData";
6868

6969
private String apiKey;
70-
private OWM owm;
70+
private OWMPro owm;
7171

7272
public DailyForecastWorkitemHandler(String apiKey) {
7373
this.apiKey = apiKey;
@@ -88,13 +88,14 @@ public void executeWorkItem(WorkItem workItem,
8888
DailyForecastData dfd = new DailyForecastData();
8989

9090
if (owm == null) {
91-
owm = new OWM(apiKey);
91+
owm = new OWMPro(apiKey);
9292
}
9393

9494
DailyWeatherForecast dailyWeatherForecast;
9595

9696
if (countryCode == null) {
97-
dailyWeatherForecast = owm.dailyWeatherForecastByCityName(cityName);
97+
// 16 is the max count, unfortunately, the constant isn't exposed outside the library.
98+
dailyWeatherForecast = owm.dailyWeatherForecastByCityName(cityName, 16);
9899
} else {
99100
dailyWeatherForecast = owm.dailyWeatherForecastByCityName(cityName,
100101
Country.valueOf(countryCode));
@@ -150,7 +151,7 @@ public void abortWorkItem(WorkItem workItem,
150151
}
151152

152153
// for testing
153-
public void setOWM(OWM owm) {
154+
public void setOWM(OWMPro owm) {
154155
this.owm = owm;
155156
}
156157
}

openweathermap-workitem/src/test/java/org/jbpm/process/workitem/owm/OpenWeatherMapWorkitemHandlerTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import java.util.Date;
2020
import java.util.List;
2121

22-
import net.aksingh.owmjapis.core.OWM;
22+
import net.aksingh.owmjapis.core.OWMPro;
2323
import net.aksingh.owmjapis.core.OWM.Country;
2424
import net.aksingh.owmjapis.model.CurrentWeather;
2525
import net.aksingh.owmjapis.model.DailyWeatherForecast;
@@ -46,16 +46,16 @@
4646
import static org.powermock.api.mockito.PowerMockito.when;
4747

4848
@RunWith(PowerMockRunner.class)
49-
@PrepareForTest({OWM.class, CurrentWeather.class, DailyWeatherForecast.class, Main.class, City.class, ForecastData.class, Temp.class})
49+
@PrepareForTest({OWMPro.class, CurrentWeather.class, DailyWeatherForecast.class, Main.class, City.class, ForecastData.class, Temp.class})
5050
@PowerMockIgnore({"jdk.internal.reflect.*"})
5151
public class OpenWeatherMapWorkitemHandlerTest extends AbstractBaseTest {
5252

53-
private OWM owm;
53+
private OWMPro owm;
5454

5555
@Before
5656
public void setUp() {
5757
try {
58-
owm = PowerMockito.mock(OWM.class);
58+
owm = PowerMockito.mock(OWMPro.class);
5959
CurrentWeather currentWeather = PowerMockito.mock(CurrentWeather.class);
6060
DailyWeatherForecast dailyWeatherForecast = PowerMockito.mock(DailyWeatherForecast.class);
6161
Main mainData = PowerMockito.mock(Main.class);
@@ -69,7 +69,7 @@ public void setUp() {
6969
when(owm.currentWeatherByCityName(anyString(),
7070
any(Country.class))).thenReturn(currentWeather);
7171

72-
when(owm.dailyWeatherForecastByCityName(anyString())).thenReturn(dailyWeatherForecast);
72+
when(owm.dailyWeatherForecastByCityName(anyString(), any(Integer.class))).thenReturn(dailyWeatherForecast);
7373
when(owm.dailyWeatherForecastByCityName(anyString(),
7474
any(Country.class))).thenReturn(dailyWeatherForecast);
7575

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<version.github.jnr>0.15</version.github.jnr>
5656
<version.squareup.okhttp3>4.12.0</version.squareup.okhttp3>
5757
<version.rxjava>1.2.4</version.rxjava>
58-
<version.owm>2.5.2.2</version.owm>
58+
<version.owm>2.5.3.0</version.owm>
5959
<version.commons.net>3.6</version.commons.net>
6060
<version.wildfly.maven.plugin>1.2.1.Final</version.wildfly.maven.plugin>
6161
<version.war.plugin>3.2.2</version.war.plugin>

0 commit comments

Comments
 (0)