当前位置: 首页>>代码示例>>Java>>正文


Java ReplaceableAttribute类代码示例

本文整理汇总了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());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:PutAttributesCommandTest.java

示例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());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:SdbComponentSpringTest.java

示例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);
    }
}
 
开发者ID:pgodzin,项目名称:QuotesSocial,代码行数:22,代码来源:SimpleDB.java

示例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);
    }
}
 
开发者ID:pgodzin,项目名称:QuotesSocial,代码行数:22,代码来源:SimpleDB.java

示例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());
    }
  }
}
 
开发者ID:signal,项目名称:agathon,代码行数:27,代码来源:SdbCassandraInstanceDaoTest.java

示例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)
    );
}
 
开发者ID:jcabi,项目名称:jcabi-simpledb,代码行数:24,代码来源:AwsItem.java

示例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);
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:14,代码来源:OptimisticPersisterTest.java

示例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);
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:33,代码来源:OptimisticPersisterTest.java

示例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);
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:40,代码来源:BookingManagerTest.java

示例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)));
    }
  });
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:16,代码来源:RuleManagerTest.java

示例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)));
    }
  });
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:28,代码来源:RuleManagerTest.java

示例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));
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:36,代码来源:LifecycleManagerTest.java

示例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());
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:30,代码来源:LifecycleManagerTest.java

示例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);
        }
    });
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:SdbComponentIntegrationTest.java

示例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();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:PutAttributesCommandTest.java


注:本文中的com.amazonaws.services.simpledb.model.ReplaceableAttribute类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。