Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,13 @@ public Map<String, Object> countCommandState(User loginUser) {
return result;
}
Long[] projectCodeArray = getProjectCodesArrays(projectIds.getLeft());
int userId = loginUser.getUserType() == UserType.ADMIN_USER ? 0 : loginUser.getId();

// count normal command state
Map<CommandType, Integer> normalCountCommandCounts = commandMapper.countCommandState(userId, start, end, projectCodeArray)
Map<CommandType, Integer> normalCountCommandCounts = commandMapper.countCommandState(start, end, projectCodeArray)
.stream()
.collect(Collectors.toMap(CommandCount::getCommandType, CommandCount::getCount));

// count error command state
Map<CommandType, Integer> errorCommandCounts = errorCommandMapper.countCommandState(userId, start, end, projectCodeArray)
Map<CommandType, Integer> errorCommandCounts = errorCommandMapper.countCommandState(start, end, projectCodeArray)
.stream()
.collect(Collectors.toMap(CommandCount::getCommandType, CommandCount::getCount));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public void testHandleSensitiveData() {
String actual = accessLogAspect.handleSensitiveData(data);

Assert.assertEquals(expected, actual);

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,15 @@ public void testCountCommandState() {
CommandCount commandCount = new CommandCount();
commandCount.setCommandType(CommandType.START_PROCESS);
commandCounts.add(commandCount);
Mockito.when(commandMapper.countCommandState(0, null, null, new Long[]{1L})).thenReturn(commandCounts);
Mockito.when(errorCommandMapper.countCommandState(0, null, null, new Long[]{1L})).thenReturn(commandCounts);
Mockito.when(commandMapper.countCommandState(null, null, new Long[]{1L})).thenReturn(commandCounts);
Mockito.when(errorCommandMapper.countCommandState(null, null, new Long[]{1L})).thenReturn(commandCounts);

Map<String, Object> result = dataAnalysisServiceImpl.countCommandState(user);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));

// when no command found then return all count are 0
Mockito.when(commandMapper.countCommandState(anyInt(), any(), any(), any())).thenReturn(Collections.emptyList());
Mockito.when(errorCommandMapper.countCommandState(anyInt(), any(), any(), any())).thenReturn(Collections.emptyList());
Mockito.when(commandMapper.countCommandState(any(), any(), any())).thenReturn(Collections.emptyList());
Mockito.when(errorCommandMapper.countCommandState(any(), any(), any())).thenReturn(Collections.emptyList());
Mockito.when(resourcePermissionCheckService.userOwnedResourceIdsAcquisition(AuthorizationType.PROJECTS, 1, serviceLogger)).thenReturn(projectIds());

Map<String, Object> result5 = dataAnalysisServiceImpl.countCommandState(user);
Expand All @@ -313,8 +313,8 @@ public void testCountCommandState() {
CommandCount errorCommandCount = new CommandCount();
errorCommandCount.setCommandType(CommandType.START_PROCESS);
errorCommandCount.setCount(5);
Mockito.when(commandMapper.countCommandState(anyInt(), any(), any(), any())).thenReturn(Collections.singletonList(normalCommandCount));
Mockito.when(errorCommandMapper.countCommandState(anyInt(), any(), any(), any())).thenReturn(Collections.singletonList(errorCommandCount));
Mockito.when(commandMapper.countCommandState(any(), any(), any())).thenReturn(Collections.singletonList(normalCommandCount));
Mockito.when(errorCommandMapper.countCommandState(any(), any(), any())).thenReturn(Collections.singletonList(errorCommandCount));

Map<String, Object> result6 = dataAnalysisServiceImpl.countCommandState(user);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ public interface CommandMapper extends BaseMapper<Command> {

/**
* count command state
* @param userId userId
* @param startTime startTime
* @param endTime endTime
* @param projectCodeArray projectCodeArray
* @return CommandCount list
*/
List<CommandCount> countCommandState(
@Param("userId") int userId,
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("projectCodeArray") Long[] projectCodeArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,12 @@ public interface ErrorCommandMapper extends BaseMapper<ErrorCommand> {

/**
* count command state
* @param userId
* @param startTime startTime
* @param endTime endTime
* @param projectCodeArray projectCodeArray
* @return CommandCount list
*/
List<CommandCount> countCommandState(
@Param("userId") int userId,
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("projectCodeArray") Long[] projectCodeArray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
select cmd.command_type as command_type, count(1) as count
from t_ds_command cmd, t_ds_process_definition process
where cmd.process_definition_code = process.code
<if test="userId != 0 ">
and process.user_id= #{userId}
</if>
<if test="projectCodeArray != null and projectCodeArray.length != 0">
and process.project_code in
<foreach collection="projectCodeArray" index="index" item="i" open="(" close=")" separator=",">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
select cmd.command_type as command_type, count(1) as count
from t_ds_error_command cmd, t_ds_process_definition process
where cmd.process_definition_code = process.code
<if test="userId != 0 ">
and process.user_id= #{userId}
</if>
<if test="projectCodeArray != null and projectCodeArray.length != 0">
and process.project_code in
<foreach collection="projectCodeArray" index="index" item="i" open="(" close=")" separator=",">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public void testCountCommandState() {

Date endTime = DateUtils.stringToDate("2019-12-29 23:59:59");

List<CommandCount> actualCommandCounts = commandMapper.countCommandState(0, startTime, endTime, projectCodeArray);
List<CommandCount> actualCommandCounts = commandMapper.countCommandState(startTime, endTime, projectCodeArray);

assertThat(actualCommandCounts.size(),greaterThanOrEqualTo(1));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public void testQuery() {
errorCommandMapper.updateById(errorCommand);

List<CommandCount> commandCounts = errorCommandMapper.countCommandState(
0,
null,
null,
new Long[0]
Expand All @@ -87,7 +86,6 @@ public void testQuery() {
projectCodeArray[0] = processDefinition.getProjectCode();
projectCodeArray[1] = 200L;
List<CommandCount> commandCounts2 = errorCommandMapper.countCommandState(
0,
null,
null,
projectCodeArray
Expand Down