StorageUnitDaoHelper { public void updateStorageUnitStatus(StorageUnitEntity storageUnitEntity, String storageUnitStatus, String reason) { StorageUnitStatusEntity storageUnitStatusEntity = storageUnitStatusDaoHelper.getStorageUnitStatusEntity(storageUnitStatus); updateStorageUnitStatus(storageUnitEntity, storageUnitStatusEntity, reason); }  StorageUnitEntity findExplicitlyRegisteredSubPartitionInStorageForBusinessObjectData(StorageEntity storageEntity,
        BusinessObjectFormatEntity businessObjectFormatEntity, BusinessObjectFormat businessObjectFormat, BusinessObjectDataKey businessObjectDataKey); StorageUnitEntity getStorageUnitEntity(String storageName, BusinessObjectDataEntity businessObjectDataEntity); StorageUnitEntity getStorageUnitEntityByBusinessObjectDataAndStorage(BusinessObjectDataEntity businessObjectDataEntity, StorageEntity storageEntity); StorageUnitEntity getStorageUnitEntityByKey(BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey); void setStorageUnitStatus(StorageUnitEntity storageUnitEntity, StorageUnitStatusEntity storageUnitStatusEntity); void updateStorageUnitStatus(StorageUnitEntity storageUnitEntity, String storageUnitStatus, String reason); void updateStorageUnitStatus(StorageUnitEntity storageUnitEntity, StorageUnitStatusEntity storageUnitStatusEntity, String reason); void validateNoExplicitlyRegisteredSubPartitionInStorageForBusinessObjectData(StorageEntity storageEntity,
        BusinessObjectFormatEntity businessObjectFormatEntity, BusinessObjectDataKey businessObjectDataKey, String s3KeyPrefix);  }
@Test public void testUpdateStorageUnitStatusNewStatusPassedAsEntity() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity(); StorageEntity storageEntity = new StorageEntity(); storageEntity.setName(STORAGE_NAME); StorageUnitStatusEntity oldStorageUnitStatusEntity = new StorageUnitStatusEntity(); oldStorageUnitStatusEntity.setCode(STORAGE_UNIT_STATUS); StorageUnitStatusEntity newStorageUnitStatusEntity = new StorageUnitStatusEntity(); newStorageUnitStatusEntity.setCode(STORAGE_UNIT_STATUS_2); StorageUnitEntity storageUnitEntity = new StorageUnitEntity(); storageUnitEntity.setBusinessObjectData(businessObjectDataEntity); storageUnitEntity.setStorage(storageEntity); storageUnitEntity.setStatus(oldStorageUnitStatusEntity); storageUnitEntity.setHistoricalStatuses(new ArrayList<>()); when(businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataEntity)).thenReturn(businessObjectDataKey); storageUnitDaoHelper.updateStorageUnitStatus(storageUnitEntity, newStorageUnitStatusEntity, STORAGE_UNIT_STATUS_2); assertEquals(STORAGE_UNIT_STATUS_2, storageUnitEntity.getStatus().getCode()); verify(storageUnitDao).saveAndRefresh(storageUnitEntity); verify(businessObjectDataHelper).getBusinessObjectDataKey(businessObjectDataEntity); verify(messageNotificationEventService) .processStorageUnitStatusChangeNotificationEvent(businessObjectDataKey, STORAGE_NAME, STORAGE_UNIT_STATUS_2, STORAGE_UNIT_STATUS); verifyNoMoreInteractionsHelper(); }
@Test public void testUpdateStorageUnitStatusNewStatusPassedAsString() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity(); StorageEntity storageEntity = new StorageEntity(); storageEntity.setName(STORAGE_NAME); StorageUnitStatusEntity oldStorageUnitStatusEntity = new StorageUnitStatusEntity(); oldStorageUnitStatusEntity.setCode(STORAGE_UNIT_STATUS); StorageUnitStatusEntity newStorageUnitStatusEntity = new StorageUnitStatusEntity(); newStorageUnitStatusEntity.setCode(STORAGE_UNIT_STATUS_2); StorageUnitEntity storageUnitEntity = new StorageUnitEntity(); storageUnitEntity.setBusinessObjectData(businessObjectDataEntity); storageUnitEntity.setStorage(storageEntity); storageUnitEntity.setStatus(oldStorageUnitStatusEntity); storageUnitEntity.setHistoricalStatuses(new ArrayList<>()); when(storageUnitStatusDaoHelper.getStorageUnitStatusEntity(STORAGE_UNIT_STATUS_2)).thenReturn(newStorageUnitStatusEntity); when(businessObjectDataHelper.getBusinessObjectDataKey(businessObjectDataEntity)).thenReturn(businessObjectDataKey); storageUnitDaoHelper.updateStorageUnitStatus(storageUnitEntity, STORAGE_UNIT_STATUS_2, STORAGE_UNIT_STATUS_2); assertEquals(STORAGE_UNIT_STATUS_2, storageUnitEntity.getStatus().getCode()); verify(storageUnitStatusDaoHelper).getStorageUnitStatusEntity(STORAGE_UNIT_STATUS_2); verify(storageUnitDao).saveAndRefresh(storageUnitEntity); verify(businessObjectDataHelper).getBusinessObjectDataKey(businessObjectDataEntity); verify(messageNotificationEventService) .processStorageUnitStatusChangeNotificationEvent(businessObjectDataKey, STORAGE_NAME, STORAGE_UNIT_STATUS_2, STORAGE_UNIT_STATUS); verifyNoMoreInteractionsHelper(); }