From 8d51fe8831e533933a1bf5253b00bd05ef17490d Mon Sep 17 00:00:00 2001 From: Piotr Olaszewski Date: Tue, 15 Nov 2022 18:30:12 +0100 Subject: [PATCH] Add missing tests --- .../manager/event/BridgeCreateEventTest.java | 41 ++++++++++++++++++ .../manager/event/BridgeEnterEventTest.java | 41 ++++++++++++++++++ .../event/ConfbridgeJoinEventTest.java | 43 +++++++++++++++++++ .../event/ConfbridgeLeaveEventTest.java | 43 +++++++++++++++++++ .../manager/event/HangupEventTest.java | 43 +++++++++++++++++++ .../manager/event/HangupRequestEventTest.java | 41 ++++++++++++++++++ .../manager/event/MusicOnHoldEventTest.java | 41 ++++++++++++++++++ 7 files changed, 293 insertions(+) create mode 100644 src/test/java/org/asteriskjava/manager/event/BridgeCreateEventTest.java create mode 100644 src/test/java/org/asteriskjava/manager/event/BridgeEnterEventTest.java create mode 100644 src/test/java/org/asteriskjava/manager/event/ConfbridgeJoinEventTest.java create mode 100644 src/test/java/org/asteriskjava/manager/event/ConfbridgeLeaveEventTest.java create mode 100644 src/test/java/org/asteriskjava/manager/event/HangupEventTest.java create mode 100644 src/test/java/org/asteriskjava/manager/event/HangupRequestEventTest.java create mode 100644 src/test/java/org/asteriskjava/manager/event/MusicOnHoldEventTest.java diff --git a/src/test/java/org/asteriskjava/manager/event/BridgeCreateEventTest.java b/src/test/java/org/asteriskjava/manager/event/BridgeCreateEventTest.java new file mode 100644 index 000000000..4921541f3 --- /dev/null +++ b/src/test/java/org/asteriskjava/manager/event/BridgeCreateEventTest.java @@ -0,0 +1,41 @@ +/* + * Copyright 2004-2022 Asterisk-Java contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.asteriskjava.manager.event; + +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.HashSet; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.asteriskjava.manager.util.EventAttributesHelper.setAttributes; + +class BridgeCreateEventTest { + @Test + void shouldCreateEvent() { + //given + BridgeCreateEvent bridgeCreateEvent = new BridgeCreateEvent(new Object()); + + HashMap attributes = new HashMap<>(); + attributes.put("bridgevideosourcemode", "none"); + + //when + setAttributes(bridgeCreateEvent, attributes, new HashSet<>()); + + //then + assertThat(bridgeCreateEvent.getBridgevideosourcemode()).isNull(); + } +} diff --git a/src/test/java/org/asteriskjava/manager/event/BridgeEnterEventTest.java b/src/test/java/org/asteriskjava/manager/event/BridgeEnterEventTest.java new file mode 100644 index 000000000..75634cdc3 --- /dev/null +++ b/src/test/java/org/asteriskjava/manager/event/BridgeEnterEventTest.java @@ -0,0 +1,41 @@ +/* + * Copyright 2004-2022 Asterisk-Java contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.asteriskjava.manager.event; + +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.HashSet; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.asteriskjava.manager.util.EventAttributesHelper.setAttributes; + +class BridgeEnterEventTest { + @Test + void shouldCreateEvent() { + //given + BridgeEnterEvent bridgeEnterEvent = new BridgeEnterEvent(new Object()); + + HashMap attributes = new HashMap<>(); + attributes.put("swapuniqueid", "GW1-1517402850.50086"); + + //when + setAttributes(bridgeEnterEvent, attributes, new HashSet<>()); + + //then + assertThat(bridgeEnterEvent.getSwapuniqueid()).isEqualTo("GW1-1517402850.50086"); + } +} diff --git a/src/test/java/org/asteriskjava/manager/event/ConfbridgeJoinEventTest.java b/src/test/java/org/asteriskjava/manager/event/ConfbridgeJoinEventTest.java new file mode 100644 index 000000000..c2a3006a8 --- /dev/null +++ b/src/test/java/org/asteriskjava/manager/event/ConfbridgeJoinEventTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2004-2022 Asterisk-Java contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.asteriskjava.manager.event; + +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.HashSet; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.asteriskjava.manager.util.EventAttributesHelper.setAttributes; + +class ConfbridgeJoinEventTest { + @Test + void shouldCreateEvent() { + //given + ConfbridgeJoinEvent confbridgeJoinEvent = new ConfbridgeJoinEvent(new Object()); + + HashMap attributes = new HashMap<>(); + attributes.put("language", "en"); + attributes.put("linkedid", "1474881412.1"); + + //when + setAttributes(confbridgeJoinEvent, attributes, new HashSet<>()); + + //then + assertThat(confbridgeJoinEvent.getLanguage()).isEqualTo("en"); + assertThat(confbridgeJoinEvent.getLinkedId()).isEqualTo("1474881412.1"); + } +} diff --git a/src/test/java/org/asteriskjava/manager/event/ConfbridgeLeaveEventTest.java b/src/test/java/org/asteriskjava/manager/event/ConfbridgeLeaveEventTest.java new file mode 100644 index 000000000..5d07405cb --- /dev/null +++ b/src/test/java/org/asteriskjava/manager/event/ConfbridgeLeaveEventTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2004-2022 Asterisk-Java contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.asteriskjava.manager.event; + +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.HashSet; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.asteriskjava.manager.util.EventAttributesHelper.setAttributes; + +class ConfbridgeLeaveEventTest { + @Test + void shouldCreateEvent() { + //given + ConfbridgeLeaveEvent confbridgeLeaveEvent = new ConfbridgeLeaveEvent(new Object()); + + HashMap attributes = new HashMap<>(); + attributes.put("language", "en"); + attributes.put("linkedid", "1475486824.3"); + + //when + setAttributes(confbridgeLeaveEvent, attributes, new HashSet<>()); + + //then + assertThat(confbridgeLeaveEvent.getLanguage()).isEqualTo("en"); + assertThat(confbridgeLeaveEvent.getLinkedId()).isEqualTo("1475486824.3"); + } +} diff --git a/src/test/java/org/asteriskjava/manager/event/HangupEventTest.java b/src/test/java/org/asteriskjava/manager/event/HangupEventTest.java new file mode 100644 index 000000000..d0929c63e --- /dev/null +++ b/src/test/java/org/asteriskjava/manager/event/HangupEventTest.java @@ -0,0 +1,43 @@ +/* + * Copyright 2004-2022 Asterisk-Java contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.asteriskjava.manager.event; + +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + +import java.util.HashMap; +import java.util.HashSet; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.asteriskjava.manager.util.EventAttributesHelper.setAttributes; + +class HangupEventTest { + @ParameterizedTest + @ValueSource(strings = {"False", "762377"}) + void shouldCreateEvent(String accountCode) { + //given + HangupEvent hangupEvent = new HangupEvent(new Object()); + + HashMap attributes = new HashMap<>(); + attributes.put("accountcode", accountCode); + + //when + setAttributes(hangupEvent, attributes, new HashSet<>()); + + //then + assertThat(hangupEvent.getAccountCode()).isEqualTo(accountCode); + } +} diff --git a/src/test/java/org/asteriskjava/manager/event/HangupRequestEventTest.java b/src/test/java/org/asteriskjava/manager/event/HangupRequestEventTest.java new file mode 100644 index 000000000..bad0c3377 --- /dev/null +++ b/src/test/java/org/asteriskjava/manager/event/HangupRequestEventTest.java @@ -0,0 +1,41 @@ +/* + * Copyright 2004-2022 Asterisk-Java contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.asteriskjava.manager.event; + +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.HashSet; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.asteriskjava.manager.util.EventAttributesHelper.setAttributes; + +class HangupRequestEventTest { + @Test + void shouldCreateEvent() { + //given + HangupRequestEvent hangupRequestEvent = new HangupRequestEvent(new Object()); + + HashMap attributes = new HashMap<>(); + attributes.put("cause", "1"); + + //when + setAttributes(hangupRequestEvent, attributes, new HashSet<>()); + + //then + assertThat(hangupRequestEvent.getCause()).isEqualTo(1); + } +} diff --git a/src/test/java/org/asteriskjava/manager/event/MusicOnHoldEventTest.java b/src/test/java/org/asteriskjava/manager/event/MusicOnHoldEventTest.java new file mode 100644 index 000000000..c4d64ee5a --- /dev/null +++ b/src/test/java/org/asteriskjava/manager/event/MusicOnHoldEventTest.java @@ -0,0 +1,41 @@ +/* + * Copyright 2004-2022 Asterisk-Java contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.asteriskjava.manager.event; + +import org.junit.jupiter.api.Test; + +import java.util.HashMap; +import java.util.HashSet; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.asteriskjava.manager.util.EventAttributesHelper.setAttributes; + +class MusicOnHoldEventTest { + @Test + void shouldCreateEvent() { + //given + MusicOnHoldEvent musicOnHoldEvent = new MusicOnHoldEvent(new Object()); + + HashMap attributes = new HashMap<>(); + attributes.put("class", "default"); + + //when + setAttributes(musicOnHoldEvent, attributes, new HashSet<>()); + + //then + assertThat(musicOnHoldEvent.getClassName()).isEqualTo("default"); + } +}