From f8c9fac7b1e6e5beb619a38a390cd578a4c25aa3 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 26 Mar 2018 22:55:38 +0200 Subject: [PATCH] NonOverlapingIntervalsTest 2nd --- .../nightscout/androidaps/db/DatabaseHelper.java | 14 +++++++------- .../androidaps/data/NonOverapingIntervalsTest.java | 9 +++++++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java index b0ac846537..8432824068 100644 --- a/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java +++ b/app/src/main/java/info/nightscout/androidaps/db/DatabaseHelper.java @@ -894,13 +894,13 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { try { String units = MainApp.getConfigBuilder().getProfileUnits(); TempTarget tempTarget = new TempTarget() - .date(trJson.getLong("mills")) - .duration(trJson.getInt("duration")) - .low(Profile.toMgdl(trJson.getDouble("targetBottom"), units)) - .high(Profile.toMgdl(trJson.getDouble("targetTop"), units)) - .reason(trJson.getString("reason")) - ._id(trJson.getString("_id")) - .source(Source.NIGHTSCOUT); + .date(trJson.getLong("mills")) + .duration(trJson.getInt("duration")) + .low(Profile.toMgdl(trJson.getDouble("targetBottom"), units)) + .high(Profile.toMgdl(trJson.getDouble("targetTop"), units)) + .reason(trJson.getString("reason")) + ._id(trJson.getString("_id")) + .source(Source.NIGHTSCOUT); createOrUpdate(tempTarget); } catch (JSONException e) { log.error("Unhandled exception", e); diff --git a/app/src/test/java/info/nightscout/androidaps/data/NonOverapingIntervalsTest.java b/app/src/test/java/info/nightscout/androidaps/data/NonOverapingIntervalsTest.java index 3aae49216a..2b97615048 100644 --- a/app/src/test/java/info/nightscout/androidaps/data/NonOverapingIntervalsTest.java +++ b/app/src/test/java/info/nightscout/androidaps/data/NonOverapingIntervalsTest.java @@ -46,4 +46,13 @@ public class NonOverapingIntervalsTest { Assert.assertEquals(null, list.getValueByInterval(startDate + T.hours(10).msecs() + 1)); } + @Test + public void testCopyConstructor() { + list.reset(); + list.add(new TemporaryBasal().date(startDate).duration((int) T.hours(10).mins()).absolute(1)); + NonOverlappingIntervals list2 = new NonOverlappingIntervals<>(list); + Assert.assertEquals(1, list2.getList().size()); + } + + }