Search in sources :

Example 1 with UdfFunc

use of org.apache.dolphinscheduler.dao.entity.UdfFunc in project dolphinscheduler by apache.

the class UdfFuncServiceTest method getUdfFunc.

/**
 *  get UdfFunc id
 */
private UdfFunc getUdfFunc() {
    UdfFunc udfFunc = new UdfFunc();
    udfFunc.setFuncName("UdfFuncServiceTest");
    udfFunc.setClassName("org.apache.dolphinscheduler.api.service.UdfFuncServiceTest");
    udfFunc.setResourceId(0);
    udfFunc.setResourceName("UdfFuncServiceTest");
    udfFunc.setCreateTime(new Date());
    udfFunc.setDatabase("database");
    udfFunc.setUpdateTime(new Date());
    udfFunc.setType(UdfType.HIVE);
    return udfFunc;
}
Also used : UdfFunc(org.apache.dolphinscheduler.dao.entity.UdfFunc) Date(java.util.Date)

Example 2 with UdfFunc

use of org.apache.dolphinscheduler.dao.entity.UdfFunc in project dolphinscheduler by apache.

the class UdfFuncServiceTest method testQueryUdfFuncList.

@Test
public void testQueryUdfFuncList() {
    User user = getLoginUser();
    user.setUserType(UserType.GENERAL_USER);
    Mockito.when(udfFuncMapper.getUdfFuncByType(user.getId(), UdfType.HIVE.ordinal())).thenReturn(getList());
    Map<String, Object> result = udfFuncService.queryUdfFuncList(user, UdfType.HIVE.ordinal());
    logger.info(result.toString());
    Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
    List<UdfFunc> udfFuncList = (List<UdfFunc>) result.get(Constants.DATA_LIST);
    Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncList));
}
Also used : User(org.apache.dolphinscheduler.dao.entity.User) ArrayList(java.util.ArrayList) List(java.util.List) UdfFunc(org.apache.dolphinscheduler.dao.entity.UdfFunc) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with UdfFunc

use of org.apache.dolphinscheduler.dao.entity.UdfFunc in project dolphinscheduler by apache.

the class UDFUserMapperTest method testUpdate.

/**
 * test update
 */
@Test
public void testUpdate() {
    // insertOneUser
    User user = insertOneUser();
    // insertOneUdfFunc
    UdfFunc udfFunc = insertOneUdfFunc();
    // insertOne
    UDFUser udfUser = insertOne(user, udfFunc);
    udfUser.setUserId(2);
    udfUser.setUdfId(2);
    int update = udfUserMapper.updateById(udfUser);
    Assert.assertEquals(update, 1);
}
Also used : UDFUser(org.apache.dolphinscheduler.dao.entity.UDFUser) User(org.apache.dolphinscheduler.dao.entity.User) UDFUser(org.apache.dolphinscheduler.dao.entity.UDFUser) UdfFunc(org.apache.dolphinscheduler.dao.entity.UdfFunc) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 4 with UdfFunc

use of org.apache.dolphinscheduler.dao.entity.UdfFunc in project dolphinscheduler by apache.

the class UDFUserMapperTest method insertOneUdfFunc.

/**
 * insert one udf
 * @return UdfFunc
 */
private UdfFunc insertOneUdfFunc() {
    UdfFunc udfFunc = new UdfFunc();
    udfFunc.setFuncName("dolphin_udf_func");
    udfFunc.setClassName("org.apache.dolphinscheduler.test.mr");
    udfFunc.setType(UdfType.HIVE);
    udfFunc.setResourceId(1);
    udfFunc.setResourceName("dolphin_resource");
    udfFunc.setCreateTime(new Date());
    udfFunc.setUpdateTime(new Date());
    udfFuncMapper.insert(udfFunc);
    return udfFunc;
}
Also used : UdfFunc(org.apache.dolphinscheduler.dao.entity.UdfFunc) Date(java.util.Date)

Example 5 with UdfFunc

use of org.apache.dolphinscheduler.dao.entity.UdfFunc in project dolphinscheduler by apache.

the class UDFUserMapperTest method testDelete.

/**
 * test delete
 */
@Test
public void testDelete() {
    // insertOneUser
    User user = insertOneUser();
    // insertOneUdfFunc
    UdfFunc udfFunc = insertOneUdfFunc();
    // insertOne
    UDFUser udfUser = insertOne(user, udfFunc);
    int delete = udfUserMapper.deleteById(udfUser.getId());
    Assert.assertEquals(delete, 1);
}
Also used : UDFUser(org.apache.dolphinscheduler.dao.entity.UDFUser) User(org.apache.dolphinscheduler.dao.entity.User) UDFUser(org.apache.dolphinscheduler.dao.entity.UDFUser) UdfFunc(org.apache.dolphinscheduler.dao.entity.UdfFunc) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

UdfFunc (org.apache.dolphinscheduler.dao.entity.UdfFunc)27 Test (org.junit.Test)18 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)14 User (org.apache.dolphinscheduler.dao.entity.User)13 UDFUser (org.apache.dolphinscheduler.dao.entity.UDFUser)10 Date (java.util.Date)8 ArrayList (java.util.ArrayList)5 List (java.util.List)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 IPage (com.baomidou.mybatisplus.core.metadata.IPage)3 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)3 HashMap (java.util.HashMap)3 PageInfo (org.apache.dolphinscheduler.api.utils.PageInfo)2 Resource (org.apache.dolphinscheduler.dao.entity.Resource)2 Arrays (java.util.Arrays)1 Collectors.toList (java.util.stream.Collectors.toList)1 Result (org.apache.dolphinscheduler.api.utils.Result)1 UdfType (org.apache.dolphinscheduler.common.enums.UdfType)1 UserType (org.apache.dolphinscheduler.common.enums.UserType)1 Assert (org.junit.Assert)1