コード例 #1
0
  /**
   * Description:这里写描述<br>
   *
   * @author zouming
   * @version 0.1 2012-12-4上午9:07:42 void
   * @update 2012-12-4上午9:07:42
   */
  @Test
  public void testValidateRecompenseReportRequire() {
    RecompenseApplication app = new RecompenseApplication();
    // 1.method不为空,其他都为空
    app.setRecompenseMethod(Constants.FAST_TYPE);
    RecompenseValidator.validateRecompenseReportRequire(app);

    // 2.method不为空,其他也不为空
    app.setRecompenseType("11");
    Waybill waybill = new Waybill();
    waybill.setWaybillNumber("11");
    app.setWaybill(waybill);
    app.setInsurType("111");
    app.setInsurQuantity(123);
    app.setDeptId("123");
    app.setInsurDate(new Date());
    app.setClaimParty("aa");
    app.setRecompenseAmount(123d);
    Member customer = new Member();
    customer.setId("123");
    app.setCustomer(customer);
    app.setCompanyPhone("15921594568");

    System.err.println(RecompenseValidator.validateRecompenseReportRequire(app));
  }
コード例 #2
0
  @Test
  public void testValidateRecompenseReportCreate() {
    RecompenseApplication app = new RecompenseApplication();
    List<IssueItem> issueItemAddList = new ArrayList<IssueItem>();
    List<GoodsTrans> goodsTransAddList = new ArrayList<GoodsTrans>();
    boolean result = false;
    // 1. 都为空校验
    try {
      result = RecompenseValidator.validateRecompenseReportCreate(app);
      fail("未抛出异常");
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_REPORT_REQUIRE_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }
    app.setRecompenseMethod(null);
    app.setRecompenseType("11");
    Waybill waybill = new Waybill();
    waybill.setWaybillNumber("11");
    app.setWaybill(waybill);
    app.setInsurType("111");
    app.setInsurQuantity(123);
    app.setDeptId("123");
    app.setInsurDate(new Date());
    app.setClaimParty("aa");
    app.setRecompenseAmount(123d);
    Member customer = new Member();
    customer.setId("123");
    app.setCustomer(customer);
    app.setCompanyPhone(null);
    // 2. app不为空,app.getRecompenseMethod()为空
    try {
      result = RecompenseValidator.validateRecompenseReportCreate(app);
      fail("未抛出异常");
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_REPORT_REQUIRE_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }

    app.setRecompenseMethod(Constants.FAST_TYPE);
    // 快速理賠測試 失败
    try {
      result = RecompenseValidator.validateRecompenseReportCreate(app);
      fail("未抛出异常");
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_REPORT_REQUIRE_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }
    app.setCompanyPhone("12344");

    // 快速理賠測試
    try {
      result = RecompenseValidator.validateRecompenseReportCreate(app);
      assertTrue(true);
    } catch (GeneralException e) {
      fail("正常数据抛出异常");
    }

    // 列表都为空
    app.setRecompenseMethod(Constants.NORMAL_TYPE);
    try {
      result = RecompenseValidator.validateRecompenseReportCreate(app);
      fail("未抛出异常");
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_REPORT_REQUIRE_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }

    GoodsTrans goodsTrans = new GoodsTrans();
    goodsTransAddList.add(goodsTrans);
    app.setGoodsTransList(goodsTransAddList);
    // 一个列表为空校验
    try {
      result = RecompenseValidator.validateRecompenseReportCreate(app);
      fail("未抛出异常");
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_REPORT_REQUIRE_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }
    app.setGoodsTransList(null);
    IssueItem issueItem = new IssueItem();
    issueItemAddList.add(issueItem);
    app.setIssueItemList(issueItemAddList);
    // 一个列表不为空校验
    try {
      result = RecompenseValidator.validateRecompenseReportCreate(app);
      assertTrue(true);
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_REPORT_REQUIRE_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }

    app.setGoodsTransList(goodsTransAddList);
    // 列表不为空校验
    try {
      result = RecompenseValidator.validateRecompenseReportCreate(app);
      assertTrue(true);
    } catch (GeneralException e) {
      fail("正常数据抛出异常");
    }
  }
