[TEST] Fix ElasticsearchExceptionTests

Some test failures can happen in ElasticsearchExceptionTests, this commit fixes them.
This commit is contained in:
Tanguy Leroux 2017-01-26 16:30:10 +01:00
parent be96278c95
commit 1fa2734566
1 changed files with 4 additions and 7 deletions

View File

@ -721,7 +721,7 @@ public class ElasticsearchExceptionTests extends ESTestCase {
if (rarely()) { if (rarely()) {
// Empty or null metadata are not printed out by the toXContent method // Empty or null metadata are not printed out by the toXContent method
actualException.addMetadata("ignored", randomBoolean() ? emptyList() : null); actualException.addMetadata("es.ignored", randomBoolean() ? emptyList() : null);
} }
} }
@ -729,12 +729,9 @@ public class ElasticsearchExceptionTests extends ESTestCase {
int nbResources = randomIntBetween(1, 5); int nbResources = randomIntBetween(1, 5);
for (int i = 0; i < nbResources; i++) { for (int i = 0; i < nbResources; i++) {
String resourceType = "type_" + i; String resourceType = "type_" + i;
String[] resourceIds = null; String[] resourceIds = new String[randomIntBetween(1, 3)];
if (frequently()) { for (int j = 0; j < resourceIds.length; j++) {
resourceIds = new String[randomIntBetween(1, 3)]; resourceIds[j] = frequently() ? randomAsciiOfLength(5) : "";
for (int j = 0; j < resourceIds.length; j++) {
resourceIds[j] = frequently() ? randomAsciiOfLength(5) : "";
}
} }
actualException.setResources(resourceType, resourceIds); actualException.setResources(resourceType, resourceIds);
expected.setResources(resourceType, resourceIds); expected.setResources(resourceType, resourceIds);