-
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.
- Loading branch information
1 parent
8a5cae1
commit bdb217e
Showing
14 changed files
with
50 additions
and
96 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
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
16 changes: 0 additions & 16 deletions
16
generator-maven-plugin/src/main/java/com/oviva/spicegen/maven/SpicegenMojo.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
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
39 changes: 19 additions & 20 deletions
39
...ing/src/test/java/com/oviva/spicegen/spicedbbinding/internal/GrpcExceptionMapperTest.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 |
---|---|---|
@@ -1,63 +1,62 @@ | ||
package com.oviva.spicegen.spicedbbinding.internal; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import com.oviva.spicegen.api.exceptions.*; | ||
import io.grpc.Status; | ||
import io.grpc.StatusRuntimeException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class GrpcExceptionMapperTest { | ||
class GrpcExceptionMapperTest { | ||
|
||
private final GrpcExceptionMapper grpcExceptionMapper = new GrpcExceptionMapper(); | ||
|
||
@Test | ||
public void test_map_permissionDenied() { | ||
void test_map_permissionDenied() { | ||
var exception = grpcExceptionMapper.map(new StatusRuntimeException(Status.PERMISSION_DENIED)); | ||
|
||
assertTrue(exception instanceof AuthorizationException); | ||
assertEquals(exception.getMessage(), "permission denied"); | ||
assertInstanceOf(AuthorizationException.class, exception); | ||
assertEquals("permission denied", exception.getMessage()); | ||
} | ||
|
||
@Test | ||
public void test_map_unauthenticated() { | ||
void test_map_unauthenticated() { | ||
var exception = grpcExceptionMapper.map(new StatusRuntimeException(Status.UNAUTHENTICATED)); | ||
|
||
assertTrue(exception instanceof AuthenticationException); | ||
assertEquals(exception.getMessage(), "unauthenticated"); | ||
assertInstanceOf(AuthenticationException.class, exception); | ||
assertEquals("unauthenticated", exception.getMessage()); | ||
} | ||
|
||
@Test | ||
public void test_map_alreadyExists() { | ||
void test_map_alreadyExists() { | ||
var exception = grpcExceptionMapper.map(new StatusRuntimeException(Status.ALREADY_EXISTS)); | ||
|
||
assertTrue(exception instanceof ConflictException); | ||
assertEquals(exception.getMessage(), "already exists"); | ||
assertInstanceOf(ConflictException.class, exception); | ||
assertEquals("already exists", exception.getMessage()); | ||
} | ||
|
||
@Test | ||
public void test_map_invalidArgument() { | ||
void test_map_invalidArgument() { | ||
|
||
var exception = grpcExceptionMapper.map(new StatusRuntimeException(Status.INVALID_ARGUMENT)); | ||
|
||
assertTrue(exception instanceof ValidationException); | ||
assertEquals(exception.getMessage(), "invalid argument"); | ||
assertInstanceOf(ValidationException.class, exception); | ||
assertEquals("invalid argument", exception.getMessage()); | ||
} | ||
|
||
@Test | ||
public void test_map_failedPrecondition() { | ||
void test_map_failedPrecondition() { | ||
var exception = grpcExceptionMapper.map(new StatusRuntimeException(Status.FAILED_PRECONDITION)); | ||
|
||
assertTrue(exception instanceof ValidationException); | ||
assertEquals(exception.getMessage(), "failed precondition"); | ||
assertInstanceOf(ValidationException.class, exception); | ||
assertEquals("failed precondition", exception.getMessage()); | ||
} | ||
|
||
@Test | ||
public void test_map_unexpectedValue() { | ||
void test_map_unexpectedValue() { | ||
var exception = grpcExceptionMapper.map(new StatusRuntimeException(Status.CANCELLED)); | ||
|
||
assertTrue(exception instanceof ClientException); | ||
assertInstanceOf(ClientException.class, exception); | ||
assertTrue(exception.getMessage().startsWith("unexpected status:")); | ||
} | ||
} |
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