FlashDeliveryI18nContractTest.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package com.ruoyi.app.flashdelivery.service;
  2. import org.junit.jupiter.api.Test;
  3. import java.io.InputStream;
  4. import java.util.List;
  5. import java.util.Properties;
  6. import static org.junit.jupiter.api.Assertions.assertNotNull;
  7. import static org.junit.jupiter.api.Assertions.assertTrue;
  8. class FlashDeliveryI18nContractTest {
  9. private static final List<String> FILES = List.of("messages.properties", "messages_zh_CN.properties",
  10. "messages_zh_TW.properties", "messages_en_US.properties", "messages_vi.properties",
  11. "messages_th_TH.properties");
  12. private static final List<String> KEYS = List.of(
  13. "flash.delivery.request.required", "flash.delivery.auth.required",
  14. "flash.delivery.client.request.id.invalid", "flash.delivery.note.too.long",
  15. "flash.delivery.service.type.invalid", "flash.delivery.service.unavailable",
  16. "flash.delivery.address.invalid", "flash.delivery.address.same",
  17. "flash.delivery.order.not.found", "flash.delivery.order.already.accepted",
  18. "flash.delivery.rider.required", "flash.delivery.proof.required",
  19. "flash.delivery.proof.url.invalid", "flash.delivery.proof.too.many",
  20. "flash.delivery.transition.not.allowed",
  21. "flash.delivery.cancel.reason.required", "flash.delivery.cancel.not.allowed",
  22. "flash.delivery.complete.not.allowed", "flash.delivery.state.changed",
  23. "flash.delivery.pricing.invalid", "flash.delivery.pricing.not.available",
  24. "flash.delivery.pricing.overlap", "flash.delivery.pricing.not.found",
  25. "flash.delivery.pricing.changed",
  26. "flash.delivery.delivery.type.invalid", "flash.delivery.item.invalid",
  27. "flash.delivery.tip.invalid", "flash.delivery.quote.changed",
  28. "flash.delivery.edit.not.allowed", "flash.delivery.order.version.invalid",
  29. "flash.delivery.tip.additional.invalid",
  30. "flash.delivery.rider.exclusive.conflict", "flash.delivery.schedule.not.open",
  31. "no.message.push.new.food.order", "no.message.push.new.flash.order",
  32. "address.access.denied", "address.data.invalid");
  33. @Test
  34. void everySupportedBundleContainsEveryFlashDeliveryMessage() throws Exception {
  35. for (String file : FILES) {
  36. Properties properties = new Properties();
  37. try (InputStream input = getClass().getClassLoader().getResourceAsStream("i18n/" + file)) {
  38. assertNotNull(input, file);
  39. properties.load(input);
  40. }
  41. for (String key : KEYS) {
  42. assertTrue(properties.containsKey(key), file + " missing " + key);
  43. assertTrue(!properties.getProperty(key).isBlank(), file + " blank " + key);
  44. }
  45. }
  46. }
  47. }