Browse Source

It's to remove `static` of method dataSource,If not remove `static` the transaction will not work. (#2422)

* It's to remove `static` of method dataSource,If not remove `static` the transaction will not work.

* update testQueryDetailsById because it didn't run success
pull/2/head
lgcareer 5 years ago committed by GitHub
parent
commit
c881c9517e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java
  2. 29
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UserMapperTest.java

2
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/datasource/SpringConnectionFactory.java

@ -64,7 +64,7 @@ public class SpringConnectionFactory {
* @return druid dataSource
*/
@Bean(destroyMethod="")
public static DruidDataSource dataSource() {
public DruidDataSource dataSource() {
DruidDataSource druidDataSource = new DruidDataSource();

29
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UserMapperTest.java

@ -16,11 +16,11 @@
*/
package org.apache.dolphinscheduler.dao.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dolphinscheduler.dao.entity.*;
import org.junit.Assert;
import org.junit.Test;
@ -179,6 +179,23 @@ public class UserMapperTest {
return tenant;
}
/**
* insert one Tenant
* @return Tenant
*/
private Tenant insertOneTenant(Queue queue){
Tenant tenant = new Tenant();
tenant.setTenantCode("dolphin");
tenant.setTenantName("dolphin test");
tenant.setDescription("dolphin user use");
tenant.setQueueId(queue.getId());
tenant.setQueue(queue.getQueue());
tenant.setCreateTime(new Date());
tenant.setUpdateTime(new Date());
tenantMapper.insert(tenant);
return tenant;
}
/**
* insert one Queue
* @return Queue
@ -291,11 +308,13 @@ public class UserMapperTest {
*/
@Test
public void testQueryDetailsById() {
//insertOne
User user = insertOne();
//insertOneQueue and insertOneTenant
Queue queue = insertOneQueue();
Tenant tenant = insertOneTenant(queue);
User user = insertOne(queue,tenant);
//queryDetailsById
User queryUser = userMapper.queryDetailsById(user.getId());
Assert.assertEquals(queryUser.getUserName(), queryUser.getUserName());
Assert.assertEquals(user.getUserName(), queryUser.getUserName());
}
/**

Loading…
Cancel
Save