-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to Firmware 7.25 #18
Changes from all commits
c04fba6
df0a6f9
9f77dcc
e74a3ed
cecfe30
aeb4d6f
b972bc5
be36039
9a62817
e6b6bd6
2020151
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,38 @@ | ||||||
/** | ||||||
* A Java API for managing FritzBox HomeAutomation | ||||||
* Copyright (C) 2017 Christoph Pirkl <christoph at users.sourceforge.net> | ||||||
* | ||||||
* This program is free software: you can redistribute it and/or modify | ||||||
* it under the terms of the GNU General Public License as published by | ||||||
* the Free Software Foundation, either version 3 of the License, or | ||||||
* (at your option) any later version. | ||||||
* | ||||||
* This program is distributed in the hope that it will be useful, | ||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
* GNU General Public License for more details. | ||||||
* | ||||||
* You should have received a copy of the GNU General Public License | ||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||
*/ | ||||||
package com.github.kaklakariada.fritzbox.model; | ||||||
|
||||||
import org.simpleframework.xml.Attribute; | ||||||
import org.simpleframework.xml.Text; | ||||||
|
||||||
public class User { | ||||||
kaklakariada marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
@Attribute(name = "last", required = false) | ||||||
private int last; | ||||||
|
||||||
@Text | ||||||
private String name; | ||||||
|
||||||
public boolean isLast() { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for nit-picking. But if this returns an int, we should rename the getter.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the documentation (Page 2: "Bedeutung der Werte:") this should indicate the last user which then (from my point of view) is a boolean. My poor XML skills didn't bring me to a solution where i could mark the field to be a boolean and the xml annotation would do the translation from 1 to true. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||||||
return (last == 1); | ||||||
} | ||||||
|
||||||
public String getName() { | ||||||
return name; | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* A Java API for managing FritzBox HomeAutomation | ||
* Copyright (C) 2017 Christoph Pirkl <christoph at users.sourceforge.net> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package com.github.kaklakariada.fritzbox.model.homeautomation; | ||
|
||
import org.simpleframework.xml.Element; | ||
import org.simpleframework.xml.Root; | ||
|
||
@Root(name = "humidity") | ||
public class Humidity { | ||
|
||
@Element(name = "rel_humidity", required = false) | ||
private int relHumidity; | ||
|
||
public int getRelHumidity() { | ||
return relHumidity; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,11 @@ | |
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import junit.framework.TestCase; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import com.github.kaklakariada.fritzbox.model.SessionInfo; | ||
import com.github.kaklakariada.fritzbox.model.homeautomation.DeviceList; | ||
import com.github.kaklakariada.fritzbox.model.homeautomation.Group; | ||
import com.github.kaklakariada.fritzbox.model.homeautomation.GroupInfo; | ||
|
@@ -94,6 +96,26 @@ public void parseDeviceListAllTogether() throws IOException { | |
} | ||
|
||
@Test | ||
public void parseDeviceList() throws IOException { | ||
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceList.xml")).stream() | ||
.collect(joining("\n")); | ||
new Deserializer().parse(fileContent, DeviceList.class); | ||
} | ||
|
||
@Test | ||
public void parseSessionInfo() throws IOException { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Minor] With my from today PR I just introduced assertJ into the project. Maybe you want to have a look at those Assertion classes which allow fluent-API assertions. BR, Peter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will have a look, but as rebase is not my favourite git command, i would update these tests with my next contribution. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rebasing ist not required. I also don't use it ;) |
||
final String fileContent = Files.readAllLines(Paths.get("src/test/resources/sessionInfo.xml")).stream() | ||
.collect(joining("\n")); | ||
SessionInfo sessionInfo = new Deserializer().parse(fileContent, SessionInfo.class); | ||
TestCase.assertNotNull(sessionInfo.getUsers()); | ||
TestCase.assertEquals(3, sessionInfo.getUsers().size()); | ||
TestCase.assertEquals("UserA", sessionInfo.getUsers().get(0).getName()); | ||
TestCase.assertFalse(sessionInfo.getUsers().get(0).isLast()); | ||
TestCase.assertEquals("UserB", sessionInfo.getUsers().get(1).getName()); | ||
TestCase.assertFalse(sessionInfo.getUsers().get(1).isLast()); | ||
TestCase.assertEquals("UserC", sessionInfo.getUsers().get(2).getName()); | ||
TestCase.assertTrue(sessionInfo.getUsers().get(2).isLast()); | ||
} | ||
public void parseDeviceGroup() { | ||
//given | ||
Group group = deviceList6840.getGroupById("900"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