-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b00684
commit 6c39506
Showing
3 changed files
with
78 additions
and
23 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
68 changes: 68 additions & 0 deletions
68
jacodb-taint-configuration/src/test/kotlin/org/jacodb/configuration/UtilTest.kt
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,68 @@ | ||
/* | ||
* Copyright 2022 UnitTestBot contributors (utbot.org) | ||
* <p> | ||
* 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 | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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 org.jacodb.configuration | ||
|
||
import org.junit.jupiter.api.Test | ||
|
||
class UtilTest { | ||
@Test | ||
fun testExtractAlternatives() { | ||
val pkgMatcher = NamePatternMatcher("(org\\.jacodb)|.*\\.org\\.company") | ||
val classNameMatcher = NamePatternMatcher(".*Re(quest|sponse)|ClassName|.*|Class(A)*") | ||
|
||
val classMatcher = ClassMatcher(pkgMatcher, classNameMatcher) | ||
val alternatives = classMatcher.extractAlternatives() | ||
|
||
require(alternatives.size == 10) | ||
|
||
val extractPackageMatcher = alternatives.count { | ||
it.pkg is NameExactMatcher && (it.pkg as NameExactMatcher).name == "org.jacodb" | ||
} | ||
require(extractPackageMatcher == 5) | ||
|
||
val patternPackageMatcher = alternatives.count { | ||
it.pkg is NamePatternMatcher && (it.pkg as NamePatternMatcher).pattern == ".*\\.org\\.company" | ||
} | ||
require(patternPackageMatcher == 5) | ||
|
||
val requestClassMatcher = alternatives.count { | ||
it.classNameMatcher is NamePatternMatcher && (it.classNameMatcher as NamePatternMatcher).pattern == ".*Request" | ||
} | ||
require(requestClassMatcher == 2) | ||
|
||
val responseClassMatcher = alternatives.count { | ||
it.classNameMatcher is NamePatternMatcher && (it.classNameMatcher as NamePatternMatcher).pattern == ".*Response" | ||
} | ||
require(responseClassMatcher == 2) | ||
|
||
val classNameMatcherValue = alternatives.count { | ||
it.classNameMatcher is NameExactMatcher && (it.classNameMatcher as NameExactMatcher).name == "ClassName" | ||
} | ||
require(classNameMatcherValue == 2) | ||
|
||
val allClassNamesMatcher = alternatives.count { | ||
it.classNameMatcher is NamePatternMatcher && (it.classNameMatcher as NamePatternMatcher).pattern == ".*" | ||
} | ||
require(allClassNamesMatcher == 2) | ||
|
||
val classAPattern = alternatives.count { | ||
it.classNameMatcher is NamePatternMatcher && (it.classNameMatcher as NamePatternMatcher).pattern == "Class(A)*" | ||
} | ||
require(classAPattern == 2) | ||
} | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
jacodb-taint-configuration/src/test/resources/testJsonConfig.json
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 @@ | ||
[] |