-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug in group manager initialisation and add test (#1442)
Signed-off-by: Chris Jackson <[email protected]>
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
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
48 changes: 48 additions & 0 deletions
48
...s.zigbee/src/test/java/com/zsmartsystems/zigbee/groups/ZigBeeNetworkGroupManagerTest.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,48 @@ | ||
/** | ||
* Copyright (c) 2016-2024 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package com.zsmartsystems.zigbee.groups; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.mockito.ArgumentMatchers.any; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
import com.zsmartsystems.zigbee.ZigBeeNetworkManager; | ||
|
||
/** | ||
* Tests for {@link ZigBeeNetworkGroupManager} | ||
* | ||
* @author Chris Jackson | ||
* | ||
*/ | ||
public class ZigBeeNetworkGroupManagerTest { | ||
|
||
@Test | ||
public void initialize() { | ||
ZigBeeNetworkManager networkManager = Mockito.mock(ZigBeeNetworkManager.class); | ||
ZigBeeNetworkGroupManager groupManager = new ZigBeeNetworkGroupManager(networkManager); | ||
|
||
assertTrue(groupManager.getAll().isEmpty()); | ||
groupManager.initialize(); | ||
assertTrue(groupManager.getAll().isEmpty()); | ||
|
||
Set<ZigBeeGroupDao> daoSet = new HashSet<>(); | ||
daoSet.add(new ZigBeeGroupDao()); | ||
|
||
Mockito.when(networkManager.readNetworkDataStore(any())).thenReturn(daoSet); | ||
|
||
assertTrue(groupManager.getAll().isEmpty()); | ||
groupManager.initialize(); | ||
assertEquals(1, groupManager.getAll().size()); | ||
} | ||
} |