feat: add ut (#66)

This commit is contained in:
vran
2022-03-27 19:59:21 +08:00
committed by GitHub
parent 4edadae62e
commit 30765be4d4
9 changed files with 143 additions and 5 deletions

View File

@@ -39,9 +39,9 @@ public class OperationLogService {
private final OperationLogPojoConverter operationLogPojoConverter;
public void save(OperationLogRequest request) {
public Long save(OperationLogRequest request) {
OperationLogPojo pojo = operationLogRequestConverter.toPojo(request);
operationLogDao.insertAndReturnId(pojo);
return operationLogDao.insertAndReturnId(pojo);
}
public Page<OperationLogPageResponse> list(Pageable page,

View File

@@ -56,11 +56,11 @@ public class LoginService {
UserPojo user = userDao.selectOptionalById(login.getUserId())
.orElseThrow(() -> {
log.warn("user not exists but refresh token exists for " + login.getRefreshToken());
return DomainErrors.INVALID_REFRESH_TOKEN_OPERATION.exception();
return DomainErrors.INVALID_REFRESH_TOKEN_OPERATION.exception("invalid user");
});
if (!user.getEnabled()) {
log.warn("user disabled but refresh token exists for " + login.getRefreshToken());
throw DomainErrors.INVALID_REFRESH_TOKEN_OPERATION.exception();
throw DomainErrors.INVALID_REFRESH_TOKEN_OPERATION.exception("invalid user status");
}
String accessToken = jwtTokens.accessToken(user.getEmail());
LocalDateTime accessTokenExpireAt = jwtTokens.expireAt(accessToken);