use of org.finra.herd.model.api.xml.FileTypeKey in project herd by FINRAOS.
the class FileTypeRestControllerTest method testGetFileTypes.
@Test
public void testGetFileTypes() throws Exception {
// Get a list of test file type keys.
List<FileTypeKey> testFileTypeKeys = Arrays.asList(new FileTypeKey(FORMAT_FILE_TYPE_CODE), new FileTypeKey(FORMAT_FILE_TYPE_CODE_2));
FileTypeKeys fileTypeKeys = new FileTypeKeys(testFileTypeKeys);
// Create and persist file type entities.
when(fileTypeService.getFileTypes()).thenReturn(fileTypeKeys);
// Retrieve a list of file type keys.
FileTypeKeys resultFileTypeKeys = fileTypeRestController.getFileTypes();
// Verify the external calls.
verify(fileTypeService).getFileTypes();
verifyNoMoreInteractions(fileTypeService);
// Validate the returned object.
assertEquals(fileTypeKeys, resultFileTypeKeys);
}
use of org.finra.herd.model.api.xml.FileTypeKey in project herd by FINRAOS.
the class FileTypeDaoTest method testGetFileTypes.
@Test
public void testGetFileTypes() throws Exception {
// Create and persist file type entities.
for (FileTypeKey key : fileTypeDaoTestHelper.getTestFileTypeKeys()) {
fileTypeDaoTestHelper.createFileTypeEntity(key.getFileTypeCode());
}
// Retrieve a list of file type keys.
List<FileTypeKey> resultFileTypeKeys = fileTypeDao.getFileTypes();
// Validate the returned object.
assertNotNull(resultFileTypeKeys);
assertTrue(resultFileTypeKeys.containsAll(fileTypeDaoTestHelper.getTestFileTypeKeys()));
}
use of org.finra.herd.model.api.xml.FileTypeKey in project herd by FINRAOS.
the class FileTypeDaoImpl method getFileTypes.
@Override
public List<FileTypeKey> getFileTypes() {
// Create the criteria builder and a tuple style criteria query.
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<String> criteria = builder.createQuery(String.class);
// The criteria root is the file type.
Root<FileTypeEntity> fileTypeEntity = criteria.from(FileTypeEntity.class);
// Get the columns.
Path<String> fileTypeCodeColumn = fileTypeEntity.get(FileTypeEntity_.code);
// Add the select clause.
criteria.select(fileTypeCodeColumn);
// Add the order by clause.
criteria.orderBy(builder.asc(fileTypeCodeColumn));
// Run the query to get a list of file type codes back.
List<String> fileTypeCodes = entityManager.createQuery(criteria).getResultList();
// Populate the "keys" objects from the returned file type codes.
List<FileTypeKey> fileTypeKeys = new ArrayList<>();
for (String fileTypeCode : fileTypeCodes) {
fileTypeKeys.add(new FileTypeKey(fileTypeCode));
}
return fileTypeKeys;
}
use of org.finra.herd.model.api.xml.FileTypeKey in project herd by FINRAOS.
the class FileTypeServiceTest method testGetFileTypes.
@Test
public void testGetFileTypes() throws Exception {
// Create and persist file type entities.
for (FileTypeKey key : fileTypeDaoTestHelper.getTestFileTypeKeys()) {
fileTypeDaoTestHelper.createFileTypeEntity(key.getFileTypeCode());
}
// Retrieve a list of file type keys.
FileTypeKeys resultFileTypeKeys = fileTypeService.getFileTypes();
// Validate the returned object.
assertNotNull(resultFileTypeKeys);
assertTrue(resultFileTypeKeys.getFileTypeKeys().containsAll(fileTypeDaoTestHelper.getTestFileTypeKeys()));
}
Aggregations