Unverified Commit b8e4ae3b authored by samz406's avatar samz406 Committed by GitHub
Browse files

Merge pull request #6 from apache/dev

update
parents 50aeab54 4d8d74ac
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ It is because of the shoulders of these open source projects that the birth of t

### Get Help
1. Submit an issue
1. Mail list: dev@dolphinscheduler.apache.org. Mail to dev-subscribe@dolphinscheduler.apache.org, follow the reply to subscribe the mail list.
1. Subscribe the mail list : https://dolphinscheduler.apache.org/en-us/docs/user_doc/subscribe.html.  then send mail to dev@dolphinscheduler.apache.org
1. Contact WeChat group manager, ID 510570367. This is for Mandarin(CN) discussion.

### License
+1 −1
Original line number Diff line number Diff line
@@ -512,7 +512,7 @@ public class ProcessDefinitionService extends BaseDAGService {
                                    for (int k = 0; k < dependItemList.size(); k++) {
                                        JSONObject dependentItem = dependItemList.getJSONObject(k);
                                        int definitionId = dependentItem.getInteger("definitionId");
                                        ProcessDefinition definition = processDefineMapper.selectById(definitionId);
                                        ProcessDefinition definition = processDefineMapper.queryByDefineId(definitionId);
                                        if(definition != null){
                                            dependentItem.put("projectName",definition.getProjectName());
                                            dependentItem.put("definitionName",definition.getName());
+109 −0
Original line number Diff line number Diff line
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.apache.dolphinscheduler.api.utils;

import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;
import org.springframework.web.multipart.MultipartFile;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import static org.junit.Assert.*;

public class FileUtilsTest {

    private static final Logger logger = LoggerFactory.getLogger(FileUtilsTest.class);

    @Rule
    public TemporaryFolder folder = null;

    private String rootPath = null;

    @Before
    public void setUp() throws Exception {

        folder = new TemporaryFolder();
        folder.create();

        rootPath = folder.getRoot().getAbsolutePath();
    }

    @After
    public void tearDown() throws Exception {

        folder.delete();
    }

    /**
     * Use mock to test copyFile
     * @throws IOException
     */
    @Test
    public void testCopyFile() throws IOException {

        //Define dest file path
        String destFilename = rootPath + System.getProperty("file.separator") + "data.txt";
        logger.info("destFilename: "+destFilename);

        //Define InputStream for MultipartFile
        String data = "data text";
        InputStream targetStream = new ByteArrayInputStream(data.getBytes());

        //Use Mockito to mock MultipartFile
        MultipartFile file = Mockito.mock(MultipartFile.class);
        Mockito.when(file.getInputStream()).thenReturn(targetStream);

        //Invoke copyFile
        FileUtils.copyFile(file,destFilename);

        //Test file exists
        File destFile = new File(destFilename);
        assertTrue(destFile.exists());

    }

    @Test
    public void testFile2Resource() throws IOException {

        //Define dest file path
        String destFilename = rootPath + System.getProperty("file.separator") + "data.txt";
        logger.info("destFilename: "+destFilename);

        //Define test resource
        File file = folder.newFile("resource.txt");

        //Invoke file2Resource and test not null
        Resource resource = FileUtils.file2Resource(file.getAbsolutePath());
        assertNotNull(resource);

        //Invoke file2Resource and test null
        Resource resource1 = FileUtils.file2Resource(file.getAbsolutePath()+"abc");
        assertNull(resource1);

    }
}
 No newline at end of file
+40 −0
Original line number Diff line number Diff line
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.dolphinscheduler.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

@Getter
public enum SparkVersion {

    /**
     * 0 SPARK1
     * 1 SPARK2
     */
    SPARK1(0, "SPARK1"),
    SPARK2(1, "SPARK2");

    SparkVersion(int code, String descp){
        this.code = code;
        this.descp = descp;
    }

    @EnumValue
    private final int code;
    private final String descp;
}
+15 −2
Original line number Diff line number Diff line
@@ -95,6 +95,11 @@ public class SparkParameters extends AbstractParameters {
   */
  private ProgramType programType;

  /**
   * spark version
   */
  private String sparkVersion;

  public ResourceInfo getMainJar() {
    return mainJar;
  }
@@ -200,9 +205,17 @@ public class SparkParameters extends AbstractParameters {
    this.programType = programType;
  }

  public String getSparkVersion() {
    return sparkVersion;
  }

  public void setSparkVersion(String sparkVersion) {
    this.sparkVersion = sparkVersion;
  }

  @Override
  public boolean checkParameters() {
    return mainJar != null && programType != null;
    return mainJar != null && programType != null && sparkVersion != null;
  }


@@ -211,7 +224,7 @@ public class SparkParameters extends AbstractParameters {
    if(resourceList !=null ) {
      this.resourceList.add(mainJar);
      return resourceList.stream()
              .map(p -> p.getRes()).collect(Collectors.toList());
              .map(ResourceInfo::getRes).collect(Collectors.toList());
    }
    return null;
  }
Loading