diff --git a/app/build.gradle b/app/build.gradle index 2ba21b4d43..c9e31881d3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -246,7 +246,7 @@ dependencies { testImplementation "junit:junit:$junit_version" testImplementation 'org.json:json:20200518' - testImplementation "org.mockito:mockito-core:2.8.47" + testImplementation "org.mockito:mockito-core:${mockitoVersion}" testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}" testImplementation "org.powermock:powermock-module-junit4-rule-agent:${powermockVersion}" testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}" diff --git a/build.gradle b/build.gradle index a7ce6acdb8..3eca243412 100644 --- a/build.gradle +++ b/build.gradle @@ -23,6 +23,7 @@ buildscript { work_version = '2.4.0' junit_version = '4.13.1' + mockitoVersion = '2.8.47' powermockVersion = "1.7.3" dexmakerVersion = "1.2" retrofit2Version = '2.9.0' diff --git a/omnipod/build.gradle b/omnipod/build.gradle index 5e2efbf15b..8fb1b2d51f 100644 --- a/omnipod/build.gradle +++ b/omnipod/build.gradle @@ -59,7 +59,7 @@ dependencies { kapt "com.google.dagger:dagger-compiler:$dagger_version" testImplementation "junit:junit:$junit_version" - testImplementation "org.mockito:mockito-core:2.8.47" + testImplementation "org.mockito:mockito-core:${mockitoVersion}" testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion" testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}" testImplementation 'joda-time:joda-time:2.10.6' diff --git a/rileylink/build.gradle b/rileylink/build.gradle index cdeb8d9bc3..308f4bdeb5 100644 --- a/rileylink/build.gradle +++ b/rileylink/build.gradle @@ -50,6 +50,9 @@ dependencies { kapt "com.google.dagger:dagger-compiler:$dagger_version" testImplementation "junit:junit:$junit_version" + testImplementation "org.mockito:mockito-core:${mockitoVersion}" + testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}" + testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}" androidTestImplementation "androidx.test.ext:junit:$androidx_junit" androidTestImplementation "androidx.test:rules:$androidx_rules" } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java index 5bec93fb4c..c264d6a4f9 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java @@ -98,7 +98,9 @@ public class RFSpy { // firmware version public void initializeRileyLink() { bleVersion = getVersion(); - rileyLinkServiceData.firmwareVersion = getFirmwareVersion(); + String cc1110Version = getCC1110Version(); + rileyLinkServiceData.versionCC110 = cc1110Version; + rileyLinkServiceData.firmwareVersion = getFirmwareVersion(aapsLogger, bleVersion, cc1110Version); } @@ -123,15 +125,7 @@ public class RFSpy { } } - public boolean isRileyLinkStillAvailable() { - RileyLinkFirmwareVersion firmwareVersion = getFirmwareVersion(); - - return (firmwareVersion != RileyLinkFirmwareVersion.UnknownVersion); - } - - - private RileyLinkFirmwareVersion getFirmwareVersion() { - + private String getCC1110Version() { aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version. Get Version - Start"); for (int i = 0; i < 5; i++) { @@ -146,19 +140,29 @@ public class RFSpy { if (response != null) { // && response[0] == (byte) 0xDD) { String versionString = StringUtil.fromBytes(response); - - RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(StringUtil - .fromBytes(response)); - - aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version string: {}, resolved to {}.", versionString, version); - - if (version != RileyLinkFirmwareVersion.UnknownVersion) - return version; - + if (versionString.length() > 3) { + if (versionString.indexOf('s') >= 0) { + versionString = versionString.substring(versionString.indexOf('s')); + } + return versionString; + } SystemClock.sleep(1000); } } + return null; + } + + static RileyLinkFirmwareVersion getFirmwareVersion(AAPSLogger aapsLogger, String bleVersion, String cc1110Version) { + if (cc1110Version != null) { + RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(cc1110Version); + aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version string: {}, resolved to {}.", cc1110Version, version); + + if (version != RileyLinkFirmwareVersion.UnknownVersion) { + return version; + } + } + aapsLogger.error(LTag.PUMPBTCOMM, "Firmware Version can't be determined. Checking with BLE Version [{}].", bleVersion); if (bleVersion.contains(" 2.")) { @@ -168,7 +172,6 @@ public class RFSpy { return RileyLinkFirmwareVersion.UnknownVersion; } - private byte[] writeToDataRaw(byte[] bytes, int responseTimeout_ms) { SystemClock.sleep(100); // FIXME drain read queue? @@ -373,7 +376,7 @@ public class RFSpy { private void setMedtronicEncoding() { RileyLinkEncodingType encoding = RileyLinkEncodingType.FourByteSixByteLocal; - if (RileyLinkFirmwareVersion.isSameVersion(rileyLinkServiceData.firmwareVersion, RileyLinkFirmwareVersion.Version2AndHigher)) { + if (rileyLinkServiceData.firmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) { if (sp.getString(RileyLinkConst.Prefs.Encoding, "None") .equals(resourceHelper.gs(R.string.key_medtronic_pump_encoding_4b6b_rileylink))) { encoding = RileyLinkEncodingType.FourByteSixByteRileyLink; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/RadioResponse.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/RadioResponse.java index dccf3a5c15..92dd858185 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/RadioResponse.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/RadioResponse.java @@ -74,8 +74,7 @@ public class RadioResponse { } byte[] encodedPayload; - if (RileyLinkFirmwareVersion.isSameVersion(rileyLinkServiceData.versionCC110, - RileyLinkFirmwareVersion.Version2AndHigher)) { + if (rileyLinkServiceData.firmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) { encodedPayload = ByteUtil.substring(rxData, 3, rxData.length - 3); rssi = rxData[1]; responseNumber = rxData[2]; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersion.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersion.java index 1a6b42c443..3239580512 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersion.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersion.java @@ -1,6 +1,9 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs; +import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -10,19 +13,22 @@ public enum RileyLinkFirmwareVersion { Version_0_0(0, 0, "0.0"), // just for defaulting Version_0_9(0, 9, "0.9"), // Version_1_0(1, 0, "1.0"), // + Version_1_x(1, null, "1.x"), // Version_2_0(2, 0, "2.0"), // Version_2_2(2, 2, "2.2"), // - Version_3_x(3, 0, "3.x"), // - Version_4_x(4, 0, "4.x"), // - UnknownVersion(0, 0, "???"), // - Version1(Version_0_0, Version_0_9, Version_1_0), // - Version2(Version_2_0, Version_2_2), // - Version2AndHigher(Version_2_0, Version_2_2, Version_3_x, Version_4_x), // - ; + Version_2_x(2, null, "2.x"), // + Version_3_x(3, null, "3.x"), // + Version_4_x(4, null, "4.x"), // + UnknownVersion(null, null, "???"), // + Version1(Version_0_0, Version_0_9, Version_1_0, Version_1_x), // + Version2(Version_2_0, Version_2_2, Version_2_x), // + Version3(Version_3_x), // + Version4(Version_4_x), // + Version2AndHigher(Version2, Version3, Version4); private static final String FIRMWARE_IDENTIFICATION_PREFIX = "subg_rfspy "; private static final Pattern _version_pattern = Pattern.compile(FIRMWARE_IDENTIFICATION_PREFIX - + "([0-9]+)\\.([0-9]+)"); + + "([0-9]+)\\.([0-9]+)"); static Map mapByVersion; static { @@ -34,13 +40,12 @@ public enum RileyLinkFirmwareVersion { } } - protected RileyLinkFirmwareVersion[] familyMembers; - private int major; - private int minor; + private List familyMembers; + private Integer major; + private Integer minor; private String versionKey = ""; - - RileyLinkFirmwareVersion(int major, int minor, String versionKey) { + RileyLinkFirmwareVersion(Integer major, Integer minor, String versionKey) { this.major = major; this.minor = minor; this.versionKey = versionKey; @@ -48,23 +53,39 @@ public enum RileyLinkFirmwareVersion { RileyLinkFirmwareVersion(RileyLinkFirmwareVersion... familyMembers) { - this.familyMembers = familyMembers; + this.familyMembers = Arrays.asList(familyMembers); } + public boolean hasFamilyMembers() { + return familyMembers != null; + } - public static boolean isSameVersion(RileyLinkFirmwareVersion versionWeCheck, RileyLinkFirmwareVersion versionSources) { - if (versionSources.familyMembers != null) { - for (RileyLinkFirmwareVersion vrs : versionSources.familyMembers) { - if (vrs == versionWeCheck) - return true; + private List getFamilyMembersRecursive() { + List members = new ArrayList<>(); + if (hasFamilyMembers()) { + for (RileyLinkFirmwareVersion version : familyMembers) { + members.add(version); + if (version.hasFamilyMembers()) { + members.addAll(version.getFamilyMembersRecursive()); + } } - } else { - return (versionWeCheck == versionSources); } + + return members; + } + + static boolean isSameVersion(RileyLinkFirmwareVersion versionWeCheck, RileyLinkFirmwareVersion versionSources) { + if (versionWeCheck == versionSources) { + return true; + } + + if (versionSources.familyMembers != null) { + return versionSources.getFamilyMembersRecursive().contains(versionWeCheck); + } + return false; } - public static RileyLinkFirmwareVersion getByVersionString(String versionString) { if (versionString != null) { Matcher m = _version_pattern.matcher(versionString); @@ -76,7 +97,7 @@ public enum RileyLinkFirmwareVersion { return mapByVersion.get(versionKey); } else { return defaultToLowestMajorVersion(major); // just in case there is new release that we don't cover - // example: 2.3 etc + // example: 2.3 etc } } } @@ -86,8 +107,8 @@ public enum RileyLinkFirmwareVersion { private static RileyLinkFirmwareVersion defaultToLowestMajorVersion(int major) { - if (mapByVersion.containsKey(major + ".0")) { - return mapByVersion.get(major + ".0"); + if (mapByVersion.containsKey(major + ".x")) { + return mapByVersion.get(major + ".x"); } return UnknownVersion; } @@ -100,6 +121,9 @@ public enum RileyLinkFirmwareVersion { @Override public String toString() { + if (hasFamilyMembers()) { + return FIRMWARE_IDENTIFICATION_PREFIX + name(); + } return FIRMWARE_IDENTIFICATION_PREFIX + versionKey; } } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java index 6f4462a470..85cf96a350 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/dialog/RileyLinkStatusGeneralFragment.java @@ -108,13 +108,11 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re "-" : resourceHelper.gs(rileyLinkServiceData.rileyLinkError.getResourceId(targetDevice))); - RileyLinkFirmwareVersion firmwareVersion = rileyLinkServiceData.versionCC110; - if (firmwareVersion == null) { this.firmwareVersion.setText("BLE113: -\nCC110: -"); } else { - this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 + // - "\nCC110: " + firmwareVersion.toString()); + this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 + + "\nCC110: " + rileyLinkServiceData.versionCC110); } } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkBroadcastReceiver.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkBroadcastReceiver.java index 337f8b5527..b240f8bc0b 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkBroadcastReceiver.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkBroadcastReceiver.java @@ -159,7 +159,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver { // if (isLoggingEnabled()) aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy Radio version (CC110): " + rlVersion.name()); - this.rileyLinkServiceData.versionCC110 = rlVersion; + this.rileyLinkServiceData.firmwareVersion = rlVersion; ServiceTask task = new InitializePumpManagerTask(injector, context); serviceTaskExecutor.startTask(task); diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java index 02b27846bc..6223d7b182 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/service/RileyLinkServiceData.java @@ -32,7 +32,7 @@ public class RileyLinkServiceData { public RileyLinkError rileyLinkError; public RileyLinkServiceState rileyLinkServiceState = RileyLinkServiceState.NotStarted; private long lastServiceStateChange = 0L; - public RileyLinkFirmwareVersion firmwareVersion; + public RileyLinkFirmwareVersion firmwareVersion; // here we have "compatibility level" version public RileyLinkTargetFrequency rileyLinkTargetFrequency; public String rileylinkAddress; long lastTuneUpTime = 0L; @@ -41,7 +41,8 @@ public class RileyLinkServiceData { // bt version public String versionBLE113; // radio version - public RileyLinkFirmwareVersion versionCC110; + public String versionCC110; + public RileyLinkTargetDevice targetDevice; @@ -77,7 +78,6 @@ public class RileyLinkServiceData { private synchronized RileyLinkServiceState workWithServiceState(RileyLinkServiceState newState, RileyLinkError errorCode, boolean set) { if (set) { - rileyLinkServiceState = newState; lastServiceStateChange = System.currentTimeMillis(); this.rileyLinkError = errorCode; @@ -87,7 +87,6 @@ public class RileyLinkServiceData { rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(rileyLinkServiceState, errorCode, targetDevice)); rxBus.send(new EventRileyLinkDeviceStatusChange(targetDevice, newState, errorCode)); return null; - } else { return rileyLinkServiceState; } diff --git a/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpyTest.java b/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpyTest.java new file mode 100644 index 0000000000..8afff65fa4 --- /dev/null +++ b/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpyTest.java @@ -0,0 +1,47 @@ +package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.modules.junit4.PowerMockRunner; + +import info.nightscout.androidaps.logging.AAPSLogger; +import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion; + +import static org.junit.Assert.assertEquals; + +@RunWith(PowerMockRunner.class) +public class RFSpyTest { + @Mock + private AAPSLogger aapsLogger; + + @Test + public void testGetFirmwareVersion() { + assertEquals(RileyLinkFirmwareVersion.Version_1_0, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.0")); + assertEquals(RileyLinkFirmwareVersion.Version_1_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1")); + assertEquals(RileyLinkFirmwareVersion.Version_1_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1.13")); + + assertEquals(RileyLinkFirmwareVersion.Version_2_0, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0")); + assertEquals(RileyLinkFirmwareVersion.Version_2_0, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0.1")); + assertEquals(RileyLinkFirmwareVersion.Version_2_2, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2")); + assertEquals(RileyLinkFirmwareVersion.Version_2_2, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.16")); + assertEquals(RileyLinkFirmwareVersion.Version_2_2, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.17")); + assertEquals(RileyLinkFirmwareVersion.Version_2_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3")); + assertEquals(RileyLinkFirmwareVersion.Version_2_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.0")); + assertEquals(RileyLinkFirmwareVersion.Version_2_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.17")); + + assertEquals(RileyLinkFirmwareVersion.Version_3_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0")); + assertEquals(RileyLinkFirmwareVersion.Version_3_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0.1")); + assertEquals(RileyLinkFirmwareVersion.Version_3_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1")); + assertEquals(RileyLinkFirmwareVersion.Version_3_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1.13")); + + assertEquals(RileyLinkFirmwareVersion.Version_4_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0")); + assertEquals(RileyLinkFirmwareVersion.Version_4_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0.4")); + assertEquals(RileyLinkFirmwareVersion.Version_4_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.3")); + assertEquals(RileyLinkFirmwareVersion.Version_4_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.5.7")); + + assertEquals(RileyLinkFirmwareVersion.UnknownVersion, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0")); + assertEquals(RileyLinkFirmwareVersion.UnknownVersion, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0.0")); + assertEquals(RileyLinkFirmwareVersion.UnknownVersion, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.5.5")); + } +} \ No newline at end of file diff --git a/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersionTest.java b/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersionTest.java new file mode 100644 index 0000000000..90351e7d89 --- /dev/null +++ b/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkFirmwareVersionTest.java @@ -0,0 +1,60 @@ +package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs; + +import org.junit.Test; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class RileyLinkFirmwareVersionTest { + + @Test + public void testIsSameVersion() { + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version1, RileyLinkFirmwareVersion.Version1)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_1_0, RileyLinkFirmwareVersion.Version1)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_0_0, RileyLinkFirmwareVersion.Version1)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_0_9, RileyLinkFirmwareVersion.Version1)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_1_x, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version1, RileyLinkFirmwareVersion.Version_1_0)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_0_0, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_1_0, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_0_9, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_1_x, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version1, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_0, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_2, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_x, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_3_x, RileyLinkFirmwareVersion.Version1)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_4_x, RileyLinkFirmwareVersion.Version1)); + + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2, RileyLinkFirmwareVersion.Version2)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2, RileyLinkFirmwareVersion.Version2AndHigher)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_0, RileyLinkFirmwareVersion.Version2)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_0, RileyLinkFirmwareVersion.Version2AndHigher)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_2, RileyLinkFirmwareVersion.Version2)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_2, RileyLinkFirmwareVersion.Version2AndHigher)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_x, RileyLinkFirmwareVersion.Version2)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_x, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2, RileyLinkFirmwareVersion.Version_2_x)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version2)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version2)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_3_x, RileyLinkFirmwareVersion.Version2)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_4_x, RileyLinkFirmwareVersion.Version2)); + + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version3)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version2AndHigher)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_3_x, RileyLinkFirmwareVersion.Version3)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_3_x, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version_3_x)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version3)); + + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version4)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version2AndHigher)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_4_x, RileyLinkFirmwareVersion.Version4)); + assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_4_x, RileyLinkFirmwareVersion.Version2AndHigher)); + assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version_4_x)); + } +} \ No newline at end of file diff --git a/wear/build.gradle b/wear/build.gradle index a1cab4f14c..db4b0c5129 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -127,7 +127,7 @@ dependencies { testImplementation "junit:junit:$junit_version" testImplementation 'org.json:json:20200518' - testImplementation("org.mockito:mockito-core:2.8.47") { + testImplementation("org.mockito:mockito-core:${mockitoVersion}") { exclude group: 'net.bytebuddy', module: 'byte-buddy' exclude group: 'net.bytebuddy', module: 'byte-buddy-android' exclude group: 'net.bytebuddy', module: 'byte-buddy-agent'