Skip to content

Commit

Permalink
update assertions in unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Natasja Nortier <[email protected]>
  • Loading branch information
natasja-n committed Jan 22, 2025
1 parent ea2e21d commit 2f2cc7c
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
package org.opensmartgridplatform.adapter.protocol.dlms.application.services;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -74,7 +73,7 @@ public void init() {

@Test
void testGetKeys() {
final List<SecurityKeyType> keyTypes = Arrays.asList(KEY_TYPE);
final List<SecurityKeyType> keyTypes = List.of(KEY_TYPE);
final GetSecretsResponse response = new GetSecretsResponse();
response.setResult(OsgpResultType.OK);
response.setTypedSecrets(new TypedSecrets());
Expand Down Expand Up @@ -117,17 +116,17 @@ void testStoreNewKeysThrowsException() {
when(this.secretManagementClient.storeSecretsRequest(same(messageMetadata), any()))
.thenThrow(new RuntimeException("Simulated exception"));

assertThrows(
StoreNewKeyException.class,
() -> {
this.secretManagementTestService.storeNewKeys(
messageMetadata, DEVICE_IDENTIFICATION, keys);
});
assertThatThrownBy(
() -> {
this.secretManagementTestService.storeNewKeys(
messageMetadata, DEVICE_IDENTIFICATION, keys);
})
.isInstanceOf(StoreNewKeyException.class);
}

@Test
void testActivateKeys() {
final List<SecurityKeyType> keyTypes = Arrays.asList(KEY_TYPE);
final List<SecurityKeyType> keyTypes = List.of(KEY_TYPE);
final ArgumentCaptor<ActivateSecretsRequest> activateSecretsCaptor =
ArgumentCaptor.forClass(ActivateSecretsRequest.class);
// EXECUTE
Expand All @@ -144,7 +143,7 @@ void testActivateKeys() {

@Test
void testGenerateAndStoreKeys() {
final List<SecurityKeyType> keyTypes = Arrays.asList(KEY_TYPE);
final List<SecurityKeyType> keyTypes = List.of(KEY_TYPE);
final GenerateAndStoreSecretsResponse response = new GenerateAndStoreSecretsResponse();
response.setResult(OsgpResultType.OK);
response.setTypedSecrets(new TypedSecrets());
Expand Down

0 comments on commit 2f2cc7c

Please sign in to comment.