This repository has been archived by the owner on May 26, 2020. It is now read-only.
-
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 an option to look for RAML files in the classpath
- Loading branch information
Showing
40 changed files
with
739 additions
and
152 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
32 changes: 32 additions & 0 deletions
32
io-utils/src/main/java/uk/gov/justice/raml/io/AntPathMatcher.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,32 @@ | ||
package uk.gov.justice.raml.io; | ||
|
||
import com.google.common.base.Predicate; | ||
|
||
import static java.io.File.separatorChar; | ||
import static org.codehaus.plexus.util.SelectorUtils.matchPath; | ||
|
||
/** | ||
* matches resource path against Ant url pattern | ||
*/ | ||
public class AntPathMatcher implements Predicate<String> { | ||
private final String antPattern; | ||
|
||
/** | ||
* @param antPattern - ant pattern to be used in matching | ||
*/ | ||
public AntPathMatcher(final String antPattern) { | ||
this.antPattern = antPattern; | ||
} | ||
|
||
/** | ||
* Matches path against the antPattern | ||
* | ||
* @param path - resource path | ||
* @return - returns true if the path matches the pattern provided in the constructor, false otherwise | ||
*/ | ||
@Override | ||
public boolean apply(final String path) { | ||
return matchPath(antPattern.replace('/', separatorChar), path); | ||
} | ||
} | ||
|
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
27 changes: 27 additions & 0 deletions
27
io-utils/src/test/java/uk/gov/justice/raml/io/AntPathMatcherTest.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,27 @@ | ||
package uk.gov.justice.raml.io; | ||
|
||
import com.google.common.base.Predicate; | ||
import org.junit.Test; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
public class AntPathMatcherTest { | ||
private Predicate<String> antPathMatcher; | ||
|
||
@Test | ||
public void shouldMatchFilesWithExtension() throws Exception { | ||
antPathMatcher = new AntPathMatcher("**/*.raml"); | ||
assertThat(antPathMatcher.apply("abc.raml"), is(true)); | ||
assertThat(antPathMatcher.apply("aaa-bcd.raml"), is(true)); | ||
assertThat(antPathMatcher.apply("aaa-bcd.aml"), is(false)); | ||
} | ||
|
||
@Test | ||
public void shouldMatchFilesEndingWithSpecificEnding() throws Exception { | ||
antPathMatcher = new AntPathMatcher("**/*abc.raml"); | ||
assertThat(antPathMatcher.apply("abc.raml"), is(true)); | ||
assertThat(antPathMatcher.apply("aaa-aabc.raml"), is(true)); | ||
assertThat(antPathMatcher.apply("aaa-bcd.aml"), is(false)); | ||
} | ||
} |
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,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>raml-maven</artifactId> | ||
<groupId>uk.gov.justice.maven</groupId> | ||
<version>1.1.1-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>raml-for-testing-io</artifactId> | ||
|
||
|
||
</project> |
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,2 @@ | ||
#%RAML 0.8 | ||
title: external-3.raml |
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,2 @@ | ||
#%RAML 0.8 | ||
title: external-4.raml |
2 changes: 2 additions & 0 deletions
2
raml-for-testing-io/src/main/resources/raml/external-ignore.raml
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,2 @@ | ||
#%RAML 0.8 | ||
title: external-ignore.raml |
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,2 @@ | ||
#%RAML 0.8 | ||
title: external-1.raml |
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,2 @@ | ||
#%RAML 0.8 | ||
title: external-2.raml |
Oops, something went wrong.