From 6d437b4afa056fc8222ccede38effb228d64fba8 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sat, 23 Jun 2018 11:35:01 +0200 Subject: [PATCH] Test stubs. --- .../plugins/Source/SourceXdripPlugin.java | 2 ++ .../plugins/Source/SourceXdripPluginTest.java | 26 +++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java index 647e5cf877..9c90ae8249 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Source/SourceXdripPlugin.java @@ -54,6 +54,8 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface { String sourceDescription = bundle.getString(Intents.XDRIP_DATA_SOURCE_DESCRIPTION, ""); bgReading.filtered = sourceDescription.equals("G5 Native"); if (MainApp.engineeringMode && !bgReading.filtered && bgReading.noise >= 0 && bgReading.noise <= 4) { + // TODO syncing noice with NS is neither implemented nor tested + // * NSUpload.uploadBg log.debug("Setting filtered=true, since noise is provided and passed check: " + bgReading.noise); bgReading.filtered = true; } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceXdripPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceXdripPluginTest.java index 458feb2d34..17e0544904 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceXdripPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/Source/SourceXdripPluginTest.java @@ -44,7 +44,7 @@ public class SourceXdripPluginTest { } // TODO - @Ignore("Bundle needs to be properly mocked") + @Ignore("Bundle needs to be properly mocked or Robolectrics issues with SQLite resolved") @Test public void bgWithUnknownSourceIsMarkedUnfiltered() { Bundle bundle = createBroadcastBundle(); @@ -53,7 +53,7 @@ public class SourceXdripPluginTest { } // TODO - @Ignore("Bundle needs to be properly mocked") + @Ignore("Bundle needs to be properly mocked or Robolectrics issues with SQLite resolved") @Test public void bgWithSourceG5NativeIsMarkedFiltered() { Bundle bundle = createBroadcastBundle(); @@ -63,6 +63,28 @@ public class SourceXdripPluginTest { assertTrue(bgReadings.filtered); } + // TODO + @Ignore("Bundle needs to be properly mocked or Robolectrics issues with SQLite resolved") + @Test + public void bgWithWithGoodNoiseIsMarkedFiltered() { + Bundle bundle = createBroadcastBundle(); + bundle.putString(Intents.EXTRA_NOISE, "1.0"); + + BgReading bgReadings = plugin.processNewData(bundle).get(0); + assertTrue(bgReadings.filtered); + } + + // TODO + @Ignore("Bundle needs to be properly mocked or Robolectrics issues with SQLite resolved") + @Test + public void bgWithWithExcessiveNoiseDataIsMarkedFiltered() { + Bundle bundle = createBroadcastBundle(); + bundle.putString(Intents.EXTRA_NOISE, "80.0"); + + BgReading bgReadings = plugin.processNewData(bundle).get(0); + assertTrue(bgReadings.filtered); + } + @NonNull private Bundle createBroadcastBundle() { Bundle bundle = new Bundle();