‘m working on a Spring Batch application and have implemented a custom Partitioner
to divide processing across multiple threads. I’m having trouble writing a JUnit 4 test for my partition
method. I’ve mocked my DataSource
and JdbcTemplate
, but I’m not sure if I’m asserting the right conditions or if my setup is correct This code checks the number of occurrences of something, which could be anything from records to events, as referenced by a method on a dto (data transfer object). Here’s what the logic does, described in plain words:
The code asks the dto for the number of occurrences with the method dto.getNumOfOccur().
If the number of occurrences is zero (meaning there have been no occurrences), the code sets a status on the dto to “NEW”, indicating that whatever is being checked is new or hasn’t occurred before.
If there is any number greater than zero (meaning there has been at least one occurrence), the status is set to “EXISTS”, indicating that the occurrence is not new and has happened before.
This status is set using the dto.setNeworexist() method with either “NEW” or “EXISTS” as the
```
staging.aggregator.format=%-1s%-11s%-12s%-8s%-8s%-26s%-8s%-3s%-15s%-20s%-1s%-1s%-35s%-5s%-5s%-15s%-120s%-120s%-35s%-5s%-5s%-15s%-120s%-120s%-10s%-10s%-20s%-15s%-32s%-3s%-3s%-3s%-3s%-10s%-3s%-36s%-29s%-3s%-3s%-3s%-3s%-10s%-3s%-36s%-6s%-29s
public static String[] outputFields() {
return new String[]{
"recordType", // 'D'
"cciNo", // CCI_NO
"xferRefId", // XFER_REF_ID
"frstTranDt", // FRST_TRAN_DT
"nxtTranDt", // NXT_TRAN_DT
"schdCreatTs", // SCHD_CREAT_TS
"lstTranDt", // LST_TRAN_DT
"frqCd", // FRQ_CD
"pmtAm", // PMT_AM
"payAmtType", // PAY_AMT_TYPE
"casgFlag", // CASG_FLAG
"cardFlag", // CARD_FLAG
"srcActNbr", // SRC_ACT_NBR
"srcEntity", // SRC_ENTITY
"srcProdCode", // SRC_PROD_CODE
"srcAcctType", // SRC_ACCT_TYPE
"srcFirstName", // SRC_FIRST_NAME
"srcLastName", // SRC_LAST_NAME
"trgtActNbr", // TRG_ACT_NBR
"trgtEntity", // TRG_ENTITY
"trgtProdCode", // TRG_PROD_CODE
"trgtAcctType", // TRG_ACCT_TYPE
"trgtFirstName", // TRG_FIRST_NAME
"trgtLastName", // TRG_LAST_NAME
"domain", // DOMAIN
"recipe2NTType", // RECIPE2NTYPE
"deliveryMethod", // DELIVERYMETHOD
"letterName", // LETTERNAME
"sentBy", // SENTBY
"accDtype", // ACCOUNTTYPE
"phnNo", // PHONENUMBER
"baccorRspL1", // BACCORRESPL1
"baccorRspL2", // BACCORRESPL2
"baccorRspCty", // BACCORRESPCTY
"cancelDate", // CANCEL_DATE
"subChannel", // SUB-CHANNEL
"callerTraceId", // CALLER_TRACE_ID
"channel", // CHANNEL
"filler" // FILLER
};
}
2