Skip to content

Commit 0168eea

Browse files
committed
Improve maintainability according to Sonar recommendations.
1 parent a146eab commit 0168eea

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/main/java/com/github/hrytsenko/jsondata/springboot/error/WrapErrorsAspect.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ class WrapErrorsAspect {
3030
public Object handle(ProceedingJoinPoint point, WrapErrors config) {
3131
try {
3232
return point.proceed();
33+
} catch (ServiceException exception) {
34+
throw exception;
3335
} catch (Exception exception) {
34-
if (exception instanceof ServiceException) {
35-
throw exception;
36-
}
3736
throw new ServiceException.InternalServer(config.value(), exception);
3837
}
3938
}

src/test/java/com/github/hrytsenko/jsondata/springboot/error/WrapErrorsAspectTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ void handle_noException() {
3636
ProceedingJoinPoint sourceJoinPoint = Mockito.mock(ProceedingJoinPoint.class);
3737
WrapErrors sourceConfig = Mockito.mock(WrapErrors.class);
3838

39-
aspect.handle(sourceJoinPoint, sourceConfig);
39+
Assertions.assertDoesNotThrow(
40+
() -> aspect.handle(sourceJoinPoint, sourceConfig));
4041
}
4142

4243
@Test

src/test/java/com/github/hrytsenko/jsondata/springboot/web/ValidateRequestAspectTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ void validate_success() {
4343
Mockito.doReturn(sourceSchema)
4444
.when(aspect).loadSchema(Mockito.any());
4545

46-
aspect.handle(sourceJoinPoint, sourceConfig);
46+
Assertions.assertDoesNotThrow(
47+
() -> aspect.handle(sourceJoinPoint, sourceConfig));
4748
}
4849

4950
@Test

src/test/java/com/github/hrytsenko/jsondata/springboot/web/ValidateResponseAspectTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ void validate_success() {
4444
Mockito.doReturn(sourceSchema)
4545
.when(aspect).loadSchema(Mockito.any());
4646

47-
aspect.handle(sourceJoinPoint, sourceConfig);
47+
Assertions.assertDoesNotThrow(
48+
() -> aspect.handle(sourceJoinPoint, sourceConfig));
4849
}
4950

5051
@Test

0 commit comments

Comments
 (0)