REO progress

This commit is contained in:
rusefi 2020-06-22 18:16:00 -04:00
parent bceb432bdc
commit aeb3cf3db3
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,10 @@
package com.rusefi.ui;
public class AutoTokenUtil {
public static boolean isToken(String content) {
content = content.trim();
if (content.length() != 8 + 1 + 4 + 1 + 4 + 1 + 4 + 1 + 12)
return false;
return content.charAt(8) == '-' && content.charAt(8 + 1 + 4) == '-';
}
}

View File

@ -0,0 +1,18 @@
package com.rusefi.ui.test;
import com.rusefi.ui.AutoTokenUtil;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class AuthTokenUtilTest {
@Test
public void test() {
assertTrue(AutoTokenUtil.isToken(" 11112222-5719-4444-84d4-111122223333 "));
assertFalse(AutoTokenUtil.isToken(" 11112222x5719-4444-84d4-111122223333 "));
assertFalse(AutoTokenUtil.isToken(" 11112222-5719-4444-84d4-11112222333 "));
}
}