Skip to content

convert twilio unit test from groovy to java#13077

Merged
laurit merged 7 commits into
open-telemetry:mainfrom
shalk:test-twilio
Jan 24, 2025
Merged

convert twilio unit test from groovy to java#13077
laurit merged 7 commits into
open-telemetry:mainfrom
shalk:test-twilio

Conversation

@shalk

@shalk shalk commented Jan 21, 2025

Copy link
Copy Markdown
Member

relate to #7195

@shalk shalk requested a review from a team as a code owner January 21, 2025 07:26
shalk and others added 4 commits January 22, 2025 14:14
Co-authored-by: Jean Bisutti <jean.bisutti@gmail.com>
Co-authored-by: Jay DeLuca <jaydeluca4@gmail.com>

@Test
void synchronousMessage() {
twilioRestClient = mock(TwilioRestClient.class);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can skip this if you add @ExtendWith(MockitoExtension.class) to the test class and @Mock to the twilioRestClient field.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +216 to +217
CloseableHttpResponse response1 = mockResponse(MESSAGE_RESPONSE_BODY, 200);
when(httpClient.execute(any())).thenReturn(response1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rename response1 -> response or inline it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


@Test
void httpClient() throws IOException {
CloseableHttpClient httpClient = mock(CloseableHttpClient.class);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to duplicated definitions in three different unit tests, how about extracting it out like twilioRestClient?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@laurit laurit merged commit 9e70f93 into open-telemetry:main Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants