diff --git a/src/main/java/org/asteriskjava/manager/event/AbstractChannelTalkingEvent.java b/src/main/java/org/asteriskjava/manager/event/AbstractChannelTalkingEvent.java new file mode 100644 index 000000000..e2a278ab6 --- /dev/null +++ b/src/main/java/org/asteriskjava/manager/event/AbstractChannelTalkingEvent.java @@ -0,0 +1,59 @@ +/* + * 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; + +public abstract class AbstractChannelTalkingEvent extends ManagerEvent { + private String language; + private String accountCode; + private String uniqueId; + private String linkedId; + + public AbstractChannelTalkingEvent(Object source) { + super(source); + } + + public String getLanguage() { + return language; + } + + public void setLanguage(String language) { + this.language = language; + } + + public String getAccountCode() { + return accountCode; + } + + public void setAccountCode(String accountCode) { + this.accountCode = accountCode; + } + + public String getUniqueId() { + return uniqueId; + } + + public void setUniqueId(String uniqueId) { + this.uniqueId = uniqueId; + } + + public String getLinkedId() { + return linkedId; + } + + public void setLinkedId(String linkedId) { + this.linkedId = linkedId; + } +} diff --git a/src/main/java/org/asteriskjava/manager/event/ChannelTalkingStartEvent.java b/src/main/java/org/asteriskjava/manager/event/ChannelTalkingStartEvent.java new file mode 100644 index 000000000..e305d69f3 --- /dev/null +++ b/src/main/java/org/asteriskjava/manager/event/ChannelTalkingStartEvent.java @@ -0,0 +1,22 @@ +/* + * 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; + +public class ChannelTalkingStartEvent extends AbstractChannelTalkingEvent { + public ChannelTalkingStartEvent(Object source) { + super(source); + } +} diff --git a/src/main/java/org/asteriskjava/manager/event/ChannelTalkingStopEvent.java b/src/main/java/org/asteriskjava/manager/event/ChannelTalkingStopEvent.java new file mode 100644 index 000000000..6e0968e5d --- /dev/null +++ b/src/main/java/org/asteriskjava/manager/event/ChannelTalkingStopEvent.java @@ -0,0 +1,32 @@ +/* + * 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; + +public class ChannelTalkingStopEvent extends AbstractChannelTalkingEvent { + private Long duration; + + public ChannelTalkingStopEvent(Object source) { + super(source); + } + + public Long getDuration() { + return duration; + } + + public void setDuration(Long duration) { + this.duration = duration; + } +} diff --git a/src/test/java/org/asteriskjava/manager/event/ChannelTalkingStartEventTest.java b/src/test/java/org/asteriskjava/manager/event/ChannelTalkingStartEventTest.java new file mode 100644 index 000000000..b51997795 --- /dev/null +++ b/src/test/java/org/asteriskjava/manager/event/ChannelTalkingStartEventTest.java @@ -0,0 +1,53 @@ +/* + * 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 ChannelTalkingStartEventTest { + @Test + void shouldCreateEvent() { + //given + ChannelTalkingStartEvent channelTalkingStartEvent = new ChannelTalkingStartEvent(new Object()); + + HashMap attributes = new HashMap<>(); + attributes.put("language", "en"); + attributes.put("accountcode", ""); + attributes.put("context", "phones"); + attributes.put("exten", "5"); + attributes.put("priority", "4"); + attributes.put("uniqueid", "1547252114.0"); + attributes.put("linkedid", "1547252114.0"); + + //when + setAttributes(channelTalkingStartEvent, attributes, new HashSet<>()); + + //then + assertThat(channelTalkingStartEvent.getLanguage()).isEqualTo("en"); + assertThat(channelTalkingStartEvent.getAccountCode()).isEqualTo(""); + assertThat(channelTalkingStartEvent.getContext()).isEqualTo("phones"); + assertThat(channelTalkingStartEvent.getExten()).isEqualTo("5"); + assertThat(channelTalkingStartEvent.getPriority()).isEqualTo(4); + assertThat(channelTalkingStartEvent.getUniqueId()).isEqualTo("1547252114.0"); + assertThat(channelTalkingStartEvent.getLinkedId()).isEqualTo("1547252114.0"); + } +} diff --git a/src/test/java/org/asteriskjava/manager/event/ChannelTalkingStopEventTest.java b/src/test/java/org/asteriskjava/manager/event/ChannelTalkingStopEventTest.java new file mode 100644 index 000000000..db0115041 --- /dev/null +++ b/src/test/java/org/asteriskjava/manager/event/ChannelTalkingStopEventTest.java @@ -0,0 +1,55 @@ +/* + * 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 ChannelTalkingStopEventTest { + @Test + void shouldCreateEvent() { + //given + ChannelTalkingStopEvent channelTalkingStopEvent = new ChannelTalkingStopEvent(new Object()); + + HashMap attributes = new HashMap<>(); + attributes.put("language", "en"); + attributes.put("accountcode", ""); + attributes.put("context", "phones"); + attributes.put("exten", "5"); + attributes.put("priority", "4"); + attributes.put("uniqueid", "1547252114.0"); + attributes.put("linkedid", "1547252114.0"); + attributes.put("duration", "6030"); + + //when + setAttributes(channelTalkingStopEvent, attributes, new HashSet<>()); + + //then + assertThat(channelTalkingStopEvent.getLanguage()).isEqualTo("en"); + assertThat(channelTalkingStopEvent.getAccountCode()).isEqualTo(""); + assertThat(channelTalkingStopEvent.getContext()).isEqualTo("phones"); + assertThat(channelTalkingStopEvent.getExten()).isEqualTo("5"); + assertThat(channelTalkingStopEvent.getPriority()).isEqualTo(4); + assertThat(channelTalkingStopEvent.getUniqueId()).isEqualTo("1547252114.0"); + assertThat(channelTalkingStopEvent.getLinkedId()).isEqualTo("1547252114.0"); + assertThat(channelTalkingStopEvent.getDuration()).isEqualTo(6030); + } +}