-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from PeterJelitsch/feature/IDEA-114-homeautoma…
…tion-group-support IDEA-114 added homeautomation group support
- Loading branch information
Showing
15 changed files
with
635 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/main/java/com/github/kaklakariada/fritzbox/model/homeautomation/Group.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/** | ||
* 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.Attribute; | ||
import org.simpleframework.xml.Element; | ||
import org.simpleframework.xml.Root; | ||
|
||
@Root(name = "group") | ||
public class Group { | ||
|
||
@Attribute(name = "identifier") | ||
private String identifier; | ||
@Attribute(name = "id") | ||
private String id; | ||
@Attribute(name = "functionbitmask") | ||
private int functionBitmask; | ||
@Attribute(name = "fwversion") | ||
private String firmwareVersion; | ||
@Attribute(name = "manufacturer") | ||
private String manufacturer; | ||
@Attribute(name = "productname") | ||
private String productName; | ||
@Element(name = "present") | ||
private String present; | ||
@Element(name = "name") | ||
private String name; | ||
@Element(name = "switch", required = false) | ||
private SwitchState switchState; | ||
@Element(name = "powermeter", required = false) | ||
private PowerMeter powerMeter; | ||
@Element(name = "groupinfo", required = false) | ||
private GroupInfo groupInfo; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public int getFunctionBitmask() { | ||
return functionBitmask; | ||
} | ||
|
||
public String getFirmwareVersion() { | ||
return firmwareVersion; | ||
} | ||
|
||
public String getManufacturer() { | ||
return manufacturer; | ||
} | ||
|
||
public String getProductName() { | ||
return productName; | ||
} | ||
|
||
public String getPresent() { | ||
return present; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public SwitchState getSwitchState() { | ||
return switchState; | ||
} | ||
|
||
public PowerMeter getPowerMeter() { | ||
return powerMeter; | ||
} | ||
|
||
public String getIdentifier() { | ||
return identifier; | ||
} | ||
|
||
public GroupInfo getGroupInfo() { | ||
return groupInfo; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/com/github/kaklakariada/fritzbox/model/homeautomation/GroupInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* 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 java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.simpleframework.xml.Element; | ||
import org.simpleframework.xml.Root; | ||
|
||
@Root(name="groupinfo") | ||
public class GroupInfo { | ||
|
||
@Element(name="masterdeviceid") | ||
private String masterDeviceId; | ||
|
||
/** | ||
* Comma seperated list of devices identfied by their id. | ||
*/ | ||
@Element(name="members") | ||
private String members; | ||
|
||
public String getMasterDeviceId() { | ||
return masterDeviceId; | ||
} | ||
|
||
public String getMembers() { | ||
return members; | ||
} | ||
|
||
public List<String> getMemberList() { | ||
return Arrays.asList(this.members.split(",")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/test/java/com/github/kaklakariada/fritzbox/assertions/DeviceListAssert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* 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.assertions; | ||
|
||
import org.assertj.core.api.AbstractObjectAssert; | ||
import org.assertj.core.api.Assertions; | ||
|
||
import com.github.kaklakariada.fritzbox.model.homeautomation.DeviceList; | ||
|
||
public class DeviceListAssert extends AbstractObjectAssert<DeviceListAssert, DeviceList> { | ||
|
||
private static final String ERROR_MESSAGE = "Expected %s to be <%s> but was <%s> (%s)"; | ||
|
||
DeviceListAssert(DeviceList actual) { | ||
super(actual, DeviceListAssert.class); | ||
} | ||
|
||
public DeviceListAssert hasGroupsSize(int expected) { | ||
int actualGroupsSize = actual.getGroups().size(); | ||
Assertions.assertThat(actualGroupsSize) | ||
.overridingErrorMessage(ERROR_MESSAGE, "groupSize", expected, actualGroupsSize, descriptionText()) | ||
.isEqualTo(expected); | ||
return this; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/test/java/com/github/kaklakariada/fritzbox/assertions/GroupAssert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* 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.assertions; | ||
|
||
import org.assertj.core.api.AbstractObjectAssert; | ||
import org.assertj.core.api.Assertions; | ||
|
||
import com.github.kaklakariada.fritzbox.model.homeautomation.Group; | ||
|
||
|
||
public class GroupAssert extends AbstractObjectAssert<GroupAssert, Group> { | ||
|
||
private static final String ERROR_MESSAGE = "Expected %s to be <%s> but was <%s> (%s)"; | ||
|
||
GroupAssert(Group actual) { | ||
super(actual, GroupAssert.class); | ||
} | ||
|
||
public GroupAssert hasName(String expected) { | ||
String actual = this.actual.getName(); | ||
Assertions.assertThat(actual) | ||
.overridingErrorMessage(ERROR_MESSAGE, "name", expected, actual, descriptionText()) | ||
.isEqualTo(expected); | ||
return this; | ||
} | ||
|
||
public GroupAssert hasPresent(String expected) { | ||
String actual = this.actual.getPresent(); | ||
Assertions.assertThat(actual) | ||
.overridingErrorMessage(ERROR_MESSAGE, "present", expected, actual, descriptionText()) | ||
.isEqualTo(expected); | ||
return this; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/test/java/com/github/kaklakariada/fritzbox/assertions/GroupInfoAssert.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* 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.assertions; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.assertj.core.api.AbstractObjectAssert; | ||
import org.assertj.core.api.Assertions; | ||
|
||
import com.github.kaklakariada.fritzbox.model.homeautomation.GroupInfo; | ||
|
||
|
||
public class GroupInfoAssert extends AbstractObjectAssert<GroupInfoAssert, GroupInfo> { | ||
|
||
private static final String ERROR_MESSAGE = "Expected %s to be <%s> but was <%s> (%s)"; | ||
|
||
GroupInfoAssert(GroupInfo actual) { | ||
super(actual, GroupInfoAssert.class); | ||
} | ||
|
||
public GroupInfoAssert hasMasterDeviceId(String expected) { | ||
String actual = this.actual.getMasterDeviceId(); | ||
Assertions.assertThat(actual) | ||
.overridingErrorMessage(ERROR_MESSAGE, "masterDeviceId", expected, actual, descriptionText()) | ||
.isEqualTo(expected); | ||
return this; | ||
} | ||
|
||
public GroupInfoAssert containsAllMembers(String ... expected) { | ||
List<String> actual = this.actual.getMemberList(); | ||
Assertions.assertThat(actual) | ||
.overridingErrorMessage(ERROR_MESSAGE, "memberList", expected, actual, descriptionText()) | ||
.containsExactlyInAnyOrderElementsOf(Arrays.asList(expected)); | ||
return this; | ||
} | ||
} |
Oops, something went wrong.