5
5
package org .opensmartgridplatform .adapter .protocol .dlms .application .services ;
6
6
7
7
import static org .assertj .core .api .Assertions .assertThat ;
8
- import static org .junit . jupiter .api .Assertions .assertThrows ;
8
+ import static org .assertj . core .api .Assertions .assertThatThrownBy ;
9
9
import static org .mockito .ArgumentMatchers .any ;
10
10
import static org .mockito .ArgumentMatchers .same ;
11
11
import static org .mockito .Mockito .times ;
12
12
import static org .mockito .Mockito .verify ;
13
13
import static org .mockito .Mockito .when ;
14
14
15
- import java .util .Arrays ;
16
15
import java .util .EnumMap ;
17
16
import java .util .List ;
18
17
import java .util .Map ;
@@ -74,7 +73,7 @@ public void init() {
74
73
75
74
@ Test
76
75
void testGetKeys () {
77
- final List <SecurityKeyType > keyTypes = Arrays . asList (KEY_TYPE );
76
+ final List <SecurityKeyType > keyTypes = List . of (KEY_TYPE );
78
77
final GetSecretsResponse response = new GetSecretsResponse ();
79
78
response .setResult (OsgpResultType .OK );
80
79
response .setTypedSecrets (new TypedSecrets ());
@@ -117,17 +116,17 @@ void testStoreNewKeysThrowsException() {
117
116
when (this .secretManagementClient .storeSecretsRequest (same (messageMetadata ), any ()))
118
117
.thenThrow (new RuntimeException ("Simulated exception" ));
119
118
120
- assertThrows (
121
- StoreNewKeyException . class ,
122
- () -> {
123
- this . secretManagementTestService . storeNewKeys (
124
- messageMetadata , DEVICE_IDENTIFICATION , keys );
125
- } );
119
+ assertThatThrownBy (
120
+ () -> {
121
+ this . secretManagementTestService . storeNewKeys (
122
+ messageMetadata , DEVICE_IDENTIFICATION , keys );
123
+ })
124
+ . isInstanceOf ( StoreNewKeyException . class );
126
125
}
127
126
128
127
@ Test
129
128
void testActivateKeys () {
130
- final List <SecurityKeyType > keyTypes = Arrays . asList (KEY_TYPE );
129
+ final List <SecurityKeyType > keyTypes = List . of (KEY_TYPE );
131
130
final ArgumentCaptor <ActivateSecretsRequest > activateSecretsCaptor =
132
131
ArgumentCaptor .forClass (ActivateSecretsRequest .class );
133
132
// EXECUTE
@@ -144,7 +143,7 @@ void testActivateKeys() {
144
143
145
144
@ Test
146
145
void testGenerateAndStoreKeys () {
147
- final List <SecurityKeyType > keyTypes = Arrays . asList (KEY_TYPE );
146
+ final List <SecurityKeyType > keyTypes = List . of (KEY_TYPE );
148
147
final GenerateAndStoreSecretsResponse response = new GenerateAndStoreSecretsResponse ();
149
148
response .setResult (OsgpResultType .OK );
150
149
response .setTypedSecrets (new TypedSecrets ());
0 commit comments