File tree Expand file tree Collapse file tree 7 files changed +201
-10
lines changed
main/java/org/openapitools/client/model/bxml
test/java/org/openapitools/client/model/unit/bxml Expand file tree Collapse file tree 7 files changed +201
-10
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ public void addVerb(Verb verb) {
3131
3232 @ Override
3333 public String toBxml () throws JsonProcessingException {
34- ObjectMapper mapper = new ObjectMapper ();
3534 XmlMapper xmlMapper = new XmlMapper ();
3635 xmlMapper .writerWithDefaultPrettyPrinter ();
3736 return xmlMapper .writer ().withRootName (tag ).writeValueAsString (this .content );
Original file line number Diff line number Diff line change 1+ package org .openapitools .client .model .bxml .verbs ;
2+
3+ import org .openapitools .client .model .bxml .TerminalVerb ;
4+
5+
6+ public class Hangup extends TerminalVerb {
7+
8+ public Hangup () {
9+ super ("Hangup" , null );
10+ }
11+ }
Original file line number Diff line number Diff line change 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 .databind .node .ObjectNode ;
8+ import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
9+ import com .fasterxml .jackson .dataformat .xml .annotation .JacksonXmlProperty ;
10+
11+ import lombok .Data ;
12+
13+ @ Data
14+ public class Ring extends TerminalVerb {
15+
16+ @ JacksonXmlProperty (isAttribute = true )
17+ private String duration ;
18+ @ JacksonXmlProperty (isAttribute = true )
19+ private String answerCall ;
20+ @ JsonIgnore
21+ private String tag ;
22+
23+ public Ring () {
24+ super ("Ring" , null );
25+ }
26+
27+ public Ring (String duration ) {
28+ super ("Ring" , null );
29+ this .duration = duration ;
30+ }
31+
32+ public Ring (String duration , String answerCall ) {
33+ super ("Ring" , null );
34+ this .duration = duration ;
35+ this .answerCall = answerCall ;
36+
37+ }
38+
39+ @ Override
40+ public String toBxml () throws JsonProcessingException {
41+ XmlMapper xmlMapper = new XmlMapper ();
42+ xmlMapper .writerWithDefaultPrettyPrinter ();
43+ return xmlMapper .writer ().withRootName (tag ).writeValueAsString (this );
44+ }
45+ }
Original file line number Diff line number Diff line change 11package org .openapitools .client .model .bxml .verbs ;
22
33import org .openapitools .client .model .bxml .TerminalVerb ;
4- import org .openapitools .client .model .bxml .Root ;
54
6- import com .fasterxml .jackson .annotation . JsonProperty ;
7- import com .fasterxml .jackson .dataformat .xml .annotation . JacksonXmlText ;
5+ import com .fasterxml .jackson .core . JsonProcessingException ;
6+ import com .fasterxml .jackson .dataformat .xml .XmlMapper ;
87
98public class Tag extends TerminalVerb {
109
11- @ JacksonXmlText ()
12- private String content ;
13-
1410 public Tag () {
15- super ("Tag" );
11+ super ();
1612 }
1713
1814 public Tag (String content ) {
19- super ("Tag" );
20- this .content = content ;
15+ super ("Tag" ,content );
2116 }
2217
2318 @ Override
@@ -29,4 +24,11 @@ public String getContent() {
2924 public void setContent (String content ) {
3025 this .content = content ;
3126 }
27+
28+ @ Override
29+ public String toBxml () throws JsonProcessingException {
30+ XmlMapper xmlMapper = new XmlMapper ();
31+ xmlMapper .writerWithDefaultPrettyPrinter ();
32+ return xmlMapper .writer ().withRootName (tag ).writeValueAsString (this .content );
33+ }
3234}
Original file line number Diff line number Diff line change 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 .Hangup ;
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 HangupVerbTest {
15+
16+ /**
17+ * Setting up Variables
18+ */
19+
20+ Hangup hangupVerb = new Hangup ();
21+ Verb verb = new Verb ("TestVerb" , "test" );
22+
23+ /**
24+ *
25+ *
26+ * Unit tests for Hangup Verb class
27+ *
28+ * @throws Exception if the test fails
29+ */
30+
31+ @ Test
32+ public void testHangupVerbSerialization () throws Exception {
33+ String expectedBxml = "<Hangup/>" ;
34+
35+ assertThat (hangupVerb , instanceOf (Hangup .class ));
36+ assertThat (hangupVerb .toBxml (), is (expectedBxml ));
37+ };
38+
39+ @ Test
40+ public void testAddingVerbsToHangup () throws UnsupportedOperationException {
41+ UnsupportedOperationException exception = Assertions .assertThrows (UnsupportedOperationException .class , () -> hangupVerb .addVerb (verb ));
42+ assertThat (exception , instanceOf (UnsupportedOperationException .class ));
43+ };
44+ };
Original file line number Diff line number Diff line change 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 .Ring ;
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 RingVerbTest {
15+
16+ /**
17+ * Setting up Variables
18+ */
19+
20+ Ring ringVerb = new Ring ("10" , "false" );
21+ Verb verb = new Verb ("TestVerb" , "test" );
22+
23+ /**
24+ *
25+ *
26+ * Unit tests for Ring Verb class
27+ *
28+ * @throws Exception if the test fails
29+ */
30+
31+ @ Test
32+ public void testRingVerbSerialization () throws Exception {
33+ String expectedBxml = "<Ring duration=\" 10\" answerCall=\" false\" />" ;
34+ System .out .println (expectedBxml );
35+ System .out .println (ringVerb .toBxml ());
36+
37+ assertThat (ringVerb , instanceOf (Ring .class ));
38+ assertThat (ringVerb .toBxml (), is (expectedBxml ));
39+ };
40+
41+ @ Test
42+ public void testAddingVerbsToRingVerb () throws UnsupportedOperationException {
43+ UnsupportedOperationException exception = Assertions .assertThrows (UnsupportedOperationException .class , () -> ringVerb .addVerb (verb ));
44+ assertThat (exception , instanceOf (UnsupportedOperationException .class ));
45+ };
46+ };
Original file line number Diff line number Diff line change 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 .Tag ;
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 TagVerbTest {
15+
16+ /**
17+ * Setting up Variables
18+ */
19+
20+ Tag tagVerb = new Tag ("Tag Test Content" );
21+ Verb verb = new Verb ("TestVerb" , "test" );
22+
23+ /**
24+ *
25+ *
26+ * Unit tests for Tag Verb class
27+ *
28+ * @throws Exception if the test fails
29+ */
30+
31+ @ Test
32+ public void testTagVerbSerialization () throws Exception {
33+ String expectedBxml = "<Tag>Tag Test Content</Tag>" ;
34+
35+ assertThat (tagVerb , instanceOf (Tag .class ));
36+ assertThat (tagVerb .toBxml (), is (expectedBxml ));
37+ };
38+
39+ @ Test
40+ public void testAddingVerbsToTerminalVerb () throws UnsupportedOperationException {
41+ UnsupportedOperationException exception = Assertions .assertThrows (UnsupportedOperationException .class , () -> tagVerb .addVerb (verb ));
42+ assertThat (exception , instanceOf (UnsupportedOperationException .class ));
43+ };
44+ };
You can’t perform that action at this time.
0 commit comments