Search in sources :

Example 21 with SourceConfig

use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.

the class SourceConfigUtilsTest method testMergeDifferentName.

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Function Names differ")
public void testMergeDifferentName() {
    SourceConfig sourceConfig = createSourceConfig();
    SourceConfig newSourceConfig = createUpdatedSourceConfig("name", "Different");
    SourceConfigUtils.validateUpdate(sourceConfig, newSourceConfig);
}
Also used : BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Test(org.testng.annotations.Test)

Example 22 with SourceConfig

use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.

the class SourceConfigUtilsTest method testMergeDifferentSecrets.

@Test
public void testMergeDifferentSecrets() {
    SourceConfig sourceConfig = createSourceConfig();
    Map<String, String> mySecrets = new HashMap<>();
    mySecrets.put("MyKey", "MyValue");
    SourceConfig newSourceConfig = createUpdatedSourceConfig("secrets", mySecrets);
    SourceConfig mergedConfig = SourceConfigUtils.validateUpdate(sourceConfig, newSourceConfig);
    assertEquals(mergedConfig.getSecrets(), mySecrets);
    mergedConfig.setSecrets(sourceConfig.getSecrets());
    assertEquals(new Gson().toJson(sourceConfig), new Gson().toJson(mergedConfig));
}
Also used : HashMap(java.util.HashMap) BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Gson(com.google.gson.Gson) Test(org.testng.annotations.Test)

Example 23 with SourceConfig

use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.

the class SourceConfigUtilsTest method testSupportsBatchBuilderWhenProducerConfigIsNull.

@Test
public void testSupportsBatchBuilderWhenProducerConfigIsNull() {
    SourceConfig sourceConfig = createSourceConfig();
    sourceConfig.setProducerConfig(null);
    sourceConfig.setBatchBuilder("KEY_BASED");
    Function.FunctionDetails functionDetails = SourceConfigUtils.convert(sourceConfig, new SourceConfigUtils.ExtractedSourceDetails(null, null));
    assertEquals(functionDetails.getSink().getProducerSpec().getBatchBuilder(), "KEY_BASED");
}
Also used : Function(org.apache.pulsar.functions.proto.Function) BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Test(org.testng.annotations.Test)

Example 24 with SourceConfig

use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.

the class SourceConfigUtilsTest method testMergeDifferentUserConfig.

@Test
public void testMergeDifferentUserConfig() {
    SourceConfig sourceConfig = createSourceConfig();
    Map<String, String> myConfig = new HashMap<>();
    myConfig.put("MyKey", "MyValue");
    SourceConfig newSourceConfig = createUpdatedSourceConfig("configs", myConfig);
    SourceConfig mergedConfig = SourceConfigUtils.validateUpdate(sourceConfig, newSourceConfig);
    assertEquals(mergedConfig.getConfigs(), myConfig);
    mergedConfig.setConfigs(sourceConfig.getConfigs());
    assertEquals(new Gson().toJson(sourceConfig), new Gson().toJson(mergedConfig));
}
Also used : HashMap(java.util.HashMap) BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Gson(com.google.gson.Gson) Test(org.testng.annotations.Test)

Example 25 with SourceConfig

use of org.apache.pulsar.common.io.SourceConfig in project pulsar by apache.

the class SourceConfigUtilsTest method testBatchConfigMergeEqual.

@Test
public void testBatchConfigMergeEqual() {
    SourceConfig sourceConfig = createSourceConfigWithBatch();
    SourceConfig newSourceConfig = createSourceConfigWithBatch();
    SourceConfig mergedConfig = SourceConfigUtils.validateUpdate(sourceConfig, newSourceConfig);
    assertEquals(new Gson().toJson(sourceConfig), new Gson().toJson(mergedConfig));
}
Also used : BatchSourceConfig(org.apache.pulsar.common.io.BatchSourceConfig) SourceConfig(org.apache.pulsar.common.io.SourceConfig) Gson(com.google.gson.Gson) Test(org.testng.annotations.Test)

Aggregations

SourceConfig (org.apache.pulsar.common.io.SourceConfig)192 BatchSourceConfig (org.apache.pulsar.common.io.BatchSourceConfig)141 Test (org.testng.annotations.Test)129 Gson (com.google.gson.Gson)42 HashMap (java.util.HashMap)30 File (java.io.File)27 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)27 Function (org.apache.pulsar.functions.proto.Function)24 IOException (java.io.IOException)21 Response (javax.ws.rs.core.Response)18 List (java.util.List)15 Map (java.util.Map)15 RestException (org.apache.pulsar.common.util.RestException)15 IdentityFunction (org.apache.pulsar.functions.api.utils.IdentityFunction)15 FunctionMetaDataManager (org.apache.pulsar.functions.worker.FunctionMetaDataManager)15 Lists (com.google.common.collect.Lists)12 FileInputStream (java.io.FileInputStream)12 InputStream (java.io.InputStream)12 Files (java.nio.file.Files)12 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)12