@Test public void testInvalidToken() { final VariantType andVariantType = VariantType.ANDROID; assertThat(DeviceTokenValidator.isValidDeviceTokenForVariant("some-bogus:token", andVariantType)).isFalse(); }
public static boolean isValidDeviceTokenForVariant(final String deviceToken, final VariantType type) { switch (type) { case IOS: case IOS_TOKEN: return IOS_DEVICE_TOKEN.matcher(deviceToken).matches(); case ANDROID: return ANDROID_DEVICE_TOKEN.matcher(deviceToken).matches(); case WEB_PUSH: return isWebPushRegistration(deviceToken); } return false; }
DeviceTokenValidator implements ConstraintValidator<DeviceTokenCheck, Installation> { public static boolean isValidDeviceTokenForVariant(final String deviceToken, final VariantType type) { switch (type) { case IOS: case IOS_TOKEN: return IOS_DEVICE_TOKEN.matcher(deviceToken).matches(); case ANDROID: return ANDROID_DEVICE_TOKEN.matcher(deviceToken).matches(); case WEB_PUSH: return isWebPushRegistration(deviceToken); } return false; } }
DeviceTokenValidator implements ConstraintValidator<DeviceTokenCheck, Installation> { public static boolean isValidDeviceTokenForVariant(final String deviceToken, final VariantType type) { switch (type) { case IOS: case IOS_TOKEN: return IOS_DEVICE_TOKEN.matcher(deviceToken).matches(); case ANDROID: return ANDROID_DEVICE_TOKEN.matcher(deviceToken).matches(); case WEB_PUSH: return isWebPushRegistration(deviceToken); } return false; }  }
DeviceTokenValidator implements ConstraintValidator<DeviceTokenCheck, Installation> { public static boolean isValidDeviceTokenForVariant(final String deviceToken, final VariantType type) { switch (type) { case IOS: case IOS_TOKEN: return IOS_DEVICE_TOKEN.matcher(deviceToken).matches(); case ANDROID: return ANDROID_DEVICE_TOKEN.matcher(deviceToken).matches(); case WEB_PUSH: return isWebPushRegistration(deviceToken); } return false; }  @Override void initialize(DeviceTokenCheck constraintAnnotation); @Override boolean isValid(Installation installation, ConstraintValidatorContext context); static boolean isValidDeviceTokenForVariant(final String deviceToken, final VariantType type); }
DeviceTokenValidator implements ConstraintValidator<DeviceTokenCheck, Installation> { public static boolean isValidDeviceTokenForVariant(final String deviceToken, final VariantType type) { switch (type) { case IOS: case IOS_TOKEN: return IOS_DEVICE_TOKEN.matcher(deviceToken).matches(); case ANDROID: return ANDROID_DEVICE_TOKEN.matcher(deviceToken).matches(); case WEB_PUSH: return isWebPushRegistration(deviceToken); } return false; }  @Override void initialize(DeviceTokenCheck constraintAnnotation); @Override boolean isValid(Installation installation, ConstraintValidatorContext context); static boolean isValidDeviceTokenForVariant(final String deviceToken, final VariantType type);  }