diff --git a/src/main/java/com/vonage/client/meetings/RoomLanguage.java b/src/main/java/com/vonage/client/meetings/RoomLanguage.java index af03fe8a5..94f7543a3 100644 --- a/src/main/java/com/vonage/client/meetings/RoomLanguage.java +++ b/src/main/java/com/vonage/client/meetings/RoomLanguage.java @@ -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 */ @@ -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; @@ -75,6 +106,6 @@ public static RoomLanguage fromString(String value) { @JsonValue @Override public String toString() { - return name().toLowerCase(); + return name().replace('_', '-'); } } diff --git a/src/test/java/com/vonage/client/meetings/MeetingRoomTest.java b/src/test/java/com/vonage/client/meetings/MeetingRoomTest.java index c6a58a7a7..37e4ff39c 100644 --- a/src/test/java/com/vonage/client/meetings/MeetingRoomTest.java +++ b/src/test/java/com/vonage/client/meetings/MeetingRoomTest.java @@ -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; @@ -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 @@ -324,8 +324,7 @@ 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()); @@ -333,11 +332,20 @@ public void testInvalidEnums() { 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()); } } \ No newline at end of file diff --git a/src/test/java/com/vonage/client/meetings/MeetingsClientTest.java b/src/test/java/com/vonage/client/meetings/MeetingsClientTest.java index 65b6c7002..5686572fc 100644 --- a/src/test/java/com/vonage/client/meetings/MeetingsClientTest.java +++ b/src/test/java/com/vonage/client/meetings/MeetingsClientTest.java @@ -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\"}," +