@Test public void setSecret() { AWSSetSecretData setSecretData = mock(AWSSetSecretData.class); String secretName = "id"; String secret = "secret"; when(setSecretData.getSecretName()).thenReturn(secretName); when(setSecretData.getSecret()).thenReturn(secret); keyVaultService.setSecret(setSecretData); CreateSecretRequest expected = CreateSecretRequest.builder().name(secretName).secretString(secret).build(); ArgumentCaptor<CreateSecretRequest> argument = ArgumentCaptor.forClass(CreateSecretRequest.class); verify(secretsManager).createSecret(argument.capture()); assertThat(argument.getValue()).isEqualToComparingFieldByField(expected); }
@Override public Object setSecret(AWSSetSecretData setSecretData) { CreateSecretRequest createSecretRequest = CreateSecretRequest.builder() .name(setSecretData.getSecretName()) .secretString(setSecretData.getSecret()) .build(); return secretsManager.createSecret(createSecretRequest); }
AWSKeyVaultService implements KeyVaultService<AWSSetSecretData, AWSGetSecretData> { @Override public Object setSecret(AWSSetSecretData setSecretData) { CreateSecretRequest createSecretRequest = CreateSecretRequest.builder() .name(setSecretData.getSecretName()) .secretString(setSecretData.getSecret()) .build(); return secretsManager.createSecret(createSecretRequest); } }
AWSKeyVaultService implements KeyVaultService<AWSSetSecretData, AWSGetSecretData> { @Override public Object setSecret(AWSSetSecretData setSecretData) { CreateSecretRequest createSecretRequest = CreateSecretRequest.builder() .name(setSecretData.getSecretName()) .secretString(setSecretData.getSecret()) .build(); return secretsManager.createSecret(createSecretRequest); } AWSKeyVaultService(SecretsManagerClient secretsManager); }
AWSKeyVaultService implements KeyVaultService<AWSSetSecretData, AWSGetSecretData> { @Override public Object setSecret(AWSSetSecretData setSecretData) { CreateSecretRequest createSecretRequest = CreateSecretRequest.builder() .name(setSecretData.getSecretName()) .secretString(setSecretData.getSecret()) .build(); return secretsManager.createSecret(createSecretRequest); } AWSKeyVaultService(SecretsManagerClient secretsManager); @Override String getSecret(AWSGetSecretData getSecretData); @Override Object setSecret(AWSSetSecretData setSecretData); }
AWSKeyVaultService implements KeyVaultService<AWSSetSecretData, AWSGetSecretData> { @Override public Object setSecret(AWSSetSecretData setSecretData) { CreateSecretRequest createSecretRequest = CreateSecretRequest.builder() .name(setSecretData.getSecretName()) .secretString(setSecretData.getSecret()) .build(); return secretsManager.createSecret(createSecretRequest); } AWSKeyVaultService(SecretsManagerClient secretsManager); @Override String getSecret(AWSGetSecretData getSecretData); @Override Object setSecret(AWSSetSecretData setSecretData);  }