-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update the verify rule of delete relation (#177)
- Loading branch information
Showing
5 changed files
with
68 additions
and
7 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
50 changes: 50 additions & 0 deletions
50
center/src/test/java/com/microsoft/hydralab/center/service/DeviceGroupServiceTest.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,50 @@ | ||
package com.microsoft.hydralab.center.service; | ||
|
||
import com.microsoft.hydralab.center.test.BaseTest; | ||
import com.microsoft.hydralab.common.entity.center.DeviceGroup; | ||
import com.microsoft.hydralab.common.entity.center.DeviceGroupRelation; | ||
import com.microsoft.hydralab.common.entity.center.SysTeam; | ||
import com.microsoft.hydralab.common.util.Const; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.annotation.Resource; | ||
import java.util.List; | ||
|
||
class DeviceGroupServiceTest extends BaseTest { | ||
|
||
@Resource | ||
DeviceGroupService deviceGroupService; | ||
@Resource | ||
SysTeamService sysTeamService; | ||
|
||
String groupName = "GROUP"; | ||
String deviceSerial = "DEVICE"; | ||
|
||
|
||
@Test | ||
void testDeviceGroupManagement() { | ||
SysTeam defaultTeam = sysTeamService.getOrCreateDefaultTeam(Const.DefaultTeam.DEFAULT_TEAM_NAME); | ||
|
||
deviceGroupService.createGroup(defaultTeam.getTeamId(), defaultTeam.getTeamName(), groupName, null); | ||
DeviceGroup group = deviceGroupService.getGroupByName(Const.DeviceGroup.groupPre + groupName); | ||
Assertions.assertNotNull(group, "Insert group failed!"); | ||
|
||
deviceGroupService.saveRelation(groupName, deviceSerial); | ||
DeviceGroupRelation relation = deviceGroupService.getRelation(groupName, deviceSerial); | ||
Assertions.assertNotNull(relation, "Insert relation failed!"); | ||
|
||
List<DeviceGroupRelation> relationD = deviceGroupService.getGroupByDevice(deviceSerial); | ||
Assertions.assertNotNull(relationD, "Query relation by device failed!"); | ||
Assertions.assertEquals(relationD.size(), 1, "Query relation by device failed!"); | ||
|
||
List<DeviceGroupRelation> relationG = deviceGroupService.getDeviceByGroup(groupName); | ||
Assertions.assertNotNull(relationG, "Query relation by group failed!"); | ||
Assertions.assertEquals(relationG.size(), 1, "Query relation by group failed!"); | ||
|
||
deviceGroupService.deleteRelation(groupName, deviceSerial); | ||
relation = deviceGroupService.getRelation(groupName, deviceSerial); | ||
Assertions.assertNull(relation, "Delete relation failed!"); | ||
} | ||
|
||
} |
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