View Javadoc
1   /*
2    * Licensed to the Hipparchus project under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The Hipparchus project licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      https://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.hipparchus.exception;
18  
19  import org.junit.jupiter.api.Assertions;
20  import org.junit.jupiter.api.Test;
21  
22  import java.util.Locale;
23  
24  /**
25   * Intentionally incomplete localizable, for testing purposes
26   * @author Luc Maisonobe
27   */
28  public class IntentionallyIncompleteLocalizableTest
29  {
30      @Test
31      public void testFixedLocale() {
32          Assertions.assertEquals("message without argument",
33                                  IntentionallyIncompleteLocalizable.MESSAGE_WITHOUT_ARGUMENT.getLocalizedString(Locale.ENGLISH));
34          Assertions.assertEquals("message with one argument {0}",
35                                  IntentionallyIncompleteLocalizable.MESSAGE_WITH_ONE_ARGUMENT.getLocalizedString(Locale.ENGLISH));
36          Assertions.assertEquals("message with two arguments {0}, {1}",
37                                  IntentionallyIncompleteLocalizable.MESSAGE_WITH_TWO_ARGUMENTS.getLocalizedString(Locale.ENGLISH));
38      }
39  
40      @Test
41      public void testUnsupportedLocale() {
42          Assertions.assertEquals("message without argument",
43                                  IntentionallyIncompleteLocalizable.MESSAGE_WITHOUT_ARGUMENT.getLocalizedString(Locale.TRADITIONAL_CHINESE));
44          Assertions.assertEquals("message with one argument {0}",
45                                  IntentionallyIncompleteLocalizable.MESSAGE_WITH_ONE_ARGUMENT.getLocalizedString(Locale.TRADITIONAL_CHINESE));
46          Assertions.assertEquals("message with two arguments {0}, {1}",
47                                  IntentionallyIncompleteLocalizable.MESSAGE_WITH_TWO_ARGUMENTS.getLocalizedString(Locale.TRADITIONAL_CHINESE));
48      }
49  
50      @Test
51      public void testIncompleteTranslations() {
52          Assertions.assertEquals("message sans argument",
53                                  IntentionallyIncompleteLocalizable.MESSAGE_WITHOUT_ARGUMENT.getLocalizedString(Locale.FRENCH));
54          Assertions.assertEquals("message with one argument {0}",
55                                  IntentionallyIncompleteLocalizable.MESSAGE_WITH_ONE_ARGUMENT.getLocalizedString(Locale.FRENCH));
56          Assertions.assertEquals("message with two arguments {0}, {1}",
57                                  IntentionallyIncompleteLocalizable.MESSAGE_WITH_TWO_ARGUMENTS.getLocalizedString(Locale.FRENCH));
58      }
59  
60  }