Ejemplo n.º 1
0
  /**
   * Description:这里写描述<br>
   *
   * @author zouming
   * @version 0.1 2012-12-4上午9:08:48 void
   * @update 2012-12-4上午9:08:48
   */
  @Test
  public void testValidateRecompensePaymentRequire() {
    PaymentBill paymentBill = new PaymentBill();
    BankAccount bankAccount = new BankAccount();

    bankAccount.setBankName("德邦银行");
    bankAccount.setOpenName("德邦大爷");
    bankAccount.setAccount("008009001002");
    bankAccount.setProvince("天堂省");
    bankAccount.setCity("极乐城");
    bankAccount.setBranchName("德邦小弟银行");
    bankAccount.setMobile("0214008305555");

    paymentBill.setPaymentType("月结");
    paymentBill.setPaymentAmount(100d);
    paymentBill.setBankAccount(bankAccount);
    System.err.println(RecompenseValidator.validateRecompensePayment(paymentBill));

    paymentBill.setPaymentAmount(-100d);
    //		System.err.println();
    try {
      RecompenseValidator.validateRecompensePayment(paymentBill);
      fail("大人,未抛出异常。");
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_PAYMENT_AMOUNT_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("大人,异常不正确");
      }
    }
  }
Ejemplo n.º 2
0
 @Test
 public void testValidateOAWorkflowNull() {
   OAWorkflow oaWorkflow = null;
   boolean result = false;
   try {
     result = RecompenseValidator.validateOAWorkflowNull(oaWorkflow);
     assertTrue(result);
   } catch (GeneralException e) {
     if (e.getErrorCode()
         .equals(RecompenseExceptionType.RECOMPENSE_OA_WORKFLOW_NULL.getErrorCode())) {
       System.out.println(e.getErrorCode());
       assertTrue(true);
     } else {
       fail("抛出异常不正确");
     }
   }
   oaWorkflow = new OAWorkflow();
   result = RecompenseValidator.validateOAWorkflowNull(oaWorkflow);
   System.out.println(result);
   assertTrue(result);
 }
Ejemplo n.º 3
0
 @Test
 public void testValidateRecompenseNull() {
   RecompenseApplication app = null;
   boolean result = false;
   try {
     result = RecompenseValidator.validateRecompenseNull(app);
     assertTrue(result);
   } catch (GeneralException e) {
     if (e.getErrorCode()
         .equals(RecompenseExceptionType.RECOMPENSE_APPLICATION_NULL.getErrorCode())) {
       System.out.println(e.getErrorCode());
       assertTrue(true);
     } else {
       fail("抛出异常不正确");
     }
   }
   app = new RecompenseApplication();
   result = RecompenseValidator.validateRecompenseNull(app);
   System.out.println(result);
   assertTrue(result);
 }
Ejemplo n.º 4
0
 @Test
 public void testValidateRecompenseStatusOne() {
   String oldStatus = "recompense";
   String maacthStatus = "recompense1";
   boolean result = false;
   try {
     result = RecompenseValidator.validateRecompenseStatus(oldStatus, maacthStatus);
     assertFalse(result);
   } catch (GeneralException e) {
     if (e.getErrorCode()
         .equals(RecompenseExceptionType.RECOMPENSE_STATUS_NOTMATCH_ERROR.getErrorCode())) {
       System.out.println(e.getErrorCode());
       assertTrue(true);
     } else {
       fail("抛出异常不正确");
     }
   }
   maacthStatus = "recompense";
   result = RecompenseValidator.validateRecompenseStatus(oldStatus, maacthStatus);
   assertTrue(result);
 }
Ejemplo n.º 5
0
 @Test
 public void testValidateRecompenseStatus() {
   String status = "recompense";
   List<String> statusList = new ArrayList<String>();
   statusList.add("hello");
   boolean result = false;
   try {
     result = RecompenseValidator.validateRecompenseStatus(status, statusList);
     assertFalse(result);
   } catch (GeneralException e) {
     if (e.getErrorCode()
         .equals(RecompenseExceptionType.RECOMPENSE_STATUS_NOTMATCH_ERROR.getErrorCode())) {
       System.out.println(e.getErrorCode());
       assertTrue(true);
     } else {
       fail("抛出异常不正确");
     }
   }
   statusList.add(status);
   result = RecompenseValidator.validateRecompenseStatus(status, statusList);
   assertTrue(result);
 }
