-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add new unit test
- Loading branch information
Showing
7 changed files
with
112 additions
and
40 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package io.github.ajclopez.mss; | ||
|
||
import io.github.ajclopez.mss.model.CastType; | ||
import io.github.ajclopez.mss.model.SearchCriteria; | ||
import io.github.ajclopez.mss.parser.QueryParser; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
public class QueryParserTest { | ||
|
||
|
||
@Test | ||
public void whenQueryNotMatchThenReturnNull() { | ||
|
||
SearchCriteria result = QueryParser.criteriaParser("", null); | ||
Assert.assertEquals(null, result); | ||
} | ||
|
||
@Test | ||
public void whenRegexNotMatchWithPatternThenReturnPatternWithValue() { | ||
|
||
String regex = "^58"; | ||
Object result = QueryParser.parseValue(regex, CastType.PATTERN); | ||
Assert.assertEquals(Pattern.compile(regex).toString(), result.toString()); | ||
} | ||
|
||
@Test | ||
public void whenFalseValueThenReturnBooleanWithFalseValue() { | ||
|
||
Object result = QueryParser.parseValue("false", null); | ||
Assert.assertEquals(Boolean.parseBoolean("false"), result); | ||
} | ||
|
||
@Test | ||
public void whenValueIsNullThenReturnNullValue() { | ||
|
||
Object result = QueryParser.parseValue(null, null); | ||
Assert.assertEquals(null, result); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/test/java/io/github/ajclopez/mss/SearchPatternsTest.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,21 @@ | ||
package io.github.ajclopez.mss; | ||
|
||
import io.github.ajclopez.mss.pattern.SearchPatterns; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class SearchPatternsTest { | ||
|
||
@Test | ||
public void canUseDefaultFlagWithNullOptions() { | ||
int flags = SearchPatterns.getFlags(null); | ||
Assert.assertEquals(0x00, flags); | ||
} | ||
|
||
@Test | ||
public void canUseDefaultFlagWithUnknownRegexFlag() { | ||
int flags = SearchPatterns.getFlags("t"); | ||
Assert.assertEquals(0x00, flags); | ||
} | ||
|
||
} |