mirror of https://github.com/elunez/eladmin
Add unit tests for me.zhengjie.utils.StringUtils
parent
3cde757b32
commit
333212a15f
|
@ -0,0 +1,49 @@
|
|||
package me.zhengjie.utils;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
import static me.zhengjie.utils.StringUtils.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class StringUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testInString() {
|
||||
assertTrue(inString("?", "?"));
|
||||
assertFalse(inString("?", new String[]{}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToCamelCase() {
|
||||
assertNull(toCamelCase(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToCapitalizeCamelCase() {
|
||||
assertNull(StringUtils.toCapitalizeCamelCase(null));
|
||||
assertEquals("HelloWorld", toCapitalizeCamelCase("hello_world"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToUnderScoreCase() {
|
||||
assertNull(StringUtils.toUnderScoreCase(null));
|
||||
assertEquals("hello_world", toUnderScoreCase("helloWorld"));
|
||||
assertEquals("\u0000\u0000", toUnderScoreCase("\u0000\u0000"));
|
||||
assertEquals("\u0000_a", toUnderScoreCase("\u0000A"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetWeekDay() {
|
||||
SimpleDateFormat simpleDateformat = new SimpleDateFormat("E");
|
||||
assertEquals(simpleDateformat.format(new Date()), getWeekDay());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetIP() {
|
||||
assertEquals("127.0.0.1", getIP(new MockHttpServletRequest()));
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package me.zhengjie.modules.security.service;
|
||||
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.modules.system.domain.*;
|
||||
import me.zhengjie.exception.EntityNotFoundException;
|
||||
import me.zhengjie.modules.system.repository.PermissionRepository;
|
||||
|
@ -40,7 +41,7 @@ public class JwtUserDetailsService implements UserDetailsService {
|
|||
|
||||
User user = userService.findByName(username);
|
||||
if (user == null) {
|
||||
throw new EntityNotFoundException(User.class, "name", username);
|
||||
throw new BadRequestException("账号不存在");
|
||||
} else {
|
||||
return createJwtUser(user);
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ import me.zhengjie.aop.log.Log;
|
|||
import me.zhengjie.domain.AlipayConfig;
|
||||
import me.zhengjie.domain.vo.TradeVo;
|
||||
import me.zhengjie.service.AlipayService;
|
||||
import me.zhengjie.util.AliPayStatusEnum;
|
||||
import me.zhengjie.util.AlipayUtils;
|
||||
import me.zhengjie.utils.AliPayStatusEnum;
|
||||
import me.zhengjie.utils.AlipayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
|
|
@ -9,7 +9,7 @@ import me.zhengjie.domain.vo.TradeVo;
|
|||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.repository.AlipayRepository;
|
||||
import me.zhengjie.service.AlipayService;
|
||||
import me.zhengjie.util.AlipayUtils;
|
||||
import me.zhengjie.utils.AlipayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
|
|
|
@ -15,7 +15,7 @@ import me.zhengjie.exception.BadRequestException;
|
|||
import me.zhengjie.repository.QiNiuConfigRepository;
|
||||
import me.zhengjie.repository.QiniuContentRepository;
|
||||
import me.zhengjie.service.QiNiuService;
|
||||
import me.zhengjie.util.QiNiuUtil;
|
||||
import me.zhengjie.utils.QiNiuUtil;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
import me.zhengjie.utils.ValidationUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -25,7 +25,6 @@ import org.springframework.transaction.annotation.Propagation;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package me.zhengjie.util;
|
||||
package me.zhengjie.utils;
|
||||
|
||||
/**
|
||||
* 支付状态
|
|
@ -1,4 +1,4 @@
|
|||
package me.zhengjie.util;
|
||||
package me.zhengjie.utils;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alipay.api.AlipayApiException;
|
|
@ -1,8 +1,8 @@
|
|||
package me.zhengjie.util;
|
||||
package me.zhengjie.utils;
|
||||
|
||||
import com.qiniu.common.Zone;
|
||||
import com.qiniu.storage.Configuration;
|
||||
import me.zhengjie.utils.FileUtil;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
Loading…
Reference in New Issue