CleansingOperator { @Branch public CleansingResultType dataCleansing(final Receipt receipt) { if (receipt.getReceiptIdOption().isNull() || receipt.getUnitSalesOption().isNull() || receipt.getUnitSales() < 0 || receipt.getSellingPriceOption().isNull() || receipt.getSellingPrice() < 0) { return CleansingResultType.INVALID; } if (receipt.getIssueDate().getElapsedSeconds() >= parameters .getFromIssueDate().getElapsedSeconds() && receipt.getIssueDate().getElapsedSeconds() <= parameters .getToIssueDate().getElapsedSeconds()) { return CleansingResultType.VALID; } else { return CleansingResultType.EXCLUDE; } }  @Branch CleansingResultType dataCleansing(final Receipt receipt); @MasterCheck abstract boolean exists(@Key(group = "shopCode") Shop shop,
			@Key(group = "shopCode") Receipt receipt); @Update void setErrorMessage(ErrorReceipt error, String message);  }
@Test public void testResultTypeIsInvalid() { receipt.setReceiptIdOption(null); actual = operator.dataCleansing(receipt); assertThat("レシートIDがNullならINVALID", actual, is(CleansingResultType.INVALID)); }
@Test public void testResultTypeIsValid() { receipt.setIssueDate(DateTime.valueOf("20111101000000", Format.SIMPLE)); actual = operator.dataCleansing(receipt); assertThat("対象データ(2011/11/01)ならVALID", actual, is(CleansingResultType.VALID)); receipt.setIssueDate(DateTime.valueOf("20111130000000", Format.SIMPLE)); actual = operator.dataCleansing(receipt); assertThat("対象データ(2011/11/30)ならVALID", actual, is(CleansingResultType.VALID)); }
@Test public void testResultTypeIsExclude() { receipt.setIssueDate(DateTime.valueOf("20111031000000", Format.SIMPLE)); actual = operator.dataCleansing(receipt); assertThat("対象外データ(2011/10/31)ならEXCLUDE", actual, is(CleansingResultType.EXCLUDE)); receipt.setIssueDate(DateTime.valueOf("20111201000000", Format.SIMPLE)); actual = operator.dataCleansing(receipt); assertThat("対象外データ(2011/12/01)ならEXCLUDE", actual, is(CleansingResultType.EXCLUDE)); }