Skip to content

Commit 2b97f64

Browse files
authored
Add comprehensive unit tests for PlatformHistoryServiceImpl (opentiny#297)
* fix: add PlatformHistoryServiceImplTest * fix: remove unused
1 parent c30544d commit 2b97f64

File tree

2 files changed

+748
-2
lines changed

2 files changed

+748
-2
lines changed

base/src/main/java/com/tinyengine/it/service/platform/impl/PlatformHistoryServiceImpl.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public List<PlatformHistory> queryAllPlatformHistory() {
5151
*/
5252
@Override
5353
public PlatformHistory queryPlatformHistoryById(Integer id) {
54+
if(id == null||id<=0) {
55+
throw new IllegalArgumentException("id cannot be null");
56+
}
5457
return baseMapper.queryPlatformHistoryById(id);
5558
}
5659

@@ -95,6 +98,7 @@ public Result<PlatformHistory> updatePlatformHistoryById(PlatformHistory platfor
9598
if (platformHistory == null || platformHistory.getId() == null) {
9699
return Result.failed(ExceptionEnum.CM002);
97100
}
101+
98102
int updateResult = baseMapper.updatePlatformHistoryById(platformHistory);
99103
if (updateResult != 1) {
100104
return Result.failed(ExceptionEnum.CM008);
@@ -117,10 +121,10 @@ public Result<PlatformHistory> createPlatformHistory(PlatformHistory platformHis
117121
if (platformHistory.getRefId() == null) {
118122
return Result.failed(ExceptionEnum.CM002);
119123
}
120-
if (platformHistory.getName() == null || platformHistory.getName().isEmpty()) {
124+
if (platformHistory.getName() == null || platformHistory.getName().trim().isEmpty()) {
121125
return Result.failed(ExceptionEnum.CM002);
122126
}
123-
if (platformHistory.getVersion() == null || platformHistory.getVersion().isEmpty()) {
127+
if (platformHistory.getVersion() == null || platformHistory.getVersion().trim().isEmpty()) {
124128
return Result.failed(ExceptionEnum.CM002);
125129
}
126130
if (platformHistory.getMaterialHistoryId() == null) {

0 commit comments

Comments
 (0)