Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ofir76 committed Apr 12, 2018
1 parent aeb0edc commit 2cb85cb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

import static org.junit.Assert.assertEquals;

/**
* @author Bartosz Polnik
*/
public class CatRecoveryBuilderTest {
@Test
public void shouldSetApplicationJsonHeader() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ public class FieldsStatsTest {
public void testBasicUriGeneration() {
FieldStats fieldStats = new FieldStats.Builder(FIELDS).setIndex(INDEX).build();
assertEquals("POST", fieldStats.getRestMethodName());
assertEquals(INDEX + "/_field_stats", fieldStats.getURI(ElasticsearchVersion.V55));
assertEquals(INDEX + "/_field_stats", fieldStats.getURI(ElasticsearchVersion.UNKNOWN));
assertEquals("{\"fields\":[\"" + TEST_FIELD + "\"]}", fieldStats.getData(new Gson()));
}

@Test
public void testBasicUriGenerationNoIndex() {
FieldStats fieldStats = new FieldStats.Builder(FIELDS).build();
assertEquals("POST", fieldStats.getRestMethodName());
assertEquals("_field_stats", fieldStats.getURI(ElasticsearchVersion.V55));
assertEquals("_field_stats", fieldStats.getURI(ElasticsearchVersion.UNKNOWN));
assertEquals("{\"fields\":[\"" + TEST_FIELD + "\"]}", fieldStats.getData(new Gson()));
}

@Test
public void testBasicUriGenerationWithLevel() {
FieldStats fieldStats = new FieldStats.Builder(FIELDS).setIndex(INDEX).setLevel("indices").build();
assertEquals("POST", fieldStats.getRestMethodName());
assertEquals(INDEX + "/_field_stats?level=indices", fieldStats.getURI(ElasticsearchVersion.V55));
assertEquals(INDEX + "/_field_stats?level=indices", fieldStats.getURI(ElasticsearchVersion.UNKNOWN));
assertEquals("{\"fields\":[\"" + TEST_FIELD + "\"]}", fieldStats.getData(new Gson()));
}
}
14 changes: 7 additions & 7 deletions jest/src/test/java/io/searchbox/core/CatIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,19 @@ public void shouldDisplayRecoveryForSingleResult() throws IOException, JSONExcep

CatResult result = client.execute(new Cat.RecoveryBuilder().addIndex(INDEX).setParameter("h", "index,stage").build());

ArrayList<String[]> expectedsPlainText = new ArrayList<>();
ArrayList<String> recovertResponsePerShared = new ArrayList<>();
ArrayList<String[]> expectedPlainText = new ArrayList<>();
ArrayList<String> recoveryResponsePerShared = new ArrayList<>();

String expectedLine = "{\"index\":\"catintegrationindex\",\"stage\":\"done\"}";
expectedsPlainText.add(new String[]{"index", "stage"});
expectedPlainText.add(new String[]{"index", "stage"});

IntStream.range(0, getNumShards(INDEX).totalNumShards).forEach(value -> {
expectedsPlainText.add(new String[]{INDEX, "done"});
recovertResponsePerShared.add(expectedLine);
expectedPlainText.add(new String[]{INDEX, "done"});
recoveryResponsePerShared.add(expectedLine);
});
assertArrayEquals(expectedsPlainText.toArray(), result.getPlainText());
assertArrayEquals(expectedPlainText.toArray(), result.getPlainText());

String expectedSourceAsString = "[" + String.join(",", recovertResponsePerShared) + "]";
String expectedSourceAsString = "[" + String.join(",", recoveryResponsePerShared) + "]";

JSONAssert.assertEquals(expectedSourceAsString, result.getSourceAsString(), false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
@ESIntegTestCase.ClusterScope(scope = ESIntegTestCase.Scope.SUITE, numDataNodes = 1)
public class FieldStatsIntegrationTest extends AbstractIntegrationTest {

static final String INDEX = "twitter";
static final String TYPE = "tweet";
static final String TEST_FIELD = "test_name";
static final List FIELDS = Collections.singletonList(TEST_FIELD);
private static final String INDEX = "twitter";
private static final String TYPE = "tweet";
private static final String TEST_FIELD = "test_name";
private static final List FIELDS = Collections.singletonList(TEST_FIELD);

@Test
public void testFieldStats() throws IOException {
Expand Down

0 comments on commit 2cb85cb

Please sign in to comment.