ComPlayerCultivateTests.java 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. package com.td.boss;
  2. import cn.hutool.json.JSONUtil;
  3. import com.td.boss.common.pojo.Result;
  4. import com.td.boss.game.comconfigland.service.ComConfigLandService;
  5. import com.td.boss.game.comconfigland.vo.ComConfigLandVo;
  6. import com.td.boss.game.commallfood.controller.ComMallFoodController;
  7. import com.td.boss.game.commallfood.vo.ComMallFoodSimpleVo;
  8. import com.td.boss.game.commallseed.controller.ComMallSeedController;
  9. import com.td.boss.game.commallseed.vo.ComMallSeedVo;
  10. import com.td.boss.game.complayercultivate.controller.ComPlayerCultivateController;
  11. import com.td.boss.game.complayercultivate.pojo.ComPlayerCultivate;
  12. import com.td.boss.game.complayercultivate.serivce.ComPlayerCultivateSerivce;
  13. import com.td.boss.game.complayerdog.controller.ComPlayerDogController;
  14. import com.td.boss.game.complayergoods.controller.ComPlayerGoodsController;
  15. import com.td.boss.game.complayerland.controller.ComPlayerLandController;
  16. import com.td.boss.game.complayerland.vo.ComPlayerLandAndPlantVo;
  17. import org.junit.Test;
  18. import org.junit.runner.RunWith;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.boot.test.context.SpringBootTest;
  21. import org.springframework.test.context.junit4.SpringRunner;
  22. import java.util.List;
  23. import java.util.Map;
  24. @RunWith(SpringRunner.class)
  25. @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  26. public class ComPlayerCultivateTests {
  27. private String userId = "1002";
  28. private int configlandid = 25;
  29. @Autowired
  30. private ComPlayerLandController comPlayerLandController;
  31. @Autowired
  32. private ComMallSeedController comMallSeedController;
  33. @Autowired
  34. private ComPlayerGoodsController comPlayerGoodsController;
  35. @Autowired
  36. private ComConfigLandService comConfigLandService;
  37. @Autowired
  38. private ComPlayerCultivateController comPlayerCultivateController;
  39. @Autowired
  40. private ComPlayerCultivateSerivce comPlayerCultivateSerivce;
  41. //需要测试 多天上线以后情况
  42. //解锁某个土地 【新增功能】【测试完】
  43. @Test
  44. public void buyLand() {
  45. Result<?> comPlayerLandAndPlantVoResult = comPlayerCultivateController.payLand(userId, 26);
  46. print(comPlayerLandAndPlantVoResult);
  47. }
  48. //种种子选择放养数量 【修改完毕】【测试完】
  49. @Test
  50. public void plantFunction() {
  51. //测试重复种植
  52. // print(comPlayerLandController.plantFunction(userId, configlandid, 11, 1000));
  53. //测试种植数量大于土地最大承受
  54. // print(comPlayerLandController.plantFunction(userId, 26, 11, 1000));
  55. //测试种植 包里没有的种子
  56. // print(comPlayerLandController.plantFunction(userId, 26, 11, 20));
  57. //测试种子数量不足
  58. // print(comPlayerLandController.plantFunction(userId, 26, 10, 20));
  59. print(comPlayerLandController.plantFunction(userId, 26, 10, 2));
  60. }
  61. //喂养就是购买粮食 【修改完毕】【测试完】
  62. @Test
  63. public void buyFood() {
  64. //需要计算一下 有多少只动物。要喂多少天。就算一下一共花多少钱。还得插一个喂养明细。
  65. // print( comPlayerDogController.addFoodFunction(userId,6,1));
  66. // print( comPlayerCultivateSerivce.buyFood(userId, configlandid));
  67. // print( comPlayerCultivateSerivce.buyFood(userId, 26));
  68. print(comPlayerCultivateSerivce.buyFood(userId, 26));
  69. }
  70. //获取某个人所有土地 【修改完毕】【测试完】,需要查询喂养记录,重新计算成熟日期
  71. @Test
  72. public void getLandByUserId() {
  73. Result<List<ComPlayerLandAndPlantVo>> landFunction = comPlayerLandController.getLandFunction(userId, null);
  74. print(landFunction);
  75. }
  76. //偷果实 【修改完毕 待测试】
  77. @Test
  78. public void stealFruitFunction() {
  79. comPlayerGoodsController.stealFruitFunction(userId, userId, configlandid);
  80. }
  81. //收货,成熟 【修改完毕 测试完】,一天不喂延长2天
  82. @Test
  83. public void addFruitFunction() {
  84. comPlayerGoodsController.addFruitFunction(userId, 26);
  85. }
  86. //获取所有土地 【一点没变】【测试完】
  87. @Test
  88. public void getLands() {
  89. Result<List<ComConfigLandVo>> list = comConfigLandService.list(new ComConfigLandVo());
  90. print(list);
  91. }
  92. //获取所有种子列表 【一点没变】【测试完】
  93. @Test
  94. public void getSeed() {
  95. Result<List<ComMallSeedVo>> snbFunction = comMallSeedController.getSNBFunction(userId);
  96. print(snbFunction);
  97. }
  98. //购买种子【一点没变】【测试完】这块逻辑是只要钱够,种子id对就没问题
  99. @Test
  100. public void buySeeds() {
  101. comMallSeedController.snbBuySeedsFunction(userId, 200, 10);
  102. }
  103. //购买种子,进入仓库【一点没变】【测试完】
  104. @Test
  105. public void getGood() {
  106. Result<Map> seedAndFruitFunction = comPlayerGoodsController.getSeedAndFruitFunction(userId);
  107. print(seedAndFruitFunction);
  108. }
  109. private void print(Result result) {
  110. System.out.println(JSONUtil.toJsonStr(result.getData()));
  111. }
  112. }