View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   https://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.apache.commons.csv;
21  
22  import static org.junit.jupiter.api.Assertions.assertEquals;
23  
24  import org.junit.jupiter.api.Test;
25  
26  /**
27   * Tests {@link CSVFormat.Predefined}.
28   */
29  class CSVFormatPredefinedTest {
30  
31      private void test(final CSVFormat format, final String enumName) {
32          assertEquals(format, CSVFormat.Predefined.valueOf(enumName).getFormat());
33          assertEquals(format, CSVFormat.valueOf(enumName));
34      }
35  
36      @Test
37      void testDefault() {
38          test(CSVFormat.DEFAULT, "Default");
39      }
40  
41      @Test
42      void testExcel() {
43          test(CSVFormat.EXCEL, "Excel");
44      }
45  
46      @Test
47      void testMongoDbCsv() {
48          test(CSVFormat.MONGODB_CSV, "MongoDBCsv");
49      }
50  
51      @Test
52      void testMongoDbTsv() {
53          test(CSVFormat.MONGODB_TSV, "MongoDBTsv");
54      }
55  
56      @Test
57      void testMySQL() {
58          test(CSVFormat.MYSQL, "MySQL");
59      }
60  
61      @Test
62      void testOracle() {
63          test(CSVFormat.ORACLE, "Oracle");
64      }
65  
66      @Test
67      void testPostgreSqlCsv() {
68          test(CSVFormat.POSTGRESQL_CSV, "PostgreSQLCsv");
69      }
70  
71      @Test
72      void testPostgreSqlText() {
73          test(CSVFormat.POSTGRESQL_TEXT, "PostgreSQLText");
74      }
75  
76      @Test
77      void testRFC4180() {
78          test(CSVFormat.RFC4180, "RFC4180");
79      }
80  
81      @Test
82      void testTDF() {
83          test(CSVFormat.TDF, "TDF");
84      }
85  }