Skip to content

Commit dd52876

Browse files
committed
Add Sip constructor that takes a URI
Add a constructor to the Sip Noun with a text element URI. Previously, the only way to do this was to append a Uri Noun to the Sip Noun. Also, add a couple of unit tests.
1 parent 2ac3338 commit dd52876

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

src/main/java/com/twilio/sdk/verbs/Sip.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,19 @@ public class Sip extends Verb {
88
/**
99
* Instantiates a new Sip.
1010
*/
11-
public Sip() {
12-
super(V_SIP, null);
11+
public Sip(final String uri) {
12+
super(V_SIP, uri);
1313
this.allowedVerbs = new ArrayList<String>();
1414
this.allowedVerbs.add(Verb.V_URI);
1515
}
1616

17+
/**
18+
* Instantiates a new Sip Noun with no URI.
19+
*/
20+
public Sip() {
21+
this(null);
22+
}
23+
1724
public void setUsername(String username) {
1825
this.set("username", username);
1926
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.twilio.sdk.verbs;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.assertEquals;
6+
7+
public class SipTest {
8+
9+
/**
10+
* Test the SIP noun with a text element representing the URI.
11+
*/
12+
@Test
13+
public void testBasicSip() {
14+
Sip sip = new Sip("sip:alice@twilio.com;transport=udp");
15+
assertEquals("<Sip>sip:alice@twilio.com;transport=udp</Sip>", sip.toXML());
16+
}
17+
18+
/**
19+
* Test the SIP noun with a child URI noun.
20+
* @throws TwiMLException
21+
*/
22+
@Test
23+
public void testSipUriNoun() throws TwiMLException {
24+
Sip sip = new Sip();
25+
Uri uri = new Uri("sip:alice@twilio.com;transport=udp");
26+
uri.setUsername("alice");
27+
uri.setPassword("hellotwilio");
28+
sip.append(uri);
29+
assertEquals("<Sip><Uri username=\"alice\" password=\"hellotwilio\">sip:alice@twilio.com;transport=udp</Uri></Sip>",
30+
sip.toXML());
31+
}
32+
}

0 commit comments

Comments
 (0)