Browse Source

[FIX][UT]testVerifyTenantCode assert error (#4460)

* [FIX][UT]testVerifyTenantCode assert error

* [FIX][UT]testVerifyTenantCode assert error

* code smell
pull/3/MERGE
Kirs 4 years ago committed by GitHub
parent
commit
b6ce3cfdf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TenantServiceTest.java

18
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TenantServiceTest.java

@ -35,7 +35,6 @@ import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.junit.Assert; import org.junit.Assert;
@ -81,7 +80,7 @@ public class TenantServiceTest {
try { try {
//check tenantCode //check tenantCode
Map<String, Object> result = Map<String, Object> result =
tenantService.createTenant(getLoginUser(), "%!1111", 1, "TenantServiceTest"); tenantService.createTenant(getLoginUser(), "%!1111", 1, "TenantServiceTest");
logger.info(result.toString()); logger.info(result.toString());
Assert.assertEquals(Status.VERIFY_OS_TENANT_CODE_ERROR, result.get(Constants.STATUS)); Assert.assertEquals(Status.VERIFY_OS_TENANT_CODE_ERROR, result.get(Constants.STATUS));
@ -109,7 +108,7 @@ public class TenantServiceTest {
page.setRecords(getList()); page.setRecords(getList());
page.setTotal(1L); page.setTotal(1L);
Mockito.when(tenantMapper.queryTenantPaging(Mockito.any(Page.class), Mockito.eq("TenantServiceTest"))) Mockito.when(tenantMapper.queryTenantPaging(Mockito.any(Page.class), Mockito.eq("TenantServiceTest")))
.thenReturn(page); .thenReturn(page);
Map<String, Object> result = tenantService.queryTenantList(getLoginUser(), "TenantServiceTest", 1, 10); Map<String, Object> result = tenantService.queryTenantList(getLoginUser(), "TenantServiceTest", 1, 10);
logger.info(result.toString()); logger.info(result.toString());
PageInfo<Tenant> pageInfo = (PageInfo<Tenant>) result.get(Constants.DATA_LIST); PageInfo<Tenant> pageInfo = (PageInfo<Tenant>) result.get(Constants.DATA_LIST);
@ -124,7 +123,7 @@ public class TenantServiceTest {
try { try {
// id not exist // id not exist
Map<String, Object> result = Map<String, Object> result =
tenantService.updateTenant(getLoginUser(), 912222, tenantCode, 1, "desc"); tenantService.updateTenant(getLoginUser(), 912222, tenantCode, 1, "desc");
logger.info(result.toString()); logger.info(result.toString());
// success // success
Assert.assertEquals(Status.TENANT_NOT_EXIST, result.get(Constants.STATUS)); Assert.assertEquals(Status.TENANT_NOT_EXIST, result.get(Constants.STATUS));
@ -143,7 +142,7 @@ public class TenantServiceTest {
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
Mockito.when(processInstanceMapper.queryByTenantIdAndStatus(1, Constants.NOT_TERMINATED_STATES)) Mockito.when(processInstanceMapper.queryByTenantIdAndStatus(1, Constants.NOT_TERMINATED_STATES))
.thenReturn(getInstanceList()); .thenReturn(getInstanceList());
Mockito.when(processDefinitionMapper.queryDefinitionListByTenant(2)).thenReturn(getDefinitionsList()); Mockito.when(processDefinitionMapper.queryDefinitionListByTenant(2)).thenReturn(getDefinitionsList());
Mockito.when(userMapper.queryUserListByTenant(3)).thenReturn(getUserList()); Mockito.when(userMapper.queryUserListByTenant(3)).thenReturn(getUserList());
@ -191,14 +190,7 @@ public class TenantServiceTest {
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
// tenantCode exist // tenantCode exist
result = tenantService.verifyTenantCode(getTenant().getTenantCode()); result = tenantService.verifyTenantCode(getTenant().getTenantCode());
String resultString; Assert.assertEquals(Status.OS_TENANT_CODE_EXIST.getCode(), result.getCode().intValue());
if (Locale.SIMPLIFIED_CHINESE.getLanguage().equals(LocaleContextHolder.getLocale().getLanguage())) {
resultString = "操作系统租户[TenantServiceTest]已存在";
} else {
resultString = "tenant code TenantServiceTest already exists";
}
logger.info(result.toString());
Assert.assertEquals(resultString, result.getMsg());
} }
/** /**

Loading…
Cancel
Save