0

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.

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.