Skip to content

Commit

Permalink
test: Don't use string templates (preview)
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Aug 7, 2024
1 parent ccbe0e0 commit 70ca591
Show file tree
Hide file tree
Showing 10 changed files with 313 additions and 354 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.0%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE.txt)
[![Snyk](https://snyk.io/test/github/vonage/vonage-java-sdk/badge.svg)](https://snyk.io/test/github/vonage/vonage-java-sdk)
[![Pulse](https://img.shields.io/github/commit-activity/m/vonage/vonage-java-sdk)](https://github.com/vonage/vonage-java-sdk/pulse)
<!---[![Pulse](https://img.shields.io/github/commit-activity/m/vonage/vonage-java-sdk)](https://github.com/vonage/vonage-java-sdk/pulse)-->

<img src="https://developer.nexmo.com/assets/images/Vonage_Nexmo.svg" height="48px" alt="Nexmo is now known as Vonage" />

Expand Down
4 changes: 0 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,12 @@
<testSource>${java.testVersion}</testSource>
<testTarget>${java.testVersion}</testTarget>
<testRelease>${java.testVersion}</testRelease>
<testCompilerArgument>--enable-preview</testCompilerArgument>
</configuration>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>

<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
abstract class AbstractEventTest {
final int randomEventId = ConversationsClientTest.EVENT_ID;
final UUID randomId = UUID.randomUUID();
final String randomIdStr = randomId.toString(), from = STR."MEM-\{UUID.randomUUID()}";
final String randomIdStr = randomId.toString(), from = "MEM-"+UUID.randomUUID();

<E extends EventWithBody<?>, B extends EventWithBody.Builder<? extends E, B>> B applyBaseFields(B builder) {
return builder.from(from);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,14 @@ <E extends AudioPlayStatusEvent, B extends AudioPlayStatusEvent.Builder<E, B>> v
<E extends AudioPlayStatusEvent> void testStatusEvent(
EventType eventType, String eventTypeStr, Class<E> eventClass) {

E event = parseEvent(eventType, eventClass, STR."""
{
"id": \{randomEventId},
"type": "audio:play:\{eventTypeStr}",
"body": {
"play_id": "\{randomIdStr}"
},
"_links": {}
}
"""
E event = parseEvent(eventType, eventClass, "{\n" +
" \"id\": " + randomEventId + ",\n" +
" \"type\": \"audio:play:" + eventTypeStr + "\",\n" +
" \"body\": {\n" +
" \"play_id\": \"" + randomIdStr + "\"\n" +
" },\n" +
" \"_links\": {}\n" +
"}"
);
assertEquals(randomId, event.getPlayId());
assertEquals(randomEventId, event.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,14 @@ <E extends AudioSayStatusEvent, B extends AudioSayStatusEvent.Builder<E, B>> voi
<E extends AudioSayStatusEvent> void testStatusEvent(
EventType eventType, String eventTypeStr, Class<E> eventClass) {

E event = parseEvent(eventType, eventClass, STR."""
{
"id": \{randomEventId},
"type": "audio:say:\{eventTypeStr}",
"body": {
"say_id": "\{randomIdStr}"
},
"_links": {}
}
"""
E event = parseEvent(eventType, eventClass, "{\n" +
" \"id\": " + randomEventId + ",\n" +
" \"type\": \"audio:say:" + eventTypeStr + "\",\n" +
" \"body\": {\n" +
" \"say_id\": \"" + randomIdStr + "\"\n" +
" },\n" +
" \"_links\": {}\n" +
"}"
);
assertEquals(randomId, event.getSayId());
assertEquals(randomEventId, event.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,21 @@ public class ConversationUpdatedEventTest extends AbstractEventTest {

@Test
public void testParseConversationUpdatedEvent() {
var event = parseEvent(EventType.CONVERSATION_UPDATED, ConversationUpdatedEvent.class, STR."""
{
"type": "conversation:updated",
"body": {
"id": "CON-\{randomId}",
"name": "Test_conv",
"timestamp": {
"created": "2020-01-01T14:00:00.02Z",
"updated": "2020-01-01T14:05:00.00Z",
"destroyed": "2020-01-01T14:20:00.36Z"
},
"display_name": "Conversation DP",
"image_url": "https://example.org/pic.png",
"state": "ACTIVE"
}
}
"""
var event = parseEvent(EventType.CONVERSATION_UPDATED, ConversationUpdatedEvent.class, "{\n" +
" \"type\": \"conversation:updated\",\n" +
" \"body\": {\n" +
" \"id\": \"CON-" + randomId + "\",\n" +
" \"name\": \"Test_conv\",\n" +
" \"timestamp\": {\n" +
" \"created\": \"2020-01-01T14:00:00.02Z\",\n" +
" \"updated\": \"2020-01-01T14:05:00.00Z\",\n" +
" \"destroyed\": \"2020-01-01T14:20:00.36Z\"\n" +
" },\n" +
" \"display_name\": \"Conversation DP\",\n" +
" \"image_url\": \"https://example.org/pic.png\",\n" +
" \"state\": \"ACTIVE\"\n" +
" }\n" +
"}"
);
BaseConversation conversation = event.getConversation();
TestUtils.testJsonableBaseObject(conversation);
Expand Down
Loading

0 comments on commit 70ca591

Please sign in to comment.