Skip to content

Commit

Permalink
Fix typo in HttpHeadersAssert#doesNotContainHeaders
Browse files Browse the repository at this point in the history
This commit deprecates the existing doesNotContainsHeaders in favor of a
newly introduced method that does not have the typo.

Closes gh-34263
  • Loading branch information
snicoll committed Jan 15, 2025
1 parent e08a7ec commit d280358
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -78,8 +78,21 @@ public HttpHeadersAssert doesNotContainHeader(String name) {
* Verify that the actual HTTP headers do not contain any of the headers
* with the given {@code names}.
* @param names the names of HTTP headers that should not be present
* @since 6.2.2
* @see #doesNotContainKeys
*/
public HttpHeadersAssert doesNotContainHeaders(String... names) {
return doesNotContainKeys(names);
}

/**
* Verify that the actual HTTP headers do not contain any of the headers
* with the given {@code names}.
* @param names the names of HTTP headers that should not be present
* @see #doesNotContainKeys
* @deprecated in favor of {@link #doesNotContainHeaders(String...)}
*/
@Deprecated(since = "6.2.2", forRemoval = true)
public HttpHeadersAssert doesNotContainsHeaders(String... names) {
return doesNotContainKeys(names);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2024 the original author or authors.
* Copyright 2002-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -78,11 +78,29 @@ void doesNotContainHeaderWithNamePresent() {
@Test
void doesNotContainHeaders() {
assertThat(Map.of("first", "1", "third", "3"))
.doesNotContainsHeaders("second", "fourth");
.doesNotContainHeaders("second", "fourth");
}

@Test
void doesNotContainHeadersWithSeveralNamesPresent() {
Map<String, String> map = Map.of("first", "1", "second", "2", "third", "3");
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(map).doesNotContainHeaders("first", "another-wrong-name", "second"))
.withMessageContainingAll("HTTP headers", "first", "second");
}

@Test
@Deprecated(forRemoval = true)
@SuppressWarnings("removal")
void doesNotContainHeadersWithDeprecatedMethod() {
assertThat(Map.of("first", "1", "third", "3"))
.doesNotContainsHeaders("second", "fourth");
}

@Test
@Deprecated(forRemoval = true)
@SuppressWarnings("removal")
void doesNotContainHeadersWithSeveralNamesPresentWithDeprecatedMethod() {
Map<String, String> map = Map.of("first", "1", "second", "2", "third", "3");
assertThatExceptionOfType(AssertionError.class)
.isThrownBy(() -> assertThat(map).doesNotContainsHeaders("first", "another-wrong-name", "second"))
Expand Down

0 comments on commit d280358

Please sign in to comment.