Skip to content

Commit 3e7353a

Browse files
authored
Merge pull request #195 from surik/depricate-callflow-title
Deprecate CallFlow Title usage
2 parents 3092647 + 66d6526 commit 3e7353a

15 files changed

+69
-16
lines changed

api/src/main/java/com/messagebird/MessageBirdServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ private void handleHttpFailStatuses(final int status, String body) throws Unauth
363363
<P> APIResponse doRequest(final String method, final String url, final Map<String, String> headers, final P payload) throws GeneralException {
364364
HttpURLConnection connection = null;
365365
InputStream inputStream = null;
366-
366+
367367
if (METHOD_PATCH.equalsIgnoreCase(method)) {
368368
// It'd perhaps be cleaner to call this in the constructor, but
369369
// we'd then need to throw GeneralExceptions from there. This means

api/src/main/java/com/messagebird/objects/voicecalls/VoiceCallFlow.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ public void setId(String id) {
3737
this.id = id;
3838
}
3939

40+
@Deprecated
4041
public String getTitle() {
4142
return title;
4243
}
4344

45+
@Deprecated
4446
public void setTitle(String title) {
4547
this.title = title;
4648
}

api/src/main/java/com/messagebird/objects/voicecalls/VoiceCallFlowRequest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ public void setId(String id) {
3636
this.id = id;
3737
}
3838

39+
@Deprecated
3940
public String getTitle() {
4041
return title;
4142
}
4243

44+
@Deprecated
4345
public void setTitle(String title) {
4446
this.title = title;
4547
}

api/src/test/java/com/messagebird/MessageBirdClientTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ public void shouldThrowIllegalArgumentExceptionWhenSourceOfVoiceCallIsMissing()
427427
voiceCall.setDestination("ANY_DESTINATION");
428428

429429
final VoiceCallFlow voiceCallFlow = new VoiceCallFlow();
430-
voiceCallFlow.setTitle("Test title");
431430
VoiceStep voiceStep = new VoiceStep();
432431
voiceStep.setAction("say");
433432

@@ -448,7 +447,6 @@ public void shouldThrowIllegalArgumentExceptionWhenDestinationOfVoiceCallIsMissi
448447
voiceCall.setSource("ANY_SOURCE");
449448

450449
final VoiceCallFlow voiceCallFlow = new VoiceCallFlow();
451-
voiceCallFlow.setTitle("Test title");
452450
VoiceStep voiceStep = new VoiceStep();
453451
voiceStep.setAction("say");
454452

api/src/test/java/com/messagebird/SpyService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static <P> SpyService expects(final String method, final String url, final P pay
7070
service.method = method;
7171
service.url = url;
7272
service.payload = payload;
73-
73+
7474
return service;
7575
}
7676

api/src/test/java/com/messagebird/TestUtil.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ static VoiceCall createVoiceCall(String destination) {
2828
voiceCall.setDestination(destination);
2929

3030
final VoiceCallFlow voiceCallFlow = new VoiceCallFlow();
31-
voiceCallFlow.setTitle("Test title");
3231
VoiceStep voiceStep = new VoiceStep();
3332
voiceStep.setAction("say");
3433

@@ -211,7 +210,6 @@ public static VoiceStep createVoiceStep() {
211210

212211
public static VoiceCallFlowRequest createVoiceCallFlowRequest() {
213212
final VoiceCallFlowRequest voiceCallFlow = new VoiceCallFlowRequest();
214-
voiceCallFlow.setTitle("ANY_TITLE");
215213
voiceCallFlow.setRecord(true);
216214
voiceCallFlow.setSteps(Collections.singletonList(createVoiceStep()));
217215
voiceCallFlow.setDefaultCall(true);

api/src/test/java/com/messagebird/VoiceCallFlowTest.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ public void testView() throws GeneralException, UnauthorizedException, NotFoundE
6464
this.testVoiceCallFlowAgainstFixture(voiceCallFlow);
6565
}
6666

67+
@Test
68+
public void testViewTitlePresent() throws GeneralException, UnauthorizedException, NotFoundException {
69+
String responseFixture = Resources.readResourceText("/fixtures/call_flow_view_title.json");
70+
MessageBirdService messageBirdService = SpyService
71+
.expects("GET", "call-flows/e781a76f-14ad-45b0-8490-409300244e20")
72+
.withVoiceCallAPIBaseURL()
73+
.andReturns(new APIResponse(responseFixture));
74+
MessageBirdClient messageBirdClient = new MessageBirdClient(messageBirdService);
75+
VoiceCallFlow voiceCallFlow = messageBirdClient
76+
.viewVoiceCallFlow("e781a76f-14ad-45b0-8490-409300244e20")
77+
.getData()
78+
.get(0);
79+
this.testVoiceCallFlowAgainstFixture(voiceCallFlow, true);
80+
}
81+
6782
@Test (expected = IllegalArgumentException.class)
6883
public void testViewShouldThrowInvalidArgumentException() throws NotFoundException, GeneralException, UnauthorizedException {
6984
String responseFixture = Resources.readResourceText("/fixtures/call_flow_view.json");
@@ -81,7 +96,6 @@ public void testUpdate() throws GeneralException, UnauthorizedException, NotFoun
8196
String responseFixture = Resources.readResourceText("/fixtures/call_flow_update_response.json");
8297

8398
VoiceCallFlowRequest voiceCallFlowRequest = new VoiceCallFlowRequest("e781a76f-14ad-45b0-8490-409300244e20");
84-
voiceCallFlowRequest.setTitle("Forward call to 316123456782");
8599
voiceCallFlowRequest.setDefaultCall(true);
86100
voiceCallFlowRequest.setRecord(true);
87101
voiceCallFlowRequest.setSteps(
@@ -220,9 +234,15 @@ public void testDeleteIllegalArgumentException() throws NotFoundException, Gener
220234
* In order to reuse this method for further tests you need to make sure that the fixtures
221235
* match the date in this test. See call_flows_post.json
222236
*/
237+
223238
private void testVoiceCallFlowAgainstFixture(VoiceCallFlow voiceCallFlow) {
239+
testVoiceCallFlowAgainstFixture(voiceCallFlow, false);
240+
}
241+
242+
private void testVoiceCallFlowAgainstFixture(VoiceCallFlow voiceCallFlow, boolean hasTitle) {
224243
assertEquals(voiceCallFlow.getId(), "e781a76f-14ad-45b0-8490-409300244e20");
225-
assertEquals(voiceCallFlow.getTitle(), "Forward call to 31612345678");
244+
if (!hasTitle) assertEquals(voiceCallFlow.getTitle(), null);
245+
if (hasTitle) assertNotEquals(voiceCallFlow.getTitle(), null);
226246
assertEquals(voiceCallFlow.isRecord(), true);
227247
assertEquals(voiceCallFlow.isDefaultCall(), false);
228248
assertEquals(voiceCallFlow.getCreatedAt().toString(), "Tue Aug 06 16:13:06 CEST 2019");

api/src/test/resources/fixtures/call_flow_update_response.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"data": [
33
{
44
"id": "e781a76f-14ad-45b0-8490-409300244e20",
5-
"title": "Forward call to 31612345678",
65
"steps": [
76
{
87
"id": "a8e44a38-b935-482f-b17f-ed3472c6292c",

api/src/test/resources/fixtures/call_flow_view.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"data": [
33
{
44
"id": "e781a76f-14ad-45b0-8490-409300244e20",
5-
"title": "Forward call to 31612345678",
65
"steps": [
76
{
87
"id": "a8e44a38-b935-482f-b17f-ed3472c6292c",
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"data": [
3+
{
4+
"title": "Call title",
5+
"id": "e781a76f-14ad-45b0-8490-409300244e20",
6+
"steps": [
7+
{
8+
"id": "a8e44a38-b935-482f-b17f-ed3472c6292c",
9+
"action": "transfer",
10+
"options": {
11+
"destination" : "31612345678",
12+
"payload" : "Test payload",
13+
"language" : "en-GB",
14+
"voice" : "male",
15+
"repeat" : 1,
16+
"media" : "test.mp3",
17+
"length" : 1,
18+
"maxLength" : 2,
19+
"timeout" : 3,
20+
"finishOnKey" : "1",
21+
"transcribe" : "false",
22+
"transcribeLanguage" : "en-GB",
23+
"record" : "both",
24+
"url" : "http://",
25+
"ifMachine" : "ifMachine",
26+
"machineTimeout" : 200,
27+
"onFinish" : "http://",
28+
"mask" : false
29+
}
30+
}
31+
],
32+
"record": true,
33+
"default": false,
34+
"createdAt": "2019-08-06T14:13:06Z",
35+
"updatedAt": "2019-08-06T14:13:06Z"
36+
}
37+
],
38+
"_links": {
39+
"self": "/call-flows/70fbdda2-4f1f-44ce-8792-75af32cf598c"
40+
}
41+
}

api/src/test/resources/fixtures/call_flows_list.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"data": [
33
{
44
"id": "e781a76f-14ad-45b0-8490-409300244e20",
5-
"title": "Forward call to 31612345678",
65
"steps": [
76
{
87
"id": "a8e44a38-b935-482f-b17f-ed3472c6292c",

api/src/test/resources/fixtures/call_flows_post.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"data": [
33
{
44
"id": "e781a76f-14ad-45b0-8490-409300244e20",
5-
"title": "Forward call to 31612345678",
65
"steps": [
76
{
87
"id": "a8e44a38-b935-482f-b17f-ed3472c6292c",

examples/src/main/java/ExampleCreateVoiceCallFlow.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public static void main(String[] args) {
2424

2525
final VoiceCallFlowRequest voiceCallFlowRequest = new VoiceCallFlowRequest();
2626

27-
voiceCallFlowRequest.setTitle(args[1]);
2827
voiceCallFlowRequest.setRecord(true); // Can be false as well, see docs
2928
VoiceStep voiceStep = new VoiceStep();
3029
voiceCallFlowRequest.setSteps(Collections.singletonList(voiceStep)); // VoiceStep Object

examples/src/main/java/ExampleSendVoiceCall.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ public static void main(String[] args) {
3333
voiceCall.setDestination(args[1]);
3434
voiceCall.setWebhook("https://example.com/","foobar");
3535

36-
//Title and steps are required fields for creating callFlow
3736
final VoiceCallFlow voiceCallFlow = new VoiceCallFlow();
38-
voiceCallFlow.setTitle("Test title");
3937
//action is required
4038
VoiceStep voiceStep = new VoiceStep();
4139
voiceStep.setAction("say");

examples/src/main/java/ExampleUpdateVoiceCallFlow.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public static void main(String[] args) {
2424

2525
final VoiceCallFlowRequest voiceCallFlowRequest = new VoiceCallFlowRequest();
2626

27-
voiceCallFlowRequest.setTitle(args[2]);
2827
voiceCallFlowRequest.setRecord(true); // Can be false as well, see docs
2928
VoiceStep voiceStep = new VoiceStep();
3029
voiceCallFlowRequest.setSteps(Collections.singletonList(voiceStep)); // VoiceStep Object

0 commit comments

Comments
 (0)