use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class JobDefinitionDaoTest method testGetJobDefinitionByAltKey.
@Test
public void testGetJobDefinitionByAltKey() {
// Create a namespace database entity.
NamespaceEntity namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
// Create and persist a job definition entity.
JobDefinitionEntity jobDefinitionEntity = jobDefinitionDaoTestHelper.createJobDefinitionEntity(namespaceEntity, JOB_NAME, JOB_DESCRIPTION, ACTIVITI_ID);
// Retrieve the job definition by its key.
assertEquals(jobDefinitionEntity, jobDefinitionDao.getJobDefinitionByAltKey(NAMESPACE, JOB_NAME));
// Retrieve the job definition by its key in uppercase.
assertEquals(jobDefinitionEntity, jobDefinitionDao.getJobDefinitionByAltKey(NAMESPACE.toUpperCase(), JOB_NAME.toUpperCase()));
// Retrieve the job definition by its key in lowercase.
assertEquals(jobDefinitionEntity, jobDefinitionDao.getJobDefinitionByAltKey(NAMESPACE.toLowerCase(), JOB_NAME.toLowerCase()));
// Try to retrieve a job definition for a non-existing namespace.
assertNull(jobDefinitionDao.getJobDefinitionByAltKey("I_DO_NOT_EXIST", JOB_NAME));
// Try to retrieve a job definition for a non-existing job name.
assertNull(jobDefinitionDao.getJobDefinitionByAltKey(NAMESPACE, "I_DO_NOT_EXIST"));
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class NamespaceDaoTest method testGetNamespaceByKey.
@Test
public void testGetNamespaceByKey() {
// Create a namespace entity.
namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
// Retrieve the namespace entity.
NamespaceEntity resultNamespaceEntity = namespaceDao.getNamespaceByKey(new NamespaceKey(NAMESPACE));
// Validate the results.
assertEquals(NAMESPACE, resultNamespaceEntity.getCode());
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationDaoTest method getNamespaceIamRoleAuthorizationsAssertFilterByNamespaceWhenGiven.
@Test
public void getNamespaceIamRoleAuthorizationsAssertFilterByNamespaceWhenGiven() {
NamespaceEntity namespaceEntity1 = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
NamespaceEntity namespaceEntity2 = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE_2);
{
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizations = namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(namespaceEntity1);
assertNotNull(namespaceIamRoleAuthorizations);
assertEquals(0, namespaceIamRoleAuthorizations.size());
}
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity1 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity1.setNamespace(namespaceEntity1);
namespaceIamRoleAuthorizationEntity1.setIamRoleName("iamRoleName1");
namespaceIamRoleAuthorizationEntity1.setDescription("description1");
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity1);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity2 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity2.setNamespace(namespaceEntity2);
namespaceIamRoleAuthorizationEntity2.setIamRoleName("iamRoleName2");
namespaceIamRoleAuthorizationEntity2.setDescription("description2");
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity2);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity3 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity3.setNamespace(namespaceEntity1);
namespaceIamRoleAuthorizationEntity3.setIamRoleName("iamRoleName3");
namespaceIamRoleAuthorizationEntity3.setDescription("description3");
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity3);
{
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizations = namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(namespaceEntity1);
assertNotNull(namespaceIamRoleAuthorizations);
assertEquals(2, namespaceIamRoleAuthorizations.size());
{
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = namespaceIamRoleAuthorizations.get(0);
assertNotNull(namespaceIamRoleAuthorizationEntity);
assertEquals(namespaceEntity1.getCode(), namespaceIamRoleAuthorizationEntity.getNamespace().getCode());
assertEquals(namespaceIamRoleAuthorizationEntity1.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity1.getDescription(), namespaceIamRoleAuthorizationEntity.getDescription());
}
{
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = namespaceIamRoleAuthorizations.get(1);
assertNotNull(namespaceIamRoleAuthorizationEntity);
assertEquals(namespaceEntity1.getCode(), namespaceIamRoleAuthorizationEntity.getNamespace().getCode());
assertEquals(namespaceIamRoleAuthorizationEntity3.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity3.getDescription(), namespaceIamRoleAuthorizationEntity.getDescription());
}
}
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class NamespaceIamRoleAuthorizationDaoTest method getNamespaceIamRoleAuthorizationsAssertGetAllWhenNamespaceIsNotGiven.
@Test
public void getNamespaceIamRoleAuthorizationsAssertGetAllWhenNamespaceIsNotGiven() {
NamespaceEntity namespaceEntity1 = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE);
NamespaceEntity namespaceEntity2 = namespaceDaoTestHelper.createNamespaceEntity(NAMESPACE_2);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity1 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity1.setNamespace(namespaceEntity1);
namespaceIamRoleAuthorizationEntity1.setIamRoleName("iamRoleName1");
namespaceIamRoleAuthorizationEntity1.setDescription("description1");
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity1);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity2 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity2.setNamespace(namespaceEntity2);
namespaceIamRoleAuthorizationEntity2.setIamRoleName("iamRoleName2");
namespaceIamRoleAuthorizationEntity2.setDescription("description2");
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity2);
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity3 = new NamespaceIamRoleAuthorizationEntity();
namespaceIamRoleAuthorizationEntity3.setNamespace(namespaceEntity1);
namespaceIamRoleAuthorizationEntity3.setIamRoleName("iamRoleName3");
namespaceIamRoleAuthorizationEntity3.setDescription("description3");
namespaceIamRoleAuthorizationDao.saveAndRefresh(namespaceIamRoleAuthorizationEntity3);
{
List<NamespaceIamRoleAuthorizationEntity> namespaceIamRoleAuthorizations = namespaceIamRoleAuthorizationDao.getNamespaceIamRoleAuthorizations(null);
assertNotNull(namespaceIamRoleAuthorizations);
assertEquals(3, namespaceIamRoleAuthorizations.size());
{
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = namespaceIamRoleAuthorizations.get(0);
assertNotNull(namespaceIamRoleAuthorizationEntity);
assertEquals(namespaceEntity1.getCode(), namespaceIamRoleAuthorizationEntity.getNamespace().getCode());
assertEquals(namespaceIamRoleAuthorizationEntity1.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity1.getDescription(), namespaceIamRoleAuthorizationEntity.getDescription());
}
{
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = namespaceIamRoleAuthorizations.get(1);
assertNotNull(namespaceIamRoleAuthorizationEntity);
assertEquals(namespaceEntity1.getCode(), namespaceIamRoleAuthorizationEntity.getNamespace().getCode());
assertEquals(namespaceIamRoleAuthorizationEntity3.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity3.getDescription(), namespaceIamRoleAuthorizationEntity.getDescription());
}
{
NamespaceIamRoleAuthorizationEntity namespaceIamRoleAuthorizationEntity = namespaceIamRoleAuthorizations.get(2);
assertNotNull(namespaceIamRoleAuthorizationEntity);
assertEquals(namespaceEntity2.getCode(), namespaceIamRoleAuthorizationEntity.getNamespace().getCode());
assertEquals(namespaceIamRoleAuthorizationEntity2.getIamRoleName(), namespaceIamRoleAuthorizationEntity.getIamRoleName());
assertEquals(namespaceIamRoleAuthorizationEntity2.getDescription(), namespaceIamRoleAuthorizationEntity.getDescription());
}
}
}
use of org.finra.herd.model.jpa.NamespaceEntity in project herd by FINRAOS.
the class NotificationRegistrationDaoTestHelper method createStorageUnitNotificationRegistrationEntity.
/**
* Creates and persists a storage unit notification registration entity.
*
* @param notificationRegistrationKey the business object data notification registration key
* @param notificationEventTypeCode the notification event type
* @param businessObjectDefinitionNamespace the business object definition namespace
* @param businessObjectDefinitionName the business object definition name
* @param businessObjectFormatUsage the business object usage
* @param businessObjectFormatFileType the business object format file type
* @param businessObjectFormatVersion the business object format version
* @param storageName the storage name
* @param newStorageUnitStatus the new storage unit status
* @param oldStorageUnitStatus the old storage unit status
* @param jobActions the list of job actions
* @param notificationRegistrationStatus the notification registration status
*
* @return the newly created storage unit notification registration entity
*/
public StorageUnitNotificationRegistrationEntity createStorageUnitNotificationRegistrationEntity(NotificationRegistrationKey notificationRegistrationKey, String notificationEventTypeCode, String businessObjectDefinitionNamespace, String businessObjectDefinitionName, String businessObjectFormatUsage, String businessObjectFormatFileType, Integer businessObjectFormatVersion, String storageName, String newStorageUnitStatus, String oldStorageUnitStatus, List<JobAction> jobActions, String notificationRegistrationStatus) {
// Create a namespace entity if needed.
NamespaceEntity namespaceEntity = namespaceDao.getNamespaceByCd(notificationRegistrationKey.getNamespace());
if (namespaceEntity == null) {
namespaceEntity = namespaceDaoTestHelper.createNamespaceEntity(notificationRegistrationKey.getNamespace());
}
// Create a notification event type entity if needed.
NotificationEventTypeEntity notificationEventTypeEntity = notificationEventTypeDao.getNotificationEventTypeByCode(notificationEventTypeCode);
if (notificationEventTypeEntity == null) {
notificationEventTypeEntity = createNotificationEventTypeEntity(notificationEventTypeCode);
}
// Create a business object definition entity if needed.
BusinessObjectDefinitionEntity businessObjectDefinitionEntity = businessObjectDefinitionDao.getBusinessObjectDefinitionByKey(new BusinessObjectDefinitionKey(businessObjectDefinitionNamespace, businessObjectDefinitionName));
if (businessObjectDefinitionEntity == null) {
businessObjectDefinitionEntity = businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(businessObjectDefinitionNamespace, businessObjectDefinitionName, AbstractDaoTest.DATA_PROVIDER_NAME, AbstractDaoTest.BDEF_DESCRIPTION);
}
// Create a business object format file type entity if needed.
FileTypeEntity fileTypeEntity = null;
if (StringUtils.isNotBlank(businessObjectFormatFileType)) {
fileTypeEntity = fileTypeDao.getFileTypeByCode(businessObjectFormatFileType);
if (fileTypeEntity == null) {
fileTypeEntity = fileTypeDaoTestHelper.createFileTypeEntity(businessObjectFormatFileType);
}
}
// Create a storage entity.
StorageEntity storageEntity = storageDao.getStorageByName(storageName);
if (storageEntity == null) {
storageEntity = storageDaoTestHelper.createStorageEntity(storageName, StoragePlatformEntity.S3);
}
// Create a business object status entity for new status if needed.
StorageUnitStatusEntity newStorageUnitStatusEntity = null;
if (StringUtils.isNotBlank(newStorageUnitStatus)) {
newStorageUnitStatusEntity = storageUnitStatusDao.getStorageUnitStatusByCode(newStorageUnitStatus);
if (newStorageUnitStatusEntity == null) {
newStorageUnitStatusEntity = storageUnitStatusDaoTestHelper.createStorageUnitStatusEntity(newStorageUnitStatus);
}
}
// Create a business object status entity for new status if needed.
StorageUnitStatusEntity oldStorageUnitStatusEntity = null;
if (StringUtils.isNotBlank(oldStorageUnitStatus)) {
oldStorageUnitStatusEntity = storageUnitStatusDao.getStorageUnitStatusByCode(oldStorageUnitStatus);
if (oldStorageUnitStatusEntity == null) {
oldStorageUnitStatusEntity = storageUnitStatusDaoTestHelper.createStorageUnitStatusEntity(oldStorageUnitStatus);
}
}
// Create a notification registration status entity if needed.
NotificationRegistrationStatusEntity notificationRegistrationStatusEntity = notificationRegistrationStatusDao.getNotificationRegistrationStatus(notificationRegistrationStatus);
if (notificationRegistrationStatusEntity == null) {
notificationRegistrationStatusEntity = createNotificationRegistrationStatusEntity(notificationRegistrationStatus);
}
// Create a business object data notification registration entity.
StorageUnitNotificationRegistrationEntity storageUnitNotificationRegistrationEntity = new StorageUnitNotificationRegistrationEntity();
storageUnitNotificationRegistrationEntity.setNamespace(namespaceEntity);
storageUnitNotificationRegistrationEntity.setName(notificationRegistrationKey.getNotificationName());
storageUnitNotificationRegistrationEntity.setNotificationEventType(notificationEventTypeEntity);
storageUnitNotificationRegistrationEntity.setBusinessObjectDefinition(businessObjectDefinitionEntity);
storageUnitNotificationRegistrationEntity.setUsage(businessObjectFormatUsage);
storageUnitNotificationRegistrationEntity.setFileType(fileTypeEntity);
storageUnitNotificationRegistrationEntity.setBusinessObjectFormatVersion(businessObjectFormatVersion);
storageUnitNotificationRegistrationEntity.setStorage(storageEntity);
storageUnitNotificationRegistrationEntity.setNewStorageUnitStatus(newStorageUnitStatusEntity);
storageUnitNotificationRegistrationEntity.setOldStorageUnitStatus(oldStorageUnitStatusEntity);
storageUnitNotificationRegistrationEntity.setNotificationRegistrationStatus(notificationRegistrationStatusEntity);
if (!CollectionUtils.isEmpty(jobActions)) {
List<NotificationActionEntity> notificationActionEntities = new ArrayList<>();
storageUnitNotificationRegistrationEntity.setNotificationActions(notificationActionEntities);
for (JobAction jobAction : jobActions) {
// Create a job definition entity if needed.
JobDefinitionEntity jobDefinitionEntity = jobDefinitionDao.getJobDefinitionByAltKey(jobAction.getNamespace(), jobAction.getJobName());
if (jobDefinitionEntity == null) {
jobDefinitionEntity = jobDefinitionDaoTestHelper.createJobDefinitionEntity(jobAction.getNamespace(), jobAction.getJobName(), String.format("Description of \"%s.%s\" job definition.", jobAction.getNamespace(), jobAction.getJobName()), String.format("%s.%s.%s", jobAction.getNamespace(), jobAction.getJobName(), AbstractDaoTest.ACTIVITI_ID));
}
NotificationJobActionEntity notificationJobActionEntity = new NotificationJobActionEntity();
notificationActionEntities.add(notificationJobActionEntity);
notificationJobActionEntity.setNotificationRegistration(storageUnitNotificationRegistrationEntity);
notificationJobActionEntity.setJobDefinition(jobDefinitionEntity);
notificationJobActionEntity.setCorrelationData(jobAction.getCorrelationData());
}
}
return storageUnitNotificationRegistrationDao.saveAndRefresh(storageUnitNotificationRegistrationEntity);
}
Aggregations