-
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.
* ErrorDecoder handling * Version update & changelogs Co-authored-by: SEBASTIEN MONEUSE - E437830 <sebastien.moneuse@ext.mpsa.com>
- Loading branch information
Showing
12 changed files
with
146 additions
and
1 deletion.
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
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
21 changes: 21 additions & 0 deletions
21
src/test/java/org/seedstack/feign/fixtures/FeignTestException.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 @@ | ||
/* | ||
* Copyright © 2013-2020, The SeedStack authors <http://seedstack.org> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package org.seedstack.feign.fixtures; | ||
|
||
/** | ||
* Feign addon test exception | ||
*/ | ||
public class FeignTestException extends Exception{ | ||
/** | ||
* Statndard constructor | ||
* @param message exception message | ||
*/ | ||
public FeignTestException(String message){ | ||
super(message); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/java/org/seedstack/feign/fixtures/TestErrorDecoder.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,36 @@ | ||
/* | ||
* Copyright © 2013-2020, The SeedStack authors <http://seedstack.org> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package org.seedstack.feign.fixtures; | ||
|
||
import feign.FeignException; | ||
import feign.Response; | ||
import feign.codec.ErrorDecoder; | ||
|
||
/** | ||
* Custom Error Decoder | ||
*/ | ||
public class TestErrorDecoder implements ErrorDecoder { | ||
|
||
/** | ||
* Treat request error, as used in a unit test, resolving with a specific error message in the exception that should be verified in the unit test | ||
* @param methodKey The method key | ||
* @param response the feign request response | ||
* @return Exception | ||
*/ | ||
@Override | ||
public Exception decode(String methodKey, Response response) { | ||
switch (response.status()){ | ||
case 404 : { | ||
return new FeignTestException("Feign addon unit test : received HTTP 404 error code"); | ||
} | ||
default:{ | ||
return new FeignTestException(response.reason()); | ||
} | ||
} | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
src/test/java/org/seedstack/feign/fixtures/apis/ErrorDecoderTestAPI.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,25 @@ | ||
/* | ||
* Copyright © 2013-2020, The SeedStack authors <http://seedstack.org> | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package org.seedstack.feign.fixtures.apis; | ||
|
||
import feign.RequestLine; | ||
import org.seedstack.feign.FeignApi; | ||
import org.seedstack.feign.fixtures.Message; | ||
|
||
/** | ||
* Unit test API for error handling | ||
*/ | ||
@FeignApi | ||
public interface ErrorDecoderTestAPI { | ||
|
||
/** | ||
* Requesting the endpoint responding HTTP 204 | ||
*/ | ||
@RequestLine("GET /testErrorDecoder") | ||
Message fakeRequest(); | ||
} |
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