本文整理汇总了Java中org.apache.commons.collections4.IterableUtils.get方法的典型用法代码示例。如果您正苦于以下问题:Java IterableUtils.get方法的具体用法?Java IterableUtils.get怎么用?Java IterableUtils.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.collections4.IterableUtils
的用法示例。
在下文中一共展示了IterableUtils.get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testUpdateBusinessObjectDataAttributesAttributeAdded
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
@Test
public void testUpdateBusinessObjectDataAttributesAttributeAdded()
{
// Create a list of attributes.
List<Attribute> attributes = Arrays.asList(new Attribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE));
// Create a business object data entity without attributes.
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
businessObjectDataEntity.setAttributes(new ArrayList<>());
// Call the method under test.
attributeDaoHelper.updateBusinessObjectDataAttributes(businessObjectDataEntity, attributes);
// Verify the external calls.
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(1, CollectionUtils.size(businessObjectDataEntity.getAttributes()));
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = IterableUtils.get(businessObjectDataEntity.getAttributes(), 0);
assertEquals(businessObjectDataEntity, businessObjectDataAttributeEntity.getBusinessObjectData());
assertEquals(ATTRIBUTE_NAME, businessObjectDataAttributeEntity.getName());
assertEquals(ATTRIBUTE_VALUE, businessObjectDataAttributeEntity.getValue());
}
示例2: testUpdateBusinessObjectDataAttributesAttributeValueNotUpdated
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
@Test
public void testUpdateBusinessObjectDataAttributesAttributeValueNotUpdated()
{
// Create a business object data attribute entity.
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = new BusinessObjectDataAttributeEntity();
businessObjectDataAttributeEntity.setName(ATTRIBUTE_NAME);
businessObjectDataAttributeEntity.setValue(ATTRIBUTE_VALUE);
// Create a business object data entity that contains one attribute entity.
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
List<BusinessObjectDataAttributeEntity> businessObjectDataAttributeEntities = new ArrayList<>();
businessObjectDataEntity.setAttributes(businessObjectDataAttributeEntities);
businessObjectDataAttributeEntities.add(businessObjectDataAttributeEntity);
// Call the method under test.
attributeDaoHelper.updateBusinessObjectDataAttributes(businessObjectDataEntity, Arrays.asList(new Attribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE)));
// Verify the external calls.
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(1, CollectionUtils.size(businessObjectDataEntity.getAttributes()));
BusinessObjectDataAttributeEntity result = IterableUtils.get(businessObjectDataEntity.getAttributes(), 0);
assertEquals(ATTRIBUTE_NAME, result.getName());
assertEquals(ATTRIBUTE_VALUE, result.getValue());
}
示例3: testUpdateBusinessObjectDataAttributesAttributeValueUpdated
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
@Test
public void testUpdateBusinessObjectDataAttributesAttributeValueUpdated()
{
// Create a business object data attribute entity.
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = new BusinessObjectDataAttributeEntity();
businessObjectDataAttributeEntity.setName(ATTRIBUTE_NAME);
businessObjectDataAttributeEntity.setValue(ATTRIBUTE_VALUE);
// Create a business object data entity that contains one attribute entity.
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
List<BusinessObjectDataAttributeEntity> businessObjectDataAttributeEntities = new ArrayList<>();
businessObjectDataEntity.setAttributes(businessObjectDataAttributeEntities);
businessObjectDataAttributeEntities.add(businessObjectDataAttributeEntity);
// Call the method under test.
attributeDaoHelper.updateBusinessObjectDataAttributes(businessObjectDataEntity, Arrays.asList(new Attribute(ATTRIBUTE_NAME, ATTRIBUTE_VALUE_2)));
// Verify the external calls.
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(1, CollectionUtils.size(businessObjectDataEntity.getAttributes()));
BusinessObjectDataAttributeEntity result = IterableUtils.get(businessObjectDataEntity.getAttributes(), 0);
assertEquals(ATTRIBUTE_NAME, result.getName());
assertEquals(ATTRIBUTE_VALUE_2, result.getValue());
}
示例4: getFirst
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
/**
* Gets the first json element, if any, in the list. Else returns null
*
* @param elements the json elements
* @return the first json element in the list
*/
public JsonElement getFirst(Iterable<JsonElement> elements) {
JsonElement first = null;
if (!IterableUtils.isEmpty(elements)) {
first = IterableUtils.get(elements, 0);
}
return first;
}
示例5: testInitiateUploadSingleAssertUseTargetStorageInRequest
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
/**
* Asserts that the target business object data that is created is using the target storage name that is specified in the request.
*/
@Test
public void testInitiateUploadSingleAssertUseTargetStorageInRequest()
{
// Create database entities required for testing.
uploadDownloadServiceTestHelper.createDatabaseEntitiesForUploadDownloadTesting();
StorageEntity storageEntity = storageDaoTestHelper.createStorageEntity(STORAGE_NAME_3);
storageEntity.getAttributes().add(storageDaoTestHelper
.createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_BUCKET_NAME), "testBucketName"));
storageEntity.getAttributes().add(storageDaoTestHelper
.createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KEY_PREFIX_VELOCITY_TEMPLATE),
"$environment/$namespace/$businessObjectDataPartitionValue"));
storageEntity.getAttributes().add(storageDaoTestHelper
.createStorageAttributeEntity(storageEntity, configurationHelper.getProperty(ConfigurationValue.S3_ATTRIBUTE_NAME_KMS_KEY_ID),
"arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"));
// Initiate a file upload.
UploadSingleInitiationRequest uploadSingleInitiationRequest = uploadDownloadServiceTestHelper.createUploadSingleInitiationRequest();
uploadSingleInitiationRequest.setTargetStorageName(STORAGE_NAME_3);
UploadSingleInitiationResponse resultUploadSingleInitiationResponse = uploadDownloadService.initiateUploadSingle(uploadSingleInitiationRequest);
// Validate the returned object.
uploadDownloadServiceTestHelper
.validateUploadSingleInitiationResponse(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, NAMESPACE, BDEF_NAME_2,
FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2, businessObjectDefinitionServiceTestHelper.getNewAttributes(), FILE_NAME,
FILE_SIZE_1_KB, STORAGE_NAME_3, resultUploadSingleInitiationResponse);
BusinessObjectDataEntity targetBusinessObjectDataEntity = businessObjectDataDao.getBusinessObjectDataByAltKey(
new BusinessObjectDataKey(NAMESPACE, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION_2,
resultUploadSingleInitiationResponse.getTargetBusinessObjectData().getPartitionValue(), null, 0));
assertNotNull(targetBusinessObjectDataEntity);
assertNotNull(targetBusinessObjectDataEntity.getStorageUnits());
assertEquals(1, targetBusinessObjectDataEntity.getStorageUnits().size());
StorageUnitEntity storageUnit = IterableUtils.get(targetBusinessObjectDataEntity.getStorageUnits(), 0);
assertNotNull(storageUnit);
assertNotNull(storageUnit.getStorage());
assertEquals(STORAGE_NAME_3, storageUnit.getStorage().getName());
}
示例6: testInitiateDownloadSingleMultipleStorageFilesExist
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
@Test
public void testInitiateDownloadSingleMultipleStorageFilesExist()
{
// Create the upload data.
UploadSingleInitiationResponse uploadSingleInitiationResponse =
uploadDownloadServiceTestHelper.createUploadedFileData(BusinessObjectDataStatusEntity.VALID);
// Get the target business object data entity.
BusinessObjectDataEntity targetBusinessObjectDataEntity = businessObjectDataDao
.getBusinessObjectDataByAltKey(businessObjectDataHelper.getBusinessObjectDataKey(uploadSingleInitiationResponse.getTargetBusinessObjectData()));
// Get the target bushiness object data storage unit.
StorageUnitEntity targetStorageUnitEntity = IterableUtils.get(targetBusinessObjectDataEntity.getStorageUnits(), 0);
// Add a second storage file to the target business object data storage unit.
storageFileDaoTestHelper.createStorageFileEntity(targetStorageUnitEntity, FILE_NAME_2, FILE_SIZE_1_KB, ROW_COUNT_1000);
// Try to initiate a single file download when business object data has more than one storage file.
try
{
// Initiate the download against the uploaded data (i.e. the target business object data).
initiateDownload(uploadSingleInitiationResponse.getTargetBusinessObjectData());
fail("Suppose to throw an IllegalArgumentException when business object has more than one storage file.");
}
catch (IllegalArgumentException e)
{
BusinessObjectData businessObjectData = uploadSingleInitiationResponse.getTargetBusinessObjectData();
assertEquals(String.format("Found 2 registered storage files when expecting one in \"%s\" storage for the business object data {%s}.",
targetStorageUnitEntity.getStorage().getName(), businessObjectDataServiceTestHelper
.getExpectedBusinessObjectDataKeyAsString(businessObjectDataHelper.getBusinessObjectDataKey(businessObjectData))), e.getMessage());
}
}
示例7: testUpdateBusinessObjectDataAttributesAttributeValueUpdatedAttributeNamesEqualIgnoreCase
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
@Test
public void testUpdateBusinessObjectDataAttributesAttributeValueUpdatedAttributeNamesEqualIgnoreCase()
{
// Create a business object data attribute entity.
BusinessObjectDataAttributeEntity businessObjectDataAttributeEntity = new BusinessObjectDataAttributeEntity();
businessObjectDataAttributeEntity.setName(ATTRIBUTE_NAME.toUpperCase());
businessObjectDataAttributeEntity.setValue(ATTRIBUTE_VALUE);
// Create a business object data entity that contains one attribute entity.
BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
List<BusinessObjectDataAttributeEntity> businessObjectDataAttributeEntities = new ArrayList<>();
businessObjectDataEntity.setAttributes(businessObjectDataAttributeEntities);
businessObjectDataAttributeEntities.add(businessObjectDataAttributeEntity);
// Call the method under test.
attributeDaoHelper
.updateBusinessObjectDataAttributes(businessObjectDataEntity, Arrays.asList(new Attribute(ATTRIBUTE_NAME.toLowerCase(), ATTRIBUTE_VALUE_2)));
// Verify the external calls.
verifyNoMoreInteractionsHelper();
// Validate the results.
assertEquals(1, CollectionUtils.size(businessObjectDataEntity.getAttributes()));
BusinessObjectDataAttributeEntity result = IterableUtils.get(businessObjectDataEntity.getAttributes(), 0);
assertEquals(ATTRIBUTE_NAME.toUpperCase(), result.getName());
assertEquals(ATTRIBUTE_VALUE_2, result.getValue());
}
示例8: testBuildNamespaceAuthorizationsAssertAuthLookupByUserId
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
@Test
public void testBuildNamespaceAuthorizationsAssertAuthLookupByUserId()
{
ApplicationUser applicationUser = new ApplicationUser(getClass());
String userId = "userId";
applicationUser.setUserId(userId);
when(configurationHelper.getBooleanProperty(any())).thenReturn(true);
List<UserNamespaceAuthorizationEntity> userNamespaceAuthorizationEntities = new ArrayList<>();
UserNamespaceAuthorizationEntity userNamespaceAuthorizationEntity = new UserNamespaceAuthorizationEntity();
userNamespaceAuthorizationEntity.setUserId("userNamespaceAuthorizationEntityUserId");
NamespaceEntity namespaceEntity = new NamespaceEntity();
namespaceEntity.setCode("namespace");
userNamespaceAuthorizationEntity.setNamespace(namespaceEntity);
userNamespaceAuthorizationEntities.add(userNamespaceAuthorizationEntity);
when(userNamespaceAuthorizationDao.getUserNamespaceAuthorizationsByUserId(any())).thenReturn(userNamespaceAuthorizationEntities);
userNamespaceAuthorizationHelper.buildNamespaceAuthorizations(applicationUser);
assertEquals(1, applicationUser.getNamespaceAuthorizations().size());
NamespaceAuthorization namespaceAuthorization = IterableUtils.get(applicationUser.getNamespaceAuthorizations(), 0);
assertEquals(namespaceEntity.getCode(), namespaceAuthorization.getNamespace());
verify(userNamespaceAuthorizationDao).getUserNamespaceAuthorizationsByUserId(eq(userId));
verify(userNamespaceAuthorizationDao).getUserNamespaceAuthorizationsByUserIdStartsWith(eq(WildcardHelper.WILDCARD_TOKEN));
verifyNoMoreInteractions(userNamespaceAuthorizationDao, wildcardHelper);
}
示例9: testBuildNamespaceAuthorizationsAssertWildcardQueryExecuted
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
@Test
public void testBuildNamespaceAuthorizationsAssertWildcardQueryExecuted()
{
ApplicationUser applicationUser = new ApplicationUser(getClass());
String userId = "userId";
applicationUser.setUserId(userId);
when(configurationHelper.getBooleanProperty(any())).thenReturn(true);
List<UserNamespaceAuthorizationEntity> wildcardEntities = new ArrayList<>();
UserNamespaceAuthorizationEntity wildcardEntity = new UserNamespaceAuthorizationEntity();
wildcardEntity.setUserId("wildcardEntityUserId");
NamespaceEntity namespaceEntity = new NamespaceEntity();
namespaceEntity.setCode("namespace");
wildcardEntity.setNamespace(namespaceEntity);
wildcardEntities.add(wildcardEntity);
when(userNamespaceAuthorizationDao.getUserNamespaceAuthorizationsByUserIdStartsWith(any())).thenReturn(wildcardEntities);
when(wildcardHelper.matches(any(), any())).thenReturn(true);
userNamespaceAuthorizationHelper.buildNamespaceAuthorizations(applicationUser);
assertEquals(1, applicationUser.getNamespaceAuthorizations().size());
NamespaceAuthorization namespaceAuthorization = IterableUtils.get(applicationUser.getNamespaceAuthorizations(), 0);
assertEquals(namespaceEntity.getCode(), namespaceAuthorization.getNamespace());
verify(userNamespaceAuthorizationDao).getUserNamespaceAuthorizationsByUserId(eq(userId));
verify(userNamespaceAuthorizationDao).getUserNamespaceAuthorizationsByUserIdStartsWith(eq(WildcardHelper.WILDCARD_TOKEN));
verify(wildcardHelper).matches(eq(userId.toUpperCase()), eq(wildcardEntity.getUserId().toUpperCase()));
verifyNoMoreInteractions(userNamespaceAuthorizationDao, wildcardHelper);
}
示例10: initiateDownloadSingle
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.READ)
@Override
public DownloadSingleInitiationResponse initiateDownloadSingle(String namespace, String businessObjectDefinitionName, String businessObjectFormatUsage,
String businessObjectFormatFileType, Integer businessObjectFormatVersion, String partitionValue, Integer businessObjectDataVersion)
{
// Create the business object data key.
BusinessObjectDataKey businessObjectDataKey =
new BusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType,
businessObjectFormatVersion, partitionValue, null, businessObjectDataVersion);
// Validate the parameters
businessObjectDataHelper.validateBusinessObjectDataKey(businessObjectDataKey, true, true);
// Retrieve the persisted business object data
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey);
// Make sure the status of the business object data is VALID
businessObjectDataHelper.assertBusinessObjectDataStatusEquals(BusinessObjectDataStatusEntity.VALID, businessObjectDataEntity);
// Get the external storage registered against this data
// Validate that the storage unit exists
StorageUnitEntity storageUnitEntity = IterableUtils.get(businessObjectDataEntity.getStorageUnits(), 0);
// Validate that the storage unit contains only 1 file
assertHasOneStorageFile(storageUnitEntity);
String s3BucketName = storageHelper.getStorageBucketName(storageUnitEntity.getStorage());
String s3ObjectKey = IterableUtils.get(storageUnitEntity.getStorageFiles(), 0).getPath();
// Get the temporary credentials
Credentials downloaderCredentials =
getExternalDownloaderCredentials(storageUnitEntity.getStorage(), String.valueOf(businessObjectDataEntity.getId()), s3ObjectKey);
// Generate a pre-signed URL
Date expiration = downloaderCredentials.getExpiration();
S3FileTransferRequestParamsDto s3BucketAccessParams = storageHelper.getS3BucketAccessParams(storageUnitEntity.getStorage());
String presignedUrl = s3Dao.generateGetObjectPresignedUrl(s3BucketName, s3ObjectKey, expiration, s3BucketAccessParams);
// Construct and return the response
DownloadSingleInitiationResponse response = new DownloadSingleInitiationResponse();
response.setBusinessObjectData(businessObjectDataHelper.createBusinessObjectDataFromEntity(businessObjectDataEntity));
response.setAwsAccessKey(downloaderCredentials.getAccessKeyId());
response.setAwsSecretKey(downloaderCredentials.getSecretAccessKey());
response.setAwsSessionToken(downloaderCredentials.getSessionToken());
response.setAwsSessionExpirationTime(HerdDateUtils.getXMLGregorianCalendarValue(expiration));
response.setPreSignedUrl(presignedUrl);
return response;
}
示例11: extendUploadSingleCredentials
import org.apache.commons.collections4.IterableUtils; //导入方法依赖的package包/类
@NamespacePermission(fields = "#namespace", permissions = NamespacePermissionEnum.WRITE)
@Override
public UploadSingleCredentialExtensionResponse extendUploadSingleCredentials(String namespace, String businessObjectDefinitionName,
String businessObjectFormatUsage, String businessObjectFormatFileType, Integer businessObjectFormatVersion, String partitionValue,
Integer businessObjectDataVersion)
{
// Create the business object data key.
BusinessObjectDataKey businessObjectDataKey =
new BusinessObjectDataKey(namespace, businessObjectDefinitionName, businessObjectFormatUsage, businessObjectFormatFileType,
businessObjectFormatVersion, partitionValue, null, businessObjectDataVersion);
// Validate and trim the business object data key.
businessObjectDataHelper.validateBusinessObjectDataKey(businessObjectDataKey, true, true);
// Get the business object data for the key.
BusinessObjectDataEntity businessObjectDataEntity = businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey);
// Ensure the status of the business object data is "uploading" in order to extend credentials.
if (!(businessObjectDataEntity.getStatus().getCode().equals(BusinessObjectDataStatusEntity.UPLOADING)))
{
throw new IllegalArgumentException(String.format(String
.format("Business object data {%s} has a status of \"%s\" and must be \"%s\" to extend " + "credentials.",
businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey), businessObjectDataEntity.getStatus().getCode(),
BusinessObjectDataStatusEntity.UPLOADING)));
}
// Get the S3 managed "loading dock" storage entity and make sure it exists.
StorageEntity storageEntity = storageDaoHelper.getStorageEntity(StorageEntity.MANAGED_LOADING_DOCK_STORAGE);
String s3BucketName = storageHelper.getStorageBucketName(storageEntity);
// Get the storage unit entity for this business object data in the S3 managed "loading dock" storage and make sure it exists.
StorageUnitEntity storageUnitEntity = storageUnitDaoHelper.getStorageUnitEntity(StorageEntity.MANAGED_LOADING_DOCK_STORAGE, businessObjectDataEntity);
// Validate that the storage unit contains exactly one storage file.
assertHasOneStorageFile(storageUnitEntity);
// Get the storage file entity.
StorageFileEntity storageFileEntity = IterableUtils.get(storageUnitEntity.getStorageFiles(), 0);
// Get the storage file path.
String storageFilePath = storageFileEntity.getPath();
String awsRoleArn = getStorageUploadRoleArn(storageEntity);
Integer awsRoleDurationSeconds = getStorageUploadSessionDuration(storageEntity);
String awsKmsKeyId = storageHelper.getStorageKmsKeyId(storageEntity);
// Get the temporary security credentials to access S3_MANAGED_STORAGE.
Credentials assumedSessionCredentials = stsDao
.getTemporarySecurityCredentials(awsHelper.getAwsParamsDto(), String.valueOf(businessObjectDataEntity.getId()), awsRoleArn, awsRoleDurationSeconds,
createUploaderPolicy(s3BucketName, storageFilePath, awsKmsKeyId));
// Create the response.
UploadSingleCredentialExtensionResponse response = new UploadSingleCredentialExtensionResponse();
response.setAwsAccessKey(assumedSessionCredentials.getAccessKeyId());
response.setAwsSecretKey(assumedSessionCredentials.getSecretAccessKey());
response.setAwsSessionToken(assumedSessionCredentials.getSessionToken());
response.setAwsSessionExpirationTime(HerdDateUtils.getXMLGregorianCalendarValue(assumedSessionCredentials.getExpiration()));
return response;
}