rename opertion EQUAL to EQUALS (#457)

* rename opertion EQUAL to EQUALS

* add change log
pull/463/head
lepdou 2 years ago committed by GitHub
parent d0234d8514
commit 1f4007a3f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14,3 +14,4 @@
- [Feature: add feature env examples](https://github.com/Tencent/spring-cloud-tencent/pull/450)
- [Feature: Add disposable metadata transfer support](https://github.com/Tencent/spring-cloud-tencent/pull/430)
- [Bugfix: Removed unused class for circuit-breaker module](https://github.com/Tencent/spring-cloud-tencent/pull/455)
- [Optimize: rename opertion EQUAL to EQUALS](https://github.com/Tencent/spring-cloud-tencent/pull/457)

@ -34,11 +34,11 @@ public enum Operation {
/**
* case sensitive string equals.
*/
EQUAL("EQUAL"),
EQUALS("EQUALS"),
/**
* case sensitive string not equals.
*/
NOT_EQUAL("NOT_EQUAL"),
NOT_EQUALS("NOT_EQUALS"),
/**
* whether element in collection.
*/
@ -73,9 +73,9 @@ public enum Operation {
}
switch (getOperation(rawOperation)) {
case EQUAL:
case EQUALS:
return firstExpectedValue != null && StringUtils.equals(actualValue, firstExpectedValue);
case NOT_EQUAL:
case NOT_EQUALS:
return firstExpectedValue == null || !StringUtils.equals(actualValue, firstExpectedValue);
case BLANK:
return StringUtils.isBlank(actualValue);
@ -103,11 +103,11 @@ public enum Operation {
}
public static Operation getOperation(String operation) {
if (StringUtils.equalsIgnoreCase(operation, EQUAL.value)) {
return EQUAL;
if (StringUtils.equalsIgnoreCase(operation, EQUALS.value)) {
return EQUALS;
}
if (StringUtils.equalsIgnoreCase(operation, NOT_EQUAL.value)) {
return NOT_EQUAL;
if (StringUtils.equalsIgnoreCase(operation, NOT_EQUALS.value)) {
return NOT_EQUALS;
}
if (StringUtils.equalsIgnoreCase(operation, IN.value)) {
return IN;

@ -35,22 +35,22 @@ public class OperationTest {
@Test
public void testEqual() {
Assert.assertTrue(Operation.match(Collections.singletonList("v1"), "v1", Operation.EQUAL.getValue()));
Assert.assertFalse(Operation.match(Collections.singletonList("v1"), "v2", Operation.EQUAL.getValue()));
Assert.assertFalse(Operation.match(Collections.singletonList(""), "v2", Operation.EQUAL.getValue()));
Assert.assertFalse(Operation.match(Collections.singletonList("v1"), "", Operation.EQUAL.getValue()));
Assert.assertFalse(Operation.match(Collections.singletonList("v1"), null, Operation.EQUAL.getValue()));
Assert.assertFalse(Operation.match(Collections.emptyList(), "v1", Operation.EQUAL.getValue()));
Assert.assertTrue(Operation.match(Collections.singletonList("v1"), "v1", Operation.EQUALS.getValue()));
Assert.assertFalse(Operation.match(Collections.singletonList("v1"), "v2", Operation.EQUALS.getValue()));
Assert.assertFalse(Operation.match(Collections.singletonList(""), "v2", Operation.EQUALS.getValue()));
Assert.assertFalse(Operation.match(Collections.singletonList("v1"), "", Operation.EQUALS.getValue()));
Assert.assertFalse(Operation.match(Collections.singletonList("v1"), null, Operation.EQUALS.getValue()));
Assert.assertFalse(Operation.match(Collections.emptyList(), "v1", Operation.EQUALS.getValue()));
}
@Test
public void testNotEqual() {
Assert.assertFalse(Operation.match(Collections.singletonList("v1"), "v1", Operation.NOT_EQUAL.getValue()));
Assert.assertTrue(Operation.match(Collections.singletonList("v1"), "v2", Operation.NOT_EQUAL.getValue()));
Assert.assertTrue(Operation.match(Collections.singletonList(""), "v2", Operation.NOT_EQUAL.getValue()));
Assert.assertTrue(Operation.match(Collections.singletonList("v1"), "", Operation.NOT_EQUAL.getValue()));
Assert.assertTrue(Operation.match(Collections.singletonList("v1"), null, Operation.NOT_EQUAL.getValue()));
Assert.assertTrue(Operation.match(Collections.emptyList(), "v1", Operation.NOT_EQUAL.getValue()));
Assert.assertFalse(Operation.match(Collections.singletonList("v1"), "v1", Operation.NOT_EQUALS.getValue()));
Assert.assertTrue(Operation.match(Collections.singletonList("v1"), "v2", Operation.NOT_EQUALS.getValue()));
Assert.assertTrue(Operation.match(Collections.singletonList(""), "v2", Operation.NOT_EQUALS.getValue()));
Assert.assertTrue(Operation.match(Collections.singletonList("v1"), "", Operation.NOT_EQUALS.getValue()));
Assert.assertTrue(Operation.match(Collections.singletonList("v1"), null, Operation.NOT_EQUALS.getValue()));
Assert.assertTrue(Operation.match(Collections.emptyList(), "v1", Operation.NOT_EQUALS.getValue()));
}
@Test

@ -44,7 +44,7 @@ public class RuleStainingExecutorTest {
public void testMatchCondition() {
Condition condition1 = new Condition();
condition1.setKey("${http.header.uid}");
condition1.setOperation(Operation.EQUAL.toString());
condition1.setOperation(Operation.EQUALS.toString());
condition1.setValues(Collections.singletonList("1000"));
Condition condition2 = new Condition();
@ -81,7 +81,7 @@ public class RuleStainingExecutorTest {
public void testNotMatchCondition() {
Condition condition1 = new Condition();
condition1.setKey("${http.header.uid}");
condition1.setOperation(Operation.EQUAL.toString());
condition1.setOperation(Operation.EQUALS.toString());
condition1.setValues(Collections.singletonList("1000"));
Condition condition2 = new Condition();
@ -117,7 +117,7 @@ public class RuleStainingExecutorTest {
public void testMatchTwoRulesAndNotMatchOneRule() {
Condition condition1 = new Condition();
condition1.setKey("${http.header.uid}");
condition1.setOperation(Operation.EQUAL.toString());
condition1.setOperation(Operation.EQUALS.toString());
condition1.setValues(Collections.singletonList("1000"));
Condition condition2 = new Condition();

Loading…
Cancel
Save