|
| 1 | +/* |
| 2 | + * Copyright © 2024 Cask Data, Inc. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not |
| 5 | + * use this file except in compliance with the License. You may obtain a copy of |
| 6 | + * the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | + * License for the specific language governing permissions and limitations under |
| 14 | + * the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package io.cdap.plugin; |
| 18 | + |
| 19 | + |
| 20 | +import io.cdap.cdap.api.data.schema.Schema; |
| 21 | +import io.cdap.cdap.etl.api.validation.ValidationException; |
| 22 | +import io.cdap.cdap.etl.mock.common.MockPipelineConfigurer; |
| 23 | +import io.cdap.plugin.format.MultiTableConf; |
| 24 | + |
| 25 | +import org.junit.Assert; |
| 26 | +import org.junit.Before; |
| 27 | +import org.junit.Test; |
| 28 | + |
| 29 | +/** |
| 30 | + * Tests for MultiTableDBSource |
| 31 | + */ |
| 32 | +public class MultiTableDBSourceTest { |
| 33 | + |
| 34 | + MockPipelineConfigurer mockPipelineConfigurer = new MockPipelineConfigurer(Schema.of(Schema.Type.STRING)); |
| 35 | + MultiTableDBSource multiTableDBSource; |
| 36 | + String referenceNameWithSpace = "Hello MultiTable"; |
| 37 | + |
| 38 | + @Before |
| 39 | + public void setUp() { |
| 40 | + multiTableDBSource = new MultiTableDBSource(new MultiTableConf(referenceNameWithSpace)); |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Plugin should not allow space in reference name for MultiTableDBSource |
| 45 | + */ |
| 46 | + @Test |
| 47 | + public void testMultiTableReferenceNameWithSpace() { |
| 48 | + try { |
| 49 | + multiTableDBSource.configurePipeline(mockPipelineConfigurer); |
| 50 | + } catch (ValidationException e) { |
| 51 | + // expected |
| 52 | + } |
| 53 | + Assert.assertEquals(1, mockPipelineConfigurer.getStageConfigurer().getFailureCollector().getValidationFailures() |
| 54 | + .size()); |
| 55 | + } |
| 56 | +} |
0 commit comments