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


Java Attribute.setName方法代码示例

本文整理汇总了Java中com.amazonaws.services.simpledb.model.Attribute.setName方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.setName方法的具体用法?Java Attribute.setName怎么用?Java Attribute.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.amazonaws.services.simpledb.model.Attribute的用法示例。


在下文中一共展示了Attribute.setName方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteBooking

import com.amazonaws.services.simpledb.model.Attribute; //导入方法依赖的package包/类
@Override
public List<Booking> deleteBooking(Booking bookingToDelete, boolean isSquashServiceUserCall)
    throws Exception {

  if (!initialised) {
    throw new IllegalStateException("The booking manager has not been initialised");
  }

  getLifecycleManager().throwIfOperationInvalidForCurrentLifecycleState(false,
      isSquashServiceUserCall);

  logger.log("About to delete booking from database: " + bookingToDelete.toString());
  Attribute attribute = new Attribute();
  attribute.setName(getAttributeNameFromBooking(bookingToDelete));
  attribute.setValue(bookingToDelete.getName());
  getOptimisticPersister().delete(bookingToDelete.getDate(), attribute);

  logger.log("Deleted booking from database");

  return getVersionedBookings(bookingToDelete.getDate()).right;
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:22,代码来源:BookingManager.java

示例2: deleteRule

import com.amazonaws.services.simpledb.model.Attribute; //导入方法依赖的package包/类
@Override
public void deleteRule(BookingRule bookingRuleToDelete, boolean isSquashServiceUserCall)
    throws Exception {

  if (!initialised) {
    throw new IllegalStateException("The rule manager has not been initialised");
  }

  lifecycleManager
      .throwIfOperationInvalidForCurrentLifecycleState(false, isSquashServiceUserCall);

  logger.log("About to delete booking rule from simpledb: " + bookingRuleToDelete.toString());

  String attributeName = getAttributeNameFromBookingRule(bookingRuleToDelete);
  String attributeValue = StringUtils.join(bookingRuleToDelete.getDatesToExclude(), ",");
  logger.log("Booking rule attribute name is: " + attributeName);
  logger.log("Booking rule attribute value is: " + attributeValue);
  Attribute attribute = new Attribute();
  attribute.setName(attributeName);
  attribute.setValue(attributeValue);
  optimisticPersister.delete(ruleItemName, attribute);

  logger.log("Deleted booking rule.");
  return;
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:26,代码来源:RuleManager.java

示例3: expectOptimisticPersisterToReturnVersionedAttributes

import com.amazonaws.services.simpledb.model.Attribute; //导入方法依赖的package包/类
private void expectOptimisticPersisterToReturnVersionedAttributes(int expectedVersion,
    List<BookingRule> bookingRules, int numCalls) throws Exception {

  // Set up attributes to be returned from the database's booking rule item
  Set<Attribute> attributes = new HashSet<>();
  for (BookingRule bookingRule : bookingRules) {
    Attribute attribute = new Attribute();
    attribute.setName(getAttributeNameFromBookingRule(bookingRule));
    String[] datesToExclude = bookingRule.getDatesToExclude();
    attribute.setValue(StringUtils.join(datesToExclude, ","));
    attributes.add(attribute);
  }
  mockery.checking(new Expectations() {
    {
      exactly(numCalls).of(mockOptimisticPersister).get(with(equal(ruleItemName)));
      will(returnValue(new ImmutablePair<>(Optional.of(expectedVersion), attributes)));
    }
  });
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:20,代码来源:RuleManagerTest.java

示例4: expectToDeleteRulesViaOptimisticPersister

import com.amazonaws.services.simpledb.model.Attribute; //导入方法依赖的package包/类
private void expectToDeleteRulesViaOptimisticPersister(List<BookingRule> rulesToDelete)
    throws Exception {

  // Set up attributes to be deleted from the database's booking rule item
  for (BookingRule ruleToDelete : rulesToDelete) {
    Attribute attribute = new Attribute();
    attribute.setName(getAttributeNameFromBookingRule(ruleToDelete));
    String[] datesToExclude = ruleToDelete.getDatesToExclude();
    attribute.setValue(StringUtils.join(datesToExclude, ","));

    mockery.checking(new Expectations() {
      {
        oneOf(mockOptimisticPersister).delete(with(equal(ruleItemName)), with(equal(attribute)));
      }
    });
  }
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:18,代码来源:RuleManagerTest.java

示例5: beforeTest

import com.amazonaws.services.simpledb.model.Attribute; //导入方法依赖的package包/类
@Before
public void beforeTest() {

  optimisticPersister = new TestOptimisticPersister();

  // Set up the mocks
  mockLogger = mockery.mock(LambdaLogger.class);
  mockery.checking(new Expectations() {
    {
      ignoring(mockLogger);
    }
  });
  mockSimpleDBClient = mockery.mock(AmazonSimpleDB.class);

  optimisticPersister.setSimpleDBClient(mockSimpleDBClient);

  // Set up some typical test attributes
  allAttributes = new HashSet<>();
  nonVersionAttributes = new HashSet<>();
  activeNonVersionAttributes = new HashSet<>();
  Attribute versionAttribute = new Attribute();
  versionAttribute.setName(versionAttributeName);
  versionAttribute.setValue(Integer.toString(testVersionNumber));
  Attribute activeAttribute = new Attribute();
  activeAttribute.setName("ActiveAttribute");
  activeAttribute.setValue("Active");
  Attribute inactiveAttribute = new Attribute();
  inactiveAttribute.setName("InactiveAttribute");
  inactiveAttribute.setValue("Inactive");
  allAttributes.add(versionAttribute);
  allAttributes.add(activeAttribute);
  allAttributes.add(inactiveAttribute);
  nonVersionAttributes.add(activeAttribute);
  nonVersionAttributes.add(inactiveAttribute);
  activeNonVersionAttributes.add(activeAttribute);
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:37,代码来源:OptimisticPersisterTest.java

示例6: testDeleteThrowsWhenOptimisticPersisterUninitialised

import com.amazonaws.services.simpledb.model.Attribute; //导入方法依赖的package包/类
@Test
public void testDeleteThrowsWhenOptimisticPersisterUninitialised() 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 delete should throw
  Attribute testAttribute = new Attribute();
  testAttribute.setName("Name");
  testAttribute.setValue("Value");
  optimisticPersister.delete(testItemName, testAttribute);
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:14,代码来源:OptimisticPersisterTest.java

示例7: doTestDeleteReturnsEarlyIfAttributeBeingDeletedDoesNotExist

import com.amazonaws.services.simpledb.model.Attribute; //导入方法依赖的package包/类
private void doTestDeleteReturnsEarlyIfAttributeBeingDeletedDoesNotExist(
    Boolean versionNumberExists) throws Exception {

  // ARRANGE
  initialiseOptimisticPersister();

  // Configure database to return no attributes.
  GetAttributesRequest simpleDBRequest = new GetAttributesRequest(testSimpleDBDomainName,
      testItemName);
  simpleDBRequest.setConsistentRead(true);
  GetAttributesResult getAttributesResult = new GetAttributesResult();
  if (versionNumberExists) {
    // Ensure we return at least the version number attribute
    getAttributesResult.setAttributes(allAttributes);
  }
  mockery.checking(new Expectations() {
    {
      oneOf(mockSimpleDBClient).getAttributes(with(equal(simpleDBRequest)));
      will(returnValue(getAttributesResult));
    }
  });

  // Ensure we return early.
  mockery.checking(new Expectations() {
    {
      never(mockSimpleDBClient).deleteAttributes(with(anything()));
    }
  });

  // ACT
  Attribute attributeToDelete = new Attribute();
  attributeToDelete.setName("Name");
  attributeToDelete.setValue("Value");
  optimisticPersister.delete(testItemName, attributeToDelete);
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:36,代码来源:OptimisticPersisterTest.java

示例8: expectDeleteBookingToReturnUpdatedBookingsOrThrow

import com.amazonaws.services.simpledb.model.Attribute; //导入方法依赖的package包/类
private void expectDeleteBookingToReturnUpdatedBookingsOrThrow(Booking bookingToDelete,
    Optional<List<Booking>> expectedBookingsAfterDelete, Optional<Exception> exceptionToThrow)
    throws Exception {

  String attributeName;
  attributeName = bookingToDelete.getCourt().toString() + "-"
      + bookingToDelete.getCourtSpan().toString() + "-" + bookingToDelete.getSlot().toString()
      + "-" + bookingToDelete.getSlotSpan().toString();

  Attribute attribute = new Attribute();
  attribute.setName(attributeName);
  attribute.setValue(bookingToDelete.getName());

  if (!exceptionToThrow.isPresent()) {
    mockery.checking(new Expectations() {
      {
        oneOf(mockOptimisticPersister).delete(with(equal(bookingToDelete.getDate())),
            with(equal(attribute)));
      }
    });

    // We expect call to getBookings after the delete
    Integer someArbitraryNumber = 42;
    expectOptimisticPersisterGetToReturnVersionedAttributesOrThrow(
        Optional.of(someArbitraryNumber), expectedBookingsAfterDelete.get(), Optional.empty());
  } else {
    mockery.checking(new Expectations() {
      {
        oneOf(mockOptimisticPersister).delete(with(equal(bookingToDelete.getDate())),
            with(equal(attribute)));
        will(throwException(exceptionToThrow.get()));
      }
    });
  }
  bookingManager.setOptimisticPersister(mockOptimisticPersister);
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:37,代码来源:BookingManagerTest.java

示例9: testthrowIfOperationInvalidForCurrentLifecycleStateThrowsForEndUserCallsInRetiredStateWithoutUrl

import com.amazonaws.services.simpledb.model.Attribute; //导入方法依赖的package包/类
@Test
public void testthrowIfOperationInvalidForCurrentLifecycleStateThrowsForEndUserCallsInRetiredStateWithoutUrl()
    throws Exception {
  // All end-user operations should not be allowed in RETIRED state. N.B.
  // System operations will still be allowed. This just adds check that if
  // we're retired but for some reason don't have a forwarding url that we
  // still throw. But we should never get to this state...

  // ARRANGE
  thrown.expect(Exception.class);
  thrown
      .expectMessage("Cannot access bookings or rules - there is an updated version of the booking service. Forwarding Url: UrlNotPresent");

  lifecycleManager.initialise(mockLogger);

  // Set up a defective retired lifecycle-state item - with missing url.
  Attribute retiredStateAttribute = new Attribute();
  retiredStateAttribute.setName("State");
  retiredStateAttribute.setValue("RETIRED");
  Set<Attribute> retiredAttributes = new HashSet<Attribute>();
  retiredAttributes.add(retiredStateAttribute);

  mockery.checking(new Expectations() {
    {
      exactly(1).of(mockOptimisticPersister).get(with(equal("LifecycleState")));
      will(returnValue(new ImmutablePair<Optional<Integer>, Set<Attribute>>(Optional.of(40),
          retiredAttributes)));
    }
  });

  // ACT
  // Should throw - as its an end-user operation when in RETIRED state.
  lifecycleManager.throwIfOperationInvalidForCurrentLifecycleState(true, true);
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:35,代码来源:LifecycleManagerTest.java

示例10: beforeTest

import com.amazonaws.services.simpledb.model.Attribute; //导入方法依赖的package包/类
@Before
public void beforeTest() {

  // Set up a retired lifecycle-state item - with arbitrary version number.
  Attribute retiredStateAttribute = new Attribute();
  retiredStateAttribute.setName("State");
  retiredStateAttribute.setValue("RETIRED");
  Attribute retiredUrlAttribute = new Attribute();
  retiredUrlAttribute.setName("Url");
  retiredUrlAttribute.setValue(exampleForwardingUrl);
  Set<Attribute> retiredAttributes = new HashSet<Attribute>();
  retiredAttributes.add(retiredStateAttribute);
  retiredAttributes.add(retiredUrlAttribute);
  exampleRetiredLifecycleItem = new ImmutablePair<Optional<Integer>, Set<Attribute>>(
      Optional.of(40), retiredAttributes);

  // Set up a readonly lifecycle-state item - with arbitrary version number.
  Attribute readonlyStateAttribute = new Attribute();
  readonlyStateAttribute.setName("State");
  readonlyStateAttribute.setValue("READONLY");
  Set<Attribute> readonlyAttributes = new HashSet<Attribute>();
  readonlyAttributes.add(readonlyStateAttribute);
  exampleReadonlyLifecycleItem = new ImmutablePair<Optional<Integer>, Set<Attribute>>(
      Optional.of(42), readonlyAttributes);

  // Set up an active lifecycle-state item - with arbitrary version number.
  Attribute activeStateAttribute = new Attribute();
  activeStateAttribute.setName("State");
  activeStateAttribute.setValue("ACTIVE");
  Set<Attribute> activeAttributes = new HashSet<Attribute>();
  activeAttributes.add(activeStateAttribute);
  exampleActiveLifecycleItem = new ImmutablePair<Optional<Integer>, Set<Attribute>>(
      Optional.of(43), activeAttributes);

  // Set up mock logger
  mockLogger = mockery.mock(LambdaLogger.class);
  mockery.checking(new Expectations() {
    {
      ignoring(mockLogger);
    }
  });
  mockOptimisticPersister = mockery.mock(IOptimisticPersister.class);

  // Set up the lifecycle manager
  lifecycleManager = new squash.booking.lambdas.core.LifecycleManagerTest.TestLifecycleManager();
  lifecycleManager.setOptimisticPersister(mockOptimisticPersister);
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:48,代码来源:LifecycleManagerTest.java


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