fork download
  1. public interface SmsNotification {
  2.  
  3. public void notifyUser(String type);
  4.  
  5. public String getBalance();
  6.  
  7. public String getStatus(String msgId);
  8.  
  9. }
  10.  
  11. //TODO add telephone number field to entity and web form
  12. /**
  13.  * Service class which gives opportunity send sms notifications to user's mobile phone,
  14.  * get balance on service account, get status of notification (in this partial case vendor is)
  15.  */
  16. @Service
  17. public class SmsNotificationTurboSmsImpl implements SmsNotification {
  18.  
  19. private final static Logger logger = LoggerFactory.getLogger(SmsNotificationTurboSmsImpl.class);
  20.  
  21. private final static String NEW_MESSAGE_TYPE = "message";
  22. private final static String NEW_VIDEO_TYPE = "video";
  23. private final static String NEW_ADVERTISEMENT_TYPE = "advertisement";
  24.  
  25. @Inject
  26. private UserRepository userRepository;
  27.  
  28. @Inject
  29. private static MessageSource messageSource;
  30.  
  31. @Inject
  32. private RequestBuilder requestBuilder;
  33.  
  34. private boolean serviceEnabled;
  35.  
  36. private final static JHipsterProperties jHipsterProperties = new JHipsterProperties();
  37. private final static String serviceLogin = jHipsterProperties.getSmsNotification().getLogin();
  38. private final static String servicePassword = jHipsterProperties.getSmsNotification().getPassword();
  39. private final static String applicationName = jHipsterProperties.getSmsNotification().getApplicationName();
  40.  
  41. private final static String WRONG_MESSAGE_TYPE = "Wrong message type";
  42.  
  43. /*
  44.   * Top level method to notify user by sending him sms
  45.   * Invoking service classes to get xml query, establish connection,
  46.   * send request and process response in well-read form
  47.   * Result should be logged for further control by administrator
  48.   * Current user getting from security utils class
  49.   * @param type - type of message(new message or video etc)
  50.   *
  51.   */
  52. @Override
  53. public void notifyUser(String type) {
  54. if(serviceEnabled = false){
  55. return;
  56. }
  57. String login = SecurityUtils.getCurrentUserLogin();
  58. User user = userRepository.findOneByLogin(login).get();
  59. logger.debug("Invoke notifyUser method with user {}, message type {}", user.getLogin(), type);
  60. Locale locale = Locale.forLanguageTag(user.getLangKey());
  61. String telNumber = user.getEmail(); //TODO add new field to user entity!
  62. String request = getRequestStringToSendSms(type, locale, telNumber);
  63. logger.info("Sending sms notification request was sent to service, message recipient is user {}, message type is {}", user.getLogin(), type);
  64. String rawResponse = requestBuilder.doXMLQuery(request);
  65. String parsedResponse = SmsNotificationUtils.parseDeliveryOrBalanceReport(rawResponse);
  66. logger.info("Notification service response after sending request to notify user {} with message type {} is: {}", user.getLogin(), type, parsedResponse);
  67. }
  68.  
  69. /*
  70.   * Top-level method for getting current account balance of sms service
  71.   * @return parsed response - response in well-read form
  72.   */
  73. @Override
  74. public String getBalance() {
  75. String request = getRequestStringToGetBalance();
  76. String rawResponse = requestBuilder.doXMLQuery(request);
  77. String parsedResponse = SmsNotificationUtils.parseDeliveryOrBalanceReport(rawResponse);
  78. return parsedResponse;
  79. }
  80.  
  81. /*
  82.   * Top-level method for getting status of particular sms
  83.   * @param msgId - sms id
  84.   * @return response in well-read form
  85.   */
  86. @Override
  87. public String getStatus(String msgId) {
  88. String request = getRequestStringToGetSmsStatus(msgId);
  89. String rawResponse = requestBuilder.doXMLQuery(request);
  90. String parsedResponse = SmsNotificationUtils.parseMessageStatusResponse(rawResponse);
  91. return parsedResponse;
  92. }
  93.  
  94. /*
  95.   * Create a string with XML query for sending sms
  96.   * @param type - type of message
  97.   * @param locale - user's locale
  98.   * @param telNumber
  99.   * @return string with query
  100.   */
  101. private static String getRequestStringToSendSms(String type, Locale locale,
  102. String telNumber){
  103. String text = null;
  104. switch (type){
  105. case NEW_ADVERTISEMENT_TYPE : text = messageSource.getMessage("sms.notification.newAdvertisement", null, locale);
  106. case NEW_MESSAGE_TYPE : text = messageSource.getMessage("sms.notification.newMessage", null, locale);
  107. case NEW_VIDEO_TYPE : text = messageSource.getMessage("sms.notification.newVideo", null, locale);
  108. }
  109. if(text.equals(null)){
  110. throw new RuntimeException(WRONG_MESSAGE_TYPE);
  111. }
  112. StringBuilder sb = new StringBuilder();
  113. sb.append("<SMS>");
  114. sb.append("<operations>");
  115. sb.append("<operation>SEND</operation>");
  116. sb.append("</operations>");
  117. sb.append("<authentification>");
  118. sb.append("<username>" + serviceLogin + "</username>");
  119. sb.append("<password>" + servicePassword + "</password>");
  120. sb.append("</authentification>");
  121. sb.append("<message>");
  122. sb.append("<sender>" + applicationName + "</sender>");
  123. sb.append("<text>" + text + "</text>");
  124. sb.append("</message>");
  125. sb.append("<numbers>");
  126. sb.append(telNumber);
  127. sb.append("</numbers>");
  128. sb.append("</SMS>");
  129. return sb.toString();
  130. }
  131. /*
  132.   * Creates a string with XML query for getting account balance
  133.   */
  134. private static String getRequestStringToGetBalance(){
  135. StringBuilder stringBuilder = new StringBuilder();
  136. stringBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  137. stringBuilder.append("<SMS>");
  138. stringBuilder.append("<operations>");
  139. stringBuilder.append("<operation>BALANCE</operation>");
  140. stringBuilder.append("</operations>");
  141. stringBuilder.append("<authentification>");
  142. stringBuilder.append("<username>" + serviceLogin + "</username>");
  143. stringBuilder.append("<password>" + servicePassword + "</password>");
  144. stringBuilder.append("</authentification> ");
  145. stringBuilder.append("</SMS>");
  146. return stringBuilder.toString();
  147. }
  148.  
  149. /*
  150.   * Creates a string with XML query for getting message status details
  151.   * @param msgId - sms id
  152.   * @return string with query
  153.   */
  154. private static String getRequestStringToGetSmsStatus(String msgId){
  155. StringBuilder stringBuilder = new StringBuilder();
  156. stringBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  157. stringBuilder.append("<SMS><operations><operation>GETSTATUS</operation></operations>");
  158. stringBuilder.append("<authentification>");
  159. stringBuilder.append("<username>" + serviceLogin + "</username>");
  160. stringBuilder.append("<password>" + servicePassword + "</password>");
  161. stringBuilder.append("</authentification>");
  162. stringBuilder.append("<statistics>");
  163. stringBuilder.append("<messageid>" + msgId + "</messageid>");
  164. stringBuilder.append("</statistics>");
  165. stringBuilder.append("</SMS>");
  166. return stringBuilder.toString();
  167. }
  168.  
  169. public SmsNotificationTurboSmsImpl() {
  170. }
  171.  
  172. public UserRepository getUserRepository() {
  173. return userRepository;
  174. }
  175.  
  176. public void setUserRepository(UserRepository userRepository) {
  177. this.userRepository = userRepository;
  178. }
  179.  
  180. public static MessageSource getMessageSource() {
  181. return messageSource;
  182. }
  183.  
  184. public static void setMessageSource(MessageSource messageSource) {
  185. SmsNotificationTurboSmsImpl.messageSource = messageSource;
  186. }
  187.  
  188. public RequestBuilder getRequestBuilder() {
  189. return requestBuilder;
  190. }
  191.  
  192. public void setRequestBuilder(RequestBuilder requestBuilder) {
  193. this.requestBuilder = requestBuilder;
  194. }
  195.  
  196. public boolean isServiceEnabled() {
  197. return serviceEnabled;
  198. }
  199.  
  200. public void setServiceEnabled(boolean serviceEnabled) {
  201. this.serviceEnabled = serviceEnabled;
  202. }
  203.  
  204. public static JHipsterProperties getjHipsterProperties() {
  205. return jHipsterProperties;
  206. }
  207. }
  208.  
  209.  
  210.  
  211.  
  212. /**
  213.  * Connection with sms service API
  214.  */
  215. public class TurboSmsVendorConnection {
  216.  
  217. private final static Logger logger = LoggerFactory.getLogger(TurboSmsVendorConnection.class);
  218.  
  219. private final static Boolean USE_CACHES = false;
  220. private final static Boolean DO_INPUT = true;
  221. private final static Boolean DO_OUTPUT = true;
  222. private final static String CONNECTION_ERROR = "Connection is not established!";
  223. private final static String ENCODING = "UTF-8";
  224. private final static String PARAM_SEPARATOR = "&";
  225. private final static String PARAM_EQUAL = "=";
  226.  
  227. private static HttpURLConnection httpURLConnection;
  228.  
  229. /*
  230.   * Makes HTTP request using POST method to specified URL
  231.   * @param requestURL - message service URL
  232.   * @param params - map contains POST data in pairs key-value
  233.   * @throws IOException
  234.   * @return httpURLConnection instance
  235.   */
  236. public static HttpURLConnection sendPostRequest(String requestUrl, Map<String, String> params) throws IOException {
  237. logger.debug("Invoke sendPostRequest method");
  238. URL url = new URL(requestUrl);
  239. httpURLConnection = (HttpURLConnection) url.openConnection();
  240. httpURLConnection.setUseCaches(USE_CACHES);
  241. httpURLConnection.setDoInput(DO_INPUT);
  242. StringBuffer requestParams = new StringBuffer();
  243.  
  244. if (params != null && params.size() > 0) {
  245. httpURLConnection.setDoOutput(DO_OUTPUT); // true indicates POST request
  246. Iterator<String> paramIterator = params.keySet().iterator();
  247.  
  248. boolean isFirst=true;
  249. while (paramIterator.hasNext()) {
  250. String key = paramIterator.next();
  251. String value = params.get(key);
  252. if(!isFirst){ requestParams.append(PARAM_SEPARATOR);}
  253. requestParams.append(key);
  254. requestParams.append(PARAM_EQUAL).append(URLEncoder.encode(value, ENCODING));
  255. isFirst=false;
  256. }
  257. // sends POST request
  258. OutputStreamWriter writer = new OutputStreamWriter(httpURLConnection.getOutputStream());
  259. URLEncoder.encode(requestParams.toString(), ENCODING);
  260. writer.write(requestParams.toString());
  261. writer.flush();
  262. }
  263. return httpURLConnection;
  264. }
  265.  
  266. /*
  267.   * Pulls string with response from httpURLConnection
  268.   * @throws IOException
  269.   */
  270. public static String readSingleLine() throws IOException {
  271. logger.debug("Invoke readSingleLine method.");
  272. InputStream inputStream = null;
  273. if(httpURLConnection != null){
  274. inputStream = httpURLConnection.getInputStream();
  275. }else {
  276. logger.error("HttpURLConnection not established.");
  277. throw new IOException(CONNECTION_ERROR);
  278. }
  279. BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
  280. String response = bufferedReader.readLine();
  281. bufferedReader.close();
  282. return response;
  283. }
  284.  
  285. /*
  286.   * Pulls multiple strings from httpURLConnection
  287.   * @return divided by lines response in a string array
  288.   * @throws IOException
  289.   */
  290. public static String[] readMultipleLinesResponse() throws IOException {
  291. logger.debug("Invoke readMultipleLinesResponse method.");
  292. InputStream inputStream = null;
  293. if (httpURLConnection != null) {
  294. inputStream = httpURLConnection.getInputStream();
  295. } else {
  296. logger.error("HttpURLConnection is not established.");
  297. throw new IOException(CONNECTION_ERROR);
  298. }
  299.  
  300. BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
  301. List<String> response = new ArrayList<String>();
  302.  
  303. String line = "";
  304. while ((line = reader.readLine()) != null) {
  305. response.add(line);
  306. }
  307. reader.close();
  308.  
  309. return (String[]) response.toArray(new String[0]);
  310. }
  311.  
  312. /*
  313.   * Disconnect method
  314.   */
  315. public static void disconnect() {
  316. if(httpURLConnection != null){
  317. httpURLConnection.disconnect();
  318. }
  319. }
  320.  
  321. public static HttpURLConnection getHttpURLConnection() {
  322. return httpURLConnection;
  323. }
  324.  
  325. public static void setHttpURLConnection(HttpURLConnection httpURLConnection) {
  326. TurboSmsVendorConnection.httpURLConnection = httpURLConnection;
  327. }
  328. }
  329.  
  330.  
  331. /**
  332.  * Wrapper class to perform XML request and getting response
  333.  */
  334. public class RequestBuilder {
  335.  
  336. private final static Logger logger = LoggerFactory.getLogger(RequestBuilder.class);
  337.  
  338. private final static String CONNECTION_PARAM = "XML";
  339.  
  340. @Inject
  341. private JHipsterProperties jHipsterProperties;
  342.  
  343. /*
  344.   * This method getting string with string query in XML format,
  345.   * invoking connection and returning result string
  346.   * @throws IOException in case appearing any IO exception
  347.   * @param xml - string with query in XML format
  348.   * @return string with service response
  349.   */
  350. public String doXMLQuery(String xml) {
  351.  
  352. logger.debug("Invoke doXMLQuery method.");
  353.  
  354. StringBuilder responseString = new StringBuilder();
  355.  
  356. Map<String, String> params = new HashMap();
  357. params.put(CONNECTION_PARAM, xml);
  358. try {
  359. TurboSmsVendorConnection.sendPostRequest(jHipsterProperties.getSmsNotification().getURL(), params);
  360. String[] response = TurboSmsVendorConnection.readMultipleLinesResponse();
  361. for (String line : response) {
  362. responseString.append(line);
  363. }
  364. } catch (IOException e) {
  365. logger.error("IOException in doXMLQueryMethod.", e);
  366. }
  367. TurboSmsVendorConnection.disconnect();
  368. return responseString.toString();
  369. }
  370.  
  371. public JHipsterProperties getjHipsterProperties() {
  372. return jHipsterProperties;
  373. }
  374.  
  375. public void setjHipsterProperties(JHipsterProperties jHipsterProperties) {
  376. this.jHipsterProperties = jHipsterProperties;
  377. }
  378. }
  379.  
  380.  
  381. /**
  382.  * Utilize class for processing request "raw" string to well-read form
  383.  */
  384. public final class SmsNotificationUtils {
  385.  
  386. private final static String STATUS_PREFIX = "<status>";
  387. private final static String STATUS_SUFFIX = "</status>";
  388.  
  389. private final static String CREDITS_PREFIX = "<credits>";
  390. private final static String CREDITS_SUFFIX = "</credits>";
  391.  
  392. private final static String SENT_DATE = "sentdate=";
  393. private final static String DONE_DATE = "donedate=";
  394. private final static String STATUS = "status=";
  395.  
  396. private static final Map<String, String> deliveryMessageStatusCodes = new HashMap<>();
  397. static {
  398. deliveryMessageStatusCodes.put("-1", "Authentication failed.");
  399. deliveryMessageStatusCodes.put("-2", "Wrong XML syntax.");
  400. deliveryMessageStatusCodes.put("-3", "Not enough credits on account balance.");
  401. deliveryMessageStatusCodes.put("1", "Message was delivered successfully.");
  402. deliveryMessageStatusCodes.put("0", "Request balance status is OK");
  403. }
  404.  
  405. private static final Map<String, String> messageStatuses = new HashMap<>();
  406. {
  407. messageStatuses.put("SENT", "Message was sent.");
  408. messageStatuses.put("NOT_DELIVERED", "Message wasn't delivered.");
  409. messageStatuses.put("DELIVERED", "Message was delivered");
  410. messageStatuses.put("INVALID_DESTINATION_ADDRESS", "Destination address invalid.");
  411. messageStatuses.put("INVALID_SOURCE_ADDRESS", "Source address invalid");
  412. messageStatuses.put("NOT_ALLOWED", "Recipient mobile operator is out of processing.");
  413. messageStatuses.put("NOT_ENOUGH_CREDITS", "Not enough credits on account balance.");
  414. }
  415.  
  416. private final static String DELIVERY_STATUS = "Delivery status is: ";
  417. private final static String AVAILABLE_CREDITS = "Available credits: ";
  418.  
  419. private final static String SEND_DATE_TEXT = "Message send date: ";
  420. private final static String DONE_DATE_TEXT = "Message delivered at: ";
  421. private final static String STATUS_TEXT = "Delivery status is: ";
  422.  
  423. /*
  424.   * Convert raw response with number codes after string after message sending to well-read form
  425.   * @param serverResponse - raw string from server
  426.   * @return string in well-read form
  427.   */
  428. public static String parseDeliveryOrBalanceReport(String serverResponse){
  429. //typical service response is: <?xml version="1.0" encoding="UTF-8"?><RESPONSE><status>2</status><credits>0.682</credits></RESPONSE>
  430. //AUTH_FAILED -1 Wrong login or password
  431. //XML_ERROR -2 Wrong XML syntax
  432. //NOT_ENOUGH_CREDITS -3 Not enough credits on account balance
  433. //NO_RECIPIENTS -4 Missing correct recipient number
  434. //SEND_OK >0 count of received messages, in this case should always be 1
  435. //SEND_OK 0 request to get current credit balance on service account
  436.  
  437. String statusCode = serverResponse.substring(serverResponse.indexOf(STATUS_PREFIX) + STATUS_PREFIX.length(),
  438. serverResponse.indexOf(STATUS_SUFFIX));
  439. String availableCredits = serverResponse.substring(serverResponse.indexOf(CREDITS_PREFIX) + CREDITS_PREFIX.length(),
  440. serverResponse.indexOf(CREDITS_SUFFIX));
  441. String convertedStatusForm = deliveryMessageStatusCodes.get(statusCode);
  442. return DELIVERY_STATUS + convertedStatusForm + AVAILABLE_CREDITS + availableCredits;
  443. }
  444.  
  445. /*
  446.   * Parses string with "raw" response to well-read form
  447.   * @param messageStatusResponse - response string
  448.   */
  449. public static String parseMessageStatusResponse(String messageStatusResponse){
  450. //typical service response is: <?xml version="1.0" encoding="UTF-8"?><deliveryreport><message id="1299" sentdate="0000-00-00 00:00:00" donedate="0000-00-00 00:00:00" status="0" /></deliveryreport>
  451.  
  452. //SENT Was sent
  453. //NOT_DELIVERED Wasn't delivered
  454. //DELIVERED Delivered
  455. //NOT_ALLOWED Operator is not allowed
  456. //INVALID_DESTINATION_ADDRESS Wrong destination address
  457. //INVALID_SOURCE_ADDRESS Wrong source name
  458. //NOT_ENOUGH_CREDITS Not enough credits
  459. String send_date = messageStatusResponse.substring(messageStatusResponse.indexOf(SENT_DATE) + SENT_DATE.length(),
  460. messageStatusResponse.indexOf(SENT_DATE) + SENT_DATE.length() + 21);
  461. String done_date = messageStatusResponse.substring(messageStatusResponse.indexOf(DONE_DATE) + DONE_DATE.length(),
  462. messageStatusResponse.indexOf(DONE_DATE) + DONE_DATE.length() + 21);
  463. String status_code = messageStatusResponse.substring(messageStatusResponse.indexOf(STATUS) + STATUS.length(),
  464. messageStatusResponse.lastIndexOf("\""));
  465.  
  466. String status = messageStatuses.get(status_code);
  467. return SEND_DATE_TEXT + send_date + DONE_DATE_TEXT + done_date + STATUS_TEXT + status;
  468. }
  469. }
  470.  
  471.  
  472. public class SmsNotificationTest {
  473.  
  474. @Mock
  475. private RequestBuilder requestBuilder;
  476.  
  477. @Inject
  478. TurboSmsVendorConnection turboSmsVendorConnection;
  479.  
  480. SmsNotificationTurboSmsImpl turboSms;
  481.  
  482. @Before
  483. public void setup(){
  484. MockitoAnnotations.initMocks(this);
  485.  
  486. SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
  487. securityContext.setAuthentication(new UsernamePasswordAuthenticationToken("admin", "admin"));
  488. SecurityContextHolder.setContext(securityContext);
  489.  
  490. turboSms = new SmsNotificationTurboSmsImpl();
  491. when(requestBuilder.doXMLQuery(anyString())).thenReturn("<?xml version=\"1.0\" encoding=\"UTF-8\"?><RESPONSE><status>1</status><credits>0.682</credits></RESPONSE>");
  492.  
  493. turboSms.setServiceEnabled(true);
  494.  
  495. ReflectionTestUtils.setField(turboSms, "requestBuilder", requestBuilder);
  496. }
  497.  
  498. @Test
  499. public void testDeliveryOrBalanceReport(){
  500. assertThat(turboSms.notifyUser("message")).isEqualTo("Delivery status is: Message was delivered successfully.Available credits: 0.628");
  501. }
  502.  
  503. }
  504.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:1: error: class SmsNotification is public, should be declared in a file named SmsNotification.java
