From fcf86af9177afa6d516b34367a45d6ab02214eaf Mon Sep 17 00:00:00 2001 From: Nitin Vavdiya Date: Wed, 29 May 2024 14:37:11 +0530 Subject: [PATCH] fix: javadoc, imports and throws --- .../controller/SecureTokenController.java | 2 -- .../dao/repository/WalletKeyRepository.java | 2 +- ...SigningServiceTypeToExistingWalletsTest.java | 6 +++--- .../service/IssuersCredentialServiceTest.java | 17 +++++++---------- .../managedidentitywallets/utils/MockUtil.java | 4 ++-- .../vc/FrameworkHoldersCredentialTest.java | 6 +++--- .../vc/HoldersCredentialTest.java | 2 +- .../vc/IssuersCredentialTest.java | 2 +- ...bleCredentialIssuerEqualProofSignerTest.java | 3 +-- .../wallet/WalletTest.java | 2 +- 10 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/eclipse/tractusx/managedidentitywallets/controller/SecureTokenController.java b/src/main/java/org/eclipse/tractusx/managedidentitywallets/controller/SecureTokenController.java index b8acd6ead..3cfd78657 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/controller/SecureTokenController.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/controller/SecureTokenController.java @@ -50,14 +50,12 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.util.MultiValueMap; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import java.text.ParseException; diff --git a/src/main/java/org/eclipse/tractusx/managedidentitywallets/dao/repository/WalletKeyRepository.java b/src/main/java/org/eclipse/tractusx/managedidentitywallets/dao/repository/WalletKeyRepository.java index fcd0bc11b..54196d73b 100644 --- a/src/main/java/org/eclipse/tractusx/managedidentitywallets/dao/repository/WalletKeyRepository.java +++ b/src/main/java/org/eclipse/tractusx/managedidentitywallets/dao/repository/WalletKeyRepository.java @@ -33,7 +33,7 @@ public interface WalletKeyRepository extends BaseRepository { /** * Gets by wallet id and algorithm. * - * @param id the id param algorithm the algorithm + * @param id the wallet id * @param algorithm the algorithm * @return the by wallet id */ diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/migration/SetSigningServiceTypeToExistingWalletsTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/migration/SetSigningServiceTypeToExistingWalletsTest.java index fcfc5eccf..ec7fed508 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/migration/SetSigningServiceTypeToExistingWalletsTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/migration/SetSigningServiceTypeToExistingWalletsTest.java @@ -27,7 +27,6 @@ import liquibase.database.jvm.JdbcConnection; import liquibase.resource.ClassLoaderResourceAccessor; import lombok.SneakyThrows; -import org.h2.command.query.Select; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -35,14 +34,15 @@ import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; -import java.sql.ResultSetMetaData; import java.sql.Statement; import java.sql.Timestamp; import java.time.Instant; import java.util.ArrayList; import java.util.List; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; class SetSigningServiceTypeToExistingWalletsTest { public static final int EXPECTED_WALLET_COUNT = 5; diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/service/IssuersCredentialServiceTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/service/IssuersCredentialServiceTest.java index 246efc8ad..e64a6e0c7 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/service/IssuersCredentialServiceTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/service/IssuersCredentialServiceTest.java @@ -56,7 +56,6 @@ import org.eclipse.tractusx.ssi.lib.crypt.x25519.X25519PrivateKey; import org.eclipse.tractusx.ssi.lib.did.resolver.DidResolver; import org.eclipse.tractusx.ssi.lib.exception.did.DidParseException; -import org.eclipse.tractusx.ssi.lib.exception.did.DidResolverException; import org.eclipse.tractusx.ssi.lib.exception.key.InvalidPrivateKeyFormatException; import org.eclipse.tractusx.ssi.lib.exception.key.KeyTransformationException; import org.eclipse.tractusx.ssi.lib.jwt.SignedJwtFactory; @@ -78,10 +77,8 @@ import org.mockito.stubbing.Answer; import org.springframework.security.oauth2.jwt.JwtException; -import java.io.IOException; import java.sql.Connection; import java.sql.SQLException; -import java.text.ParseException; import java.time.Duration; import java.time.Instant; import java.util.Collections; @@ -170,7 +167,7 @@ class issueMembershipCredentialTest { @Test void shouldIssueCredentialAsJwt() - throws IOException, InvalidPrivateKeyFormatException, KeyTransformationException { + throws InvalidPrivateKeyFormatException, KeyTransformationException { Map wallets = mockBaseAndHolderWallet(); Wallet baseWallet = (Wallet) wallets.get("base"); String baseWalletBpn = baseWallet.getBpn(); @@ -225,7 +222,7 @@ class issueFrameWorkCredentialTest { @Test void shouldIssueCredentialAsJwt() - throws IOException, InvalidPrivateKeyFormatException, ParseException, JwtException, KeyTransformationException { + throws InvalidPrivateKeyFormatException, JwtException, KeyTransformationException { Map wallets = mockBaseAndHolderWallet(); Wallet baseWallet = (Wallet) wallets.get("base"); String baseWalletBpn = baseWallet.getBpn(); @@ -285,7 +282,7 @@ void shouldIssueCredentialAsJwt() class issueDismantlerCredentialTest { @Test - void shouldIssueCredentialAsJwt() throws IOException, InvalidPrivateKeyFormatException, ParseException, + void shouldIssueCredentialAsJwt() throws InvalidPrivateKeyFormatException, JwtException, KeyTransformationException { Map wallets = mockBaseAndHolderWallet(); Wallet baseWallet = (Wallet) wallets.get("base"); @@ -337,7 +334,7 @@ void shouldIssueCredentialAsJwt() throws IOException, InvalidPrivateKeyFormatExc class issueCredentialUsingBaseWallet { @Test - void shouldIssueCredentialAsJwt() throws IOException, ParseException, InvalidPrivateKeyFormatException, + void shouldIssueCredentialAsJwt() throws InvalidPrivateKeyFormatException, KeyTransformationException, JwtException { Map wallets = mockBaseAndHolderWallet(); Wallet baseWallet = (Wallet) wallets.get("base"); @@ -363,7 +360,7 @@ void shouldIssueCredentialAsJwt() throws IOException, ParseException, InvalidPri when(holdersCredentialRepository.save(any(HoldersCredential.class))) .thenAnswer(new Answer() { @Override - public HoldersCredential answer(InvocationOnMock invocation) throws Throwable { + public HoldersCredential answer(InvocationOnMock invocation) { HoldersCredential argument = invocation.getArgument(0, HoldersCredential.class); argument.setId(42L); return argument; @@ -506,7 +503,7 @@ private void mockCommon( when(holdersCredentialRepository.save(any(HoldersCredential.class))) .thenAnswer(new Answer() { @Override - public HoldersCredential answer(InvocationOnMock invocation) throws Throwable { + public HoldersCredential answer(InvocationOnMock invocation) { HoldersCredential argument = invocation.getArgument(0, HoldersCredential.class); argument.setId(42L); return argument; @@ -527,7 +524,7 @@ private void validateCredentialResponse(CredentialsResponse credentialsResponse, SignedJwtVerifier jwtVerifier = new SignedJwtVerifier(new DidResolver() { @Override - public DidDocument resolve(Did did) throws DidResolverException { + public DidDocument resolve(Did did) { return didDocument; } diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/MockUtil.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/MockUtil.java index 5168e6b50..652c975c8 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/MockUtil.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/utils/MockUtil.java @@ -232,7 +232,7 @@ public static void makeCreateWorkForHolder(HoldersCredentialRepository holdersCr when(holdersCredentialRepository.save(any(HoldersCredential.class))) .thenAnswer(new Answer() { @Override - public HoldersCredential answer(InvocationOnMock invocation) throws Throwable { + public HoldersCredential answer(InvocationOnMock invocation) { HoldersCredential argument = invocation.getArgument(0, HoldersCredential.class); argument.setId(42L); return argument; @@ -245,7 +245,7 @@ public static void makeCreateWorkForIssuer(IssuersCredentialRepository issuersCr when(issuersCredentialRepository.save(any(IssuersCredential.class))) .thenAnswer(new Answer() { @Override - public IssuersCredential answer(InvocationOnMock invocation) throws Throwable { + public IssuersCredential answer(InvocationOnMock invocation) { IssuersCredential argument = invocation.getArgument(0, IssuersCredential.class); argument.setId(42L); return argument; diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/FrameworkHoldersCredentialTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/FrameworkHoldersCredentialTest.java index 4089d7fe5..23a0b028b 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/FrameworkHoldersCredentialTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/FrameworkHoldersCredentialTest.java @@ -100,7 +100,7 @@ void issueFrameworkCredentialTest403() { } @Test - void issueFrameworkCredentialWithInvalidBpnAccessTest403() throws JsonProcessingException, JSONException { + void issueFrameworkCredentialWithInvalidBpnAccessTest403() throws JSONException { String bpn = TestUtils.getRandomBpmNumber(); String did = DidWebFactory.fromHostnameAndPath(miwSettings.host(), bpn).toString(); TestUtils.createWallet(bpn, did, walletRepository); @@ -118,7 +118,7 @@ void issueFrameworkCredentialWithInvalidBpnAccessTest403() throws JsonProcessing } @Test - void issueFrameWorkVCToBaseWalletTest201() throws JSONException, JsonProcessingException { + void issueFrameWorkVCToBaseWalletTest201() throws JSONException { String bpn = miwSettings.authorityWalletBpn(); String type = "PcfCredential"; //create wallet @@ -176,7 +176,7 @@ static Stream getTypes() { @Test @DisplayName("Issue framework with invalid type") - void issueFrameworkCredentialTest400() throws JsonProcessingException, JSONException { + void issueFrameworkCredentialTest400() throws JSONException { String bpn = TestUtils.getRandomBpmNumber(); String did = DidWebFactory.fromHostnameAndPath(miwSettings.host(), bpn).toString(); Wallet wallet = TestUtils.createWallet(bpn, did, walletRepository); diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/HoldersCredentialTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/HoldersCredentialTest.java index 7698ffcf7..ccab25372 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/HoldersCredentialTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/HoldersCredentialTest.java @@ -225,7 +225,7 @@ void getCredentials200() throws com.fasterxml.jackson.core.JsonProcessingExcepti @Test @DisplayName("Get Credentials as JWT") - void getCredentialsAsJWT200() throws com.fasterxml.jackson.core.JsonProcessingException, JSONException { + void getCredentialsAsJWT200() throws JSONException { String baseDID = miwSettings.authorityWalletDid(); String bpn = TestUtils.getRandomBpmNumber(); diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/IssuersCredentialTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/IssuersCredentialTest.java index e7c394075..8f96a1dd6 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/IssuersCredentialTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/IssuersCredentialTest.java @@ -162,7 +162,7 @@ void getCredentials200() throws com.fasterxml.jackson.core.JsonProcessingExcepti @Test @DisplayName("Get Credentials as JWT") - void getCredentialsAsJWT200() throws com.fasterxml.jackson.core.JsonProcessingException, JSONException { + void getCredentialsAsJWT200() throws JSONException { String baseBPN = miwSettings.authorityWalletBpn(); String holderBpn = TestUtils.getRandomBpmNumber(); String holderDID = "did:web:localhost:" + holderBpn; diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/VerifiableCredentialIssuerEqualProofSignerTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/VerifiableCredentialIssuerEqualProofSignerTest.java index 3373c9c64..4537be004 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/VerifiableCredentialIssuerEqualProofSignerTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/vc/VerifiableCredentialIssuerEqualProofSignerTest.java @@ -21,7 +21,6 @@ package org.eclipse.tractusx.managedidentitywallets.vc; -import com.fasterxml.jackson.core.JsonProcessingException; import lombok.SneakyThrows; import org.eclipse.tractusx.managedidentitywallets.ManagedIdentityWalletsApplication; import org.eclipse.tractusx.managedidentitywallets.config.MIWSettings; @@ -109,7 +108,7 @@ public void test() { } @SneakyThrows - private VerifiableCredential issueVC(String issuerDid, Wallet signerWallet) throws JsonProcessingException { + private VerifiableCredential issueVC(String issuerDid, Wallet signerWallet) { List contexts = new ArrayList(); contexts.add(URI.create("https://www.w3.org/2018/credentials/v1")); // if the credential does not contain the JWS proof-context add it diff --git a/src/test/java/org/eclipse/tractusx/managedidentitywallets/wallet/WalletTest.java b/src/test/java/org/eclipse/tractusx/managedidentitywallets/wallet/WalletTest.java index e4b4d4d2f..c562ce977 100644 --- a/src/test/java/org/eclipse/tractusx/managedidentitywallets/wallet/WalletTest.java +++ b/src/test/java/org/eclipse/tractusx/managedidentitywallets/wallet/WalletTest.java @@ -151,7 +151,7 @@ void createWalletTestWithUserToken403() { @Test @DisplayName("Create wallet with invalid BPN, it should return 400 ") - void createWalletWithInvalidBPNTest400() throws JsonProcessingException, JSONException { + void createWalletWithInvalidBPNTest400() throws JSONException { String bpn = "invalid bpn"; String name = "Sample Wallet"; String baseBpn = miwSettings.authorityWalletBpn();