package io.searchbox.indices;

import io.searchbox.action.Action;
import org.junit.Test;

import java.net.URLDecoder;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;

public class StatsTest {

    @Test
    public void testBasicUriGeneration() {
        Stats stats = new Stats.Builder().addIndex("twitter").build();

        assertEquals("GET", stats.getRestMethodName());
        assertEquals("twitter/_stats", stats.getURI());
    }

    @Test
    public void equalsReturnsTrueForSameIndex() {
        Stats stats1 = new Stats.Builder().addIndex("twitter").build();
        Stats stats1Duplicate = new Stats.Builder().addIndex("twitter").build();

        assertEquals(stats1, stats1Duplicate);
    }

    @Test
    public void equalsReturnsFalseForDifferentIndex() {
        Stats stats1 = new Stats.Builder().addIndex("twitter").build();
        Stats stats2 = new Stats.Builder().addIndex("myspace").build();

        assertNotEquals(stats1, stats2);
    }

    @Test
    public void testUriGenerationWithStatsFields() throws Exception {
        Action action = new Stats.Builder()
                .flush(true)
                .indexing(true)
                .search(true, "group1", "group2")
                .build();
        assertEquals("_all/_stats/flush,indexing,search?groups=group1,group2", URLDecoder.decode(action.getURI()));
    }

}
@@ -1387,9 +1387,347 @@
 %0A    %7D%0A%0A
+    @Test%0A    public void testUriGenerationWhenRemovingStatsFields() throws Exception %7B%0A        Action action = new Stats.Builder()%0A                .flush(true)%0A                .indexing(true)%0A                .indexing(false)%0A                .build();%0A        assertEquals(%22_all/_stats/flush%22, URLDecoder.decode(action.getURI()));%0A    %7D%0A%0A
 %7D

Add test to removeCleanApiParameter method