|
|
@ -76,7 +76,7 @@ public class QueueServiceTest { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryList(){ |
|
|
|
public void testQueryList() { |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(queueMapper.selectList(null)).thenReturn(getQueueList()); |
|
|
|
Mockito.when(queueMapper.selectList(null)).thenReturn(getQueueList()); |
|
|
|
Map<String, Object> result = queueService.queryList(getLoginUser()); |
|
|
|
Map<String, Object> result = queueService.queryList(getLoginUser()); |
|
|
@ -86,7 +86,7 @@ public class QueueServiceTest { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testQueryListPage(){ |
|
|
|
public void testQueryListPage() { |
|
|
|
|
|
|
|
|
|
|
|
IPage<Queue> page = new Page<>(1,10); |
|
|
|
IPage<Queue> page = new Page<>(1,10); |
|
|
|
page.setTotal(1L); |
|
|
|
page.setTotal(1L); |
|
|
@ -98,7 +98,7 @@ public class QueueServiceTest { |
|
|
|
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists())); |
|
|
|
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists())); |
|
|
|
} |
|
|
|
} |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testCreateQueue(){ |
|
|
|
public void testCreateQueue() { |
|
|
|
|
|
|
|
|
|
|
|
// queue is null
|
|
|
|
// queue is null
|
|
|
|
Map<String, Object> result = queueService.createQueue(getLoginUser(),null,queueName); |
|
|
|
Map<String, Object> result = queueService.createQueue(getLoginUser(),null,queueName); |
|
|
@ -114,13 +114,13 @@ public class QueueServiceTest { |
|
|
|
Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS)); |
|
|
|
Assert.assertEquals(Status.SUCCESS,result.get(Constants.STATUS)); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testUpdateQueue(){ |
|
|
|
public void testUpdateQueue() { |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(queueMapper.selectById(1)).thenReturn(getQueue()); |
|
|
|
Mockito.when(queueMapper.selectById(1)).thenReturn(getQueue()); |
|
|
|
Mockito.when(queueMapper.queryAllQueueList("test", null)).thenReturn(getQueueList()); |
|
|
|
Mockito.when(queueMapper.existQueue("test", null)).thenReturn(true); |
|
|
|
Mockito.when(queueMapper.queryAllQueueList(null, "test")).thenReturn(getQueueList()); |
|
|
|
Mockito.when(queueMapper.existQueue(null, "test")).thenReturn(true); |
|
|
|
Mockito.when(userMapper.queryUserListByQueue(queueName)).thenReturn(getUserList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// not exist
|
|
|
|
// not exist
|
|
|
|
Map<String, Object> result = queueService.updateQueue(getLoginUser(),0,"queue",queueName); |
|
|
|
Map<String, Object> result = queueService.updateQueue(getLoginUser(),0,"queue",queueName); |
|
|
@ -144,11 +144,12 @@ public class QueueServiceTest { |
|
|
|
Assert.assertEquals(Status.SUCCESS.getCode(),((Status)result.get(Constants.STATUS)).getCode()); |
|
|
|
Assert.assertEquals(Status.SUCCESS.getCode(),((Status)result.get(Constants.STATUS)).getCode()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testVerifyQueue(){ |
|
|
|
public void testVerifyQueue() { |
|
|
|
|
|
|
|
|
|
|
|
Mockito.when(queueMapper.queryAllQueueList(queueName, null)).thenReturn(getQueueList()); |
|
|
|
Mockito.when(queueMapper.existQueue(queueName, null)).thenReturn(true); |
|
|
|
Mockito.when(queueMapper.queryAllQueueList(null, queueName)).thenReturn(getQueueList()); |
|
|
|
Mockito.when(queueMapper.existQueue(null, queueName)).thenReturn(true); |
|
|
|
|
|
|
|
|
|
|
|
//queue null
|
|
|
|
//queue null
|
|
|
|
Result result = queueService.verifyQueue(null,queueName); |
|
|
|
Result result = queueService.verifyQueue(null,queueName); |
|
|
@ -175,13 +176,13 @@ public class QueueServiceTest { |
|
|
|
logger.info(result.toString()); |
|
|
|
logger.info(result.toString()); |
|
|
|
Assert.assertEquals(result.getCode().intValue(), Status.SUCCESS.getCode()); |
|
|
|
Assert.assertEquals(result.getCode().intValue(), Status.SUCCESS.getCode()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* create admin user |
|
|
|
* create admin user |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private User getLoginUser(){ |
|
|
|
private User getLoginUser() { |
|
|
|
|
|
|
|
|
|
|
|
User loginUser = new User(); |
|
|
|
User loginUser = new User(); |
|
|
|
loginUser.setUserType(UserType.ADMIN_USER); |
|
|
|
loginUser.setUserType(UserType.ADMIN_USER); |
|
|
@ -189,7 +190,7 @@ public class QueueServiceTest { |
|
|
|
return loginUser; |
|
|
|
return loginUser; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<User> getUserList(){ |
|
|
|
private List<User> getUserList() { |
|
|
|
List<User> list = new ArrayList<>(); |
|
|
|
List<User> list = new ArrayList<>(); |
|
|
|
list.add(getLoginUser()); |
|
|
|
list.add(getLoginUser()); |
|
|
|
return list; |
|
|
|
return list; |
|
|
@ -200,7 +201,7 @@ public class QueueServiceTest { |
|
|
|
* get queue |
|
|
|
* get queue |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private Queue getQueue(){ |
|
|
|
private Queue getQueue() { |
|
|
|
Queue queue = new Queue(); |
|
|
|
Queue queue = new Queue(); |
|
|
|
queue.setId(1); |
|
|
|
queue.setId(1); |
|
|
|
queue.setQueue(queueName); |
|
|
|
queue.setQueue(queueName); |
|
|
@ -208,7 +209,7 @@ public class QueueServiceTest { |
|
|
|
return queue; |
|
|
|
return queue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<Queue> getQueueList(){ |
|
|
|
private List<Queue> getQueueList() { |
|
|
|
List<Queue> queueList = new ArrayList<>(); |
|
|
|
List<Queue> queueList = new ArrayList<>(); |
|
|
|
queueList.add(getQueue()); |
|
|
|
queueList.add(getQueue()); |
|
|
|
return queueList; |
|
|
|
return queueList; |
|
|
|