RetentionExpirationDestroyerController { protected List<BusinessObjectDataKey> getBusinessObjectDataKeys(File inputCsvFile) throws IOException { List<BusinessObjectDataKey> businessObjectDataKeyList = new ArrayList<>(); try (CSVReader csvReader = new CSVReader(new InputStreamReader(new FileInputStream(inputCsvFile), StandardCharsets.UTF_8))) { String[] line; if ((line = csvReader.readNext()) == null || !Arrays.equals(line, CSV_FILE_HEADER_COLUMNS)) { throw new IllegalArgumentException(String.format("Input file \"%s\" does not contain the expected CSV file header.", inputCsvFile.toString())); } int lineCount = 2; while ((line = csvReader.readNext()) != null) { businessObjectDataKeyList.add(getBusinessObjectDataKey(line, lineCount++, inputCsvFile)); } } return businessObjectDataKeyList; }  void performRetentionExpirationDestruction(File localInputFile, RegServerAccessParamsDto regServerAccessParamsDto);  }
@Test public void testGetBusinessObjectDataKeys() throws Exception { File inputCsvFile = createLocalInputCsvFile(); List<BusinessObjectDataKey> result = retentionExpirationDestroyerController.getBusinessObjectDataKeys(inputCsvFile); assertEquals(Arrays.asList( new BusinessObjectDataKey(NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME, BUSINESS_OBJECT_FORMAT_USAGE, BUSINESS_OBJECT_FORMAT_FILE_TYPE, BUSINESS_OBJECT_FORMAT_VERSION, PRIMARY_PARTITION_VALUE, SUB_PARTITION_VALUES, BUSINESS_OBJECT_DATA_VERSION), new BusinessObjectDataKey(NAMESPACE, BUSINESS_OBJECT_DEFINITION_NAME, BUSINESS_OBJECT_FORMAT_USAGE, BUSINESS_OBJECT_FORMAT_FILE_TYPE, BUSINESS_OBJECT_FORMAT_VERSION, PRIMARY_PARTITION_VALUE, NO_SUB_PARTITION_VALUES, BUSINESS_OBJECT_DATA_VERSION), new BusinessObjectDataKey(NAMESPACE + ",\"", BUSINESS_OBJECT_DEFINITION_NAME + ",\"", BUSINESS_OBJECT_FORMAT_USAGE + ",\"", BUSINESS_OBJECT_FORMAT_FILE_TYPE + ",\"", BUSINESS_OBJECT_FORMAT_VERSION, PRIMARY_PARTITION_VALUE + ",\"", Arrays .asList(SUB_PARTITION_VALUES.get(0) + ",\"", SUB_PARTITION_VALUES.get(1) + ",\"", SUB_PARTITION_VALUES.get(2) + ",\"", SUB_PARTITION_VALUES.get(3) + ",\""), BUSINESS_OBJECT_DATA_VERSION)), result); }
@Test public void testGetBusinessObjectDataKeysMissingCsvHeader() throws IOException { File inputCsvFile = new File(LOCAL_INPUT_FILE); FileUtils.writeStringToFile(inputCsvFile, STRING_VALUE, StandardCharsets.UTF_8); try { retentionExpirationDestroyerController.getBusinessObjectDataKeys(inputCsvFile); fail(); } catch (IllegalArgumentException e) { assertEquals(String.format("Input file \"%s\" does not contain the expected CSV file header.", inputCsvFile.toString()), e.getMessage()); } }