Skip to content

Commit

Permalink
fix: add AbstractFunctionTestBases
Browse files Browse the repository at this point in the history
  • Loading branch information
emptyOVO committed Oct 10, 2024
1 parent a3c9a64 commit d584c00
Show file tree
Hide file tree
Showing 33 changed files with 248 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.inlong.sdk.transform.process.function.collection;

import org.apache.inlong.sdk.transform.pojo.CsvSourceInfo;
import org.apache.inlong.sdk.transform.pojo.FieldInfo;
import org.apache.inlong.sdk.transform.pojo.KvSinkInfo;

import java.util.ArrayList;
import java.util.List;

/**
* AbstractFunctionStringTestBase
* description: define static parameters for StringFunction tests
*/
public abstract class AbstractFunctionCollectionTestBase {

protected static final List<FieldInfo> srcFields = new ArrayList<>();
protected static final List<FieldInfo> dstFields = new ArrayList<>();
protected static final CsvSourceInfo csvSource;
protected static final KvSinkInfo kvSink;

static {
for (int i = 1; i < 4; i++) {
FieldInfo field = new FieldInfo();
field.setName("string" + i);
srcFields.add(field);
}
for (int i = 1; i < 4; i++) {
FieldInfo field = new FieldInfo();
field.setName("numeric" + i);
srcFields.add(field);
}
FieldInfo field = new FieldInfo();
field.setName("result");
dstFields.add(field);
csvSource = new CsvSourceInfo("UTF-8", '|', '\\', srcFields);
kvSink = new KvSinkInfo("UTF-8", dstFields);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import org.apache.inlong.sdk.transform.encode.SinkEncoderFactory;
import org.apache.inlong.sdk.transform.pojo.TransformConfig;
import org.apache.inlong.sdk.transform.process.TransformProcessor;
import org.apache.inlong.sdk.transform.process.function.string.AbstractFunctionStringTestBase;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;

public class TestArrayFunction extends AbstractFunctionStringTestBase {
public class TestArrayFunction extends AbstractFunctionCollectionTestBase {

@Test
public void testArrayFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import org.apache.inlong.sdk.transform.encode.SinkEncoderFactory;
import org.apache.inlong.sdk.transform.pojo.TransformConfig;
import org.apache.inlong.sdk.transform.process.TransformProcessor;
import org.apache.inlong.sdk.transform.process.function.string.AbstractFunctionStringTestBase;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;

public class TestFindInSetFunction extends AbstractFunctionStringTestBase {
public class TestFindInSetFunction extends AbstractFunctionCollectionTestBase {

@Test
public void testFindInSetFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import org.apache.inlong.sdk.transform.encode.SinkEncoderFactory;
import org.apache.inlong.sdk.transform.pojo.TransformConfig;
import org.apache.inlong.sdk.transform.process.TransformProcessor;
import org.apache.inlong.sdk.transform.process.function.string.AbstractFunctionStringTestBase;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;

public class TestMapEntriesFunction extends AbstractFunctionStringTestBase {
public class TestMapEntriesFunction extends AbstractFunctionCollectionTestBase {

@Test
public void testMapEntriesFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import org.apache.inlong.sdk.transform.encode.SinkEncoderFactory;
import org.apache.inlong.sdk.transform.pojo.TransformConfig;
import org.apache.inlong.sdk.transform.process.TransformProcessor;
import org.apache.inlong.sdk.transform.process.function.string.AbstractFunctionStringTestBase;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;

public class TestMapFromArraysFunction extends AbstractFunctionStringTestBase {
public class TestMapFromArraysFunction extends AbstractFunctionCollectionTestBase {

@Test
public void testMapFromArraysFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import org.apache.inlong.sdk.transform.encode.SinkEncoderFactory;
import org.apache.inlong.sdk.transform.pojo.TransformConfig;
import org.apache.inlong.sdk.transform.process.TransformProcessor;
import org.apache.inlong.sdk.transform.process.function.string.AbstractFunctionStringTestBase;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;

public class TestMapFunction extends AbstractFunctionStringTestBase {
public class TestMapFunction extends AbstractFunctionCollectionTestBase {

@Test
public void testMapFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import org.apache.inlong.sdk.transform.encode.SinkEncoderFactory;
import org.apache.inlong.sdk.transform.pojo.TransformConfig;
import org.apache.inlong.sdk.transform.process.TransformProcessor;
import org.apache.inlong.sdk.transform.process.function.string.AbstractFunctionStringTestBase;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;

public class TestMapKeysFunction extends AbstractFunctionStringTestBase {
public class TestMapKeysFunction extends AbstractFunctionCollectionTestBase {

@Test
public void testMapKeysFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import org.apache.inlong.sdk.transform.encode.SinkEncoderFactory;
import org.apache.inlong.sdk.transform.pojo.TransformConfig;
import org.apache.inlong.sdk.transform.process.TransformProcessor;
import org.apache.inlong.sdk.transform.process.function.string.AbstractFunctionStringTestBase;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;

public class TestMapUnionFunction extends AbstractFunctionStringTestBase {
public class TestMapUnionFunction extends AbstractFunctionCollectionTestBase {

@Test
public void testMapUnionFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import org.apache.inlong.sdk.transform.encode.SinkEncoderFactory;
import org.apache.inlong.sdk.transform.pojo.TransformConfig;
import org.apache.inlong.sdk.transform.process.TransformProcessor;
import org.apache.inlong.sdk.transform.process.function.string.AbstractFunctionStringTestBase;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;

public class TestMapValuesFunction extends AbstractFunctionStringTestBase {
public class TestMapValuesFunction extends AbstractFunctionCollectionTestBase {

@Test
public void testMapValuesFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.inlong.sdk.transform.process.function.compression;

import org.apache.inlong.sdk.transform.pojo.CsvSourceInfo;
import org.apache.inlong.sdk.transform.pojo.FieldInfo;
import org.apache.inlong.sdk.transform.pojo.KvSinkInfo;

import java.util.ArrayList;
import java.util.List;

/**
* AbstractFunctionStringTestBase
* description: define static parameters for StringFunction tests
*/
public abstract class AbstractFunctionCompressionTestBase {

protected static final List<FieldInfo> srcFields = new ArrayList<>();
protected static final List<FieldInfo> dstFields = new ArrayList<>();
protected static final CsvSourceInfo csvSource;
protected static final KvSinkInfo kvSink;

static {
for (int i = 1; i < 4; i++) {
FieldInfo field = new FieldInfo();
field.setName("string" + i);
srcFields.add(field);
}
for (int i = 1; i < 4; i++) {
FieldInfo field = new FieldInfo();
field.setName("numeric" + i);
srcFields.add(field);
}
FieldInfo field = new FieldInfo();
field.setName("result");
dstFields.add(field);
csvSource = new CsvSourceInfo("UTF-8", '|', '\\', srcFields);
kvSink = new KvSinkInfo("UTF-8", dstFields);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import org.apache.inlong.sdk.transform.encode.SinkEncoderFactory;
import org.apache.inlong.sdk.transform.pojo.TransformConfig;
import org.apache.inlong.sdk.transform.process.TransformProcessor;
import org.apache.inlong.sdk.transform.process.function.string.AbstractFunctionStringTestBase;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;

public class TestCompressFunction extends AbstractFunctionStringTestBase {
public class TestCompressFunction extends AbstractFunctionCompressionTestBase {

@Test
public void testCompressFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import org.apache.inlong.sdk.transform.encode.SinkEncoderFactory;
import org.apache.inlong.sdk.transform.pojo.TransformConfig;
import org.apache.inlong.sdk.transform.process.TransformProcessor;
import org.apache.inlong.sdk.transform.process.function.string.AbstractFunctionStringTestBase;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;

public class TestUnCompressFunction extends AbstractFunctionStringTestBase {
public class TestUnCompressFunction extends AbstractFunctionCompressionTestBase {

@Test
public void testUnCompressFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.ArrayList;
import java.util.List;

public abstract class AbstractFunctionFlowControlTestBase {
public abstract class AbstractFunctionConditionTestBase {

protected static final List<FieldInfo> srcFields = new ArrayList<>();
protected static final List<FieldInfo> dstFields = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.ArrayList;
import java.util.List;

public class TestIfFunction extends AbstractFunctionFlowControlTestBase {
public class TestIfFunction extends AbstractFunctionConditionTestBase {

private static final List<FieldInfo> srcFields = new ArrayList<>();
private static final List<FieldInfo> dstFields = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.HashMap;
import java.util.List;

public class TestIfNullFunction extends AbstractFunctionFlowControlTestBase {
public class TestIfNullFunction extends AbstractFunctionConditionTestBase {

@Test
public void testIfNullFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import org.apache.inlong.sdk.transform.encode.SinkEncoderFactory;
import org.apache.inlong.sdk.transform.pojo.TransformConfig;
import org.apache.inlong.sdk.transform.process.TransformProcessor;
import org.apache.inlong.sdk.transform.process.function.arithmetic.AbstractFunctionArithmeticTestBase;

import org.junit.Assert;
import org.junit.Test;

import java.util.HashMap;
import java.util.List;

public class TestIsNullFunction extends AbstractFunctionArithmeticTestBase {
public class TestIsNullFunction extends AbstractFunctionConditionTestBase {

@Test
public void testIsNullFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.util.HashMap;
import java.util.List;

public class TestNullIfFunction extends AbstractFunctionFlowControlTestBase {
public class TestNullIfFunction extends AbstractFunctionConditionTestBase {

@Test
public void testNullIfFunction() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.inlong.sdk.transform.process.function.encryption;

import org.apache.inlong.sdk.transform.pojo.CsvSourceInfo;
import org.apache.inlong.sdk.transform.pojo.FieldInfo;
import org.apache.inlong.sdk.transform.pojo.KvSinkInfo;

import java.util.ArrayList;
import java.util.List;

/**
* AbstractFunctionStringTestBase
* description: define static parameters for StringFunction tests
*/
public abstract class AbstractFunctionEncryptionTestBase {

protected static final List<FieldInfo> srcFields = new ArrayList<>();
protected static final List<FieldInfo> dstFields = new ArrayList<>();
protected static final CsvSourceInfo csvSource;
protected static final KvSinkInfo kvSink;

static {
for (int i = 1; i < 4; i++) {
FieldInfo field = new FieldInfo();
field.setName("string" + i);
srcFields.add(field);
}
for (int i = 1; i < 4; i++) {
FieldInfo field = new FieldInfo();
field.setName("numeric" + i);
srcFields.add(field);
}
FieldInfo field = new FieldInfo();
field.setName("result");
dstFields.add(field);
csvSource = new CsvSourceInfo("UTF-8", '|', '\\', srcFields);
kvSink = new KvSinkInfo("UTF-8", dstFields);
}
}
Loading

0 comments on commit d584c00

Please sign in to comment.