@Override public void setUp() throws Exception { super.setUp(); String messageFileName = LaborTestDataPropertyConstants.TEST_DATA_PACKAGE_NAME + "/message.properties"; String propertiesFileName = LaborTestDataPropertyConstants.TEST_DATA_PACKAGE_NAME + "/laborGLLedgerEntryPoster.properties"; properties = TestDataPreparator.loadPropertiesFromClassPath(propertiesFileName); fieldNames = properties.getProperty("fieldNames"); deliminator = properties.getProperty("deliminator"); keyFieldList = Arrays.asList(StringUtils.split(fieldNames, deliminator)); laborGLLedgerEntryPoster = SpringContext.getBean(PostTransaction.class, "laborGLLedgerEntryPoster"); businessObjectService = SpringContext.getBean(BusinessObjectService.class); originEntryGroupService = SpringContext.getBean(LaborOriginEntryGroupService.class); laborGeneralLedgerEntryService = SpringContext.getBean(LaborGeneralLedgerEntryService.class); DateTimeService dateTimeService = SpringContext.getBean(DateTimeService.class); // TODO:- commented out // group1 = originEntryGroupService.createGroup(dateTimeService.getCurrentSqlDate(), // LABOR_MAIN_POSTER_VALID, false, false, false); today = dateTimeService.getCurrentDate(); LaborGeneralLedgerEntry cleanup = new LaborGeneralLedgerEntry(); ObjectUtil.populateBusinessObject(cleanup, properties, "dataCleanup", fieldNames, deliminator); fieldValues = ObjectUtil.buildPropertyMap( cleanup, Arrays.asList(StringUtils.split(fieldNames, deliminator))); businessObjectService.deleteMatching(LaborGeneralLedgerEntry.class, fieldValues); }
private List loadInputData( Class clazz, String propertyKeyPrefix, int numberOfInputData, List<String> keyFieldList, int[] fieldLength) { List inputDataList = new ArrayList(); for (int i = 1; i <= numberOfInputData; i++) { String propertyKey = propertyKeyPrefix + i; try { Object inputData = clazz.newInstance(); ObjectUtil.populateBusinessObject( inputData, properties, propertyKey, fieldLength, keyFieldList); inputDataList.add(inputData); } catch (Exception e) { e.printStackTrace(); } } return inputDataList; }
private int loadInputData( String propertyKeyPrefix, int numberOfInputData, List<String> keyFieldList, int[] fieldLength) { int count = 0; for (int i = 1; i <= numberOfInputData; i++) { String propertyKey = propertyKeyPrefix + i; PendingLedgerEntryForTesting inputData = new PendingLedgerEntryForTesting(); ObjectUtil.populateBusinessObject( inputData, properties, propertyKey, fieldLength, keyFieldList); if (businessObjectService.countMatching( LaborLedgerPendingEntry.class, inputData.getPrimaryKeyMap()) <= 0) { inputData.setFinancialDocumentApprovedCode( KFSConstants.PENDING_ENTRY_APPROVED_STATUS_CODE.APPROVED); businessObjectService.save(inputData); count++; } } return count; }