This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
forked from phoenixnap/springmvc-raml-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request phoenixnap#157 from georgkoester/issue156error_rep…
…orting Fix phoenixnap#156 error reporting
- Loading branch information
Showing
7 changed files
with
140 additions
and
11 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...ngmvc-raml-parser/src/main/java/com/phoenixnap/oss/ramlapisync/raml/InvalidRamlError.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,42 @@ | ||
/* | ||
* Copyright 2002-2017 the original author or authors. | ||
* | ||
* 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.phoenixnap.oss.ramlapisync.raml; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author georgkoester | ||
*/ | ||
public class InvalidRamlError extends Error { | ||
|
||
private static final long serialVersionUID = 770865086433357483L; | ||
private final List<?> errors; | ||
private final String ramlFileUrl; | ||
|
||
public InvalidRamlError(String ramlFileUrl, List<?> errors) { | ||
this.errors = errors; | ||
this.ramlFileUrl = ramlFileUrl; | ||
} | ||
|
||
@Override | ||
public String getMessage() { | ||
return this.toString(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getClass().getSimpleName() + " on raml file " + ramlFileUrl + " {" + | ||
"errors=" + errors + | ||
'}'; | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
...rser/src/test/java/com/phoenixnap/oss/ramlapisync/generation/rules/Issue156RulesTest.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,34 @@ | ||
package com.phoenixnap.oss.ramlapisync.generation.rules; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
import com.phoenixnap.oss.ramlapisync.raml.InvalidRamlError; | ||
import com.phoenixnap.oss.ramlapisync.raml.UnsupportedRamlVersionError; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author kurtpa | ||
* @since 0.4.2 | ||
*/ | ||
public class Issue156RulesTest extends AbstractRuleTestBase { | ||
|
||
@Test | ||
public void versionCheck_shouldReportUnsupportedVersion() throws Exception { | ||
try { | ||
RamlLoader.loadRamlFromFile("issue-156-unsupported.raml"); | ||
fail(); | ||
} catch (UnsupportedRamlVersionError urve) { | ||
// ok | ||
} | ||
} | ||
|
||
@Test | ||
public void versionCheck_shouldReportErrorAsInvalidRamlError() throws Exception { | ||
try { | ||
RamlLoader.loadRamlFromFile("issue-156-normal_invalidity.raml"); | ||
fail(); | ||
} catch (InvalidRamlError ire) { | ||
// ok | ||
} | ||
} | ||
} |
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
10 changes: 10 additions & 0 deletions
10
springmvc-raml-parser/src/test/resources/issue-156-normal_invalidity.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,10 @@ | ||
#%RAML 0.8 | ||
title: raml2springmvc_invalid_raml_response_statuscode_missing | ||
version: "0.0.1" | ||
baseUri: /api | ||
/customers: | ||
get: | ||
responses: | ||
description: Example. | ||
body: | ||
text/plain: |
11 changes: 11 additions & 0 deletions
11
springmvc-raml-parser/src/test/resources/issue-156-unsupported.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,11 @@ | ||
#%RAML 0.5 | ||
title: raml2springmvc_unsupported_ramlversion | ||
version: "0.0.1" | ||
baseUri: /api | ||
/customers: | ||
get: | ||
responses: | ||
200: | ||
description: Example. | ||
body: | ||
text/plain: |