Merge branch 'sms' into 2186
This commit is contained in:
commit
16038caed8
2 changed files with 40 additions and 3 deletions
|
@ -883,7 +883,6 @@ object SmsCommunicatorPlugin : PluginBase(PluginDescription()
|
|||
for (number in substrings) {
|
||||
var cleaned = number.replace(Regex("\\s+"), "")
|
||||
if (cleaned.length < 4) continue
|
||||
if (cleaned.substring(0, 1).compareTo("+") != 0) continue
|
||||
cleaned = cleaned.replace("+", "")
|
||||
if (!cleaned.matches(Regex("[0-9]+"))) continue
|
||||
countNumbers++
|
||||
|
|
|
@ -361,6 +361,44 @@ public class SmsCommunicatorPluginTest {
|
|||
smsCommunicatorPlugin.processSms(sms);
|
||||
Assert.assertEquals("HELP PUMP", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("PUMP"));
|
||||
|
||||
//SMS : wrong format
|
||||
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||
sms = new Sms("1234", "SMS");
|
||||
smsCommunicatorPlugin.processSms(sms);
|
||||
Assert.assertFalse(sms.ignored);
|
||||
Assert.assertEquals("SMS", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
||||
|
||||
//SMS STOP
|
||||
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||
sms = new Sms("1234", "SMS DISABLE");
|
||||
smsCommunicatorPlugin.processSms(sms);
|
||||
Assert.assertEquals("SMS DISABLE", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To disable the SMS Remote Service reply with code"));
|
||||
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
||||
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
||||
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
||||
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.contains("SMS Remote Service stopped. To reactivate it, use AAPS on master smartphone."));
|
||||
|
||||
//TARGET : wrong format
|
||||
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||
sms = new Sms("1234", "TARGET");
|
||||
smsCommunicatorPlugin.processSms(sms);
|
||||
Assert.assertFalse(sms.ignored);
|
||||
Assert.assertEquals("TARGET", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
||||
|
||||
//TARGET MEAL
|
||||
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
||||
sms = new Sms("1234", "TARGET MEAL");
|
||||
smsCommunicatorPlugin.processSms(sms);
|
||||
Assert.assertEquals("TARGET MEAL", smsCommunicatorPlugin.getMessages().get(0).text);
|
||||
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To set the Temp Target MEAL reply with code"));
|
||||
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
||||
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
||||
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
||||
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.contains("Target MEAL for 45 minutes set successfully"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in a new issue