|
24 | 24 | import java.nio.file.Files; |
25 | 25 | import java.nio.file.Paths; |
26 | 26 |
|
| 27 | +import junit.framework.TestCase; |
27 | 28 | import org.junit.BeforeClass; |
28 | 29 | import org.junit.Test; |
29 | 30 |
|
| 31 | +import com.github.kaklakariada.fritzbox.model.SessionInfo; |
30 | 32 | import com.github.kaklakariada.fritzbox.model.homeautomation.DeviceList; |
31 | 33 | import com.github.kaklakariada.fritzbox.model.homeautomation.Group; |
32 | 34 | import com.github.kaklakariada.fritzbox.model.homeautomation.GroupInfo; |
@@ -94,6 +96,26 @@ public void parseDeviceListAllTogether() throws IOException { |
94 | 96 | } |
95 | 97 |
|
96 | 98 | @Test |
| 99 | + public void parseDeviceList() throws IOException { |
| 100 | + final String fileContent = Files.readAllLines(Paths.get("src/test/resources/deviceList.xml")).stream() |
| 101 | + .collect(joining("\n")); |
| 102 | + new Deserializer().parse(fileContent, DeviceList.class); |
| 103 | + } |
| 104 | + |
| 105 | + @Test |
| 106 | + public void parseSessionInfo() throws IOException { |
| 107 | + final String fileContent = Files.readAllLines(Paths.get("src/test/resources/sessionInfo.xml")).stream() |
| 108 | + .collect(joining("\n")); |
| 109 | + SessionInfo sessionInfo = new Deserializer().parse(fileContent, SessionInfo.class); |
| 110 | + TestCase.assertNotNull(sessionInfo.getUsers()); |
| 111 | + TestCase.assertEquals(3, sessionInfo.getUsers().size()); |
| 112 | + TestCase.assertEquals("UserA", sessionInfo.getUsers().get(0).getName()); |
| 113 | + TestCase.assertFalse(sessionInfo.getUsers().get(0).isLast()); |
| 114 | + TestCase.assertEquals("UserB", sessionInfo.getUsers().get(1).getName()); |
| 115 | + TestCase.assertFalse(sessionInfo.getUsers().get(1).isLast()); |
| 116 | + TestCase.assertEquals("UserC", sessionInfo.getUsers().get(2).getName()); |
| 117 | + TestCase.assertTrue(sessionInfo.getUsers().get(2).isLast()); |
| 118 | + } |
97 | 119 | public void parseDeviceGroup() { |
98 | 120 | //given |
99 | 121 | Group group = deviceList6840.getGroupById("900"); |
|
0 commit comments