コード例 #3
0
  @Test
  public void testValidateRecompenseReportUpdate() {
    Map<String, List<IssueItem>> issueItemModifyMap = new HashMap<String, List<IssueItem>>();
    Map<String, List<GoodsTrans>> goodsTransModifyMap = new HashMap<String, List<GoodsTrans>>();
    List<IssueItem> issueOriginal = new ArrayList<IssueItem>();
    List<IssueItem> issueAdd = new ArrayList<IssueItem>();
    List<IssueItem> issueDelete = new ArrayList<IssueItem>();
    List<IssueItem> issueUpdate = new ArrayList<IssueItem>();
    List<GoodsTrans> goodsTransOriginal = new ArrayList<GoodsTrans>();
    List<GoodsTrans> goodsTransAdd = new ArrayList<GoodsTrans>();
    List<GoodsTrans> goodsTransDelete = new ArrayList<GoodsTrans>();
    List<GoodsTrans> goodsTransUpdate = new ArrayList<GoodsTrans>();
    issueItemModifyMap.put(Constants.LIST_TYPE_ORIGINAL, issueOriginal);
    issueItemModifyMap.put(Constants.LIST_TYPE_ADD, issueAdd);
    issueItemModifyMap.put(Constants.LIST_TYPE_DELETE, issueDelete);
    issueItemModifyMap.put(Constants.LIST_TYPE_UPDATE, issueUpdate);
    goodsTransModifyMap.put(Constants.LIST_TYPE_ORIGINAL, goodsTransOriginal);
    goodsTransModifyMap.put(Constants.LIST_TYPE_ADD, goodsTransAdd);
    goodsTransModifyMap.put(Constants.LIST_TYPE_DELETE, goodsTransDelete);
    goodsTransModifyMap.put(Constants.LIST_TYPE_UPDATE, goodsTransUpdate);
    RecompenseApplication app = new RecompenseApplication();
    boolean result = false;
    // 1. 都为空校验
    try {
      result =
          RecompenseValidator.validateRecompenseReportUpdate(
              app, issueItemModifyMap, goodsTransModifyMap);
      fail("未抛出异常");
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_REPORT_REQUIRE_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }

    app.setRecompenseType("11");
    Waybill waybill = new Waybill();
    waybill.setWaybillNumber("11");
    app.setWaybill(waybill);
    app.setInsurType("111");
    app.setInsurQuantity(123);
    app.setDeptId("123");
    app.setInsurDate(new Date());
    app.setClaimParty("aa");
    app.setRecompenseAmount(123d);
    Member customer = new Member();
    customer.setId("123");
    app.setCustomer(customer);
    app.setCompanyPhone("123123");
    // 2.method为空
    try {
      result =
          RecompenseValidator.validateRecompenseReportUpdate(
              app, issueItemModifyMap, goodsTransModifyMap);
      fail("未抛出异常");
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_REPORT_REQUIRE_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }
    app.setRecompenseMethod(Constants.FAST_TYPE);
    // 4. 快速理賠測試
    try {
      result =
          RecompenseValidator.validateRecompenseReportUpdate(
              app, issueItemModifyMap, goodsTransModifyMap);
      assertTrue(true);
    } catch (GeneralException e) {
      fail("正常数据抛出异常");
    }
    app.setRecompenseMethod(Constants.NORMAL_TYPE);
    // 正常列表为空校验
    try {
      result =
          RecompenseValidator.validateRecompenseReportUpdate(
              app, issueItemModifyMap, goodsTransModifyMap);
      assertTrue(true);
      // fail("未抛出异常");
    } catch (GeneralException e) {
      fail("正常数据抛出异常");
      // if (e.getErrorCode().equals(
      // RecompenseExceptionType.RECOMPENSE_REPORT_REQUIRE_ERROR
      // .getErrorCode())) {
      // assertTrue(true);
      // } else {
      // fail("抛出异常不正确");
      // }
    }
    issueDelete.add(new IssueItem());
    goodsTransDelete.add(new GoodsTrans());
    // 刪除列表比原來的多
    try {
      result =
          RecompenseValidator.validateRecompenseReportUpdate(
              app, issueItemModifyMap, goodsTransModifyMap);
      fail("未抛出异常");
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_REPORT_REQUIRE_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }
    issueUpdate.add(new IssueItem());
    goodsTransUpdate.add(new GoodsTrans());
    result =
        RecompenseValidator.validateRecompenseReportUpdate(
            app, issueItemModifyMap, goodsTransModifyMap);
    // 有修改列表
    try {
      result =
          RecompenseValidator.validateRecompenseReportUpdate(
              app, issueItemModifyMap, goodsTransModifyMap);
      assertTrue(true);
    } catch (GeneralException e) {
      fail("正常数据抛出异常");
    }
    issueAdd.add(new IssueItem());
    goodsTransAdd.add(new GoodsTrans());
    result =
        RecompenseValidator.validateRecompenseReportUpdate(
            app, issueItemModifyMap, goodsTransModifyMap);
    // 有增加列表
    try {
      result =
          RecompenseValidator.validateRecompenseReportUpdate(
              app, issueItemModifyMap, goodsTransModifyMap);
      assertTrue(true);
    } catch (GeneralException e) {
      fail("正常数据抛出异常");
    }
  }