This is an automated email from the ASF dual-hosted git repository. azexin pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push: new 7a0d8651491 Add unit tests for CDCImporterManager (#28666) 7a0d8651491 is described below commit 7a0d86514916b469820a080f0d6a24ed763fd734 Author: isdrchagas <85903568+isdrcha...@users.noreply.github.com> AuthorDate: Mon Oct 9 23:40:58 2023 -0300 Add unit tests for CDCImporterManager (#28666) * Add unit tests for CDCImporterManager * Add new line to follow checkstyle rule * Remove import static to getImporter() to follow checkstyle rules * Apply spotless code style rules --- .../cdc/core/importer/CDCImporterManagerTest.java | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/core/importer/CDCImporterManagerTest.java b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/core/importer/CDCImporterManagerTest.java new file mode 100644 index 00000000000..ee756b68987 --- /dev/null +++ b/kernel/data-pipeline/scenario/cdc/core/src/test/java/org/apache/shardingsphere/data/pipeline/cdc/core/importer/CDCImporterManagerTest.java @@ -0,0 +1,60 @@ +/* + * 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.shardingsphere.data.pipeline.cdc.core.importer; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +class CDCImporterManagerTest { + + private CDCImporter actual; + + @BeforeEach + void setUp() { + actual = mock(CDCImporter.class); + when(actual.getImporterId()).thenReturn("nish8gx8"); + } + + @Test + void assertPutImporter() { + CDCImporterManager.putImporter(actual); + CDCImporter expected = CDCImporterManager.getImporter(actual.getImporterId()); + assertThat(actual.getImporterId(), is(expected.getImporterId())); + } + + @Test + void assertGetImporter() { + CDCImporterManager.putImporter(actual); + CDCImporter expected = CDCImporterManager.getImporter(actual.getImporterId()); + assertThat(actual, is(expected)); + } + + @Test + void assertRemoveImporter() { + CDCImporterManager.putImporter(actual); + CDCImporterManager.removeImporter(actual.getImporterId()); + assertNull(CDCImporterManager.getImporter(actual.getImporterId())); + } + +}