/**
 * Copyright (c) 2014,2018 Contributors to the Eclipse Foundation
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package org.eclipse.smarthome.config.core.internal.i18n;

import static org.junit.Assert.*;

import java.net.URI;
import java.util.Locale;

import org.eclipse.smarthome.config.core.ParameterOption;
import org.junit.Before;
import org.junit.Test;

/**
 * Tests for {@link I18nConfigOptionsProvider}
 *
 * @author Simon Kaufmann - initial contribution and API
 *
 */
public class I18nConfigOptionsProviderTest {

    private I18nConfigOptionsProvider provider;
    private ParameterOption expectedLangEN = new ParameterOption("en", "English");
    private ParameterOption expectedLangFR = new ParameterOption("en", "anglais");
    private ParameterOption expectedCntryEN = new ParameterOption("US", "United States");
    private ParameterOption expectedCntryFR = new ParameterOption("US", "Etats-Unis");
    private URI uriI18N;

    @Before
    public void setup() throws Exception {
        provider = new I18nConfigOptionsProvider();
        uriI18N = new URI("system:i18n");
    }

    @Test
    public void testLanguage() throws Exception {
        assertTrue(provider.getParameterOptions(uriI18N, "language", Locale.US).contains(expectedLangEN));
        assertTrue(provider.getParameterOptions(uriI18N, "language", Locale.FRENCH).contains(expectedLangFR));
        assertFalse(provider.getParameterOptions(uriI18N, "language", null).isEmpty());
    }

    @Test
    public void testRegion() throws Exception {
        assertTrue(provider.getParameterOptions(uriI18N, "region", Locale.US).contains(expectedCntryEN));
        assertTrue(provider.getParameterOptions(uriI18N, "region", Locale.FRENCH).contains(expectedCntryFR));
        assertFalse(provider.getParameterOptions(uriI18N, "region", null).isEmpty());
    }

    @Test
    public void testUnknownParameter() throws Exception {
        assertNull(provider.getParameterOptions(uriI18N, "unknown", Locale.US));
    }

}

@@ -465,16 +465,59 @@
 .i18n;%0A%0A
+import static org.hamcrest.CoreMatchers.*;%0A
 import s
@@ -542,16 +542,16 @@
 sert.*;%0A
-
 %0Aimport 
@@ -913,32 +913,38 @@
 er;%0A    private 
+final 
 ParameterOption 
@@ -1002,32 +1002,38 @@
 %22);%0A    private 
+final 
 ParameterOption 
@@ -1091,32 +1091,38 @@
 %22);%0A    private 
+final 
 ParameterOption 
@@ -1195,16 +1195,22 @@
 private 
+final 
 Paramete
@@ -1232,16 +1232,21 @@
 dCntryFR
+Java8
  = new P
@@ -1277,24 +1277,122 @@
 ats-Unis%22);%0A
+    private final ParameterOption expectedCntryFRJava9 = new ParameterOption(%22US%22, %22%C3%89tats-Unis%22);%0A
     private 
@@ -2105,35 +2105,35 @@
 %0A        assertT
-rue
+hat
 (provider.getPar
@@ -2175,33 +2175,86 @@
 cale.FRENCH)
-.contains
+,%0A                anyOf(hasItem(expectedCntryFRJava8), hasItem
 (expectedCnt
@@ -2257,16 +2257,22 @@
 dCntryFR
+Java9)
 ));%0A    

improve I18nConfigOptionsProvider tests for Java 9 (#6203)