/*
 * CODENVY CONFIDENTIAL
 * __________________
 *
 *  [2012] - [2014] Codenvy, S.A.
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Codenvy S.A. and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Codenvy S.A.
 * and its suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Codenvy S.A..
 */
package com.codenvy.analytics.persistent;

import com.codenvy.analytics.BaseTest;
import com.codenvy.analytics.services.configuration.XmlConfigurationManager;

import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.List;

import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
import static org.testng.AssertJUnit.assertEquals;

/** @author <a href="mailto:dnochevnov@codenvy.com">Dmytro Nochevnov</a> */
public class TestCollectionConfiguration extends BaseTest {

    private static final String FILE          = BASE_DIR + "/resource";
    private static final String CONFIGURATION =
            "<collections>" +
            "   <collection name=\"users_profiles_list\">" +
            "      <indexes>" +
            "         <index name=\"index name\" fixed=\"true\">" +
            "            <field>user_first_name</field>" +
            "            <field>user_last_name</field>" +
            "            <field>user_company</field>" +
            "         </index>" +
            "      </indexes>" +
            "   </collection>" +
            "</collections>";

    private XmlConfigurationManager configurationManager;

    @BeforeClass
    public void prepare() throws Exception {
        try (BufferedWriter out = new BufferedWriter(new FileWriter(FILE))) {
            out.write(CONFIGURATION);
        }

        configurationManager = new XmlConfigurationManager();
    }

    @Test
    public void testParsingConfiguration() throws Exception {
        CollectionsConfiguration configuration =
                configurationManager.loadConfiguration(CollectionsConfiguration.class, FILE);

        assertNotNull(configuration);
        assertEquals(1, configuration.getCollections().size());

        CollectionConfiguration collectionConfiguration = configuration.getCollections().get(0);
        assertEquals("users_profiles_list", collectionConfiguration.getName());

        IndexesConfiguration indexesConfiguration = collectionConfiguration.getIndexes();

        List<IndexConfiguration> indexes = indexesConfiguration.getIndexes();
        assertEquals(1, indexes.size());

        IndexConfiguration index = indexes.get(0);
        assertEquals("index name", index.getName());
        assertTrue(index.isFixed());

        List<FieldConfiguration> fields = index.getFields();
        assertEquals(3, fields.size());
        assertEquals("user_first_name", fields.get(0).getField());
        assertEquals("user_last_name", fields.get(1).getField());
        assertEquals("user_company", fields.get(2).getField());
    }
}

@@ -990,65 +990,9 @@
 ert.
-assertNotNull;%0Aimport static org.testng.Assert.assertTrue
+*
 ;%0Aim
@@ -1633,24 +1633,38 @@
       %3Cfield
+ desc=%5C%22true%5C%22
 %3Euser_compan
@@ -2248,24 +2248,8 @@
 on =
-%0A               
  con
@@ -3118,32 +3118,83 @@
 0).getField());%0A
+        assertFalse(fields.get(0).isDescending());%0A
         assertEq
@@ -3235,32 +3235,83 @@
 1).getField());%0A
+        assertFalse(fields.get(1).isDescending());%0A
         assertEq
@@ -3354,20 +3354,70 @@
 etField());%0A
+        assertTrue(fields.get(2).isDescending());%0A
     %7D%0A%7D%0A

Fix performance issue with loading users' events