/** * Create an instance of {@link Storage } * */ public Storage createStorage() { return new Storage(); }
/** * Create an instance of {@link Storage } * */ public Storage createStorage() { return new Storage(); }
/** * Create an instance of {@link Storage } * */ public Storage createStorage() { return new Storage(); }
public Object createNewInstance() { return new Storage(); }
public Object createNewInstance() { return new Storage(); }
public Object createNewInstance() { return new Storage(); }
/** * Creates a storage from it's entity object. * * @param storageEntity the storage entity * * @return the storage */ private Storage createStorageFromEntity(StorageEntity storageEntity) { // Create a list of attributes. List<Attribute> attributes = new ArrayList<>(); for (StorageAttributeEntity attributeEntity : storageEntity.getAttributes()) { attributes.add(new Attribute(attributeEntity.getName(), attributeEntity.getValue())); } return new Storage(storageEntity.getName(), storageEntity.getStoragePlatform().getName(), attributes); }
/** * Creates a storage from it's entity object. * * @param storageEntity the storage entity * * @return the storage */ private Storage createStorageFromEntity(StorageEntity storageEntity) { // Create a list of attributes. List<Attribute> attributes = new ArrayList<>(); for (StorageAttributeEntity attributeEntity : storageEntity.getAttributes()) { attributes.add(new Attribute(attributeEntity.getName(), attributeEntity.getValue())); } return new Storage(storageEntity.getName(), storageEntity.getStoragePlatform().getName(), attributes); }
@Test public void testCreateDownloaderOutputManifestDtoAssertOutputFilesEmptyWhenStorageFilesNull() { BusinessObjectData businessObjectData = new BusinessObjectData(); StorageUnit storageUnit = new StorageUnit(new Storage("storageName", null, null), null, null, StorageUnitStatusEntity.ENABLED, null, null, null); String s3KeyPrefix = "s3KeyPrefix"; DownloaderOutputManifestDto actual = downloaderController.createDownloaderOutputManifestDto(businessObjectData, storageUnit, s3KeyPrefix); assertEquals(0, actual.getManifestFiles().size()); }
@Test public void testDeleteStorage() { // Create a storage key. StorageKey storageKey = new StorageKey(STORAGE_NAME); // Create a storage. Storage storage = new Storage(STORAGE_NAME, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES); // Mock the external calls. when(storageService.deleteStorage(storageKey)).thenReturn(storage); // Call the method under test. Storage result = storageRestController.deleteStorage(STORAGE_NAME); // Verify the external calls. verify(storageService).deleteStorage(storageKey); verifyNoMoreInteractions(storageService); // Validate the returned object. assertEquals(storage, result); }
@Test public void testCreateDownloaderOutputManifestDtoAssertOutputAttributesSetWhenBdataAttributesSet() { BusinessObjectData businessObjectData = new BusinessObjectData(); businessObjectData.setAttributes(new ArrayList<>()); businessObjectData.getAttributes().add(new Attribute("name", "value")); StorageUnit storageUnit = new StorageUnit(new Storage("storageName", null, null), null, null, StorageUnitStatusEntity.ENABLED, null, null, null); String s3KeyPrefix = "s3KeyPrefix"; DownloaderOutputManifestDto actual = downloaderController.createDownloaderOutputManifestDto(businessObjectData, storageUnit, s3KeyPrefix); assertEquals(1, actual.getAttributes().size()); assertEquals("value", actual.getAttributes().get("name")); }
@Test public void testCreateStorage() { // Create a storage create request. StorageCreateRequest storageCreateRequest = new StorageCreateRequest(STORAGE_NAME, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES); // Create a storage. Storage storage = new Storage(STORAGE_NAME, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES); // Mock the external calls. when(storageService.createStorage(storageCreateRequest)).thenReturn(storage); // Call the method under test. Storage result = storageRestController.createStorage(storageCreateRequest); // Verify the external calls. verify(storageService).createStorage(storageCreateRequest); verifyNoMoreInteractions(storageService); // Validate the returned object. assertEquals(storage, result); }
@Test public void testGetStorage() { // Create a storage key. StorageKey storageKey = new StorageKey(STORAGE_NAME); // Create a storage. Storage storage = new Storage(STORAGE_NAME, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES); // Mock the external calls. when(storageService.getStorage(storageKey)).thenReturn(storage); // Call the method under test. Storage result = storageRestController.getStorage(STORAGE_NAME); // Verify the external calls. verify(storageService).getStorage(storageKey); verifyNoMoreInteractions(storageService); // Validate the returned object. assertEquals(storage, result); }
@Test public void testUpdateStorage() { // Create a storage key. StorageKey storageKey = new StorageKey(STORAGE_NAME); // Create a storage update request. StorageUpdateRequest storageUpdateRequest = new StorageUpdateRequest(); // Create a storage. Storage storage = new Storage(STORAGE_NAME, STORAGE_PLATFORM_CODE, NO_ATTRIBUTES); // Mock the external calls. when(storageService.updateStorage(storageKey, storageUpdateRequest)).thenReturn(storage); // Call the method under test. Storage result = storageRestController.updateStorage(STORAGE_NAME, storageUpdateRequest); // Verify the external calls. verify(storageService).updateStorage(storageKey, storageUpdateRequest); verifyNoMoreInteractions(storageService); // Validate the returned object. assertEquals(storage, result); }
@Test public void testCreateStorageMissingOptionalParameters() { // Create and persist a valid storage without specifying optional parameters. StorageCreateRequest request = getNewStorageCreateRequest(); request.setAttributes(null); Storage result = storageService.createStorage(request); // Validate the results. assertEquals(new Storage(request.getName(), request.getStoragePlatformName(), NO_ATTRIBUTES), result); }
@Test public void testCreateStorage() { // Create and persist a valid storage. StorageCreateRequest request = getNewStorageCreateRequest(); Storage result = storageService.createStorage(request); // Validate the results. assertEquals(new Storage(request.getName(), request.getStoragePlatformName(), request.getAttributes()), result); }
private BusinessObjectData toBusinessObjectData(final UploaderInputManifestDto uploaderInputManifestDto) { BusinessObjectData businessObjectData = new BusinessObjectData(); businessObjectData.setNamespace(uploaderInputManifestDto.getNamespace()); businessObjectData.setBusinessObjectDefinitionName(uploaderInputManifestDto.getBusinessObjectDefinitionName()); businessObjectData.setBusinessObjectFormatUsage(uploaderInputManifestDto.getBusinessObjectFormatUsage()); businessObjectData.setBusinessObjectFormatFileType(uploaderInputManifestDto.getBusinessObjectFormatFileType()); businessObjectData.setBusinessObjectFormatVersion(Integer.valueOf(uploaderInputManifestDto.getBusinessObjectFormatVersion())); businessObjectData.setPartitionKey(uploaderInputManifestDto.getPartitionKey()); businessObjectData.setPartitionValue(uploaderInputManifestDto.getPartitionValue()); businessObjectData.setSubPartitionValues(uploaderInputManifestDto.getSubPartitionValues()); businessObjectData.setVersion(TEST_DATA_VERSION_V0); businessObjectData .setStorageUnits(Arrays.asList(new StorageUnit(new Storage(StorageEntity.MANAGED_STORAGE, null, null), null, null, null, null, null, null))); return businessObjectData; } }
@Test public void testUpdateStorageAttributesRemoveAllAttributes() { // Create and persist a valid storage. StorageCreateRequest request = getNewStorageCreateRequest(); Storage storage = storageService.createStorage(request); // Update attributes for the storage. Storage result = storageService.updateStorageAttributes(new StorageKey(storage.getName()), new StorageAttributesUpdateRequest(NO_ATTRIBUTES)); // Validate the results. assertEquals(new Storage(storage.getName(), storage.getStoragePlatformName(), NO_ATTRIBUTES), result); }
@Test public void testUpdateStorage() { // Create a storage. Storage storage = storageService.createStorage(getNewStorageCreateRequest()); // Update the storage. // TODO: Update various attributes of the storage update request in the future when there is something to update. Storage result = storageService.updateStorage(new StorageKey(storage.getName()), new StorageUpdateRequest()); // Validate the results. // TODO: Add asserts to ensure fields that were update indeed got updated. assertEquals(new Storage(storage.getName(), storage.getStoragePlatformName(), storage.getAttributes()), result); }
@Test public void testUpdateStorageAttributes() { // Create and persist a valid storage. StorageCreateRequest request = getNewStorageCreateRequest(); Storage storage = storageService.createStorage(request); // Update attributes for the storage. Storage result = storageService.updateStorageAttributes(new StorageKey(storage.getName()), new StorageAttributesUpdateRequest(businessObjectDefinitionServiceTestHelper.getNewAttributes2())); // Validate the results. assertEquals(new Storage(storage.getName(), storage.getStoragePlatformName(), businessObjectDefinitionServiceTestHelper.getNewAttributes2()), result); }