Ver código fonte

Remove ImmutableOpenMap test utils (#87305)

These utilities were the equivalent hamcrest matchers to those for Map,
but are now unused.

relates #86239
Ryan Ernst 3 anos atrás
pai
commit
00689b06d9

+ 0 - 26
test/framework/src/main/java/org/elasticsearch/test/hamcrest/CollectionAssertions.java

@@ -1,26 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-package org.elasticsearch.test.hamcrest;
-
-import org.elasticsearch.common.collect.ImmutableOpenMap;
-import org.hamcrest.Matcher;
-
-/**
- * Assertions for easier handling of our custom collections,
- * for example ImmutableOpenMap
- */
-public class CollectionAssertions {
-
-    public static Matcher<ImmutableOpenMap<String, ?>> hasKey(final String key) {
-        return new CollectionMatchers.ImmutableOpenMapHasKeyMatcher(key);
-    }
-
-    public static Matcher<ImmutableOpenMap<String, ?>> hasAllKeys(final String... keys) {
-        return new CollectionMatchers.ImmutableOpenMapHasAllKeysMatcher(keys);
-    }
-}

+ 0 - 91
test/framework/src/main/java/org/elasticsearch/test/hamcrest/CollectionMatchers.java

@@ -1,91 +0,0 @@
-/*
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
- * or more contributor license agreements. Licensed under the Elastic License
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
- * in compliance with, at your election, the Elastic License 2.0 or the Server
- * Side Public License, v 1.
- */
-package org.elasticsearch.test.hamcrest;
-
-import org.elasticsearch.common.collect.ImmutableOpenMap;
-import org.hamcrest.Description;
-import org.hamcrest.TypeSafeMatcher;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Matchers for easier handling of our custom collections,
- * for example ImmutableOpenMap
- */
-public class CollectionMatchers {
-
-    public static class ImmutableOpenMapHasKeyMatcher extends TypeSafeMatcher<ImmutableOpenMap<String, ?>> {
-
-        private final String key;
-
-        public ImmutableOpenMapHasKeyMatcher(String key) {
-            this.key = key;
-        }
-
-        @Override
-        protected boolean matchesSafely(ImmutableOpenMap<String, ?> item) {
-            return item.containsKey(key);
-        }
-
-        @Override
-        public void describeMismatchSafely(final ImmutableOpenMap<String, ?> map, final Description mismatchDescription) {
-            if (map.size() == 0) {
-                mismatchDescription.appendText("was empty");
-            } else {
-                mismatchDescription.appendText(" was ").appendValue(map);
-            }
-        }
-
-        @Override
-        public void describeTo(Description description) {
-            description.appendText("ImmutableOpenMap should contain key " + key);
-        }
-    }
-
-    public static class ImmutableOpenMapHasAllKeysMatcher extends TypeSafeMatcher<ImmutableOpenMap<String, ?>> {
-
-        private final List<String> keys;
-        private String missingKey;
-
-        public ImmutableOpenMapHasAllKeysMatcher(final String... keys) {
-            this.keys = Arrays.asList(keys);
-        }
-
-        @Override
-        protected boolean matchesSafely(ImmutableOpenMap<String, ?> item) {
-            for (String key : keys) {
-                if (item.containsKey(key) == false) {
-                    missingKey = key;
-                    return false;
-                }
-            }
-
-            return true;
-        }
-
-        @Override
-        public void describeMismatchSafely(final ImmutableOpenMap<String, ?> map, final Description mismatchDescription) {
-            if (map.size() == 0) {
-                mismatchDescription.appendText("was empty");
-            } else {
-                mismatchDescription.appendText("was ").appendValue(map.keySet());
-            }
-        }
-
-        @Override
-        public void describeTo(Description description) {
-            description.appendText("ImmutableOpenMap should contain all keys ")
-                .appendValue(keys)
-                .appendText(", but key [")
-                .appendValue(missingKey)
-                .appendText("] is missing");
-        }
-    }
-
-}