Skip to content

Commit de1361c

Browse files
DX-3199, DX-3200, DX-3192, DX-3294
Added Pause Verb and refactored Ring Test
1 parent 858d302 commit de1361c

File tree

3 files changed

+91
-6
lines changed

3 files changed

+91
-6
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.openapitools.client.model.bxml.verbs;
2+
3+
import org.openapitools.client.model.bxml.TerminalVerb;
4+
5+
import com.fasterxml.jackson.annotation.JsonIgnore;
6+
import com.fasterxml.jackson.core.JsonProcessingException;
7+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
8+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
9+
10+
import lombok.Data;
11+
12+
@Data
13+
public class Pause extends TerminalVerb {
14+
15+
@JacksonXmlProperty(isAttribute = true)
16+
private String duration;
17+
@JsonIgnore
18+
private String tag;
19+
20+
public Pause() {
21+
super("Pause", null);
22+
}
23+
24+
public Pause(String duration) {
25+
super("Pause", null);
26+
this.duration = duration;
27+
}
28+
29+
@Override
30+
public String toBxml() throws JsonProcessingException {
31+
XmlMapper xmlMapper = new XmlMapper();
32+
xmlMapper.writerWithDefaultPrettyPrinter();
33+
return xmlMapper.writer().withRootName(tag).writeValueAsString(this);
34+
}
35+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package org.openapitools.client.model.unit.bxml;
2+
3+
import org.openapitools.client.model.bxml.Verb;
4+
import org.openapitools.client.model.bxml.verbs.Pause;
5+
6+
import org.junit.Test;
7+
import org.junit.jupiter.api.Assertions;
8+
9+
import static org.hamcrest.MatcherAssert.assertThat;
10+
import static org.hamcrest.CoreMatchers.instanceOf;
11+
import static org.hamcrest.Matchers.is;
12+
13+
14+
public class PauseVerbTest {
15+
16+
/**
17+
* Setting up Variables
18+
*/
19+
20+
Pause pause = new Pause("10");
21+
Pause pause2 = new Pause();
22+
Verb verb = new Verb("TestVerb", "test");
23+
24+
/**
25+
*
26+
*
27+
* Unit tests for Pause Verb class
28+
*
29+
* @throws Exception if the test fails
30+
*/
31+
32+
@Test
33+
public void testPauseVerbSerialization() throws Exception {
34+
String expectedBxml = "<Pause duration=\"10\"/>";
35+
pause2.setDuration("10");
36+
37+
assertThat(pause, instanceOf(Pause.class));
38+
assertThat(pause.toBxml(), is(expectedBxml));
39+
assertThat(pause2, instanceOf(Pause.class));
40+
assertThat(pause2.toBxml(), is(expectedBxml));
41+
};
42+
43+
@Test
44+
public void testAddingVerbsToRingVerb() throws UnsupportedOperationException {
45+
UnsupportedOperationException exception = Assertions.assertThrows(UnsupportedOperationException.class, () -> pause.addVerb(verb));
46+
assertThat(exception, instanceOf(UnsupportedOperationException.class));
47+
};
48+
};

src/test/java/org/openapitools/client/model/unit/bxml/RingVerbTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ public class RingVerbTest {
1717
* Setting up Variables
1818
*/
1919

20-
Ring ringVerb = new Ring("10", "false");
20+
Ring ring = new Ring("10", "false");
21+
Ring ring2 = new Ring();
2122
Verb verb = new Verb("TestVerb", "test");
2223

2324
/**
@@ -31,16 +32,17 @@ public class RingVerbTest {
3132
@Test
3233
public void testRingVerbSerialization() throws Exception {
3334
String expectedBxml = "<Ring duration=\"10\" answerCall=\"false\"/>";
34-
System.out.println(expectedBxml);
35-
System.out.println(ringVerb.toBxml());
35+
ring2.setAnswerCall("false");
36+
ring2.setDuration("10");
3637

37-
assertThat(ringVerb, instanceOf(Ring.class));
38-
assertThat(ringVerb.toBxml(), is(expectedBxml));
38+
assertThat(ring, instanceOf(Ring.class));
39+
assertThat(ring.toBxml(), is(expectedBxml));
40+
assertThat(ring2.toBxml(), is(expectedBxml));
3941
};
4042

4143
@Test
4244
public void testAddingVerbsToRingVerb() throws UnsupportedOperationException {
43-
UnsupportedOperationException exception = Assertions.assertThrows(UnsupportedOperationException.class, () -> ringVerb.addVerb(verb));
45+
UnsupportedOperationException exception = Assertions.assertThrows(UnsupportedOperationException.class, () -> ring.addVerb(verb));
4446
assertThat(exception, instanceOf(UnsupportedOperationException.class));
4547
};
4648
};

0 commit comments

Comments
 (0)