|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.elasticsearch.ingest.common; |
| 21 | + |
| 22 | +import org.elasticsearch.test.ESTestCase; |
| 23 | + |
| 24 | +import java.util.Collections; |
| 25 | +import java.util.HashMap; |
| 26 | + |
| 27 | +import static java.util.Collections.emptyMap; |
| 28 | +import static org.hamcrest.Matchers.equalTo; |
| 29 | +import static org.hamcrest.Matchers.is; |
| 30 | +import static org.hamcrest.Matchers.notNullValue; |
| 31 | + |
| 32 | +public class CsvProcessorFactoryTests extends ESTestCase { |
| 33 | + |
| 34 | + public void testProcessorIsCreated() { |
| 35 | + CsvProcessor.Factory factory = new CsvProcessor.Factory(); |
| 36 | + HashMap<String, Object> properties = new HashMap<>(); |
| 37 | + properties.put("field", "field"); |
| 38 | + properties.put("target_fields", Collections.singletonList("target")); |
| 39 | + properties.put("quote", "|"); |
| 40 | + properties.put("separator", "/"); |
| 41 | + properties.put("empty_value", "empty"); |
| 42 | + properties.put("trim", true); |
| 43 | + properties.put("ignore_missing", true); |
| 44 | + CsvProcessor csv = factory.create(null, "csv", properties); |
| 45 | + assertThat(csv, notNullValue()); |
| 46 | + assertThat(csv.field, equalTo("field")); |
| 47 | + assertThat(csv.headers, equalTo(new String[]{"target"})); |
| 48 | + assertThat(csv.quote, equalTo('|')); |
| 49 | + assertThat(csv.separator, equalTo('/')); |
| 50 | + assertThat(csv.emptyValue, equalTo("empty")); |
| 51 | + assertThat(csv.trim, equalTo(true)); |
| 52 | + assertThat(csv.ignoreMissing, equalTo(true)); |
| 53 | + assertThat(properties, is(emptyMap())); |
| 54 | + } |
| 55 | +} |
0 commit comments