!businessObjectFormatEntity.getRetentionType().getCode().equals(RetentionTypeEntity.BDATA_RETENTION_DATE))
/** * Create the retention type entity * @param code retention type * @return retention type entity */ public RetentionTypeEntity createRetentionTypeEntity(String code) { RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(code); return retentionTypeDao.saveAndRefresh(retentionTypeEntity); } }
RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.BDATA_RETENTION_DATE); .format("Retention information with retention type %s must be specified for the Business Object Data: {%s}", retentionTypeEntity.getCode(), BUSINESS_OBJECT_DATA_KEY_AS_STRING), e.getMessage());
RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.BDATA_RETENTION_DATE); "Business object data: {%s}", retentionTypeEntity.getCode(), businessObjectDataEntity.getRetentionExpiration(), BUSINESS_OBJECT_DATA_KEY_AS_STRING), e.getMessage());
@Test public void testUpdateBusinessObjectFormatRetentionInformationRetentionDateRetentionTypeWithRetentionPeriodInDays() { // Create a business object format key without version. BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); // Create a retention type entity for BDATA_RETENTION_DATE. RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.BDATA_RETENTION_DATE); // Mock the external calls. when(businessObjectFormatDaoHelper.getRecordRetentionTypeEntity(RetentionTypeEntity.BDATA_RETENTION_DATE)).thenReturn(retentionTypeEntity); // Try to call the method under test with retention period in days specified for BDATA_RETENTION_DATE retention type. try { businessObjectFormatServiceImpl.updateBusinessObjectFormatRetentionInformation(businessObjectFormatKey, new BusinessObjectFormatRetentionInformationUpdateRequest(RECORD_FLAG_SET, RETENTION_PERIOD_DAYS, RetentionTypeEntity.BDATA_RETENTION_DATE)); fail(); } catch (IllegalArgumentException e) { assertEquals(String.format("A retention period in days cannot be specified for %s retention type.", RetentionTypeEntity.BDATA_RETENTION_DATE), e.getMessage()); } // Verify the external calls. verify(businessObjectFormatHelper).validateBusinessObjectFormatKey(businessObjectFormatKey, false); verify(businessObjectFormatDaoHelper).getRecordRetentionTypeEntity(RetentionTypeEntity.BDATA_RETENTION_DATE); verifyNoMoreInteractionsHelper(); }
!businessObjectFormatEntity.getRetentionType().getCode().equals(RetentionTypeEntity.BDATA_RETENTION_DATE))
@Test public void testUpdateBusinessObjectFormatRetentionInformationPartitionValueRetentionTypeMissingRetentionPeriodInDays() { // Create a business object format key without version. BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); // Create a retention type entity for PARTITION_VALUE. RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.PARTITION_VALUE); // Mock the external calls. when(businessObjectFormatDaoHelper.getRecordRetentionTypeEntity(RetentionTypeEntity.PARTITION_VALUE)).thenReturn(retentionTypeEntity); // Try to call the method under test with PARTITION_VALUE retention type and without specifying a retention period in days. try { businessObjectFormatServiceImpl.updateBusinessObjectFormatRetentionInformation(businessObjectFormatKey, new BusinessObjectFormatRetentionInformationUpdateRequest(RECORD_FLAG_SET, NO_RETENTION_PERIOD_IN_DAYS, RetentionTypeEntity.PARTITION_VALUE)); fail(); } catch (IllegalArgumentException e) { assertEquals(String.format("A retention period in days must be specified for %s retention type.", RetentionTypeEntity.PARTITION_VALUE), e.getMessage()); } // Verify the external calls. verify(businessObjectFormatHelper).validateBusinessObjectFormatKey(businessObjectFormatKey, false); verify(businessObjectFormatDaoHelper).getRecordRetentionTypeEntity(RetentionTypeEntity.PARTITION_VALUE); verifyNoMoreInteractionsHelper(); }
latestVersionBusinessObjectFormatEntity.getRetentionType() != null ? latestVersionBusinessObjectFormatEntity.getRetentionType().getCode() : null; Integer retentionPeriodInDays = latestVersionBusinessObjectFormatEntity.getRetentionPeriodInDays();
@Test public void testUpdateBusinessObjectFormatRetentionInformationPartitionValueRetentionTypeNonPositiveRetentionPeriodInDays() { // Create a business object format key without version. BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION); // Create a retention type entity for PARTITION_VALUE. RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.PARTITION_VALUE); // Mock the external calls. when(businessObjectFormatDaoHelper.getRecordRetentionTypeEntity(RetentionTypeEntity.PARTITION_VALUE)).thenReturn(retentionTypeEntity); // Try to call the method under test with PARTITION_VALUE retention type and with a 0 retention period in days. try { businessObjectFormatServiceImpl.updateBusinessObjectFormatRetentionInformation(businessObjectFormatKey, new BusinessObjectFormatRetentionInformationUpdateRequest(RECORD_FLAG_SET, 0, RetentionTypeEntity.PARTITION_VALUE)); fail(); } catch (IllegalArgumentException e) { assertEquals(String.format("A positive retention period in days must be specified for %s retention type.", RetentionTypeEntity.PARTITION_VALUE), e.getMessage()); } // Verify the external calls. verify(businessObjectFormatHelper).validateBusinessObjectFormatKey(businessObjectFormatKey, false); verify(businessObjectFormatDaoHelper).getRecordRetentionTypeEntity(RetentionTypeEntity.PARTITION_VALUE); verifyNoMoreInteractionsHelper(); }
latestVersionBusinessObjectFormatEntity.getRetentionType() != null ? latestVersionBusinessObjectFormatEntity.getRetentionType().getCode() : null; Integer retentionPeriodInDays = latestVersionBusinessObjectFormatEntity.getRetentionPeriodInDays();
RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.PARTITION_VALUE);
RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.PARTITION_VALUE);
RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(INVALID_VALUE);
if (StringUtils.equals(businessObjectFormatEntity.getRetentionType().getCode(), RetentionTypeEntity.BDATA_RETENTION_DATE)) builder.lessThan(businessObjectDataEntityRoot.get(BusinessObjectDataEntity_.retentionExpiration), currentTimestamp); else if (StringUtils.equals(businessObjectFormatEntity.getRetentionType().getCode(), RetentionTypeEntity.PARTITION_VALUE) && businessObjectFormatEntity.getRetentionPeriodInDays() != null)
RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.BDATA_RETENTION_DATE);
if (StringUtils.equals(businessObjectFormatEntity.getRetentionType().getCode(), RetentionTypeEntity.BDATA_RETENTION_DATE)) builder.lessThan(businessObjectDataEntityRoot.get(BusinessObjectDataEntity_.retentionExpiration), currentTimestamp); else if (StringUtils.equals(businessObjectFormatEntity.getRetentionType().getCode(), RetentionTypeEntity.PARTITION_VALUE) && businessObjectFormatEntity.getRetentionPeriodInDays() != null)
RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity(); retentionTypeEntity.setCode(RetentionTypeEntity.BDATA_RETENTION_DATE);
if (latestVersionBusinessObjectFormatEntity.getRetentionType() != null) businessObjectFormat.setRetentionType(latestVersionBusinessObjectFormatEntity.getRetentionType().getCode());