Skip to content

Commit

Permalink
Merge pull request #205 from Smarteon/fixExt
Browse files Browse the repository at this point in the history
Fix status deserialization
  • Loading branch information
knotekt authored Sep 16, 2023
2 parents 9fa9f12 + bdbdbee commit cfa497d
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public Extension unmarshal(final Extension v) {
case "AO Extension":
case "AI Extension":
case "RS232 Extension":
case "KNX Extension":
return new BasicExtension(v);
case "Dali Extension":
return new DaliExtension(v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private static class Content {
private Link link;

@XmlElement(name = "TreeBranch")
private List<TreeBranch> treeBranches;
private TreeBranch treeBranch;

Content() { }

Expand All @@ -258,8 +258,8 @@ private static class Content {
if (link != null && link.extensions != null) {
result.addAll(link.extensions);
}
if (treeBranches != null) {
result.add(new TreeExtension(treeBranches));
if (treeBranch != null) {
result.add(new TreeExtension(treeBranch));
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public class TreeBranch implements DevicesProvider<TreeDevice> {
@XmlAttribute(name = "Errors") private Integer errors;
@XmlElement(name = "TreeDevice") @XmlJavaTypeAdapter(TreeDeviceAdapter.class) private List<TreeDevice> devices;

// only for builtin tree
@XmlAttribute(name = "Serial") String serialNumber;
@XmlAttribute(name = "Version") String version;

TreeBranch() { }

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.jetbrains.annotations.Nullable;

import java.util.Collections;
import java.util.List;

/**
Expand All @@ -18,9 +19,10 @@ public class TreeExtension extends Extension {
setBranches(e.treeBranches);
}

TreeExtension(final List<TreeBranch> branches) {
super("BuiltIn Tree", null, "BuiltIn Tree", null, null, null, true, false, null, null, null, null, null);
setBranches(branches);
TreeExtension(final TreeBranch branch) {
super("BuiltIn Tree", null, "BuiltIn Tree", branch.serialNumber, branch.version, null, true, false,
null, null, null, null, null);
setBranches(Collections.singletonList(branch));
}

private void setBranches(final List<TreeBranch> branches) {
Expand Down
5 changes: 4 additions & 1 deletion src/test/kotlin/system/status/MiniserverStatusTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,15 @@ class MiniserverStatusTest {
val ms = readResourceXml<MiniserverStatus>("system/status/status_13_1_Gen2.xml")

expectThat(ms) {
get { extensions }.hasSize(3)
get { extensions }.hasSize(5)
get { getExtensions(TreeExtension::class.java) }.hasSize(2).and {
get { firstOrNull { it.type == "BuiltIn Tree" } }.isNotNull().and {
get { serialNumber }.isEqualTo("13000001")
get { version }.isEqualTo("13.1.9.19")
get { rightBranch?.devices }.isNotNull().hasSize(1)
}
}
get { getExtensions(BasicExtension::class.java).filter { it.type == "KNX Extension" } }.hasSize(2)
}
}
}
2 changes: 2 additions & 0 deletions src/test/resources/system/status/status_13_1_Gen2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<TreeDevice Code="-2147155787" Name="TL110.1 u vchodu" Place="110 Living room" Inst="" Serial="B02E0D29" Version="12.4.6.8" Online="true" LastReceived="2022-12-07 07:20:38" TimeDiff="1" DummyDev="false"/>
</TreeBranch>
</Extension>
<Extension Type="KNX Extension" Code="197" Name="KNX_2" Serial="15d81c94" Version="10.5.2.17" Online="true" IntDev="false" DummyDev="false"/>
<Extension Type="KNX Extension" Code="197" Name="KNX_3" Serial="15d81fa8" Version="10.5.2.17" Online="true" IntDev="false" DummyDev="false"/>
</Link>
</Miniserver>
<NetworkDevices Name="Audio" Type="NetworkDevices" Branch="14" Icon="225">
Expand Down

0 comments on commit cfa497d

Please sign in to comment.