本文整理汇总了Java中com.amazonaws.services.simpledb.model.ReplaceableAttribute类的典型用法代码示例。如果您正苦于以下问题:Java ReplaceableAttribute类的具体用法?Java ReplaceableAttribute怎么用?Java ReplaceableAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReplaceableAttribute类属于com.amazonaws.services.simpledb.model包,在下文中一共展示了ReplaceableAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
@Test
public void execute() {
List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>();
replaceableAttributes.add(new ReplaceableAttribute("NAME1", "VALUE1", true));
exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
command.execute();
assertEquals("DOMAIN1", sdbClient.putAttributesRequest.getDomainName());
assertEquals("ITEM1", sdbClient.putAttributesRequest.getItemName());
assertEquals(updateCondition, sdbClient.putAttributesRequest.getExpected());
assertEquals(replaceableAttributes, sdbClient.putAttributesRequest.getAttributes());
}
示例2: putAttributes
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
@Test
public void putAttributes() {
final List<ReplaceableAttribute> replaceableAttributes = Arrays.asList(new ReplaceableAttribute[] {
new ReplaceableAttribute("NAME1", "VALUE1", true)});
final UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
template.send("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes);
exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
}
});
assertEquals("TestDomain", amazonSDBClient.putAttributesRequest.getDomainName());
assertEquals("ITEM1", amazonSDBClient.putAttributesRequest.getItemName());
assertEquals(updateCondition, amazonSDBClient.putAttributesRequest.getExpected());
assertEquals(replaceableAttributes, amazonSDBClient.putAttributesRequest.getAttributes());
}
示例3: addToFavoriteTable
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
/**
* Adds a quote and the userID of the user who favorited it to the Favorites table
*
* @param postID id for specific quote
* @param userId facebook id of the user who favorited the quote
*/
public static void addToFavoriteTable(String postID, String userId) {
ReplaceableAttribute favoritedPostID = new ReplaceableAttribute("postID", postID, Boolean.FALSE);
ReplaceableAttribute accName = new ReplaceableAttribute("likedBy", userId, Boolean.FALSE);
List<ReplaceableAttribute> attrs = new ArrayList<ReplaceableAttribute>(2);
attrs.add(favoritedPostID);
attrs.add(accName);
PutAttributesRequest par = new PutAttributesRequest("Favorites", postID + "_likedBy_" + userId, attrs);
try {
getInstance().putAttributes(par);
} catch (Exception exception) {
System.out.println("EXCEPTION = " + exception);
}
}
示例4: addToFollowingTable
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
/**
* Adds a user and the user who will follow them to the Following table
*
* @param followedId the id of the person whose posts are going to be followed
* @param followerId id of user who pressed the follow icon
*/
public static void addToFollowingTable(String followedId, String followerId) {
ReplaceableAttribute followedIdAttr = new ReplaceableAttribute("followedId", followedId, Boolean.FALSE);
ReplaceableAttribute followerIdAttr = new ReplaceableAttribute("followerId", followerId, Boolean.FALSE);
List<ReplaceableAttribute> attrs = new ArrayList<ReplaceableAttribute>(2);
attrs.add(followedIdAttr);
attrs.add(followerIdAttr);
PutAttributesRequest par = new PutAttributesRequest("Following", followedId + "_followedBy_" + followerId, attrs);
try {
getInstance().putAttributes(par);
} catch (Exception exception) {
System.out.println("EXCEPTION = " + exception);
}
}
示例5: assertReplaceableAttributes
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
private static void assertReplaceableAttributes(PutAttributesRequest request) {
assertEquals(6, request.getAttributes().size());
for (ReplaceableAttribute attr : request.getAttributes()) {
if (attr.getName().equals(SdbCassandraInstanceDao.ID_KEY)) {
assertEquals(String.valueOf(ID), attr.getValue());
assertEquals(false, attr.getReplace());
} else if (attr.getName().equals(SdbCassandraInstanceDao.DATACENTER_KEY)) {
assertEquals(DATACENTER, attr.getValue());
assertEquals(true, attr.getReplace());
} else if (attr.getName().equals(SdbCassandraInstanceDao.RACK_KEY)) {
assertEquals(RACK, attr.getValue());
assertEquals(true, attr.getReplace());
} else if (attr.getName().equals(SdbCassandraInstanceDao.HOSTNAME_KEY)) {
assertEquals(HOSTNAME, attr.getValue());
assertEquals(true, attr.getReplace());
} else if (attr.getName().endsWith(SdbCassandraInstanceDao.PUBLIC_IP_ADDRESS_KEY)) {
assertEquals(PUBLIC_IP_ADDRESS, attr.getValue());
assertEquals(true, attr.getReplace());
} else if (attr.getName().endsWith(SdbCassandraInstanceDao.FULLY_QUALIFIED_DOMAIN_NAME_KEY)) {
assertEquals(FULLY_QUALIFIED_DOMAIN_NAME, attr.getValue());
assertEquals(true, attr.getReplace());
} else {
assertDuplicateAttribute(attr.getName(), attr.getValue());
}
}
}
示例6: putAll
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public void putAll(final Map<? extends String, ? extends String> map) {
final Collection<ReplaceableAttribute> attrs =
new ArrayList<ReplaceableAttribute>(map.size());
for (final Map.Entry<?, ?> entry : map.entrySet()) {
attrs.add(
new ReplaceableAttribute()
.withName(entry.getKey().toString())
.withValue(entry.getValue().toString())
.withReplace(true)
);
}
this.credentials.aws().putAttributes(
new PutAttributesRequest()
.withDomainName(this.table)
.withItemName(this.label)
.withAttributes(attrs)
);
}
示例7: testPutThrowsWhenOptimisticPersisterUninitialised
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
@Test
public void testPutThrowsWhenOptimisticPersisterUninitialised() throws Exception {
// ARRANGE
thrown.expect(Exception.class);
thrown.expectMessage("The optimistic persister has not been initialised");
// ACT
// Do not initialise the optimistic persister first - so put should throw
ReplaceableAttribute testAttribute = new ReplaceableAttribute();
testAttribute.setName("Name");
testAttribute.setValue("Value");
optimisticPersister.put(testItemName, Optional.of(42), testAttribute);
}
示例8: testPutThrowsWhenMaximumNumberOfAttributesIsAlreadyPresent
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
@Test
public void testPutThrowsWhenMaximumNumberOfAttributesIsAlreadyPresent() throws Exception {
// ARRANGE
thrown.expect(Exception.class);
thrown.expectMessage("Database put failed");
// Initialiser persister with a max number of attributes equal to the
// current number (1 as there is only one active attribute) - so new put's
// will be rejected.
optimisticPersister.initialise(1, mockLogger);
// Configure attributes for database to return - the get is used for logging
// only, so does not really matter.
GetAttributesRequest simpleDBRequest = new GetAttributesRequest(testSimpleDBDomainName,
testItemName);
simpleDBRequest.setConsistentRead(true);
GetAttributesResult getAttributesResult = new GetAttributesResult();
getAttributesResult.setAttributes(allAttributes);
mockery.checking(new Expectations() {
{
allowing(mockSimpleDBClient).getAttributes(with(equal(simpleDBRequest)));
will(returnValue(getAttributesResult));
}
});
// ACT
ReplaceableAttribute testAttribute = new ReplaceableAttribute();
testAttribute.setName("Name");
testAttribute.setValue("Value");
// This should throw since we already have the max number of attributes.
optimisticPersister.put(testItemName, Optional.of(42), testAttribute);
}
示例9: expectCreateBookingToReturnUpdatedBookingsOrThrow
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
private void expectCreateBookingToReturnUpdatedBookingsOrThrow(List<Booking> initialBookings,
Booking bookingToCreate, Optional<Exception> exceptionToThrow, int numCalls) throws Exception {
// The value we use here is arbitrary - what matters is that the call
// to put uses the same value that is returned from get - or else we would
// get a conditional check failed exception from SimpleDB.
Optional<Integer> expectedVersionNumber = Optional.of(4);
// Create booking attribute for the booking being created
String attributeName = bookingToCreate.getCourt().toString() + "-"
+ bookingToCreate.getCourtSpan().toString() + "-" + bookingToCreate.getSlot() + "-"
+ bookingToCreate.getSlotSpan().toString();
ReplaceableAttribute bookingAttribute = new ReplaceableAttribute();
bookingAttribute.setName(attributeName);
bookingAttribute.setValue(newName);
// Booking creation gets existing bookings before trying to make the new one
expectOptimisticPersisterGetToReturnVersionedAttributesOrThrow(expectedVersionNumber,
initialBookings, Optional.empty(), numCalls);
if (!exceptionToThrow.isPresent()) {
mockery.checking(new Expectations() {
{
exactly(numCalls).of(mockOptimisticPersister).put(with(equal(bookingToCreate.getDate())),
with(equal(expectedVersionNumber)), with(equal(bookingAttribute)));
}
});
} else {
mockery.checking(new Expectations() {
{
exactly(numCalls).of(mockOptimisticPersister).put(with(equal(bookingToCreate.getDate())),
with(equal(expectedVersionNumber)), with(equal(bookingAttribute)));
will(throwException(exceptionToThrow.get()));
}
});
}
bookingManager.setOptimisticPersister(mockOptimisticPersister);
}
示例10: expectToPutRuleToOptimisticPersister
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
private void expectToPutRuleToOptimisticPersister(int expectedVersion, BookingRule ruleToPut)
throws Exception {
// Set up attributes to be returned from the database's booking rule item
ReplaceableAttribute attribute = new ReplaceableAttribute();
attribute.setName(getAttributeNameFromBookingRule(ruleToPut));
String[] datesToExclude = ruleToPut.getDatesToExclude();
attribute.setValue(StringUtils.join(datesToExclude, ","));
mockery.checking(new Expectations() {
{
oneOf(mockOptimisticPersister).put(with(equal(ruleItemName)),
with(Optional.of(expectedVersion)), with(equal(attribute)));
}
});
}
示例11: expectToAddOrDeleteRuleExclusionViaOptimisticPersister
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
private void expectToAddOrDeleteRuleExclusionViaOptimisticPersister(int expectedVersion,
String dateToExclude, Boolean doAdd, BookingRule ruleToAddExclusionTo) throws Exception {
// Set up attribute to be put to the database's booking rule item
ReplaceableAttribute replaceableAttribute = new ReplaceableAttribute();
replaceableAttribute.setName(getAttributeNameFromBookingRule(ruleToAddExclusionTo));
List<String> datesToExclude = new ArrayList<>();
datesToExclude.addAll(Arrays.asList(ruleToAddExclusionTo.getDatesToExclude()));
if (doAdd) {
datesToExclude.add(dateToExclude);
} else {
datesToExclude.remove(dateToExclude);
}
if (datesToExclude.size() > 0) {
replaceableAttribute.setValue(StringUtils.join(datesToExclude.toArray(), ","));
} else {
replaceableAttribute.setValue("");
}
replaceableAttribute.setReplace(true);
mockery.checking(new Expectations() {
{
oneOf(mockOptimisticPersister).put(with(equal(ruleItemName)),
with(Optional.of(expectedVersion)), with(equal(replaceableAttribute)));
}
});
}
示例12: testSetLifecycleStateCorrectlyCallsTheOptimisticPersister_retired_with_url
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
@Test
public void testSetLifecycleStateCorrectlyCallsTheOptimisticPersister_retired_with_url()
throws Exception {
// Tests happy path for setting RETIRED state - where we also supply a
// forwarding Url for the new site.
// ARRANGE
lifecycleManager.initialise(mockLogger);
// Set up a test lifecycle-state item - with an arbitrary version number.
ImmutablePair<Optional<Integer>, Set<Attribute>> testItem = new ImmutablePair<Optional<Integer>, Set<Attribute>>(
Optional.of(42), new HashSet<Attribute>());
ReplaceableAttribute newStateAttribute = new ReplaceableAttribute();
newStateAttribute.setName("State");
newStateAttribute.setValue("RETIRED");
newStateAttribute.setReplace(true);
ReplaceableAttribute newUrlAttribute = new ReplaceableAttribute();
newUrlAttribute.setName("Url");
newUrlAttribute.setValue(exampleForwardingUrl);
newUrlAttribute.setReplace(true);
mockery.checking(new Expectations() {
{
exactly(1).of(mockOptimisticPersister).get(with(equal("LifecycleState")));
will(returnValue(testItem));
exactly(1).of(mockOptimisticPersister).put(with(equal("LifecycleState")),
with(equal(Optional.of(42))), with(equal(newStateAttribute)));
will(returnValue(43));
exactly(1).of(mockOptimisticPersister).put(with(equal("LifecycleState")),
with(equal(Optional.of(43))), with(equal(newUrlAttribute)));
}
});
// ACT
lifecycleManager.setLifecycleState(LifecycleState.RETIRED, Optional.of(exampleForwardingUrl));
}
示例13: doTestSetLifecycleStateCorrectlyCallsTheOptimisticPersister
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
private void doTestSetLifecycleStateCorrectlyCallsTheOptimisticPersister(
LifecycleState lifecycleState) throws Exception {
// ARRANGE
lifecycleManager.initialise(mockLogger);
// Set up a test lifecycle-state item - with an arbitrary version number.
ImmutablePair<Optional<Integer>, Set<Attribute>> testItem = new ImmutablePair<Optional<Integer>, Set<Attribute>>(
Optional.of(42), new HashSet<Attribute>());
ReplaceableAttribute newStateAttribute = new ReplaceableAttribute();
newStateAttribute.setName("State");
newStateAttribute.setValue(lifecycleState.name());
newStateAttribute.setReplace(true);
mockery.checking(new Expectations() {
{
exactly(1).of(mockOptimisticPersister).get(with(equal("LifecycleState")));
will(returnValue(testItem));
exactly(1).of(mockOptimisticPersister).put(with(equal("LifecycleState")),
with(equal(Optional.of(42))), with(equal(newStateAttribute)));
// Don't want to put the Url attribute in this case - since we're not
// retiring.
never(mockOptimisticPersister).put(with(equal("LifecycleState")),
with(equal(Optional.of(43))), with(anything()));
}
});
// ACT
lifecycleManager.setLifecycleState(lifecycleState, Optional.empty());
}
示例14: putAttributes
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
@Test
public void putAttributes() {
final List<ReplaceableAttribute> replaceableAttributes = Arrays.asList(new ReplaceableAttribute[] {
new ReplaceableAttribute("NAME1", "VALUE1", true)});
final UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
template.send("direct:start", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes);
exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
}
});
}
示例15: executeWithoutItemName
import com.amazonaws.services.simpledb.model.ReplaceableAttribute; //导入依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void executeWithoutItemName() {
List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>();
replaceableAttributes.add(new ReplaceableAttribute("NAME1", "VALUE1", true));
exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
command.execute();
}