package org.ovirt.engine.core.common;

import static org.hamcrest.core.IsCollectionContaining.hasItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;

import java.util.Map;
import java.util.Set;

import org.junit.Test;
import org.ovirt.engine.core.common.config.ConfigValues;
import org.ovirt.engine.core.common.queries.ConfigurationValues;
import org.ovirt.engine.core.compat.WindowsJavaTimezoneMapping;

public class TimeZoneTypeTest {

    private static final TimeZoneType windows = TimeZoneType.WINDOWS_TIMEZONE;
    private static final TimeZoneType general = TimeZoneType.GENERAL_TIMEZONE;

    @Test
    public void testWindowsTimeZones() {
        Map<String, String> map = windows.getTimeZoneList();
        assertNotNull(map);
        assertEquals(map.get("GMT Standard Time"), "(GMT) GMT Standard Time");
    }

    @Test
    public void testGeneralTimeZones() {
        Map<String, String> map = general.getTimeZoneList();
        assertNotNull(map);
        assertFalse(map.get("Asia/Riyadh78") != null);
        assertEquals(map.get("Asia/Jerusalem"), "(GMT+02:00) Israel Standard Time");
    }

    @Test
    public void testDefaultConfigValues() {
        assertEquals(windows.getDefaultTimeZoneConfigKey(), ConfigValues.DefaultWindowsTimeZone);
        assertEquals(general.getDefaultTimeZoneConfigKey(), ConfigValues.DefaultGeneralTimeZone);
    }

    @Test
    public void testDefaultConfigurationValues() {
        assertEquals(windows.getDefaultTimeZoneConfigurationKey(), ConfigurationValues.DefaultWindowsTimeZone);
        assertEquals(general.getDefaultTimeZoneConfigurationKey(), ConfigurationValues.DefaultGeneralTimeZone);
    }

    @Test
    public void testUltimateFallbackValues() {
        assertEquals(windows.getUltimateFallback(), "GMT Standard Time");
        assertEquals(general.getUltimateFallback(), "Etc/GMT");
    }

    @Test
    public void testWindowsTimeZonesKeys() {
        final Set<String> windowsTimeZoneKeys = WindowsJavaTimezoneMapping.getKeys();
        for (String timeZoneKey : TimeZoneType.WINDOWS_TIMEZONE.getTimeZoneList().keySet()) {
            assertThat(windowsTimeZoneKeys, hasItem(timeZoneKey));
        }
    }
}

@@ -178,21 +178,23 @@
 t.assert
-False
+NotNull
 ;%0Aimport
@@ -217,35 +217,32 @@
 t.Assert.assertN
-otN
 ull;%0Aimport stat
@@ -874,32 +874,59 @@
    assertEquals(
+%22(GMT) GMT Standard Time%22, 
 map.get(%22GMT Sta
@@ -941,35 +941,8 @@
 me%22)
-, %22(GMT) GMT Standard Time%22
 );%0A 
@@ -1105,13 +1105,12 @@
 sert
-False
+Null
 (map
@@ -1134,16 +1134,8 @@
 78%22)
- != null
 );%0A 
@@ -1158,35 +1158,8 @@
 als(
-map.get(%22Asia/Jerusalem%22), 
 %22(GM
@@ -1184,24 +1184,51 @@
 andard Time%22
+, map.get(%22Asia/Jerusalem%22)
 );%0A    %7D%0A%0A  
@@ -1292,32 +1292,69 @@
    assertEquals(
+ConfigValues.DefaultWindowsTimeZone, 
 windows.getDefau
@@ -1366,34 +1366,56 @@
 eZoneConfigKey()
-, 
+);%0A        assertEquals(
 ConfigValues.Def
@@ -1414,39 +1414,39 @@
 lues.Default
-Windows
+General
 TimeZone
 );%0A        a
@@ -1437,32 +1437,10 @@
 Zone
-);%0A        assertEquals(
+, 
 gene
@@ -1476,45 +1476,8 @@
 ey()
-, ConfigValues.DefaultGeneralTimeZone
 );%0A 
@@ -1556,32 +1556,76 @@
    assertEquals(
+ConfigurationValues.DefaultWindowsTimeZone, 
 windows.getDefau
@@ -1644,34 +1644,56 @@
 nfigurationKey()
-, 
+);%0A        assertEquals(
 ConfigurationVal
@@ -1703,31 +1703,31 @@
 .Default
-Windows
+General
 TimeZone
 );%0A     
@@ -1722,32 +1722,10 @@
 Zone
-);%0A        assertEquals(
+, 
 gene
@@ -1768,52 +1768,8 @@
 ey()
-, ConfigurationValues.DefaultGeneralTimeZone
 );%0A 
@@ -1852,16 +1852,37 @@
 tEquals(
+%22GMT Standard Time%22, 
 windows.
@@ -1906,29 +1906,8 @@
 ck()
-, %22GMT Standard Time%22
 );%0A 
@@ -1926,16 +1926,27 @@
 tEquals(
+%22Etc/GMT%22, 
 general.
@@ -1970,19 +1970,8 @@
 ck()
-, %22Etc/GMT%22
 );%0A 

Fix assertions in TimeZoneTypeTest