/** * Creates and persists a new storage entity of S3 storage platform with the specified attributes. * * @param storageName the storage name * @param attributes the storage attributes. * * @return the newly created storage entity. */ public StorageEntity createStorageEntity(String storageName, List<Attribute> attributes) { return createStorageEntity(storageName, StoragePlatformEntity.S3, attributes); }
/** * Creates and persists a new storage entity of S3 storage platform with no attributes. * * @param storageName the storage name * * @return the newly created storage entity. */ public StorageEntity createStorageEntity(String storageName) { return createStorageEntity(storageName, StoragePlatformEntity.S3); }
/** * Creates and persists a new storage entity with no attributes. * * @param storageName the storage name * @param storagePlatformCode the storage platform code * * @return the newly created storage entity. */ public StorageEntity createStorageEntity(String storageName, String storagePlatformCode) { return createStorageEntity(storageName, storagePlatformCode, null); }
/** * Creates and persists a new storage entity based on the specified storage name and storage platform entity and no attributes. * * @param storageName the storage name * @param storagePlatformEntity the storage platform entity * * @return the newly created storage entity. */ public StorageEntity createStorageEntity(String storageName, StoragePlatformEntity storagePlatformEntity) { return createStorageEntity(storageName, storagePlatformEntity, null); }
/** * Creates and persists a new storage entity with a random name and no attributes. * * @return the newly created storage entity. */ public StorageEntity createStorageEntity() { return createStorageEntity("StorageTest" + AbstractDaoTest.getRandomSuffix()); }
/** * Creates and persists a new storage entity with a random name with the specified attributes. * * @param attributeName the attribute name. * @param attributeValue the attribute value. * * @return the newly created storage entity. */ public StorageEntity createStorageEntityWithAttributes(String attributeName, String attributeValue) { return createStorageEntity("StorageTest" + AbstractDaoTest.getRandomSuffix(), StoragePlatformEntity.S3, attributeName, attributeValue); }
/** * Creates and persists a new storage entity with an attribute. * * @param storageName the storage name * @param storagePlatformCode the storage platform code * @param attributeName the attribute name * @param attributeValue the attribute value * * @return the newly created storage entity. */ public StorageEntity createStorageEntity(String storageName, String storagePlatformCode, String attributeName, String attributeValue) { List<Attribute> attributes = new ArrayList<>(); attributes.add(new Attribute(attributeName, attributeValue)); return createStorageEntity(storageName, storagePlatformCode, attributes); }
private StorageEntity createTestStorageEntity(String storageName, String bucketName) throws Exception { List<Attribute> attributes = new ArrayList<>(); // If specified, populate bucket name attribute for this storage. if (StringUtils.isNotBlank(bucketName)) { attributes.add(new Attribute(configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), bucketName)); } return storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3, attributes); }
/** * Creates database entities required for relational table registration unit tests. * * @param storageName the storage name */ void createDatabaseEntitiesForRelationalTableRegistrationTesting(String storageName) { // Create RELATIONAL_TABLE file type entity. fileTypeDaoTestHelper.createFileTypeEntity(FileTypeEntity.RELATIONAL_TABLE_FILE_TYPE, AbstractServiceTest.FORMAT_FILE_TYPE_DESCRIPTION); // Create a RELATIONAL storage with attributes required for relational table registration testing. storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.RELATIONAL, getStorageAttributes()); }
/** * Creates and persists a new storage entity with the specified attributes. * * @param storageName the storage name * @param storagePlatformCode the storage platform code * @param attributes the attributes. * * @return the newly created storage entity. */ public StorageEntity createStorageEntity(String storageName, String storagePlatformCode, List<Attribute> attributes) { // Create storage platform entity if it does not exist. StoragePlatformEntity storagePlatformEntity = storagePlatformDao.getStoragePlatformByName(storagePlatformCode); if (storagePlatformEntity == null) { storagePlatformEntity = storagePlatformDaoTestHelper.createStoragePlatformEntity(storagePlatformCode); } return createStorageEntity(storageName, storagePlatformEntity, attributes); }
/** * Storage attribute: non-existent Default value: null Assert return default value */ @Test public void testGetStorageAttributeIntegerValueByNameWithDefault_2() { String attributeName = "test"; StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(); Integer defaultValue = null; Integer value = storageHelper.getStorageAttributeIntegerValueByName(attributeName, storageEntity, defaultValue); assertEquals(defaultValue, value); }
/** * Storage attribute: non-existent Default value: 2345 Assert return default value */ @Test public void testGetStorageAttributeIntegerValueByNameWithDefault_1() { String attributeName = "test"; StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(); Integer defaultValue = 2345; Integer value = storageHelper.getStorageAttributeIntegerValueByName(attributeName, storageEntity, defaultValue); assertEquals(defaultValue, value); }
/** * Storage attribute: non-existent Attribute required: false Attribute required if exists: false Assert return null */ @Test public void testGetStorageAttributeIntegerValueByName_10() { String attributeName = "test"; StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(); boolean attributeRequired = false; boolean attributeValueRequiredIfExists = true; Integer value = storageHelper.getStorageAttributeIntegerValueByName(attributeName, storageEntity, attributeRequired, attributeValueRequiredIfExists); assertEquals(null, value); }
/** * Storage attribute: non-existent Attribute required: false Attribute required if exists: true Assert return null */ @Test public void testGetStorageAttributeIntegerValueByName_8() { String attributeName = "test"; StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(); boolean attributeRequired = false; boolean attributeValueRequiredIfExists = true; Integer value = storageHelper.getStorageAttributeIntegerValueByName(attributeName, storageEntity, attributeRequired, attributeValueRequiredIfExists); assertEquals(null, value); }
@Test public void testGetStorageUnitByStorageAndDirectoryPath() { // Create two storage entities. List<StorageEntity> storageEntities = Arrays.asList(storageDaoTestHelper.createStorageEntity(STORAGE_NAME), storageDaoTestHelper.createStorageEntity(STORAGE_NAME_2)); // Create a storage unit entity. StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper .createStorageUnitEntity(STORAGE_NAME, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, STORAGE_UNIT_STATUS, STORAGE_DIRECTORY_PATH); // Retrieve the relative storage unit entity. assertEquals(storageUnitEntity, storageUnitDao.getStorageUnitByStorageAndDirectoryPath(storageEntities.get(0), STORAGE_DIRECTORY_PATH)); // Test case sensitivity of the storage directory path. assertNull(storageUnitDao.getStorageUnitByStorageAndDirectoryPath(storageEntities.get(0), STORAGE_DIRECTORY_PATH.toUpperCase())); assertNull(storageUnitDao.getStorageUnitByStorageAndDirectoryPath(storageEntities.get(0), STORAGE_DIRECTORY_PATH.toLowerCase())); // Confirm that no storage unit get selected when using wrong input parameters. assertNull(storageUnitDao.getStorageUnitByStorageAndDirectoryPath(storageEntities.get(1), STORAGE_DIRECTORY_PATH)); assertNull(storageUnitDao.getStorageUnitByStorageAndDirectoryPath(storageEntities.get(0), I_DO_NOT_EXIST)); }
@Test public void testGetAllStorage() { // Get a list of test storage keys. List<StorageKey> storageKeys = storageDaoTestHelper.getTestStorageKeys(); // Create and persist test storage entities. for (StorageKey storageKey : storageKeys) { storageDaoTestHelper.createStorageEntity(storageKey.getStorageName()); } // Retrieve a list of storage keys. StorageKeys result = storageService.getAllStorage(); // Validate the results. assertNotNull(result); assertTrue(result.getStorageKeys().containsAll(storageKeys)); }
@Test public void testGetAllStorage() { // Get a list of test storage keys. List<StorageKey> storageKeys = storageDaoTestHelper.getTestStorageKeys(); // Create and persist storage entities. for (StorageKey storageKey : storageKeys) { storageDaoTestHelper.createStorageEntity(storageKey.getStorageName()); } // Retrieve a list of storage keys for all storage registered in the system. List<StorageKey> result = storageDao.getAllStorage(); // Validate the results. assertNotNull(result); assertTrue(result.containsAll(storageDaoTestHelper.getTestStorageKeys())); } }
@Test public void testCreateBusinessObjectDataPreRegistrationAssertDirectoryPathNotRequiredWhenStatusIsPreRegistrationAndDirectoryIsSetInResponse() { StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME); storageEntity.getAttributes().add(storageDaoTestHelper .createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE), "foo")); // Create an initial version of the business object data. BusinessObjectDataCreateRequest businessObjectDataCreateRequest = businessObjectDataServiceTestHelper.getNewBusinessObjectDataCreateRequest(); businessObjectDataCreateRequest.setSubPartitionValues(null); businessObjectDataCreateRequest.setStatus("UPLOADING"); businessObjectDataCreateRequest.setStorageUnits(Arrays.asList(new StorageUnitCreateRequest(STORAGE_NAME, null, null, null))); BusinessObjectData businessObjectData = businessObjectDataService.createBusinessObjectData(businessObjectDataCreateRequest); assertEquals("foo", businessObjectData.getStorageUnits().get(0).getStorageDirectory().getDirectoryPath()); }
@Test public void testGetBusinessObjectDataPartitionValueNoStorageSpecified() { // Create database entities required for testing. StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME, STORAGE_PLATFORM_CODE); storageUnitDaoTestHelper .createStorageUnitEntity(storageEntity.getName(), NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID, STORAGE_UNIT_STATUS, NO_STORAGE_DIRECTORY_PATH); // Create a business object format key. BusinessObjectFormatKey businessObjectFormatKey = new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION); // Validate that we can retrieve maximum and minimum partition values without specifying storage. assertEquals(PARTITION_VALUE, businessObjectDataDao .getBusinessObjectDataMaxPartitionValue(BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, businessObjectFormatKey, NO_DATA_VERSION, NO_BDATA_STATUS, NO_STORAGE_NAMES, null, null, null, null)); assertEquals(PARTITION_VALUE, businessObjectDataDao .getBusinessObjectDataMinPartitionValue(BusinessObjectDataEntity.FIRST_PARTITION_COLUMN_POSITION, businessObjectFormatKey, NO_DATA_VERSION, NO_BDATA_STATUS, NO_STORAGE_NAMES, null, null)); }
@Test public void testGetStorageUnitByBusinessObjectDataAndStorage() { StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper .createStorageUnitEntity(STORAGE_NAME, NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, INITIAL_DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, STORAGE_UNIT_STATUS, STORAGE_DIRECTORY_PATH); BusinessObjectDataEntity businessObjectDataEntity = storageUnitEntity.getBusinessObjectData(); StorageEntity storageEntity = storageUnitEntity.getStorage(); // Test retrieval by entities. assertEquals(storageUnitEntity, storageUnitDao.getStorageUnitByBusinessObjectDataAndStorage(businessObjectDataEntity, storageEntity)); // Test retrieval failures. assertNull( storageUnitDao.getStorageUnitByBusinessObjectDataAndStorage(businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(), storageEntity)); assertNull(storageUnitDao.getStorageUnitByBusinessObjectDataAndStorage(businessObjectDataEntity, storageDaoTestHelper.createStorageEntity())); }