use of org.apache.pulsar.common.io.SourceConfig in project incubator-pulsar by apache.
the class SourceApiV3ResourceTest method testRegisterSourceConflictingFields.
@Test
public void testRegisterSourceConflictingFields() throws Exception {
mockWorkerUtils();
String actualTenant = "DIFFERENT_TENANT";
String actualNamespace = "DIFFERENT_NAMESPACE";
String actualName = "DIFFERENT_NAME";
this.namespaceList.add(actualTenant + "/" + actualNamespace);
when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(source))).thenReturn(true);
when(mockedManager.containsFunction(eq(actualTenant), eq(actualNamespace), eq(actualName))).thenReturn(false);
SourceConfig sourceConfig = new SourceConfig();
sourceConfig.setTenant(tenant);
sourceConfig.setNamespace(namespace);
sourceConfig.setName(source);
sourceConfig.setClassName(TWITTER_FIRE_HOSE);
sourceConfig.setParallelism(parallelism);
sourceConfig.setTopicName(outputTopic);
sourceConfig.setSerdeClassName(outputSerdeClassName);
try (InputStream inputStream = new FileInputStream(getPulsarIOTwitterNar())) {
resource.registerSource(actualTenant, actualNamespace, actualName, inputStream, mockedFormData, null, sourceConfig, null, null);
}
}
use of org.apache.pulsar.common.io.SourceConfig in project incubator-pulsar by apache.
the class SourceApiV3ResourceTest method createDefaultSourceConfig.
private SourceConfig createDefaultSourceConfig() {
SourceConfig sourceConfig = new SourceConfig();
sourceConfig.setTenant(tenant);
sourceConfig.setNamespace(namespace);
sourceConfig.setName(source);
sourceConfig.setClassName(TWITTER_FIRE_HOSE);
sourceConfig.setParallelism(parallelism);
sourceConfig.setTopicName(outputTopic);
sourceConfig.setSerdeClassName(outputSerdeClassName);
return sourceConfig;
}
use of org.apache.pulsar.common.io.SourceConfig in project incubator-pulsar by apache.
the class SourceApiV3ResourceTest method registerDefaultSourceWithPackageUrl.
private void registerDefaultSourceWithPackageUrl(String packageUrl) throws IOException {
SourceConfig sourceConfig = createDefaultSourceConfig();
resource.registerSource(tenant, namespace, source, null, null, packageUrl, sourceConfig, null, null);
}
use of org.apache.pulsar.common.io.SourceConfig in project incubator-pulsar by apache.
the class SourceApiV3ResourceTest method testRegisterSourceMissingArguments.
private void testRegisterSourceMissingArguments(String tenant, String namespace, String function, InputStream inputStream, FormDataContentDisposition details, String outputTopic, String outputSerdeClassName, String className, Integer parallelism, String pkgUrl) {
SourceConfig sourceConfig = new SourceConfig();
if (tenant != null) {
sourceConfig.setTenant(tenant);
}
if (namespace != null) {
sourceConfig.setNamespace(namespace);
}
if (function != null) {
sourceConfig.setName(function);
}
if (outputTopic != null) {
sourceConfig.setTopicName(outputTopic);
}
if (outputSerdeClassName != null) {
sourceConfig.setSerdeClassName(outputSerdeClassName);
}
if (className != null) {
sourceConfig.setClassName(className);
}
if (parallelism != null) {
sourceConfig.setParallelism(parallelism);
}
resource.registerSource(tenant, namespace, function, inputStream, details, pkgUrl, sourceConfig, null, null);
}
use of org.apache.pulsar.common.io.SourceConfig in project incubator-pulsar by apache.
the class SourceApiV3ResourceTest method testUpdateSourceMissingArguments.
private void testUpdateSourceMissingArguments(String tenant, String namespace, String function, InputStream inputStream, FormDataContentDisposition details, String outputTopic, String outputSerdeClassName, String className, Integer parallelism, String expectedError) throws Exception {
mockStatic(ConnectorUtils.class, c -> {
});
mockStatic(ClassLoaderUtils.class, c -> {
});
mockStatic(FunctionCommon.class, ctx -> {
ctx.when(() -> FunctionCommon.createPkgTempFile()).thenCallRealMethod();
ctx.when(() -> FunctionCommon.getClassLoaderFromPackage(any(), any(), any(), any())).thenCallRealMethod();
ctx.when(() -> FunctionCommon.getSourceType(argThat(clazz -> clazz.getName().equals(TWITTER_FIRE_HOSE)))).thenReturn(String.class);
ctx.when(() -> FunctionCommon.extractNarClassLoader(any(), any())).thenReturn(narClassLoader);
});
this.mockedFunctionMetaData = FunctionMetaData.newBuilder().setFunctionDetails(createDefaultFunctionDetails()).build();
when(mockedManager.getFunctionMetaData(any(), any(), any())).thenReturn(mockedFunctionMetaData);
when(mockedManager.containsFunction(eq(tenant), eq(namespace), eq(function))).thenReturn(true);
SourceConfig sourceConfig = new SourceConfig();
if (tenant != null) {
sourceConfig.setTenant(tenant);
}
if (namespace != null) {
sourceConfig.setNamespace(namespace);
}
if (function != null) {
sourceConfig.setName(function);
}
if (outputTopic != null) {
sourceConfig.setTopicName(outputTopic);
}
if (outputSerdeClassName != null) {
sourceConfig.setSerdeClassName(outputSerdeClassName);
}
if (className != null) {
sourceConfig.setClassName(className);
}
if (parallelism != null) {
sourceConfig.setParallelism(parallelism);
}
if (expectedError != null) {
doThrow(new IllegalArgumentException(expectedError)).when(mockedManager).updateFunctionOnLeader(any(FunctionMetaData.class), Mockito.anyBoolean());
}
resource.updateSource(tenant, namespace, function, inputStream, details, null, sourceConfig, null, null, null);
}
Aggregations