/** * Retrieves a list of keys for S3 storage units that are currently being restored. * * @param maxResult the maximum number of results to retrieve * * @return the list of storage unit keys */ protected List<BusinessObjectDataStorageUnitKey> getS3StorageUnitsToRestoreImpl(int maxResult) { // Retrieves a list of storage units that belong to S3 storage and have the relative S3 storage unit in RESTORING state. List<StorageUnitEntity> storageUnitEntities = storageUnitDao.getS3StorageUnitsToRestore(maxResult); // Build a list of storage unit keys. List<BusinessObjectDataStorageUnitKey> storageUnitKeys = new ArrayList<>(); for (StorageUnitEntity storageUnitEntity : storageUnitEntities) { storageUnitKeys.add(storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity)); } return storageUnitKeys; } }
/** * Returns all relational tables registered in the system. * * @return the list of relational table registrations */ List<BusinessObjectDataStorageUnitKey> getRelationalTableRegistrationsForSchemaUpdateImpl() { // Create a result list. List<BusinessObjectDataStorageUnitKey> storageUnitKeys = new ArrayList<>(); // Get all latest version storage units registered in the system that belong to storage // of the RELATIONAL storage platform type and business object format of the RELATIONAL_TABLE file type. List<StorageUnitEntity> storageUnitEntities = storageUnitDao .getLatestVersionStorageUnitsByStoragePlatformAndFileType(StoragePlatformEntity.RELATIONAL, FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE); // Populate the result list per selected storage unit entities. for (StorageUnitEntity storageUnitEntity : storageUnitEntities) { storageUnitKeys.add(storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity)); } return storageUnitKeys; }
/** * Returns all relational tables registered in the system. * * @return the list of relational table registrations */ List<BusinessObjectDataStorageUnitKey> getRelationalTableRegistrationsForSchemaUpdateImpl() { // Create a result list. List<BusinessObjectDataStorageUnitKey> storageUnitKeys = new ArrayList<>(); // Get all latest version storage units registered in the system that belong to storage // of the RELATIONAL storage platform type and business object format of the RELATIONAL_TABLE file type. List<StorageUnitEntity> storageUnitEntities = storageUnitDao .getLatestVersionStorageUnitsByStoragePlatformAndFileType(StoragePlatformEntity.RELATIONAL, FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE); // Populate the result list per selected storage unit entities. for (StorageUnitEntity storageUnitEntity : storageUnitEntities) { storageUnitKeys.add(storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity)); } return storageUnitKeys; }
/** * Retrieves a list of keys for restored S3 storage units that are ready to be expired. * * @param maxResult the maximum number of results to retrieve * * @return the list of storage unit keys */ protected List<BusinessObjectDataStorageUnitKey> getS3StorageUnitsToExpireImpl(int maxResult) { // Retrieves a list of storage units that belong to S3 storage, have RESTORED status, and ready to be expired. List<StorageUnitEntity> storageUnitEntities = storageUnitDao.getS3StorageUnitsToExpire(maxResult); // Build a list of storage unit keys. List<BusinessObjectDataStorageUnitKey> storageUnitKeys = new ArrayList<>(); for (StorageUnitEntity storageUnitEntity : storageUnitEntities) { storageUnitKeys.add(storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity)); } return storageUnitKeys; } }
/** * Retrieves a list of keys for restored S3 storage units that are ready to be expired. * * @param maxResult the maximum number of results to retrieve * * @return the list of storage unit keys */ protected List<BusinessObjectDataStorageUnitKey> getS3StorageUnitsToExpireImpl(int maxResult) { // Retrieves a list of storage units that belong to S3 storage, have RESTORED status, and ready to be expired. List<StorageUnitEntity> storageUnitEntities = storageUnitDao.getS3StorageUnitsToExpire(maxResult); // Build a list of storage unit keys. List<BusinessObjectDataStorageUnitKey> storageUnitKeys = new ArrayList<>(); for (StorageUnitEntity storageUnitEntity : storageUnitEntities) { storageUnitKeys.add(storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity)); } return storageUnitKeys; } }
/** * Retrieves a list of keys for S3 storage units that are currently being restored. * * @param maxResult the maximum number of results to retrieve * * @return the list of storage unit keys */ protected List<BusinessObjectDataStorageUnitKey> getS3StorageUnitsToRestoreImpl(int maxResult) { // Retrieves a list of storage units that belong to S3 storage and have the relative S3 storage unit in RESTORING state. List<StorageUnitEntity> storageUnitEntities = storageUnitDao.getS3StorageUnitsToRestore(maxResult); // Build a list of storage unit keys. List<BusinessObjectDataStorageUnitKey> storageUnitKeys = new ArrayList<>(); for (StorageUnitEntity storageUnitEntity : storageUnitEntities) { storageUnitKeys.add(storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity)); } return storageUnitKeys; } }
/** * Retrieves a list of keys for destroyed S3 storage units that are ready for cleanup. * * @param maxResult the maximum number of results to retrieve * * @return the list of storage unit keys */ List<BusinessObjectDataStorageUnitKey> getS3StorageUnitsToCleanupImpl(int maxResult) { // Retrieves a list of storage units that belong to S3 storage, and has a final destroy on timestamp < current time, has a DELETED status, // and associated BData has a DELETED status. List<StorageUnitEntity> storageUnitEntities = storageUnitDao.getS3StorageUnitsToCleanup(maxResult); // Build a list of storage unit keys. List<BusinessObjectDataStorageUnitKey> storageUnitKeys = new ArrayList<>(); for (StorageUnitEntity storageUnitEntity : storageUnitEntities) { storageUnitKeys.add(storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity)); } return storageUnitKeys; } }
/** * Retrieves a list of keys for destroyed S3 storage units that are ready for cleanup. * * @param maxResult the maximum number of results to retrieve * * @return the list of storage unit keys */ List<BusinessObjectDataStorageUnitKey> getS3StorageUnitsToCleanupImpl(int maxResult) { // Retrieves a list of storage units that belong to S3 storage, and has a final destroy on timestamp < current time, has a DELETED status, // and associated BData has a DELETED status. List<StorageUnitEntity> storageUnitEntities = storageUnitDao.getS3StorageUnitsToCleanup(maxResult); // Build a list of storage unit keys. List<BusinessObjectDataStorageUnitKey> storageUnitKeys = new ArrayList<>(); for (StorageUnitEntity storageUnitEntity : storageUnitEntities) { storageUnitKeys.add(storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity)); } return storageUnitKeys; } }
@Test public void testGetS3StorageUnitsToExpire() { // Create a storage unit entity. StorageUnitEntity storageUnitEntity = new StorageUnitEntity(); // Create a list of storage unit entities. List<StorageUnitEntity> storageUnitEntities = Arrays.asList(storageUnitEntity); // Create a storage unit key. BusinessObjectDataStorageUnitKey storageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME); // Mock the external calls. when(storageUnitDao.getS3StorageUnitsToExpire(MAX_RESULT)).thenReturn(storageUnitEntities); when(storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity)).thenReturn(storageUnitKey); // Call the method under test. List<BusinessObjectDataStorageUnitKey> result = expireRestoredBusinessObjectDataServiceImpl.getS3StorageUnitsToExpire(MAX_RESULT); // Verify the external calls. verify(storageUnitDao).getS3StorageUnitsToExpire(MAX_RESULT); verify(storageUnitHelper).createStorageUnitKeyFromEntity(storageUnitEntity); verifyNoMoreInteractionsHelper(); // Validate the result. assertEquals(Arrays.asList(storageUnitKey), result); }
@Test public void testGetS3StorageUnitsToCleanup() { // Create a storage unit entity. StorageUnitEntity storageUnitEntity = new StorageUnitEntity(); // Create a list of storage unit entities. List<StorageUnitEntity> storageUnitEntities = Collections.singletonList(storageUnitEntity); // Create a storage unit key. BusinessObjectDataStorageUnitKey storageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME); // Mock the external calls. when(mockStorageUnitDao.getS3StorageUnitsToCleanup(MAX_RESULT)).thenReturn(storageUnitEntities); when(mockStorageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity)).thenReturn(storageUnitKey); // Call the method under test. List<BusinessObjectDataStorageUnitKey> result = cleanupDestroyedBusinessObjectDataService.getS3StorageUnitsToCleanup(MAX_RESULT); // Verify the external calls. verify(mockStorageUnitDao).getS3StorageUnitsToCleanup(MAX_RESULT); verify(mockStorageUnitHelper).createStorageUnitKeyFromEntity(storageUnitEntity); verifyNoMoreInteractionsHelper(); // Validate the result. assertEquals(Collections.singletonList(storageUnitKey), result); }
@Test public void testGetS3StorageUnitsToRestore() { // Create a storage unit entity. StorageUnitEntity storageUnitEntity = new StorageUnitEntity(); // Create a list of storage unit entities. List<StorageUnitEntity> storageUnitEntities = Arrays.asList(storageUnitEntity); // Create a storage unit key. BusinessObjectDataStorageUnitKey storageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME); // Mock the external calls. when(storageUnitDao.getS3StorageUnitsToRestore(MAX_RESULT)).thenReturn(storageUnitEntities); when(storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity)).thenReturn(storageUnitKey); // Call the method under test. List<BusinessObjectDataStorageUnitKey> result = businessObjectDataFinalizeRestoreServiceImpl.getS3StorageUnitsToRestore(MAX_RESULT); // Verify the external calls. verify(storageUnitDao).getS3StorageUnitsToRestore(MAX_RESULT); verify(storageUnitHelper).createStorageUnitKeyFromEntity(storageUnitEntity); verifyNoMoreInteractionsHelper(); // Validate the result. assertEquals(Arrays.asList(storageUnitKey), result); }
@Test public void testGetRelationalTableRegistrationsForSchemaUpdate() { // Create a storage unit entity for a relational table registration. StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, StoragePlatformEntity.RELATIONAL, new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE, INITIAL_FORMAT_VERSION, BusinessObjectDataServiceImpl.NO_PARTITIONING_PARTITION_VALUE, NO_SUBPARTITION_VALUES, INITIAL_DATA_VERSION), AbstractDaoTest.LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID, StorageUnitStatusEntity.ENABLED, AbstractDaoTest.NO_STORAGE_DIRECTORY_PATH); // Get a list of relational table registrations for the schema update.. List<BusinessObjectDataStorageUnitKey> result = relationalTableRegistrationService.getRelationalTableRegistrationsForSchemaUpdate(); // Validate the results. assertEquals(Collections.singletonList(storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity)), result); }
BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey3 = storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntities.get(3)); BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey2 = storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntities.get(2)); assertEquals(Arrays.asList(businessObjectDataStorageUnitKey3, businessObjectDataStorageUnitKey2), result);
@Test public void testCreateStorageUnitKeyFromEntity() { // Create a business object data storage unit key. BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME); // Create a storage unit entity. StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper.createStorageUnitEntity(businessObjectDataStorageUnitKey, STORAGE_UNIT_STATUS); // Mock the external calls. when(businessObjectDataHelper.getSubPartitionValues(storageUnitEntity.getBusinessObjectData())).thenReturn(SUBPARTITION_VALUES); // Call the method under test. BusinessObjectDataStorageUnitKey result = storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity); // Verify the external calls. verify(businessObjectDataHelper).getSubPartitionValues(storageUnitEntity.getBusinessObjectData()); verifyNoMoreInteractionsHelper(); // Validate the results. assertEquals(new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME), result); }
return storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity);
BusinessObjectDataStorageUnitKey storageUnitKey = storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity);
BusinessObjectDataStorageUnitKey storageUnitKey = storageUnitHelper.createStorageUnitKeyFromEntity(storageUnitEntity);