Ejemplo n.º 6
0
  @Test
  public void testValidateRecompensePayment() {
    boolean result = false;
    PaymentBill paymentBill = null;
    // 理赔单为空
    try {
      result = RecompenseValidator.validateRecompensePayment(paymentBill);
      fail("未抛出异常");
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_PAYMENT_NULL_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }
    paymentBill = new PaymentBill();
    paymentBill.setPaymentType("现金");
    Finance finance = new Finance();
    paymentBill.setBelongfinance(finance);
    BankAccount bankAccount = new BankAccount();
    paymentBill.setBankAccount(bankAccount);

    // 理赔单金额为空
    try {
      result = RecompenseValidator.validateRecompensePayment(paymentBill);
      fail("未抛出异常");
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_PAYMENT_AMOUNT_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }

    // PaymentAmount小于0
    paymentBill.setPaymentAmount(-213d);
    try {
      result = RecompenseValidator.validateRecompensePayment(paymentBill);
      fail("未抛出异常");
    } catch (GeneralException e) {
      System.err.println("xxxxx:" + e.getErrorCode());
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_PAYMENT_AMOUNT_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }

    //
    paymentBill.setPaymentAmount(213d);
    // 理赔单数据不全
    try {
      result = RecompenseValidator.validateRecompensePayment(paymentBill);
      fail("未抛出异常");
    } catch (GeneralException e) {
      if (e.getErrorCode()
          .equals(RecompenseExceptionType.RECOMPENSE_PAYMENT_REQUIRE_ERROR.getErrorCode())) {
        assertTrue(true);
      } else {
        fail("抛出异常不正确");
      }
    }
    bankAccount.setBankName("11");
    bankAccount.setOpenName("1213");
    bankAccount.setAccount("1231");
    bankAccount.setBranchName("1213");
    bankAccount.setProvince("afa");
    bankAccount.setCity("afasdf");
    bankAccount.setMobile("123132");
    // 数据完整
    try {
      result = RecompenseValidator.validateRecompensePayment(paymentBill);
      assertTrue(true);
    } catch (GeneralException e) {
      fail("数据正常抛出异常");
    }
  }
Ejemplo n.º 7
0
 @Test
 public void testValidateRecompenseBalance() {
   Double recompenseAmount = 1000d;
   boolean result = false;
   List<Balance> balanceList = new ArrayList<Balance>();
   // 冲账单为空异常
   try {
     result = RecompenseValidator.validateRecompenseBalance(recompenseAmount, balanceList);
     fail("未抛出异常");
   } catch (GeneralException e) {
     if (e.getErrorCode()
         .equals(RecompenseExceptionType.RECOMPENSE_BALANCE_LIST_NULL.getErrorCode())) {
       assertTrue(true);
     } else {
       fail("抛出异常不正确");
     }
   }
   Balance balance1 = new Balance();
   Balance balance2 = new Balance();
   balanceList.add(balance1);
   balanceList.add(balance2);
   // 数据为空异常
   try {
     result = RecompenseValidator.validateRecompenseBalance(recompenseAmount, balanceList);
     fail("未抛出异常");
   } catch (GeneralException e) {
     if (e.getErrorCode()
         .equals(RecompenseExceptionType.RECOMPENSE_BALANCE_ITEM_UNASSGIN.getErrorCode())) {
       assertTrue(true);
     } else {
       fail("抛出异常不正确");
     }
   }
   balance1.setUsableAmount(100d);
   balance1.setBalanceAmount(110d);
   balance2.setUsableAmount(200d);
   balance2.setBalanceAmount(-300d);
   // 數據記錄負數超出异常
   try {
     result = RecompenseValidator.validateRecompenseBalance(recompenseAmount, balanceList);
     fail("未抛出异常");
   } catch (GeneralException e) {
     if (e.getErrorCode()
         .equals(RecompenseExceptionType.RECOMPENSE_BALANCE_ITEM_UNASSGIN.getErrorCode())) {
       assertTrue(true);
     } else {
       fail("抛出异常不正确");
     }
   }
   balance1.setUsableAmount(100d);
   balance1.setBalanceAmount(100d);
   balance2.setUsableAmount(200d);
   balance2.setBalanceAmount(300d);
   // 数据记录超出异常
   try {
     result = RecompenseValidator.validateRecompenseBalance(recompenseAmount, balanceList);
     fail("未抛出异常");
   } catch (GeneralException e) {
     if (e.getErrorCode()
         .equals(RecompenseExceptionType.RECOMPENSE_BALANCE_ITEM_UNASSGIN.getErrorCode())) {
       assertTrue(true);
     } else {
       fail("抛出异常不正确");
     }
   }
   balance1.setUsableAmount(100d);
   balance1.setBalanceAmount(100d);
   balance2.setUsableAmount(2000d);
   balance2.setBalanceAmount(1000d);
   // 数据超出总金额异常
   try {
     result = RecompenseValidator.validateRecompenseBalance(recompenseAmount, balanceList);
     fail("抛出异常");
   } catch (GeneralException e) {
     if (e.getErrorCode()
         .equals(RecompenseExceptionType.RECOMPENSE_BALANCE_TOTAL_UNASSGIN.getErrorCode())) {
       assertTrue(true);
     } else {
       fail("抛出异常不正确");
     }
   }
   balance1.setUsableAmount(100d);
   balance1.setBalanceAmount(100d);
   balance2.setUsableAmount(2000d);
   balance2.setBalanceAmount(100d);
   // 数据使用正常
   try {
     result = RecompenseValidator.validateRecompenseBalance(recompenseAmount, balanceList);
     assertTrue(true);
   } catch (GeneralException e) {
     fail("正常数据抛出异常");
   }
 }
Ejemplo n.º 8
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("正常数据抛出异常");
    }
  }
Ejemplo n.º 9
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("正常数据抛出异常");
    }
  }