Skip to content

Commit a73e507

Browse files
authored
Merge pull request #52 from TDesjardins/fix_empty_dev_list
Add support of empty device lists fixes #37
2 parents 141f563 + 5f085e5 commit a73e507

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
* [#29](https://github.com/kaklakariada/fritzbox-java-api/issues/29) Add support for login via Pbkdf2 challenge-response (propsed by [@linnex81](https://github.com/linnex81))
1212

13+
### Fixed
14+
15+
* [#37](https://github.com/kaklakariada/fritzbox-java-api/issues/37) Support empty device lists
16+
1317
### Refactoring
1418

1519
* [#50](https://github.com/kaklakariada/fritzbox-java-api/pull/50) Migrate to Junit 5

src/main/java/com/github/kaklakariada/fritzbox/model/homeautomation/DeviceList.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import static java.util.stream.Collectors.toList;
2121

22+
import java.util.ArrayList;
2223
import java.util.List;
2324

2425
import org.simpleframework.xml.Attribute;
@@ -31,8 +32,8 @@ public class DeviceList {
3132
@Attribute(name = "version")
3233
private String apiVersion;
3334

34-
@ElementList(name = "device", type = Device.class, inline = true)
35-
private List<Device> devices;
35+
@ElementList(name = "device", type = Device.class, inline = true, required = false)
36+
private List<Device> devices = new ArrayList<>();
3637

3738
@ElementList(name = "group", type = Group.class, inline = true, required = false)
3839
private List<Group> groups;

src/test/java/com/github/kaklakariada/fritzbox/mapping/DeserializerTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ void parseDeviceListAllTogether() throws IOException {
9090
assertThat(deviceList.getDevices()).hasSize(5);
9191
}
9292

93+
@Test
94+
void parseDeviceListEmpty() throws IOException {
95+
final DeviceList deviceList = parseDeviceList(Paths.get("src/test/resources/FritzOS29/deviceListEmpty.xml"));
96+
assertThat(deviceList.getDevices()).hasSize(0);
97+
}
98+
9399
@Test
94100
void parseDeviceList() throws IOException {
95101
final DeviceList deviceList = parseDeviceList(Paths.get("src/test/resources/deviceList.xml"));
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<devicelist version="1" fwversion="7.29"></devicelist>

0 commit comments

Comments
 (0)