Skip to content

Commit 22fa91b

Browse files
Merge pull request #42 from folio-org/EDGAPIUTL-39
EDGAPIUTL-39: Add cause to AuthorizationException and PropertiesUtil
2 parents 6147e7c + 1d719c9 commit 22fa91b

4 files changed

Lines changed: 40 additions & 8 deletions

File tree

pom.xml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@
2626
<maven-source-plugin.version>3.4.0</maven-source-plugin.version>
2727
<build-helper-maven-plugin.version>3.6.1</build-helper-maven-plugin.version>
2828
<maven-release-plugin.version>3.3.1</maven-release-plugin.version>
29-
<awaitility.version>4.3.0</awaitility.version>
30-
<junit.version>4.13.2</junit.version>
3129
<wiremock.version>3.13.2</wiremock.version>
32-
<mockito.version>5.21.0</mockito.version>
3330
<folio-spring-base.version>10.0.0</folio-spring-base.version>
3431
<folio-tls-utils.version>4.0.0</folio-tls-utils.version>
3532
</properties>
@@ -98,19 +95,26 @@
9895
<dependency>
9996
<groupId>org.awaitility</groupId>
10097
<artifactId>awaitility</artifactId>
101-
<version>${awaitility.version}</version>
10298
<scope>test</scope>
10399
</dependency>
104100
<dependency>
105101
<groupId>org.mockito</groupId>
106102
<artifactId>mockito-core</artifactId>
107-
<version>${mockito.version}</version>
103+
<scope>test</scope>
104+
</dependency>
105+
<dependency>
106+
<groupId>org.junit.jupiter</groupId>
107+
<artifactId>junit-jupiter-api</artifactId>
108108
<scope>test</scope>
109109
</dependency>
110110
<dependency>
111111
<groupId>junit</groupId>
112112
<artifactId>junit</artifactId>
113-
<version>${junit.version}</version>
113+
<scope>test</scope>
114+
</dependency>
115+
<dependency>
116+
<groupId>org.junit.vintage</groupId>
117+
<artifactId>junit-vintage-engine</artifactId>
114118
<scope>test</scope>
115119
</dependency>
116120
<dependency>
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package org.folio.edge.api.utils.exception;
22

33
/**
4-
* Specific exception for handlig edge-authorization process
4+
* Specific exception for handling edge-authorization process
55
*/
66
public class AuthorizationException extends RuntimeException {
77

88
public AuthorizationException(String message) {
99
super(message);
1010
}
11+
12+
public AuthorizationException(String message, Throwable cause) {
13+
super(message, cause);
14+
}
1115
}
1216

src/main/java/org/folio/edge/api/utils/util/PropertiesUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static Properties getProperties(String secureStorePropFile) {
3636
logger.info("Successfully loaded properties from: {}", secureStorePropFile);
3737
}
3838
} catch (Exception e) {
39-
throw new AuthorizationException("Failed to load secure store properties");
39+
throw new AuthorizationException("Failed to load secure store properties", e);
4040
}
4141
} else {
4242
logger.warn("No secure store properties file specified. Using defaults");
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.folio.edge.api.utils.exception;
2+
3+
import static org.hamcrest.MatcherAssert.assertThat;
4+
import static org.hamcrest.Matchers.theInstance;
5+
import static org.hamcrest.Matchers.is;
6+
7+
import org.junit.jupiter.api.Test;
8+
9+
class AuthorizationExceptionTest {
10+
11+
@Test
12+
void message() {
13+
var e = new AuthorizationException("hi");
14+
assertThat(e.getMessage(), is("hi"));
15+
}
16+
17+
@Test
18+
void messageAndCause() {
19+
var cause = new IllegalArgumentException("bar");
20+
var e = new AuthorizationException("foo", cause);
21+
assertThat(e.getMessage(), is("foo"));
22+
assertThat(e.getCause(), is(theInstance(cause)));
23+
}
24+
}

0 commit comments

Comments
 (0)