Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update Meetings languages #487

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 34 additions & 3 deletions src/main/java/com/vonage/client/meetings/RoomLanguage.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,19 @@ public enum RoomLanguage {

/**
* Portuguese
*
* @deprecated Replaced by {@link #PT_BR}.
*/
@Deprecated
PT,

/**
* Brazilian Portuguese
*
* @since 7.10.0
*/
PT_BR,

/**
* Italian
*/
Expand All @@ -60,12 +70,33 @@ public enum RoomLanguage {
/**
* German
*/
DE;
DE,

/**
* Arabic
*
* @since 7.10.0
*/
AR,

/**
* Chinese (Taiwan)
*
* @since 7.10.0
*/
ZH_TW,

/**
* Chinese (Mainland)
*
* @since 7.10.0
*/
ZH_CN;

@JsonCreator
public static RoomLanguage fromString(String value) {
try {
return valueOf(value.toUpperCase());
return valueOf(value.toUpperCase().replace('-', '_'));
}
catch (NullPointerException | IllegalArgumentException ex) {
return null;
Expand All @@ -75,6 +106,6 @@ public static RoomLanguage fromString(String value) {
@JsonValue
@Override
public String toString() {
return name().toLowerCase();
return name().replace('_', '-');
}
}
22 changes: 15 additions & 7 deletions src/test/java/com/vonage/client/meetings/MeetingRoomTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import com.vonage.client.VonageResponseParseException;
import com.vonage.client.VonageUnexpectedException;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import java.net.URI;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
Expand Down Expand Up @@ -292,9 +292,9 @@ public void testParseEmptyContainers() {
assertNull(response.getLinks().getHostUrl());
}

@Test(expected = VonageUnexpectedException.class)
@Test
public void testFromJsonInvalid() {
MeetingRoom.fromJson("{malformed]");
assertThrows(VonageResponseParseException.class, () -> MeetingRoom.fromJson("{malformed]"));
}

@Test
Expand Down Expand Up @@ -324,20 +324,28 @@ public void testInvalidEnums() {
MeetingRoom room = MeetingRoom.fromJson(
"{\"join_approval_level\":\"bar\"," +
"\"initial_join_options\":{\"microphone_state\":\"bombastic\"}," +
"\"type\":\"casual\"," +
"\"ui_settings\":{\"language\":\"yoda\"}}"
"\"type\":\"casual\",\"ui_settings\":{\"language\":\"yoda\"}}"
);
assertNull(room.getJoinApprovalLevel());
assertNull(room.getInitialJoinOptions().getMicrophoneState());
assertNull(room.getType());
assertNull(room.getUiSettings().getLanguage());
}

@Test(expected = VonageUnexpectedException.class)
@Test
public void testRoomLanguageEnum() {
assertEquals(RoomLanguage.DE, RoomLanguage.fromString("de"));
assertEquals(RoomLanguage.AR, RoomLanguage.fromString("AR"));
assertEquals(RoomLanguage.ZH_CN, RoomLanguage.fromString("zh-CN"));
assertEquals("PT-BR", RoomLanguage.PT_BR.toString());
assertEquals("ZH-TW", RoomLanguage.ZH_TW.toString());
}

@Test
public void triggerJsonProcessingException() {
class SelfRefrencing extends MeetingRoom {
@JsonProperty("self") final SelfRefrencing self = this;
}
new SelfRefrencing().toJson();
assertThrows(VonageUnexpectedException.class, () -> new SelfRefrencing().toJson());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ protected String sampleRequestBodyString() {
"\"join_approval_level\":\"explicit_approval\",\"recording_options\":" +
"{\"auto_record\":true,\"record_only_owner\":false}," +
"\"initial_join_options\":{\"microphone_state\":\"off\"}," +
"\"ui_settings\":{\"language\":\"it\"},\"callback_urls\":" +
"\"ui_settings\":{\"language\":\"IT\"},\"callback_urls\":" +
"{\"rooms_callback_url\":\"example.com/ro\"," +
"\"sessions_callback_url\":\"example.com/se\"," +
"\"recordings_callback_url\":\"example.com/re\"}," +
Expand Down