Skip to content

Commit

Permalink
fix match key validation for 2023 CMP double elim matches (#979)
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-lopreiato authored Jan 15, 2024
1 parent 586016b commit 584359b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private MatchHelper() {
public static boolean validateMatchKey(String key) {
if (key == null || key.isEmpty()) return false;

return key.matches("^[1-9]\\d{3}[a-z,0-9]+_(?:qm|ef\\dm|qf\\dm|sf\\dm|f\\dm)\\d+$");
return key.matches("^[1-9]\\d{3}[a-z,0-9]+_(?:qm|ef\\d+m|qf\\d+m|sf\\d+m|f\\d+m)\\d+$");
}

public static String getEventKeyFromMatchKey(String matchKey) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -46,6 +47,15 @@ public void testGetScore() {
assertEquals(0, Match.getBlueScore(mMatch.getAlliances()).intValue());
}

@Test
public void testValidateMatchKey() {
assertTrue(MatchHelper.validateMatchKey("2016cthar_qm1"));
assertTrue(MatchHelper.validateMatchKey("2016cmpmi_ef1m2"));
assertTrue(MatchHelper.validateMatchKey("2016cmpmi_sf1m3"));
assertTrue(MatchHelper.validateMatchKey("2016cthar_qf1m2"));
assertTrue(MatchHelper.validateMatchKey("2023cmptx_sf10m1"));
}

@Test
public void testEventKeyFromMatchKey() {
assertEquals(MatchHelper.getEventKeyFromMatchKey("2015cthar_f1m1"), "2015cthar");
Expand Down

0 comments on commit 584359b

Please sign in to comment.