public interface SmsNotification {
       ^
Main.java:17: error: class SmsNotificationTurboSmsImpl is public, should be declared in a file named SmsNotificationTurboSmsImpl.java
public class SmsNotificationTurboSmsImpl implements SmsNotification {
       ^
Main.java:215: error: class TurboSmsVendorConnection is public, should be declared in a file named TurboSmsVendorConnection.java
public class TurboSmsVendorConnection {
       ^
Main.java:335: error: class RequestBuilder is public, should be declared in a file named RequestBuilder.java
public class RequestBuilder {
       ^
Main.java:385: error: class SmsNotificationUtils is public, should be declared in a file named SmsNotificationUtils.java
public final class SmsNotificationUtils {
             ^
Main.java:473: error: class SmsNotificationTest is public, should be declared in a file named SmsNotificationTest.java
public class SmsNotificationTest {
       ^
Main.java:16: error: cannot find symbol
@Service
 ^
  symbol: class Service
Main.java:19: error: cannot find symbol
    private final static Logger logger = LoggerFactory.getLogger(SmsNotificationTurboSmsImpl.class);
                         ^
  symbol:   class Logger
  location: class SmsNotificationTurboSmsImpl
Main.java:26: error: cannot find symbol
    private UserRepository userRepository;
            ^
  symbol:   class UserRepository
  location: class SmsNotificationTurboSmsImpl
Main.java:29: error: cannot find symbol
    private static MessageSource messageSource;
                   ^
  symbol:   class MessageSource
  location: class SmsNotificationTurboSmsImpl
Main.java:334: error: cannot find symbol
@Component
 ^
  symbol: class Component
Main.java:36: error: cannot find symbol
    private final static JHipsterProperties jHipsterProperties = new JHipsterProperties();
                         ^
  symbol:   class JHipsterProperties
  location: class SmsNotificationTurboSmsImpl
Main.java:101: error: cannot find symbol
    private static String getRequestStringToSendSms(String type, Locale locale,
                                                                 ^
  symbol:   class Locale
  location: class SmsNotificationTurboSmsImpl
Main.java:172: error: cannot find symbol
    public UserRepository getUserRepository() {
           ^
  symbol:   class UserRepository
  location: class SmsNotificationTurboSmsImpl
Main.java:176: error: cannot find symbol
    public void setUserRepository(UserRepository userRepository) {
                                  ^
  symbol:   class UserRepository
  location: class SmsNotificationTurboSmsImpl
Main.java:180: error: cannot find symbol
    public static MessageSource getMessageSource() {
                  ^
  symbol:   class MessageSource
  location: class SmsNotificationTurboSmsImpl
Main.java:184: error: cannot find symbol
    public static void setMessageSource(MessageSource messageSource) {
                                        ^
  symbol:   class MessageSource
  location: class SmsNotificationTurboSmsImpl
Main.java:204: error: cannot find symbol
    public static JHipsterProperties getjHipsterProperties() {
                  ^
  symbol:   class JHipsterProperties
  location: class SmsNotificationTurboSmsImpl
Main.java:337: error: cannot find symbol
    private final static Logger logger = LoggerFactory.getLogger(RequestBuilder.class);
                         ^
  symbol:   class Logger
  location: class RequestBuilder
Main.java:342: error: cannot find symbol
    private JHipsterProperties jHipsterProperties;
            ^
  symbol:   class JHipsterProperties
  location: class RequestBuilder
Main.java:372: error: cannot find symbol
    public JHipsterProperties getjHipsterProperties() {
           ^
  symbol:   class JHipsterProperties
  location: class RequestBuilder
Main.java:376: error: cannot find symbol
    public void setjHipsterProperties(JHipsterProperties jHipsterProperties) {
                                      ^
  symbol:   class JHipsterProperties
  location: class RequestBuilder
Main.java:217: error: cannot find symbol
    private final static Logger logger = LoggerFactory.getLogger(TurboSmsVendorConnection.class);
                         ^
  symbol:   class Logger
  location: class TurboSmsVendorConnection
Main.java:227: error: cannot find symbol
    private static HttpURLConnection httpURLConnection;
                   ^
  symbol:   class HttpURLConnection
  location: class TurboSmsVendorConnection
Main.java:236: error: cannot find symbol
    public static HttpURLConnection sendPostRequest(String requestUrl, Map<String, String> params) throws IOException {
                                                                       ^
  symbol:   class Map
  location: class TurboSmsVendorConnection
Main.java:236: error: cannot find symbol
    public static HttpURLConnection sendPostRequest(String requestUrl, Map<String, String> params) throws IOException {
                  ^
  symbol:   class HttpURLConnection
  location: class TurboSmsVendorConnection
Main.java:236: error: cannot find symbol
    public static HttpURLConnection sendPostRequest(String requestUrl, Map<String, String> params) throws IOException {
                                                                                                          ^
  symbol:   class IOException
  location: class TurboSmsVendorConnection
Main.java:270: error: cannot find symbol
    public static String readSingleLine() throws IOException {
                                                 ^
  symbol:   class IOException
  location: class TurboSmsVendorConnection
Main.java:290: error: cannot find symbol
    public static String[] readMultipleLinesResponse() throws IOException {
                                                              ^
  symbol:   class IOException
  location: class TurboSmsVendorConnection
Main.java:321: error: cannot find symbol
    public static HttpURLConnection getHttpURLConnection() {
                  ^
  symbol:   class HttpURLConnection
  location: class TurboSmsVendorConnection
Main.java:325: error: cannot find symbol
    public static void setHttpURLConnection(HttpURLConnection httpURLConnection) {
                                            ^
  symbol:   class HttpURLConnection
  location: class TurboSmsVendorConnection
Main.java:397: error: cannot find symbol
    private static final Map<String, String> deliveryMessageStatusCodes = new HashMap<>();
                         ^
  symbol:   class Map
  location: class SmsNotificationUtils
Main.java:406: error: cannot find symbol
    private static final Map<String, String> messageStatuses = new HashMap<>();
                         ^
  symbol:   class Map
  location: class SmsNotificationUtils
Main.java:25: error: cannot find symbol
    @Inject
     ^
  symbol:   class Inject
  location: class SmsNotificationTurboSmsImpl
Main.java:28: error: cannot find symbol
    @Inject
     ^
  symbol:   class Inject
  location: class SmsNotificationTurboSmsImpl
Main.java:31: error: cannot find symbol
    @Inject
     ^
  symbol:   class Inject
  location: class SmsNotificationTurboSmsImpl
Main.java:341: error: cannot find symbol
    @Inject
     ^
  symbol:   class Inject
  location: class RequestBuilder
Main.java:475: error: cannot find symbol
    @Mock
     ^
  symbol:   class Mock
  location: class SmsNotificationTest
Main.java:478: error: cannot find symbol
    @Inject
     ^
  symbol:   class Inject
  location: class SmsNotificationTest
Main.java:483: error: cannot find symbol
    @Before
     ^
  symbol:   class Before
  location: class SmsNotificationTest
Main.java:499: error: cannot find symbol
    @Test
     ^
  symbol:   class Test
  location: class SmsNotificationTest
Main.java:19: error: cannot find symbol
    private final static Logger logger = LoggerFactory.getLogger(SmsNotificationTurboSmsImpl.class);
                                         ^
  symbol:   variable LoggerFactory
  location: class SmsNotificationTurboSmsImpl
Main.java:36: error: cannot find symbol
    private final static JHipsterProperties jHipsterProperties = new JHipsterProperties();
                                                                     ^
  symbol:   class JHipsterProperties
  location: class SmsNotificationTurboSmsImpl
Main.java:57: error: cannot find symbol
        String login = SecurityUtils.getCurrentUserLogin();
                       ^
  symbol:   variable SecurityUtils
  location: class SmsNotificationTurboSmsImpl
Main.java:58: error: cannot find symbol
        User user = userRepository.findOneByLogin(login).get();
        ^
  symbol:   class User
  location: class SmsNotificationTurboSmsImpl
Main.java:60: error: cannot find symbol
        Locale locale = Locale.forLanguageTag(user.getLangKey());
        ^
  symbol:   class Locale
  location: class SmsNotificationTurboSmsImpl
Main.java:60: error: cannot find symbol
        Locale locale = Locale.forLanguageTag(user.getLangKey());
                        ^
  symbol:   variable Locale
  location: class SmsNotificationTurboSmsImpl
Main.java:337: error: cannot find symbol
    private final static Logger logger = LoggerFactory.getLogger(RequestBuilder.class);
                                         ^
  symbol:   variable LoggerFactory
  location: class RequestBuilder
Main.java:357: error: cannot find symbol
        Map<String, String> params = new HashMap();
        ^
  symbol:   class Map
  location: class RequestBuilder
Main.java:357: error: cannot find symbol
        Map<String, String> params = new HashMap();
                                         ^
  symbol:   class HashMap
  location: class RequestBuilder
Main.java:365: error: cannot find symbol
            } catch (IOException e) {
                     ^
  symbol:   class IOException
  location: class RequestBuilder
Main.java:217: error: cannot find symbol
    private final static Logger logger = LoggerFactory.getLogger(TurboSmsVendorConnection.class);
                                         ^
  symbol:   variable LoggerFactory
  location: class TurboSmsVendorConnection
Main.java:238: error: cannot find symbol
        URL url = new URL(requestUrl);
        ^
  symbol:   class URL
  location: class TurboSmsVendorConnection
Main.java:238: error: cannot find symbol
        URL url = new URL(requestUrl);
                      ^
  symbol:   class URL
  location: class TurboSmsVendorConnection
Main.java:239: error: cannot find symbol
        httpURLConnection = (HttpURLConnection) url.openConnection();
                             ^
  symbol:   class HttpURLConnection
  location: class TurboSmsVendorConnection
Main.java:246: error: cannot find symbol
            Iterator<String> paramIterator = params.keySet().iterator();
            ^
  symbol:   class Iterator
  location: class TurboSmsVendorConnection
Main.java:254: error: cannot find symbol
                requestParams.append(PARAM_EQUAL).append(URLEncoder.encode(value, ENCODING));
                                                         ^
  symbol:   variable URLEncoder
  location: class TurboSmsVendorConnection
Main.java:258: error: cannot find symbol
            OutputStreamWriter writer = new OutputStreamWriter(httpURLConnection.getOutputStream());
            ^
  symbol:   class OutputStreamWriter
  location: class TurboSmsVendorConnection
Main.java:258: error: cannot find symbol
            OutputStreamWriter writer = new OutputStreamWriter(httpURLConnection.getOutputStream());
                                            ^
  symbol:   class OutputStreamWriter
  location: class TurboSmsVendorConnection
Main.java:259: error: cannot find symbol
            URLEncoder.encode(requestParams.toString(), ENCODING);
            ^
  symbol:   variable URLEncoder
  location: class TurboSmsVendorConnection
Main.java:272: error: cannot find symbol
        InputStream inputStream = null;
        ^
  symbol:   class InputStream
  location: class TurboSmsVendorConnection
Main.java:277: error: cannot find symbol
            throw new IOException(CONNECTION_ERROR);
                      ^
  symbol:   class IOException
  location: class TurboSmsVendorConnection
Main.java:279: error: cannot find symbol
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        ^
  symbol:   class BufferedReader
  location: class TurboSmsVendorConnection
Main.java:279: error: cannot find symbol
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
                                            ^
  symbol:   class BufferedReader
  location: class TurboSmsVendorConnection
Main.java:279: error: cannot find symbol
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
                                                               ^
  symbol:   class InputStreamReader
  location: class TurboSmsVendorConnection
Main.java:292: error: cannot find symbol
        InputStream inputStream = null;
        ^
  symbol:   class InputStream
  location: class TurboSmsVendorConnection
Main.java:297: error: cannot find symbol
            throw new IOException(CONNECTION_ERROR);
                      ^
  symbol:   class IOException
  location: class TurboSmsVendorConnection
Main.java:300: error: cannot find symbol
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        ^
  symbol:   class BufferedReader
  location: class TurboSmsVendorConnection
Main.java:300: error: cannot find symbol
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
                                    ^
  symbol:   class BufferedReader
  location: class TurboSmsVendorConnection
Main.java:300: error: cannot find symbol
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
                                                       ^
  symbol:   class InputStreamReader
  location: class TurboSmsVendorConnection
Main.java:301: error: cannot find symbol
        List<String> response = new ArrayList<String>();
        ^
  symbol:   class List
  location: class TurboSmsVendorConnection
Main.java:301: error: cannot find symbol
        List<String> response = new ArrayList<String>();
                                    ^
  symbol:   class ArrayList
  location: class TurboSmsVendorConnection
Main.java:397: error: cannot find symbol
    private static final Map<String, String> deliveryMessageStatusCodes = new HashMap<>();
                                                                              ^
  symbol:   class HashMap
  location: class SmsNotificationUtils
Main.java:406: error: cannot find symbol
    private static final Map<String, String> messageStatuses = new HashMap<>();
                                                                   ^
  symbol:   class HashMap
  location: class SmsNotificationUtils
Main.java:485: error: cannot find symbol
        MockitoAnnotations.initMocks(this);
        ^
  symbol:   variable MockitoAnnotations
  location: class SmsNotificationTest
Main.java:487: error: cannot find symbol
        SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
        ^
  symbol:   class SecurityContext
  location: class SmsNotificationTest
Main.java:487: error: cannot find symbol
        SecurityContext securityContext = SecurityContextHolder.createEmptyContext();
                                          ^
  symbol:   variable SecurityContextHolder
  location: class SmsNotificationTest
Main.java:488: error: cannot find symbol
        securityContext.setAuthentication(new UsernamePasswordAuthenticationToken("admin", "admin"));
                                              ^
  symbol:   class UsernamePasswordAuthenticationToken
  location: class SmsNotificationTest
Main.java:489: error: cannot find symbol
        SecurityContextHolder.setContext(securityContext);
        ^
  symbol:   variable SecurityContextHolder
  location: class SmsNotificationTest
Main.java:492: error: cannot find symbol
        when(requestBuilder.doXMLQuery(anyString())).thenReturn("<?xml version=\"1.0\" encoding=\"UTF-8\"?><RESPONSE><status>1</status><credits>0.682</credits></RESPONSE>");
                                       ^
  symbol:   method anyString()
  location: class SmsNotificationTest
Main.java:496: error: cannot find symbol
        ReflectionTestUtils.setField(turboSms, "requestBuilder", requestBuilder);
        ^
  symbol:   variable ReflectionTestUtils
  location: class SmsNotificationTest
Main.java:501: error: 'void' type not allowed here
        assertThat(turboSms.notifyUser("message")).isEqualTo("Delivery status is: Message was delivered successfully.Available credits: 0.628");
                                      ^
82 errors
stdout
Standard output is empty