Polish contribution

See gh-31320
This commit is contained in:
Stéphane Nicoll
2023-09-27 08:58:11 +02:00
parent d6a105c151
commit 7a05d23597
4 changed files with 50 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2021 the original author or authors.
* Copyright 2002-2023 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.
@@ -93,7 +93,7 @@ public final class ParamsRequestCondition extends AbstractRequestCondition<Param
if (other.isEmpty()) {
return this;
}
if (isEmpty()) {
else if (isEmpty()) {
return other;
}
Set<ParamExpression> set = new LinkedHashSet<>(this.expressions);

View File

@@ -27,7 +27,9 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for {@link ParamsRequestCondition}.
*
* @author Arjen Poutsma
* @author Stephane Nicoll
*/
public class ParamsRequestConditionTests {
@@ -123,6 +125,24 @@ public class ParamsRequestConditionTests {
assertThat(condition1.compareTo(condition2, request)).as("Negated match should not count as more specific").isEqualTo(0);
}
@Test
public void combineWithOtherEmpty() {
ParamsRequestCondition condition1 = new ParamsRequestCondition("foo=bar");
ParamsRequestCondition condition2 = new ParamsRequestCondition();
ParamsRequestCondition result = condition1.combine(condition2);
assertThat(result).isEqualTo(condition1);
}
@Test
public void combineWithThisEmpty() {
ParamsRequestCondition condition1 = new ParamsRequestCondition();
ParamsRequestCondition condition2 = new ParamsRequestCondition("foo=bar");
ParamsRequestCondition result = condition1.combine(condition2);
assertThat(result).isEqualTo(condition2);
}
@Test
public void combine() {
ParamsRequestCondition condition1 = new ParamsRequestCondition("foo=bar");