-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#noissue] Update plugins-it version filter
- Loading branch information
1 parent
56898af
commit 6e35e3f
Showing
6 changed files
with
118 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...lugins-test/src/main/java/com/navercorp/pinpoint/test/plugin/DependencyVersionFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* Copyright 2024 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.test.plugin; | ||
|
||
import com.navercorp.pinpoint.common.util.Filter; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class DependencyVersionFilter implements Filter<String> { | ||
|
||
private static final Pattern RC_PATTERN = Pattern.compile(".*[Rr][Cc]-?\\.?\\d*$"); | ||
private static final Pattern M_PATTERN = Pattern.compile(".*[Mm]-?\\.?\\d*$"); | ||
private static final Pattern ALPHA_PATTERN = Pattern.compile(".*[Aa][Ll][Pp][Hh][Aa]-?\\.?\\d*$"); | ||
private static final Pattern BETA_PATTERN = Pattern.compile(".*[Bb][Ee][Tt][Aa]-?\\.?\\d*$"); | ||
private static final Pattern PATCH_PATTERN = Pattern.compile(".*[Pp][Aa][Tt][Cc][Hh]-?\\.?\\d*$"); | ||
private static final Pattern TEST_PATTERN = Pattern.compile(".*[Tt][Ee][Ss][Tt]-?\\.?\\d*$"); | ||
private static final Pattern MILESTONE_PATTERN = Pattern.compile(".*[Mm][Ii][Ll][Ee][Ss][Tt][Oo][Nn][Ee]-?\\.?\\d*$"); | ||
private static final Pattern PRE_PATTERN = Pattern.compile(".*[Pp][Rr][Ee]-?\\.?\\d*$"); | ||
|
||
private static final Pattern[] PATTERNS = new Pattern[]{RC_PATTERN, M_PATTERN, ALPHA_PATTERN, BETA_PATTERN, PATCH_PATTERN, TEST_PATTERN, MILESTONE_PATTERN, PRE_PATTERN}; | ||
|
||
|
||
@Override | ||
public boolean filter(String value) { | ||
for (Pattern pattern : PATTERNS) { | ||
if (pattern.matcher(value).matches()) { | ||
return FILTERED; | ||
} | ||
} | ||
return NOT_FILTERED; | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
...ns-test/src/test/java/com/navercorp/pinpoint/test/plugin/DependencyVersionFilterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2024 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.test.plugin; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class DependencyVersionFilterTest { | ||
|
||
@Test | ||
public void filter() { | ||
DependencyVersionFilter filter = new DependencyVersionFilter(); | ||
assertFalse(filter.filter("5.0.5.RELEASE")); | ||
assertTrue(filter.filter("5.0.0.RC2")); | ||
assertTrue(filter.filter("5.0.0.RC1")); | ||
assertTrue(filter.filter("5.0.0.M2")); | ||
|
||
assertFalse(filter.filter("4.0.0")); | ||
assertTrue(filter.filter("4.0.0-rc1")); | ||
assertTrue(filter.filter("4.0.0-beta3")); | ||
assertTrue(filter.filter("4.0.0-beta2")); | ||
assertTrue(filter.filter("4.0.0-beta1")); | ||
assertTrue(filter.filter("4.0.0-alpha3")); | ||
|
||
assertTrue(filter.filter("0.3.2-patch11")); | ||
assertTrue(filter.filter("0.3.2-patch1")); | ||
assertTrue(filter.filter("0.3.2-test3")); | ||
|
||
assertTrue(filter.filter("3.0.0-milestone2")); | ||
assertTrue(filter.filter("1.15.0-rc")); | ||
assertTrue(filter.filter("1.14.1-beta")); | ||
assertTrue(filter.filter("1.14.1-beta-2")); | ||
assertTrue(filter.filter("1.4.0-rc.7")); | ||
} | ||
} |