From fc0a40dea6bc923b18dec117c70c7c237be32c68 Mon Sep 17 00:00:00 2001 From: Jack Thorley Date: Thu, 21 Jan 2016 15:08:27 +0000 Subject: [PATCH] Add characterSet overload for SMSMessageRequest for messaging service --- pom.xml | 2 +- .../model/domain/impl/BaseMessageRequest.java | 16 ++++++-- .../domain/impl/MessageCollectionRequest.java | 1 - .../MessageCollectionRequestAssembler.java | 1 + .../model/domain/impl/MessageRequest.java | 17 ++++++++- .../domain/impl/MessageRequestAssembler.java | 1 + .../domain/request/SmsMessageRequest.java | 5 +++ .../message/AbstractMessageRequestDto.java | 13 ++++++- .../message/MessageCollectionRequestDto.java | 1 - .../transfer/message/MessageRequestDto.java | 1 - .../sdk/java/model/types/CharacterSet.java | 22 +++++++++++ .../sdk/java/parser/InvalidXmlException.java | 2 +- .../sdk/java/parser/UnmappableException.java | 2 +- .../sdk/java/parser/XmlPrettyPrinter.java | 2 +- .../sdk/java/service/auth/UserPassword.java | 2 +- .../impl/SessionServiceFactoryImpl.java | 2 +- .../SendServiceSingleUnicodeSMSIT.java | 37 +++++++++++++++++++ 17 files changed, 113 insertions(+), 14 deletions(-) create mode 100644 src/main/java/esendex/sdk/java/model/types/CharacterSet.java create mode 100644 src/test/java/com/esendex/java/sdk/integration/messagingservice/SendServiceSingleUnicodeSMSIT.java diff --git a/pom.xml b/pom.xml index bdb9ec4..4abeb36 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ esendex-java-sdk esendex-java-sdk - 2.0.1 + 2.0.2 diff --git a/src/main/java/esendex/sdk/java/model/domain/impl/BaseMessageRequest.java b/src/main/java/esendex/sdk/java/model/domain/impl/BaseMessageRequest.java index 4c2a564..7b5b86c 100644 --- a/src/main/java/esendex/sdk/java/model/domain/impl/BaseMessageRequest.java +++ b/src/main/java/esendex/sdk/java/model/domain/impl/BaseMessageRequest.java @@ -1,6 +1,7 @@ package esendex.sdk.java.model.domain.impl; +import esendex.sdk.java.model.types.CharacterSet; import esendex.sdk.java.model.types.MessageType; /** @@ -11,7 +12,8 @@ public abstract class BaseMessageRequest { private String from; private Integer validity; - private MessageType messageType; + private MessageType messageType; + private CharacterSet characterSet; public BaseMessageRequest(MessageType type) { this.messageType = type; @@ -29,6 +31,14 @@ public Integer getValidity() { return validity; } + public CharacterSet getCharacterSet() { + return characterSet; + } + + public void setCharacterSet(CharacterSet characterSet) { + this.characterSet = characterSet; + } + /** * Sets the alphanumeric originator for the message to * appear to originate from. @@ -61,6 +71,6 @@ public String toString() { "\nvalidity: " + validity + "\nmessageType: " + messageType; } - - + + } diff --git a/src/main/java/esendex/sdk/java/model/domain/impl/MessageCollectionRequest.java b/src/main/java/esendex/sdk/java/model/domain/impl/MessageCollectionRequest.java index 6326e9c..510ce6b 100644 --- a/src/main/java/esendex/sdk/java/model/domain/impl/MessageCollectionRequest.java +++ b/src/main/java/esendex/sdk/java/model/domain/impl/MessageCollectionRequest.java @@ -7,7 +7,6 @@ import esendex.sdk.java.model.types.MessageType; -// TODO: Auto-generated Javadoc /** * The Class MessageCollectionRequest. * @param the generic type diff --git a/src/main/java/esendex/sdk/java/model/domain/impl/MessageCollectionRequestAssembler.java b/src/main/java/esendex/sdk/java/model/domain/impl/MessageCollectionRequestAssembler.java index e03aa9e..30b1ab5 100644 --- a/src/main/java/esendex/sdk/java/model/domain/impl/MessageCollectionRequestAssembler.java +++ b/src/main/java/esendex/sdk/java/model/domain/impl/MessageCollectionRequestAssembler.java @@ -20,6 +20,7 @@ protected void populateRequest(MessageCollectionRequestDto dto) { dto.setFrom(request.getFrom()); dto.setType(request.getMessageType()); dto.setValidity(request.getValidity()); + dto.setCharacterSet(request.getCharacterSet()); } public MessageCollectionRequestAssembler( diff --git a/src/main/java/esendex/sdk/java/model/domain/impl/MessageRequest.java b/src/main/java/esendex/sdk/java/model/domain/impl/MessageRequest.java index ff85ed0..a41a76f 100644 --- a/src/main/java/esendex/sdk/java/model/domain/impl/MessageRequest.java +++ b/src/main/java/esendex/sdk/java/model/domain/impl/MessageRequest.java @@ -1,17 +1,27 @@ package esendex.sdk.java.model.domain.impl; +import esendex.sdk.java.model.types.CharacterSet; import esendex.sdk.java.model.types.MessageType; public abstract class MessageRequest extends BaseMessageRequest { - private String to; + private CharacterSet characterSet; + private String to; private String body; public MessageRequest(String to, String body, MessageType type) { super(type); this.to = to; this.body = body; + this.characterSet = CharacterSet.GSM; + } + + public MessageRequest(String to, String body, MessageType type, CharacterSet characterSet) { + super(type); + this.to = to; + this.body = body; + this.characterSet = characterSet; } public String getTo() { @@ -22,6 +32,8 @@ public String getBody() { return body; } + public CharacterSet getCharacterSet() { return characterSet;} + public void setTo(String to) { this.to = to; } @@ -30,6 +42,7 @@ public void setBody(String body) { this.body = body; } + public void setCharacterSet(CharacterSet characterSet) { this.characterSet = characterSet; } /** * {@inheritDoc} */ @@ -40,4 +53,6 @@ public String toString() { "\nbody: " + body; } + + } diff --git a/src/main/java/esendex/sdk/java/model/domain/impl/MessageRequestAssembler.java b/src/main/java/esendex/sdk/java/model/domain/impl/MessageRequestAssembler.java index 50d2e4f..f791772 100644 --- a/src/main/java/esendex/sdk/java/model/domain/impl/MessageRequestAssembler.java +++ b/src/main/java/esendex/sdk/java/model/domain/impl/MessageRequestAssembler.java @@ -16,5 +16,6 @@ protected void populateRequest(MessageRequestDto dto) { dto.setFrom(request.getFrom()); dto.setValidity(request.getValidity()); dto.setType(request.getMessageType()); + dto.setCharacterSet(request.getCharacterSet()); } } diff --git a/src/main/java/esendex/sdk/java/model/domain/request/SmsMessageRequest.java b/src/main/java/esendex/sdk/java/model/domain/request/SmsMessageRequest.java index 87dc6bb..b317938 100644 --- a/src/main/java/esendex/sdk/java/model/domain/request/SmsMessageRequest.java +++ b/src/main/java/esendex/sdk/java/model/domain/request/SmsMessageRequest.java @@ -2,6 +2,7 @@ package esendex.sdk.java.model.domain.request; import esendex.sdk.java.model.domain.impl.MessageRequest; +import esendex.sdk.java.model.types.CharacterSet; import esendex.sdk.java.model.types.MessageType; public class SmsMessageRequest extends MessageRequest { @@ -15,6 +16,10 @@ public SmsMessageRequest(String to, String body) { super(to, body, MessageType.SMS); } + public SmsMessageRequest(String to, String body, CharacterSet characterSet) { + super(to, body, MessageType.SMS, characterSet); + } + } diff --git a/src/main/java/esendex/sdk/java/model/transfer/message/AbstractMessageRequestDto.java b/src/main/java/esendex/sdk/java/model/transfer/message/AbstractMessageRequestDto.java index fc13055..e498c05 100644 --- a/src/main/java/esendex/sdk/java/model/transfer/message/AbstractMessageRequestDto.java +++ b/src/main/java/esendex/sdk/java/model/transfer/message/AbstractMessageRequestDto.java @@ -2,6 +2,7 @@ package esendex.sdk.java.model.transfer.message; import esendex.sdk.java.model.transfer.Dto; +import esendex.sdk.java.model.types.CharacterSet; import esendex.sdk.java.model.types.MessageLanguage; import esendex.sdk.java.model.types.MessageType; @@ -18,6 +19,7 @@ public abstract class AbstractMessageRequestDto extends Dto { private MessageLanguage lang; // voice private Integer retries; // voice private Integer validity; // all + private CharacterSet characterset; // sms /** * Sets the alphanumeric originator for the message to @@ -61,6 +63,14 @@ public void setValidity(Integer validity) { this.validity = validity; } + /** + * Sets the retries. + * @param characterSet the new retries + */ + public void setCharacterSet(CharacterSet characterSet) { + this.characterset = characterSet; + } + /** * {@inheritDoc} */ @@ -71,7 +81,8 @@ public String toString() { "\ntype: " + type + "\nlang: " + lang + "\nretries: " + retries + - "\nvalidity: " + validity; + "\nvalidity: " + validity + + "\ncharacterSet:" + characterset; } diff --git a/src/main/java/esendex/sdk/java/model/transfer/message/MessageCollectionRequestDto.java b/src/main/java/esendex/sdk/java/model/transfer/message/MessageCollectionRequestDto.java index 7c0b9ec..385854f 100644 --- a/src/main/java/esendex/sdk/java/model/transfer/message/MessageCollectionRequestDto.java +++ b/src/main/java/esendex/sdk/java/model/transfer/message/MessageCollectionRequestDto.java @@ -4,7 +4,6 @@ import java.util.Date; import java.util.List; -// TODO: Auto-generated Javadoc /** * The Class MessageCollectionRequestDto. */ diff --git a/src/main/java/esendex/sdk/java/model/transfer/message/MessageRequestDto.java b/src/main/java/esendex/sdk/java/model/transfer/message/MessageRequestDto.java index 14e8034..361ee1d 100644 --- a/src/main/java/esendex/sdk/java/model/transfer/message/MessageRequestDto.java +++ b/src/main/java/esendex/sdk/java/model/transfer/message/MessageRequestDto.java @@ -1,7 +1,6 @@ package esendex.sdk.java.model.transfer.message; -// TODO: Auto-generated Javadoc /** * The Class MessageRequest. */ diff --git a/src/main/java/esendex/sdk/java/model/types/CharacterSet.java b/src/main/java/esendex/sdk/java/model/types/CharacterSet.java new file mode 100644 index 0000000..ac438ab --- /dev/null +++ b/src/main/java/esendex/sdk/java/model/types/CharacterSet.java @@ -0,0 +1,22 @@ +package esendex.sdk.java.model.types; + +public enum CharacterSet { + + AUTO ("Auto"), + GSM ("GSM"), + UNICODE ("Unicode"); + + private String representation; + + private CharacterSet(String representation) { + this.representation = representation; + } + + /** + * To string. + * @return the string {@inheritDoc} + */ + public String toString() { + return representation; + } +} diff --git a/src/main/java/esendex/sdk/java/parser/InvalidXmlException.java b/src/main/java/esendex/sdk/java/parser/InvalidXmlException.java index af93b12..2d31109 100644 --- a/src/main/java/esendex/sdk/java/parser/InvalidXmlException.java +++ b/src/main/java/esendex/sdk/java/parser/InvalidXmlException.java @@ -3,7 +3,7 @@ import esendex.sdk.java.EsendexException; -// TODO: Auto-generated Javadoc + /** * Exception to indicate that data could not be treated as xml, * probably due to not being well formed. diff --git a/src/main/java/esendex/sdk/java/parser/UnmappableException.java b/src/main/java/esendex/sdk/java/parser/UnmappableException.java index e37f165..465f31b 100644 --- a/src/main/java/esendex/sdk/java/parser/UnmappableException.java +++ b/src/main/java/esendex/sdk/java/parser/UnmappableException.java @@ -3,7 +3,7 @@ import esendex.sdk.java.EsendexException; -// TODO: Auto-generated Javadoc + /** * Exception to indicate that well formed XML could not be mapped to a * suitable Dto object. This may be due to configuration of the XmlParser. diff --git a/src/main/java/esendex/sdk/java/parser/XmlPrettyPrinter.java b/src/main/java/esendex/sdk/java/parser/XmlPrettyPrinter.java index cee085b..2c7e50f 100644 --- a/src/main/java/esendex/sdk/java/parser/XmlPrettyPrinter.java +++ b/src/main/java/esendex/sdk/java/parser/XmlPrettyPrinter.java @@ -11,7 +11,7 @@ import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; -// TODO: Auto-generated Javadoc + /** * Pretty printer for the formating of XML in a neat indented fashion. * diff --git a/src/main/java/esendex/sdk/java/service/auth/UserPassword.java b/src/main/java/esendex/sdk/java/service/auth/UserPassword.java index 557264d..5890fcb 100644 --- a/src/main/java/esendex/sdk/java/service/auth/UserPassword.java +++ b/src/main/java/esendex/sdk/java/service/auth/UserPassword.java @@ -1,7 +1,7 @@ package esendex.sdk.java.service.auth; -// TODO: Auto-generated Javadoc + /** * Simple holder for a user/password pair. Used for Basic Authentication and * initial aquisition of a session for Session Authentication. diff --git a/src/main/java/esendex/sdk/java/service/impl/SessionServiceFactoryImpl.java b/src/main/java/esendex/sdk/java/service/impl/SessionServiceFactoryImpl.java index 5ac5c10..b7911d8 100644 --- a/src/main/java/esendex/sdk/java/service/impl/SessionServiceFactoryImpl.java +++ b/src/main/java/esendex/sdk/java/service/impl/SessionServiceFactoryImpl.java @@ -7,7 +7,7 @@ import esendex.sdk.java.service.auth.SessionAuthenticator; import esendex.sdk.java.service.auth.UserPassword; -// TODO: Auto-generated Javadoc + /** * The Class SessionServiceFactoryImpl. */ diff --git a/src/test/java/com/esendex/java/sdk/integration/messagingservice/SendServiceSingleUnicodeSMSIT.java b/src/test/java/com/esendex/java/sdk/integration/messagingservice/SendServiceSingleUnicodeSMSIT.java new file mode 100644 index 0000000..a2d7791 --- /dev/null +++ b/src/test/java/com/esendex/java/sdk/integration/messagingservice/SendServiceSingleUnicodeSMSIT.java @@ -0,0 +1,37 @@ +package com.esendex.java.sdk.integration.messagingservice; + +import com.esendex.java.sdk.BaseTest; +import esendex.sdk.java.EsendexException; +import esendex.sdk.java.model.domain.request.SmsMessageRequest; +import esendex.sdk.java.model.domain.response.MessageResultResponse; +import esendex.sdk.java.model.types.CharacterSet; +import esendex.sdk.java.service.MessagingService; +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class SendServiceSingleUnicodeSMSIT extends BaseTest { + + private static MessageResultResponse resultResponse; + + @BeforeClass + public static void whenSendingASingleMessage() throws EsendexException { + + MessagingService messagingService = getFactory().getMessagingService(); + + resultResponse = messagingService.sendMessage(ACCOUNT, new SmsMessageRequest(DESTINATION_NUMBER, "\u1F43", CharacterSet.UNICODE)); + } + + @Test + public void thenABatchIdIsReturned() { + assertNotNull(resultResponse.getBatchId()); + } + + @Test + public void thenAMessageHeaderIsReturned() { + assertTrue(resultResponse.getMessageIds().size() == 1); + assertNotNull(resultResponse.getMessageIds().get(0)); + } +}