mattyb149 commented on a change in pull request #4065: NIFI-4239 - Adding CaptureChangePostgreSQL processor to capture data changes (INSERT/UPDATE/DELETE) in PostgreSQL tables via Logical Replication. URL: https://github.com/apache/nifi/pull/4065#discussion_r402363096
########## File path: nifi-nar-bundles/nifi-cdc/nifi-cdc-postgresql-bundle/nifi-cdc-postgresql-processors/src/test/groovy/org/apache/nifi/cdc/postgresql/processor/CaptureChangePostgreSQLTest.groovy ########## @@ -0,0 +1,91 @@ +/* + * 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.nifi.cdc.postgresql.processors; + +import org.apache.nifi.util.TestRunner +import org.apache.nifi.util.TestRunners +import org.junit.After +import org.junit.Before +import org.junit.Test +import org.mockito.internal.configuration.injection.filter.MockCandidateFilter + +import java.sql.Connection +import java.sql.ResultSet +import java.sql.SQLException +import java.sql.Statement +import java.util.concurrent.TimeoutException +import java.util.regex.Matcher +import java.util.regex.Pattern + +import static org.junit.Assert.assertEquals +import static org.junit.Assert.assertTrue +import static org.mockito.ArgumentMatchers.anyString +import static org.mockito.Mockito.mock +import static org.mockito.Mockito.when + +import org.apache.nifi.processor.AbstractSessionFactoryProcessor; +import org.apache.nifi.processor.ProcessContext; +import org.apache.nifi.processor.ProcessSession; +import org.apache.nifi.processor.ProcessSessionFactory; +import org.apache.nifi.processor.Relationship; +import org.apache.nifi.processor.exception.ProcessException; +import org.apache.nifi.processor.util.StandardValidators; +import org.apache.nifi.reporting.InitializationException; +import org.apache.nifi.util.file.classloader.ClassLoaderUtils; + +/** + * Unit test(s) for PostgreSQL CDC + */ +public class CaptureChangePostgreSQLTest { Review comment: This really needs to be filled in, I realize it doesn't test much of the real capability because of the mock client, but unit tests for these kind of processors are good for testing the correct lifecycle, error handling, etc. of the unit-under-test. You could (but not required) also add an integration test (start or end the class name with `IT`) that connects to a real postgres. In that case I'd suggest using default ports (5432) and such, so folks with local or Dockerized PostgreSQL instances can run the integration test manually (they are not performed as part of contrib-check, GitHub Actions, etc.) The Elasticsearch bundle has quite a few examples of this. Again the integration test(s) are not required but we do need unit tests to cover the processor logic. Feel free to ping me if you have any questions! ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
