From df3f924dc536c3a55f5c70d91f110ed7300d59b8 Mon Sep 17 00:00:00 2001 From: rusefi Date: Mon, 30 Jan 2023 08:27:13 -0500 Subject: [PATCH] LTS: firmware matcher needs to learn to migrate #5015 relevant helper method --- java_console/shared_io/build.gradle | 8 +++++++- .../src/main/java/com/rusefi/core/io/BundleUtil.java | 9 +++++++++ .../test/java/com/rusefi/core/io/BundleUtilTest.java | 12 ++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 java_console/shared_io/src/test/java/com/rusefi/core/io/BundleUtilTest.java diff --git a/java_console/shared_io/build.gradle b/java_console/shared_io/build.gradle index bfda3b8ed0..e4666ffbcd 100644 --- a/java_console/shared_io/build.gradle +++ b/java_console/shared_io/build.gradle @@ -2,5 +2,11 @@ plugins { id 'java' } +apply from: '../../android/dependencies.gradle' + // TODO: rename folder to core_io -// this CORE module cannot depend on model/ini! \ No newline at end of file +// this CORE module cannot depend on model/ini! + +dependencies { + testImplementation global_libs.junit +} \ No newline at end of file diff --git a/java_console/shared_io/src/main/java/com/rusefi/core/io/BundleUtil.java b/java_console/shared_io/src/main/java/com/rusefi/core/io/BundleUtil.java index 1bec0b9c14..faa7c84820 100644 --- a/java_console/shared_io/src/main/java/com/rusefi/core/io/BundleUtil.java +++ b/java_console/shared_io/src/main/java/com/rusefi/core/io/BundleUtil.java @@ -35,4 +35,13 @@ public class BundleUtil { bundle = bundle == null ? "unknown bundle" : bundle; return bundle; } + + public static String getBundleTarget(String s) { + if (s == null) + return null; + int lastDot = s.lastIndexOf('.'); + if (lastDot == -1) + throw new IllegalStateException("Dot expected somewhere in [" + s + "]"); + return s.substring(lastDot + 1); + } } diff --git a/java_console/shared_io/src/test/java/com/rusefi/core/io/BundleUtilTest.java b/java_console/shared_io/src/test/java/com/rusefi/core/io/BundleUtilTest.java new file mode 100644 index 0000000000..26faae6c36 --- /dev/null +++ b/java_console/shared_io/src/test/java/com/rusefi/core/io/BundleUtilTest.java @@ -0,0 +1,12 @@ +package com.rusefi.core.io; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class BundleUtilTest { + @Test + public void testExtractBundleTarget() { + assertEquals("proteus_f7", BundleUtil.getBundleTarget("rusefi.snapshot.proteus_f7")); + } +}