Skip to content

Commit

Permalink
Fix indexMappingIsEqual
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Crawford <[email protected]>
  • Loading branch information
stephen-crawford committed Apr 24, 2023
1 parent d40f98b commit cf6788d
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
*/
package org.opensearch.test.framework.matcher;

import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
import java.util.HashMap;
import java.util.Map;

import org.hamcrest.Description;
Expand All @@ -19,8 +17,6 @@
import org.opensearch.action.admin.indices.mapping.get.GetMappingsRequest;
import org.opensearch.action.admin.indices.mapping.get.GetMappingsResponse;
import org.opensearch.client.Client;
import org.opensearch.cluster.metadata.MappingMetadata;
import org.opensearch.common.settings.Settings;
import org.opensearch.index.IndexNotFoundException;
import org.opensearch.test.framework.cluster.LocalCluster;

Expand All @@ -46,12 +42,7 @@ protected boolean matchesSafely(LocalCluster cluster, Description mismatchDescri
GetMappingsResponse response = client.admin().indices()
.getMappings(new GetMappingsRequest().indices(expectedIndexName)).actionGet();

Map<String, MappingMetadata> actualMappings = new HashMap<>();
for (ObjectObjectCursor<String, MappingMetadata> cursor : response.getMappings()) {
actualMappings.put(cursor.key, cursor.value);
}

Map<String, Object> actualIndexMapping = actualMappings.get(expectedIndexName).sourceAsMap();
Map<String, Object> actualIndexMapping = response.getMappings().get(expectedIndexName).sourceAsMap();

if (!expectedMapping.equals(actualIndexMapping)) {
mismatchDescription.appendText("Actual mapping ").appendValue(actualIndexMapping).appendText(" does not match expected");
Expand Down

0 comments on commit cf6788d

Please sign in to comment.