I am facing difficulty in running Junit test cases. I am writing a test case for startUpdateRootEmailAddress.
After adding below statement:
import software.amazon.awssdk.services.account.model.StartPrimaryEmailUpdateRequest; ,
I am getting the error on running the test case.
/opt/workspace/core-public/core/service-voice-private/test/unit/java/src/servicevoice/provisioning/aws/impl/AwsProvisioningServiceImplUnitTest.java:84: error: The import software.amazon.awssdk.services.account cannot be resolved
import software.amazon.awssdk.services.account.model.StartPrimaryEmailUpdateRequest;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Below is the test case written:
@Test
public void testStartUpdateRootEmailAddress_successfulUpdate() throws Exception {
// Arrange
String accountId = "123456789012";
String newEmail = "[email protected]";
AccountClient mockAccountClient = mock(AccountClient.class);
StartPrimaryEmailUpdateResponse mockResponse = mock(StartPrimaryEmailUpdateResponse.class);
EnableAwsServiceAccessResponse mockEnableResponse = mock(EnableAwsServiceAccessResponse.class);
SdkHttpResponse mockSdkHttpResponse = mock(SdkHttpResponse.class);
when(awsApiClient.getAccountClient()).thenReturn(mockAccountClient);
when(mockAccountClient.startPrimaryEmailUpdate((StartPrimaryEmailUpdateRequest) any())).thenReturn(mockResponse);
when(mockResponse.statusAsString()).thenReturn("SUCCESS");
PowerMockito.doReturn(mockEnableResponse).when(awsProvisioningServiceImpl, "enableTrustedAccessForAccount");
PowerMockito.doNothing().when(awsProvisioningServiceImpl, "disableTrustedAccessForAccount");
when(mockEnableResponse.sdkHttpResponse()).thenReturn(mockSdkHttpResponse);
when(mockSdkHttpResponse.isSuccessful()).thenReturn(true);
// Act
String result = awsProvisioningServiceImpl.startUpdateRootEmailAddress(accountId, newEmail);
// Assert
assertEquals("SUCCESS", result);
verify(mockAccountClient, times(1)).startPrimaryEmailUpdate((StartPrimaryEmailUpdateRequest) any());
PowerMockito.verifyPrivate(awsProvisioningServiceImpl).invoke("disableTrustedAccessForAccount");
}
Any help is appreciated.