|
|
|
@ -106,32 +106,32 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("12", "aText");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertTrue(sms.ignored);
|
|
|
|
|
Assert.assertEquals("aText", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("aText", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
|
|
|
|
|
//UNKNOWN
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "UNKNOWN");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("UNKNOWN", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("UNKNOWN", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
|
|
|
|
|
//BG
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BG");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BG", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("IOB:"));
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("Last BG: 100"));
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("COB: 10(2)g"));
|
|
|
|
|
Assert.assertEquals("BG", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("IOB:"));
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("Last BG: 100"));
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("COB: 10(2)g"));
|
|
|
|
|
|
|
|
|
|
// LOOP : test remote control disabled
|
|
|
|
|
when(SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(false);
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP STATUS");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP STATUS", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("Remote command is not allowed"));
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP STATUS", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("Remote command is not allowed"));
|
|
|
|
|
when(SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(true);
|
|
|
|
|
|
|
|
|
|
//LOOP STATUS : disabled
|
|
|
|
@ -139,8 +139,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP STATUS");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("LOOP STATUS", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Loop is disabled", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("LOOP STATUS", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Loop is disabled", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//LOOP STATUS : suspended
|
|
|
|
|
when(loopPlugin.minutesToEndOfSuspend()).thenReturn(10);
|
|
|
|
@ -149,8 +149,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP STATUS");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("LOOP STATUS", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Suspended (10 m)", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("LOOP STATUS", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Suspended (10 m)", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//LOOP STATUS : enabled
|
|
|
|
|
when(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true);
|
|
|
|
@ -158,27 +158,27 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP STATUS");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP STATUS", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Loop is enabled", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP STATUS", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Loop is enabled", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//LOOP : wrong format
|
|
|
|
|
when(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true);
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//LOOP DISABLE : already disabled
|
|
|
|
|
when(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(false);
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP DISABLE");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP DISABLE", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Loop is disabled", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP DISABLE", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Loop is disabled", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//LOOP DISABLE : from enabled
|
|
|
|
|
hasBeenRun = false;
|
|
|
|
@ -190,9 +190,9 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP DISABLE");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP DISABLE", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Loop has been disabled Temp basal canceled", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP DISABLE", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Loop has been disabled Temp basal canceled", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
Assert.assertTrue(hasBeenRun);
|
|
|
|
|
|
|
|
|
|
//LOOP ENABLE : already enabled
|
|
|
|
@ -200,9 +200,9 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP ENABLE");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP ENABLE", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Loop is enabled", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP ENABLE", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Loop is enabled", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//LOOP ENABLE : from disabled
|
|
|
|
|
hasBeenRun = false;
|
|
|
|
@ -214,72 +214,72 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP ENABLE");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP ENABLE", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Loop has been enabled", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP ENABLE", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Loop has been enabled", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
Assert.assertTrue(hasBeenRun);
|
|
|
|
|
|
|
|
|
|
//LOOP RESUME : already enabled
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP RESUME");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP RESUME", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Loop resumed", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP RESUME", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Loop resumed", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//LOOP SUSPEND 1 2: wrong format
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP SUSPEND 1 2");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP SUSPEND 1 2", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP SUSPEND 1 2", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//LOOP SUSPEND 0 : wrong duration
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP SUSPEND 0");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP SUSPEND 0", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong duration", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP SUSPEND 0", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong duration", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//LOOP SUSPEND 100 : suspend for 100 min + correct answer
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP SUSPEND 100");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP SUSPEND 100", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To suspend loop for 100 minutes reply with code "));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP SUSPEND 100", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To suspend loop for 100 minutes reply with code "));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertEquals("Loop suspended Temp basal canceled", smsCommunicatorPlugin.getMessages().get(3).text);
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertEquals("Loop suspended Temp basal canceled", smsCommunicatorPlugin.getMessages().get(3).getText());
|
|
|
|
|
|
|
|
|
|
//LOOP SUSPEND 200 : limit to 180 min + wrong answer
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP SUSPEND 200");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP SUSPEND 200", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To suspend loop for 180 minutes reply with code "));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP SUSPEND 200", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To suspend loop for 180 minutes reply with code "));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
// ignore from other number
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("5678", passCode));
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", "XXXX"));
|
|
|
|
|
Assert.assertEquals("XXXX", smsCommunicatorPlugin.getMessages().get(3).text);
|
|
|
|
|
Assert.assertEquals("Wrong code. Command cancelled.", smsCommunicatorPlugin.getMessages().get(4).text);
|
|
|
|
|
Assert.assertEquals("XXXX", smsCommunicatorPlugin.getMessages().get(3).getText());
|
|
|
|
|
Assert.assertEquals("Wrong code. Command cancelled.", smsCommunicatorPlugin.getMessages().get(4).getText());
|
|
|
|
|
//then correct code should not work
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(5).text);
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(5).getText());
|
|
|
|
|
Assert.assertEquals(6, smsCommunicatorPlugin.getMessages().size()); // processed as common message
|
|
|
|
|
|
|
|
|
|
//LOOP BLABLA
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "LOOP BLABLA");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("LOOP BLABLA", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("LOOP BLABLA", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//TREATMENTS REFRESH
|
|
|
|
|
when(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true);
|
|
|
|
@ -287,9 +287,9 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "TREATMENTS REFRESH");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("TREATMENTS REFRESH", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("TREATMENTS REFRESH"));
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("TREATMENTS REFRESH", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("TREATMENTS REFRESH"));
|
|
|
|
|
|
|
|
|
|
//TREATMENTS BLA BLA
|
|
|
|
|
when(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true);
|
|
|
|
@ -297,9 +297,9 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "TREATMENTS BLA BLA");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("TREATMENTS BLA BLA", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("TREATMENTS BLA BLA", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//TREATMENTS BLABLA
|
|
|
|
|
when(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true);
|
|
|
|
@ -307,9 +307,9 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "TREATMENTS BLABLA");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("TREATMENTS BLABLA", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("TREATMENTS BLABLA", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//NSCLIENT RESTART
|
|
|
|
|
when(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true);
|
|
|
|
@ -317,9 +317,9 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "NSCLIENT RESTART");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("NSCLIENT RESTART", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("NSCLIENT RESTART"));
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("NSCLIENT RESTART", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("NSCLIENT RESTART"));
|
|
|
|
|
|
|
|
|
|
//NSCLIENT BLA BLA
|
|
|
|
|
when(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true);
|
|
|
|
@ -327,9 +327,9 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "NSCLIENT BLA BLA");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("NSCLIENT BLA BLA", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("NSCLIENT BLA BLA", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//NSCLIENT BLABLA
|
|
|
|
|
when(loopPlugin.isEnabled(PluginType.LOOP)).thenReturn(true);
|
|
|
|
@ -337,79 +337,79 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "NSCLIENT BLABLA");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertFalse(sms.ignored);
|
|
|
|
|
Assert.assertEquals("NSCLIENT BLABLA", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("NSCLIENT BLABLA", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//PUMP
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "PUMP");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("PUMP", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Virtual Pump", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("PUMP", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Virtual Pump", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//HELP
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "HELP");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("HELP", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("PUMP"));
|
|
|
|
|
Assert.assertEquals("HELP", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("PUMP"));
|
|
|
|
|
|
|
|
|
|
//HELP PUMP
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "HELP PUMP");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("HELP PUMP", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("PUMP"));
|
|
|
|
|
Assert.assertEquals("HELP PUMP", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().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);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("SMS", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//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;
|
|
|
|
|
Assert.assertEquals("SMS DISABLE", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To disable the SMS Remote Service reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
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."));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).getText().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);
|
|
|
|
|
Assert.assertFalse(sms.getIgnored());
|
|
|
|
|
Assert.assertEquals("TARGET", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//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"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("TARGET MEAL", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To set the Temp Target"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.contains("set successfully"));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).getText().contains("set successfully"));
|
|
|
|
|
|
|
|
|
|
//TARGET STOP/CANCEL
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "TARGET STOP");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("TARGET STOP", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To cancel Temp Target reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("TARGET STOP", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To cancel Temp Target reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.contains("Temp Target canceled successfully"));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).getText().contains("Temp Target canceled successfully"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -420,8 +420,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "PROFILE");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("PROFILE", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("PROFILE", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(true);
|
|
|
|
|
|
|
|
|
@ -429,15 +429,15 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "PROFILE");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("PROFILE", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("PROFILE", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//PROFILE LIST (no profile interface)
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "PROFILE LIST");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("PROFILE LIST", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Not configured", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("PROFILE LIST", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Not configured", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
ProfileInterface profileInterface = mock(SimpleProfilePlugin.class);
|
|
|
|
|
when(ConfigBuilderPlugin.getPlugin().getActiveProfileInterface()).thenReturn(profileInterface);
|
|
|
|
@ -446,8 +446,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "PROFILE LIST");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("PROFILE LIST", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Not configured", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("PROFILE LIST", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Not configured", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(profileInterface.getProfile()).thenReturn(AAPSMocker.getValidProfileStore());
|
|
|
|
|
|
|
|
|
@ -455,54 +455,54 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "PROFILE STATUS");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("PROFILE STATUS", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals(AAPSMocker.TESTPROFILENAME, smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("PROFILE STATUS", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals(AAPSMocker.TESTPROFILENAME, smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//PROFILE LIST
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "PROFILE LIST");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("PROFILE LIST", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("1. " + AAPSMocker.TESTPROFILENAME, smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("PROFILE LIST", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("1. " + AAPSMocker.TESTPROFILENAME, smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//PROFILE 2 (non existing)
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "PROFILE 2");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("PROFILE 2", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("PROFILE 2", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//PROFILE 1 0(wrong percentage)
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "PROFILE 1 0");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("PROFILE 1 0", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("PROFILE 1 0", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//PROFILE 0(wrong index)
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "PROFILE 0");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("PROFILE 0", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("PROFILE 0", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//PROFILE 1(OK)
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "PROFILE 1");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("PROFILE 1", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To switch profile to someProfile 100% reply with code"));
|
|
|
|
|
Assert.assertEquals("PROFILE 1", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To switch profile to someProfile 100% reply with code"));
|
|
|
|
|
|
|
|
|
|
//PROFILE 1 90(OK)
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "PROFILE 1 90");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("PROFILE 1 90", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To switch profile to someProfile 90% reply with code"));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("PROFILE 1 90", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To switch profile to someProfile 90% reply with code"));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertEquals("Profile switch created", smsCommunicatorPlugin.getMessages().get(3).text);
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertEquals("Profile switch created", smsCommunicatorPlugin.getMessages().get(3).getText());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -513,8 +513,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BASAL");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BASAL", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BASAL", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(true);
|
|
|
|
|
|
|
|
|
@ -522,33 +522,33 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BASAL");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BASAL", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BASAL", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//BASAL CANCEL
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BASAL CANCEL");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BASAL CANCEL", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To stop temp basal reply with code"));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("BASAL CANCEL", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To stop temp basal reply with code"));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.contains("Temp basal canceled"));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).getText().contains("Temp basal canceled"));
|
|
|
|
|
|
|
|
|
|
//BASAL a%
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BASAL a%");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BASAL a%", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BASAL a%", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//BASAL 10% 0
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BASAL 10% 0");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BASAL 10% 0", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BASAL 10% 0", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(MainApp.getConstraintChecker().applyBasalPercentConstraints(any(), any())).thenReturn(new Constraint<>(20));
|
|
|
|
|
|
|
|
|
@ -556,26 +556,26 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BASAL 20% 20");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BASAL 20% 20", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To start basal 20% for 20 min reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("BASAL 20% 20", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To start basal 20% for 20 min reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertEquals("Temp basal 20% for 20 min started successfully\nVirtual Pump", smsCommunicatorPlugin.getMessages().get(3).text);
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertEquals("Temp basal 20% for 20 min started successfully\nVirtual Pump", smsCommunicatorPlugin.getMessages().get(3).getText());
|
|
|
|
|
|
|
|
|
|
//BASAL a
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BASAL a");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BASAL a", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BASAL a", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//BASAL 1 0
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BASAL 1 0");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BASAL 1 0", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BASAL 1 0", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(MainApp.getConstraintChecker().applyBasalConstraints(any(), any())).thenReturn(new Constraint<>(1d));
|
|
|
|
|
|
|
|
|
@ -583,12 +583,12 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BASAL 1 20");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BASAL 1 20", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To start basal 1.00U/h for 20 min reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("BASAL 1 20", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To start basal 1.00U/h for 20 min reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertEquals("Temp basal 1.00U/h for 20 min started successfully\nVirtual Pump", smsCommunicatorPlugin.getMessages().get(3).text);
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertEquals("Temp basal 1.00U/h for 20 min started successfully\nVirtual Pump", smsCommunicatorPlugin.getMessages().get(3).getText());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -600,8 +600,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "EXTENDED");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("EXTENDED", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("EXTENDED", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(true);
|
|
|
|
|
|
|
|
|
@ -609,26 +609,26 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "EXTENDED");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("EXTENDED", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("EXTENDED", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//EXTENDED CANCEL
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "EXTENDED CANCEL");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("EXTENDED CANCEL", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To stop extended bolus reply with code"));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("EXTENDED CANCEL", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To stop extended bolus reply with code"));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.contains("Extended bolus canceled"));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).getText().contains("Extended bolus canceled"));
|
|
|
|
|
|
|
|
|
|
//EXTENDED a%
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "EXTENDED a%");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("EXTENDED a%", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("EXTENDED a%", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(MainApp.getConstraintChecker().applyExtendedBolusConstraints(any())).thenReturn(new Constraint<>(1d));
|
|
|
|
|
|
|
|
|
@ -636,19 +636,19 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "EXTENDED 1 0");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("EXTENDED 1 0", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("EXTENDED 1 0", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//EXTENDED 1 20
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "EXTENDED 1 20");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("EXTENDED 1 20", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To start extended bolus 1.00U for 20 min reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("EXTENDED 1 20", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To start extended bolus 1.00U for 20 min reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertEquals("Extended bolus 1.00U for 20 min started successfully\nVirtual Pump", smsCommunicatorPlugin.getMessages().get(3).text);
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertEquals("Extended bolus 1.00U for 20 min started successfully\nVirtual Pump", smsCommunicatorPlugin.getMessages().get(3).getText());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -659,8 +659,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BOLUS");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BOLUS", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BOLUS", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(true);
|
|
|
|
|
|
|
|
|
@ -668,8 +668,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BOLUS");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BOLUS", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BOLUS", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(MainApp.getConstraintChecker().applyBolusConstraints(any())).thenReturn(new Constraint<>(1d));
|
|
|
|
|
|
|
|
|
@ -678,8 +678,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BOLUS 1");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Remote bolus not available. Try again later.", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Remote bolus not available. Try again later.", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(MainApp.getConstraintChecker().applyBolusConstraints(any())).thenReturn(new Constraint<>(0d));
|
|
|
|
|
|
|
|
|
@ -689,15 +689,15 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BOLUS 0");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BOLUS 0", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BOLUS 0", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//BOLUS a
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BOLUS a");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BOLUS a", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BOLUS a", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(MainApp.getConstraintChecker().applyExtendedBolusConstraints(any())).thenReturn(new Constraint<>(1d));
|
|
|
|
|
|
|
|
|
@ -707,12 +707,12 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BOLUS 1");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To deliver bolus 1.00U reply with code"));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To deliver bolus 1.00U reply with code"));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.contains("Bolus 1.00U delivered successfully"));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).getText().contains("Bolus 1.00U delivered successfully"));
|
|
|
|
|
|
|
|
|
|
//BOLUS 1 (Suspended pump)
|
|
|
|
|
smsCommunicatorPlugin.setLastRemoteBolusTime(0);
|
|
|
|
@ -720,27 +720,27 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BOLUS 1");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Pump suspended", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BOLUS 1", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Pump suspended", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
when(virtualPumpPlugin.isSuspended()).thenReturn(false);
|
|
|
|
|
|
|
|
|
|
//BOLUS 1 a
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BOLUS 1 a");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BOLUS 1 a", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("BOLUS 1 a", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//BOLUS 1 MEAL
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "BOLUS 1 MEAL");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("BOLUS 1 MEAL", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To deliver meal bolus 1.00U reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("BOLUS 1 MEAL", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To deliver meal bolus 1.00U reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertEquals("Meal Bolus 1.00U delivered successfully\nVirtual Pump\nTarget 5.0 for 45 minutes", smsCommunicatorPlugin.getMessages().get(3).text);
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertEquals("Meal Bolus 1.00U delivered successfully\nVirtual Pump\nTarget 5.0 for 45 minutes", smsCommunicatorPlugin.getMessages().get(3).getText());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -751,8 +751,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "CAL");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("CAL", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("CAL", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(true);
|
|
|
|
|
|
|
|
|
@ -760,27 +760,27 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "CAL");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("CAL", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("CAL", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
//CAL 0
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "CAL 0");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("CAL 0", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("CAL 0", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(XdripCalibrations.sendIntent(any())).thenReturn(true);
|
|
|
|
|
//CAL 1
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "CAL 1");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("CAL 1", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To send calibration 1.00 reply with code"));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("CAL 1", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To send calibration 1.00 reply with code"));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertEquals("Calibration sent. Receiving must be enabled in xDrip.", smsCommunicatorPlugin.getMessages().get(3).text);
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertEquals("Calibration sent. Receiving must be enabled in xDrip.", smsCommunicatorPlugin.getMessages().get(3).getText());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@ -793,8 +793,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "CARBS");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("CARBS", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("CARBS", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Remote command is not allowed", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(SP.getBoolean(R.string.key_smscommunicator_remotecommandsallowed, false)).thenReturn(true);
|
|
|
|
|
|
|
|
|
@ -802,8 +802,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "CARBS");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("CARBS", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("CARBS", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(MainApp.getConstraintChecker().applyCarbsConstraints(any())).thenReturn(new Constraint<>(0));
|
|
|
|
|
|
|
|
|
@ -811,8 +811,8 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "CARBS 0");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("CARBS 0", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("CARBS 0", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("Wrong format", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
|
|
|
|
|
when(MainApp.getConstraintChecker().applyCarbsConstraints(any())).thenReturn(new Constraint<>(1));
|
|
|
|
|
|
|
|
|
@ -820,56 +820,56 @@ public class SmsCommunicatorPluginTest {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "CARBS 1");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("CARBS 1", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To enter 1g at"));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("CARBS 1", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To enter 1g at"));
|
|
|
|
|
String passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.startsWith("Carbs 1g entered successfully"));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).getText().startsWith("Carbs 1g entered successfully"));
|
|
|
|
|
|
|
|
|
|
//CARBS 1 a
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "CARBS 1 a");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("CARBS 1 a", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("Wrong format"));
|
|
|
|
|
Assert.assertEquals("CARBS 1 a", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("Wrong format"));
|
|
|
|
|
|
|
|
|
|
//CARBS 1 00
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "CARBS 1 00");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("CARBS 1 00", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("Wrong format"));
|
|
|
|
|
Assert.assertEquals("CARBS 1 00", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("Wrong format"));
|
|
|
|
|
|
|
|
|
|
//CARBS 1 12:01
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "CARBS 1 12:01");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("CARBS 1 12:01", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To enter 1g at 12:01PM reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("CARBS 1 12:01", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To enter 1g at 12:01PM reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.startsWith("Carbs 1g entered successfully"));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).getText().startsWith("Carbs 1g entered successfully"));
|
|
|
|
|
|
|
|
|
|
//CARBS 1 3:01AM
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
sms = new Sms("1234", "CARBS 1 3:01AM");
|
|
|
|
|
smsCommunicatorPlugin.processSms(sms);
|
|
|
|
|
Assert.assertEquals("CARBS 1 3:01AM", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).text.contains("To enter 1g at 03:01AM reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().confirmCode;
|
|
|
|
|
Assert.assertEquals("CARBS 1 3:01AM", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(1).getText().contains("To enter 1g at 03:01AM reply with code"));
|
|
|
|
|
passCode = smsCommunicatorPlugin.getMessageToConfirm().getConfirmCode();
|
|
|
|
|
smsCommunicatorPlugin.processSms(new Sms("1234", passCode));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).text);
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).text.startsWith("Carbs 1g entered successfully"));
|
|
|
|
|
Assert.assertEquals(passCode, smsCommunicatorPlugin.getMessages().get(2).getText());
|
|
|
|
|
Assert.assertTrue(smsCommunicatorPlugin.getMessages().get(3).getText().startsWith("Carbs 1g entered successfully"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void sendNotificationToAllNumbers() {
|
|
|
|
|
smsCommunicatorPlugin.setMessages(new ArrayList<>());
|
|
|
|
|
smsCommunicatorPlugin.sendNotificationToAllNumbers("abc");
|
|
|
|
|
Assert.assertEquals("abc", smsCommunicatorPlugin.getMessages().get(0).text);
|
|
|
|
|
Assert.assertEquals("abc", smsCommunicatorPlugin.getMessages().get(1).text);
|
|
|
|
|
Assert.assertEquals("abc", smsCommunicatorPlugin.getMessages().get(0).getText());
|
|
|
|
|
Assert.assertEquals("abc", smsCommunicatorPlugin.getMessages().get(1).getText());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Before
|
|
|
|
|