use of org.finra.herd.core.Command in project herd by FINRAOS.
the class DownloaderWebClientTest method testGetS3KeyPrefix.
@Test
public void testGetS3KeyPrefix() throws Exception {
// Upload and register business object data parents.
uploadAndRegisterTestDataParents(downloaderWebClient);
// Upload and register the initial version if of the test business object data.
uploadTestDataFilesToS3(S3_TEST_PATH_V0);
final UploaderInputManifestDto uploaderInputManifestDto = getTestUploaderInputManifestDto();
executeWithoutLogging(DataBridgeWebClient.class, new Command() {
@Override
public void execute() throws Exception {
BusinessObjectData businessObjectData = downloaderWebClient.preRegisterBusinessObjectData(uploaderInputManifestDto, StorageEntity.MANAGED_STORAGE, false);
BusinessObjectDataKey businessObjectDataKey = businessObjectDataHelper.getBusinessObjectDataKey(businessObjectData);
downloaderWebClient.addStorageFiles(businessObjectDataKey, uploaderInputManifestDto, getTestS3FileTransferRequestParamsDto(S3_TEST_PATH_V0 + "/"), StorageEntity.MANAGED_STORAGE);
downloaderWebClient.updateBusinessObjectDataStatus(businessObjectDataKey, BusinessObjectDataStatusEntity.VALID);
}
});
// Get S3 key prefix.
BusinessObjectData businessObjectData = toBusinessObjectData(uploaderInputManifestDto);
S3KeyPrefixInformation resultS3KeyPrefixInformation = downloaderWebClient.getS3KeyPrefix(businessObjectData);
// Validate the results.
assertNotNull(resultS3KeyPrefixInformation);
assertEquals(S3_SIMPLE_TEST_PATH, resultS3KeyPrefixInformation.getS3KeyPrefix());
}
use of org.finra.herd.core.Command in project herd by FINRAOS.
the class BusinessObjectFormatServiceTest method testCreateBusinessObjectFormatIncorrectLatestVersion.
@Test
public void testCreateBusinessObjectFormatIncorrectLatestVersion() throws Exception {
// Create relative database entities.
businessObjectFormatServiceTestHelper.createTestDatabaseEntitiesForBusinessObjectFormatTesting();
// Create a first version of the format with the latest flag set to false.
businessObjectFormatDaoTestHelper.createBusinessObjectFormatEntity(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, FORMAT_DESCRIPTION, false, PARTITION_KEY);
try {
// Try to create a new format version for this format.
final BusinessObjectFormatCreateRequest businessObjectFormatCreateRequest = businessObjectFormatServiceTestHelper.createBusinessObjectFormatCreateRequest(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, PARTITION_KEY, FORMAT_DESCRIPTION, businessObjectDefinitionServiceTestHelper.getNewAttributes(), businessObjectFormatServiceTestHelper.getTestAttributeDefinitions(), businessObjectFormatServiceTestHelper.getTestSchema());
executeWithoutLogging(SqlExceptionHelper.class, new Command() {
@Override
public void execute() {
businessObjectFormatService.createBusinessObjectFormat(businessObjectFormatCreateRequest);
fail("Should throw a PersistenceException since the latest flag does not identify the maximum format version.");
}
});
} catch (PersistenceException e) {
assertTrue(e.getMessage().contains("ConstraintViolationException: could not execute statement"));
}
}
use of org.finra.herd.core.Command in project herd by FINRAOS.
the class HerdThreadHelperTest method testSleep.
/*
* This test is to get the clover coverage for sleep() method on HerdHelper
*/
@Test
public void testSleep() throws Exception {
// Sleep for 1 second
herdThreadHelper.sleep(1 * 1000L);
// Passing null should result in Exception that is eaten and logged
executeWithoutLogging(HerdThreadHelper.class, new Command() {
@Override
public void execute() throws Exception {
(new HerdThreadHelper()).sleep(null);
}
});
}
use of org.finra.herd.core.Command in project herd by FINRAOS.
the class StopWatchAdviceTest method testLogMethodTimeTargetMethodIsInterface.
@Test
public void testLogMethodTimeTargetMethodIsInterface() throws Throwable {
// Mock a join point of the method call.
ProceedingJoinPoint joinPoint = getMockedProceedingJoinPoint(new Command() {
@Override
public void execute() throws Exception {
return;
}
}, Command.class.getDeclaredMethod("execute"));
// Call the method under test.
stopWatchAdvice.logMethodTime(joinPoint);
}
use of org.finra.herd.core.Command in project herd by FINRAOS.
the class StorageServiceTest method testDeleteStorageConstraintViolation.
/*
* This test is ignored because the constraint validation is a DB dependent feature. This method had inconsistent behavior between Oracle and PostgreSQL.
* Oracle was throwing the error after each statement, whereas PostgreSQL would not because it by default raises error only when transaction is committed.
*
* Besides, this test case is not valid as a use case as normal transactions wouldn't delete after insert within same transaction.
*/
@Ignore
@Test(expected = PersistenceException.class)
public void testDeleteStorageConstraintViolation() throws Exception {
// Create a storage unit entity that refers to a newly created storage.
final StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, STORAGE_UNIT_STATUS, NO_STORAGE_DIRECTORY_PATH);
executeWithoutLogging(SqlExceptionHelper.class, new Command() {
@Override
public void execute() {
// Delete the storage which is invalid because there still exists a storage unit entity that references it.
StorageKey alternateKey = new StorageKey(storageUnitEntity.getStorage().getName());
storageService.deleteStorage(alternateKey);
}
});
}
Aggregations