Skip to content

Commit

Permalink
Merge pull request #52 from TDesjardins/fix_empty_dev_list
Browse files Browse the repository at this point in the history
Add support of empty device lists fixes #37
  • Loading branch information
kaklakariada authored Aug 10, 2022
2 parents 141f563 + 5f085e5 commit a73e507
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* [#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))

### Fixed

* [#37](https://github.com/kaklakariada/fritzbox-java-api/issues/37) Support empty device lists

### Refactoring

* [#50](https://github.com/kaklakariada/fritzbox-java-api/pull/50) Migrate to Junit 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

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

import java.util.ArrayList;
import java.util.List;

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

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

@ElementList(name = "group", type = Group.class, inline = true, required = false)
private List<Group> groups;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ void parseDeviceListAllTogether() throws IOException {
assertThat(deviceList.getDevices()).hasSize(5);
}

@Test
void parseDeviceListEmpty() throws IOException {
final DeviceList deviceList = parseDeviceList(Paths.get("src/test/resources/FritzOS29/deviceListEmpty.xml"));
assertThat(deviceList.getDevices()).hasSize(0);
}

@Test
void parseDeviceList() throws IOException {
final DeviceList deviceList = parseDeviceList(Paths.get("src/test/resources/deviceList.xml"));
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/FritzOS29/deviceListEmpty.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<devicelist version="1" fwversion="7.29"></devicelist>

0 comments on commit a73e507

Please sign in to comment.