Commit d47e10bf authored by 技术部-任文超's avatar 技术部-任文超

更新Service测试用例

parent 5cc04e15
package service;
import cn.quantgroup.xyqb.Bootstrap;
import cn.quantgroup.xyqb.entity.UserAuthorized;
import cn.quantgroup.xyqb.model.AuthPattern;
import cn.quantgroup.xyqb.model.UserAuthorizedParam;
import cn.quantgroup.xyqb.service.auth.IUserAuthorizedService;
import com.ctrip.framework.apollo.spring.config.ApolloPropertySourceInitializer;
import demo.BaseParametersTests;
......@@ -18,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
/**
* 业务层测试用例
......@@ -35,17 +38,12 @@ public class UserAuthorizedServiceTests extends BaseParametersTests {
@Autowired
private IUserAuthorizedService userAuthorizedService;
private Long userId;
private String idNo;
private String name;
private AuthPattern authPattern;
private Boolean available;
UserAuthorizedParam obj = new UserAuthorizedParam();
public UserAuthorizedServiceTests(Long userId, String idNo, String name, AuthPattern authPattern, Boolean available) {
this.userId = userId;
this.idNo = idNo;
this.name = name;
this.authPattern = authPattern;
this.available = available;
obj.setUserId(userId);
obj.setIdNo(idNo);
obj.setName(name);
obj.setAuthPattern(Optional.ofNullable(authPattern).orElse(AuthPattern.ZMXY).name());
}
@Parameterized.Parameters
......@@ -61,22 +59,22 @@ public class UserAuthorizedServiceTests extends BaseParametersTests {
@Test
public void testExist() throws Exception {
log.info("testExist: name:{}, idNo:{}, userId:{}, authPattern:{}", this.name, this.idNo, this.userId, this.authPattern);
Object obj = userAuthorizedService.hasUserAuthorized(this.idNo);
log.info("testExist: name:{}, idNo:{}, userId:{}, authPattern:{}", obj.getName(), obj.getIdNo(), obj.getUserId(), obj.getAuthPattern());
Object obj = userAuthorizedService.hasUserAuthorized(this.obj.getIdNo());
Assert.assertNotNull(obj);
}
@Test
public void testSave() throws Exception {
log.info("testSave: name:{}, idNo:{}, userId:{}, authPattern:{}", this.name, this.idNo, this.userId, this.authPattern);
Object obj = userAuthorizedService.createUserAuthorized(this.name, this.idNo, this.userId, this.authPattern.name());
log.info("testSave: name:{}, idNo:{}, userId:{}, authPattern:{}", obj.getName(), obj.getIdNo(), obj.getUserId(), obj.getAuthPattern());
Object obj = userAuthorizedService.createUserAuthorized(this.obj);
Assert.assertNotNull(obj);
}
@Test
public void testQuery(){
log.info("testQuery: name:{}, idNo:{}, userId:{}, authPattern:{}", this.name, this.idNo, this.userId, this.authPattern);
Object obj = userAuthorizedService.getUserAuthorizedId(this.userId);
log.info("testQuery: name:{}, idNo:{}, userId:{}, authPattern:{}", obj.getName(), obj.getIdNo(), obj.getUserId(), obj.getAuthPattern());
Object obj = userAuthorizedService.getUserAuthorizedId(this.obj.getUserId());
Assert.assertNotNull(obj);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment