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