BusinessObjectDataHelper { public void validateRegistrationDateRangeFilter(RegistrationDateRangeFilter registrationDateRangeFilter) { Assert.isTrue(registrationDateRangeFilter.getStartRegistrationDate() != null || registrationDateRangeFilter.getEndRegistrationDate() != null, "Either start registration date or end registration date must be specified."); if (registrationDateRangeFilter.getStartRegistrationDate() != null && registrationDateRangeFilter.getEndRegistrationDate() != null) { Assert.isTrue(registrationDateRangeFilter.getStartRegistrationDate().compare(registrationDateRangeFilter.getEndRegistrationDate()) <= 0, String .format("The start registration date \"%s\" cannot be greater than the end registration date \"%s\".", registrationDateRangeFilter.getStartRegistrationDate(), registrationDateRangeFilter.getEndRegistrationDate())); } }  void assertBusinessObjectDataStatusEquals(String expectedBusinessObjectDataStatusCode, BusinessObjectDataEntity businessObjectDataEntity); String businessObjectDataEntityAltKeyToString(BusinessObjectDataEntity businessObjectDataEntity); String businessObjectDataKeyToString(BusinessObjectDataKey businessObjectDataKey); String businessObjectDataKeyToString(String namespace, String businessObjectDefinitionName, String businessObjectFormatUsage,
        String businessObjectFormatFileType, int businessObjectFormatVersion, String businessObjectDataPartitionValue,
        List<String> businessObjectDataSubPartitionValues, int businessObjectDataVersion); BusinessObjectDataCreateRequest createBusinessObjectDataCreateRequest(BusinessObjectFormatEntity businessObjectFormatEntity, String uuid,
        String businessObjectDataStatus, List<Attribute> attributes, StorageEntity storageEntity, String storageDirectoryPath, String storageFilePath,
        Long storageFileSizeBytes, Long storageFileRowCount); BusinessObjectData createBusinessObjectDataFromEntity(BusinessObjectDataEntity businessObjectDataEntity); BusinessObjectData createBusinessObjectDataFromEntity(BusinessObjectDataEntity businessObjectDataEntity,
        Boolean includeBusinessObjectDataStatusHistory, Boolean includeStorageUnitStatusHistory, Boolean excludeBusinessObjectDataStorageFiles); BusinessObjectDataKey createBusinessObjectDataKey(BusinessObjectData businessObjectData); BusinessObjectDataKey createBusinessObjectDataKeyFromEntity(BusinessObjectDataEntity businessObjectDataEntity); BusinessObjectDataKey createBusinessObjectDataKeyFromStorageUnitKey(BusinessObjectDataStorageUnitKey storageUnitKey); BusinessObjectDataKey getBusinessObjectDataKey(BusinessObjectDataEntity businessObjectDataEntity); BusinessObjectDataKey getBusinessObjectDataKey(BusinessObjectData businessObjectData); Date getDateFromString(String dateString); List<String> getPartitionFilter(BusinessObjectDataKey businessObjectDataKey, List<String> samplePartitionFilter); String getPartitionValue(BusinessObjectDataEntity businessObjectDataEntity, int partitionColumnPosition); List<String> getPrimaryAndSubPartitionValues(BusinessObjectDataKey businessObjectDataKey); List<String> getPrimaryAndSubPartitionValues(BusinessObjectData businessObjectData); List<String> getPrimaryAndSubPartitionValues(BusinessObjectDataEntity businessObjectDataEntity); StorageUnit getStorageUnitByStorageName(BusinessObjectData businessObjectData, String storageName); List<String> getSubPartitionValues(BusinessObjectDataEntity businessObjectDataEntity); void validateBusinessObjectDataKey(BusinessObjectDataKey key, boolean businessObjectFormatVersionRequired, boolean businessObjectDataVersionRequired); void validatePartitionValueFilters(List<PartitionValueFilter> partitionValueFilters, PartitionValueFilter standalonePartitionValueFilter,
        boolean allowPartitionValueTokens); void validateRegistrationDateRangeFilter(RegistrationDateRangeFilter registrationDateRangeFilter); void validateSubPartitionValues(List<String> subPartitionValues);  }
@Test public void testValidateRegistrationDateRangeFilter() throws DatatypeConfigurationException { XMLGregorianCalendar start = DatatypeFactory.newInstance().newXMLGregorianCalendar("2018-04-01"); XMLGregorianCalendar end = DatatypeFactory.newInstance().newXMLGregorianCalendar("2018-04-02"); businessObjectDataHelper.validateRegistrationDateRangeFilter(new RegistrationDateRangeFilter(start, end)); businessObjectDataHelper.validateRegistrationDateRangeFilter(new RegistrationDateRangeFilter(start, start)); }
@Test public void testValidateRegistrationDateRangeFilterMissingStartAndEndDate() { try { businessObjectDataHelper.validateRegistrationDateRangeFilter(new RegistrationDateRangeFilter()); fail(); } catch (IllegalArgumentException e) { assertEquals("Either start registration date or end registration date must be specified.", e.getMessage()); } }
@Test public void testValidateRegistrationDateRangeFilterStartDateIsGreaterThenEndDate() throws DatatypeConfigurationException { XMLGregorianCalendar end = DatatypeFactory.newInstance().newXMLGregorianCalendar("2018-04-01"); XMLGregorianCalendar start = DatatypeFactory.newInstance().newXMLGregorianCalendar("2018-04-02"); try { businessObjectDataHelper.validateRegistrationDateRangeFilter(new RegistrationDateRangeFilter(start, end)); fail(); } catch (IllegalArgumentException e) { assertEquals(String.format("The start registration date \"%s\" cannot be greater than the end registration date \"%s\".", start, end), e.getMessage()); } }