use of org.finra.herd.model.api.xml.CustomDdlKey in project herd by FINRAOS.
the class CustomDdlServiceTestHelper method validateCustomDdl.
/**
* Validates custom DDL contents against specified parameters.
*
* @param customDdlId the expected custom DDL ID
* @param expectedNamespace the expected namespace
* @param expectedBusinessObjectDefinitionName the expected business object definition name
* @param expectedBusinessObjectFormatUsage the expected business object format usage
* @param expectedBusinessObjectFormatFileType the expected business object format file type
* @param expectedBusinessObjectFormatVersion the expected business object format version
* @param expectedCustomDdlName the expected custom DDL name
* @param expectedDdl the expected DDL
* @param actualCustomDdl the custom DDL object instance to be validated
*/
public void validateCustomDdl(Integer customDdlId, String expectedNamespace, String expectedBusinessObjectDefinitionName, String expectedBusinessObjectFormatUsage, String expectedBusinessObjectFormatFileType, Integer expectedBusinessObjectFormatVersion, String expectedCustomDdlName, String expectedDdl, CustomDdl actualCustomDdl) {
assertNotNull(actualCustomDdl);
if (customDdlId != null) {
assertEquals(customDdlId, Integer.valueOf(actualCustomDdl.getId()));
}
assertEquals(new CustomDdlKey(expectedNamespace, expectedBusinessObjectDefinitionName, expectedBusinessObjectFormatUsage, expectedBusinessObjectFormatFileType, expectedBusinessObjectFormatVersion, expectedCustomDdlName), actualCustomDdl.getCustomDdlKey());
assertEquals(expectedDdl, actualCustomDdl.getDdl());
}
use of org.finra.herd.model.api.xml.CustomDdlKey in project herd by FINRAOS.
the class CustomDdlDaoTest method testGetCustomDdls.
@Test
public void testGetCustomDdls() {
// List of test custom DDL names.
List<String> testCustomDdlNames = Arrays.asList(CUSTOM_DDL_NAME, CUSTOM_DDL_NAME_2);
// Create and persist a custom DDL entities.
for (String customDdlName : testCustomDdlNames) {
customDdlDaoTestHelper.createCustomDdlEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, customDdlName, TEST_DDL);
}
// Retrieve a list of custom DDL keys.
List<CustomDdlKey> resultCustomDdlKeys = customDdlDao.getCustomDdls(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION));
// Validate the returned object.
assertNotNull(resultCustomDdlKeys);
assertEquals(testCustomDdlNames.size(), resultCustomDdlKeys.size());
for (int i = 0; i < testCustomDdlNames.size(); i++) {
assertEquals(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, testCustomDdlNames.get(i)), resultCustomDdlKeys.get(i));
}
}
use of org.finra.herd.model.api.xml.CustomDdlKey in project herd by FINRAOS.
the class CustomDdlDaoTest method testGetCustomDdlByKey.
@Test
public void testGetCustomDdlByKey() {
// Create and persist a custom DDL entity.
CustomDdlEntity customDdlEntity = customDdlDaoTestHelper.createCustomDdlEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME, TEST_DDL);
// Retrieve the custom DDL.
CustomDdlEntity resultCustomDdlEntity = customDdlDao.getCustomDdlByKey(new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME));
// Validate the returned object.
assertEquals(customDdlEntity.getId(), resultCustomDdlEntity.getId());
}
use of org.finra.herd.model.api.xml.CustomDdlKey in project herd by FINRAOS.
the class CustomDdlDaoImpl method getCustomDdls.
@Override
public List<CustomDdlKey> getCustomDdls(BusinessObjectFormatKey businessObjectFormatKey) {
// Create the criteria builder and a tuple style criteria query.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<Tuple> criteria = builder.createTupleQuery();
// The criteria root is the business object format.
Root<CustomDdlEntity> customDdlEntity = criteria.from(CustomDdlEntity.class);
// Join to the other tables we can filter on.
Join<CustomDdlEntity, BusinessObjectFormatEntity> businessObjectFormatEntity = customDdlEntity.join(CustomDdlEntity_.businessObjectFormat);
Join<BusinessObjectFormatEntity, BusinessObjectDefinitionEntity> businessObjectDefinitionEntity = businessObjectFormatEntity.join(BusinessObjectFormatEntity_.businessObjectDefinition);
Join<BusinessObjectFormatEntity, FileTypeEntity> fileTypeEntity = businessObjectFormatEntity.join(BusinessObjectFormatEntity_.fileType);
Join<BusinessObjectDefinitionEntity, NamespaceEntity> namespaceEntity = businessObjectDefinitionEntity.join(BusinessObjectDefinitionEntity_.namespace);
// Get the columns.
Path<String> namespaceCodeColumn = namespaceEntity.get(NamespaceEntity_.code);
Path<String> businessObjectDefinitionNameColumn = businessObjectDefinitionEntity.get(BusinessObjectDefinitionEntity_.name);
Path<String> businessObjectFormatUsageColumn = businessObjectFormatEntity.get(BusinessObjectFormatEntity_.usage);
Path<String> fileTypeCodeColumn = fileTypeEntity.get(FileTypeEntity_.code);
Path<Integer> businessObjectFormatVersionColumn = businessObjectFormatEntity.get(BusinessObjectFormatEntity_.businessObjectFormatVersion);
Path<String> customDdlNameColumn = customDdlEntity.get(CustomDdlEntity_.customDdlName);
// Create the standard restrictions (i.e. the standard where clauses).
Predicate queryRestriction = builder.equal(builder.upper(namespaceEntity.get(NamespaceEntity_.code)), businessObjectFormatKey.getNamespace().toUpperCase());
queryRestriction = builder.and(queryRestriction, builder.equal(builder.upper(businessObjectDefinitionEntity.get(BusinessObjectDefinitionEntity_.name)), businessObjectFormatKey.getBusinessObjectDefinitionName().toUpperCase()));
queryRestriction = builder.and(queryRestriction, builder.equal(builder.upper(businessObjectFormatEntity.get(BusinessObjectFormatEntity_.usage)), businessObjectFormatKey.getBusinessObjectFormatUsage().toUpperCase()));
queryRestriction = builder.and(queryRestriction, builder.equal(builder.upper(fileTypeEntity.get(FileTypeEntity_.code)), businessObjectFormatKey.getBusinessObjectFormatFileType().toUpperCase()));
queryRestriction = builder.and(queryRestriction, builder.equal(businessObjectFormatEntity.get(BusinessObjectFormatEntity_.businessObjectFormatVersion), businessObjectFormatKey.getBusinessObjectFormatVersion()));
// Add the select clause.
criteria.multiselect(namespaceCodeColumn, businessObjectDefinitionNameColumn, businessObjectFormatUsageColumn, fileTypeCodeColumn, businessObjectFormatVersionColumn, customDdlNameColumn);
// Add the where clause.
criteria.where(queryRestriction);
// Add the order by clause.
criteria.orderBy(builder.asc(customDdlNameColumn));
// Run the query to get a list of tuples back.
List<Tuple> tuples = entityManager.createQuery(criteria).getResultList();
// Populate the "keys" objects from the returned tuples (i.e. 1 tuple for each row).
List<CustomDdlKey> customDdlKeys = new ArrayList<>();
for (Tuple tuple : tuples) {
CustomDdlKey customDdlKey = new CustomDdlKey();
customDdlKeys.add(customDdlKey);
customDdlKey.setNamespace(tuple.get(namespaceCodeColumn));
customDdlKey.setBusinessObjectDefinitionName(tuple.get(businessObjectDefinitionNameColumn));
customDdlKey.setBusinessObjectFormatUsage(tuple.get(businessObjectFormatUsageColumn));
customDdlKey.setBusinessObjectFormatFileType(tuple.get(fileTypeCodeColumn));
customDdlKey.setBusinessObjectFormatVersion(tuple.get(businessObjectFormatVersionColumn));
customDdlKey.setCustomDdlName(tuple.get(customDdlNameColumn));
}
return customDdlKeys;
}
use of org.finra.herd.model.api.xml.CustomDdlKey in project herd by FINRAOS.
the class CustomDdlRestControllerTest method testUpdateCustomDdl.
@Test
public void testUpdateCustomDdl() {
CustomDdlUpdateRequest request = customDdlServiceTestHelper.createCustomDdlUpdateRequest(TEST_DDL_2);
CustomDdlKey customDdlKey = new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME);
CustomDdl customDdl = new CustomDdl(ID, new CustomDdlKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME), TEST_DDL_2);
when(customDdlService.updateCustomDdl(customDdlKey, request)).thenReturn(customDdl);
// Update the custom DDL.
CustomDdl updatedCustomDdl = customDdlRestController.updateCustomDdl(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, CUSTOM_DDL_NAME, request);
// Verify the external calls.
verify(customDdlService).updateCustomDdl(customDdlKey, request);
verifyNoMoreInteractions(customDdlService);
// Validate the returned object.
assertEquals(customDdl, updatedCustomDdl);
}
Aggregations