-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
functionPathName: Rework using pathTemplateIdentifiers() to give bett…
…er results for templated paths
- Loading branch information
1 parent
86dfee0
commit e3a5f79
Showing
2 changed files
with
80 additions
and
3 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
55 changes: 55 additions & 0 deletions
55
tcases-openapi/src/test/java/org/cornutum/tcases/openapi/FunctionPathNameTest.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,55 @@ | ||
////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2019, Cornutum Project | ||
// www.cornutum.org | ||
// | ||
////////////////////////////////////////////////////////////////////////////// | ||
package org.cornutum.tcases.openapi; | ||
|
||
import static org.cornutum.tcases.openapi.InputModeller.functionPathName; | ||
|
||
import org.junit.Test; | ||
import static org.hamcrest.MatcherAssert.*; | ||
import static org.hamcrest.Matchers.*; | ||
|
||
public class FunctionPathNameTest | ||
{ | ||
@Test | ||
public void whenSingleElement() | ||
{ | ||
// Given... | ||
String pathName = "/someResource"; | ||
|
||
// When... | ||
String functionPathName = functionPathName( pathName); | ||
|
||
// Then... | ||
assertThat( "Function path name", functionPathName, is( "someResource")); | ||
} | ||
|
||
@Test | ||
public void whenMultipleTemplates() | ||
{ | ||
// Given... | ||
String pathName = "/{service}/{caseId}.{ext}"; | ||
|
||
// When... | ||
String functionPathName = functionPathName( pathName); | ||
|
||
// Then... | ||
assertThat( "Function path name", functionPathName, is( "service-caseId-ext")); | ||
} | ||
|
||
@Test | ||
public void whenNonIdentifierChars() | ||
{ | ||
// Given... | ||
String pathName = "/What /is {12?}/34{56?}+{78?}90=/?"; | ||
|
||
// When... | ||
String functionPathName = functionPathName( pathName); | ||
|
||
// Then... | ||
assertThat( "Function path name", functionPathName, is( "What-is-12-34-56-78-90")); | ||
} | ||
} |