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


Java SNSEvent.setRecords方法代码示例

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


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

示例1: createSnsEvent

import com.amazonaws.services.lambda.runtime.events.SNSEvent; //导入方法依赖的package包/类
private SNSEvent createSnsEvent(final String githubEvent) {
    SNSEvent.SNS sns = new SNSEvent.SNS();
    sns.setMessageAttributes(new HashMap<String, SNSEvent.MessageAttribute>(1, 1) {
        {
            SNSEvent.MessageAttribute attr = new SNSEvent.MessageAttribute();
            attr.setValue(githubEvent);
            put("X-Github-Event", attr);
        }
    });
    try (InputStream is = getClass().getResourceAsStream("/github-push-payload.json")) {
        sns.setMessage(IOUtils.toString(is));
    }
    catch (IOException e) {
        throw new IllegalArgumentException(e);
    }

    SNSEvent.SNSRecord record = new SNSEvent.SNSRecord();
    record.setSns(sns);

    SNSEvent snsEvent = new SNSEvent();
    snsEvent.setRecords(Collections.singletonList(record));
    return snsEvent;
}
 
开发者ID:berlam,项目名称:github-bucket,代码行数:24,代码来源:LambdaTest.java

示例2: testHandleRequest

import com.amazonaws.services.lambda.runtime.events.SNSEvent; //导入方法依赖的package包/类
public void testHandleRequest() {
    System.out.println("handleRequest");
    
    SNS sns = new SNS();
    sns.setMessage("test message");

    SNSRecord record = new SNSRecord();
    record.setSns(sns);

    SNSEvent request = new SNSEvent();
    List<SNSRecord> records = new ArrayList<>();
    records.add(record);
    request.setRecords(records);

    Context context = new TestContext();
    SnsEventHandler instance = new SnsEventHandler();
    
    instance.handleRequest(request, context);
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:20,代码来源:SnsEventHandlerTest.java

示例3: testMultipleRecordsCreateMultipleRequest

import com.amazonaws.services.lambda.runtime.events.SNSEvent; //导入方法依赖的package包/类
@Test
public void testMultipleRecordsCreateMultipleRequest() {
	SNSEvent snsEvent = new SNSEvent();
	SNSRecord snsRecord0 = createSnsRecord("a:b:mytopic", "inject-sns-record-member0");
	SNSRecord snsRecord1 = createSnsRecord("a:b:mytopic", "inject-sns-record-member1");
	snsEvent.setRecords(ImmutableList.of(snsRecord0, snsRecord1));
	handler.handleRequest(snsEvent, context);
	InOrder inOrder = Mockito.inOrder(testService);
	inOrder.verify(testService).injectedSns(snsRecord0.getSNS());
	inOrder.verify(testService).injectedSns(snsRecord1.getSNS());
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:12,代码来源:SnsRequestHandlerIntTest.java

示例4: getTestEvent

import com.amazonaws.services.lambda.runtime.events.SNSEvent; //导入方法依赖的package包/类
@Override
public SNSEvent getTestEvent() throws Exception {
  /*
   * Upload a test resoruce to the mock S3
   */
  String payload = IOUtils.toString(
      new InputStreamReader(this.getClass().getResourceAsStream("basic_input.log"), "UTF-8"));
  this.client.putObject(S3_BUCKET, "basic_input.log", payload);

  /*
   * Create a S3EventNotification event
   */
  S3ObjectEntity objEntity = new S3ObjectEntity("basic_input.log", 1L, null, null);
  S3BucketEntity bucketEntity = new S3BucketEntity(S3_BUCKET, null, null);
  S3Entity entity = new S3Entity(null, bucketEntity, objEntity, null);

  S3EventNotificationRecord rec = new S3EventNotificationRecord(null, null, null,
      "1970-01-01T00:00:00.000Z", null, null, null, entity, null);

  List<S3EventNotificationRecord> notifications = new ArrayList<S3EventNotificationRecord>(2);
  notifications.add(rec);

  /*
   * Wrap as an SNS Event
   */
  S3EventNotification event = new S3EventNotification(notifications);
  SNSEvent.SNS sns = new SNSEvent.SNS();
  sns.setMessage(event.toJson());

  SNSEvent snsEvent = new SNSEvent();

  ArrayList<SNSRecord> snsRecords = new ArrayList<SNSRecord>(1);
  SNSRecord snsRecord = new SNSRecord();
  snsRecord.setEventSource("aws:sns");
  snsRecord.setEventVersion("1.0");
  snsRecord.setEventSubscriptionArn("arn");

  snsRecord.setSns(sns);
  snsRecords.add(snsRecord);
  snsEvent.setRecords(snsRecords);

  return snsEvent;
}
 
开发者ID:Nextdoor,项目名称:bender,代码行数:44,代码来源:SNSS3HandlerTest.java

示例5: getTestEvent

import com.amazonaws.services.lambda.runtime.events.SNSEvent; //导入方法依赖的package包/类
private SNSEvent getTestEvent(String bucket, boolean doPut) throws Exception {
  /*
   * Upload a test resoruce to the mock S3
   */
  if (doPut) {
    String payload = IOUtils.toString(
        new InputStreamReader(this.getClass().getResourceAsStream("basic_input.log"), "UTF-8"));
    this.client.putObject(bucket, "basic_input.log", payload);
  }
  /*
   * Create a S3EventNotification event
   */
  S3ObjectEntity objEntity = new S3ObjectEntity("basic_input.log", 1L, null, null);
  S3BucketEntity bucketEntity = new S3BucketEntity(bucket, null, null);
  S3Entity entity = new S3Entity(null, bucketEntity, objEntity, null);

  S3EventNotificationRecord rec = new S3EventNotificationRecord(null, null, null,
      "1970-01-01T00:00:00.000Z", null, null, null, entity, null);

  List<S3EventNotificationRecord> notifications = new ArrayList<S3EventNotificationRecord>(2);
  notifications.add(rec);

  /*
   * Wrap as an SNS Event
   */
  S3EventNotification event = new S3EventNotification(notifications);
  SNSEvent.SNS sns = new SNSEvent.SNS();
  sns.setMessage(event.toJson());

  SNSEvent snsEvent = new SNSEvent();

  ArrayList<SNSRecord> snsRecords = new ArrayList<SNSRecord>(1);
  SNSRecord snsRecord = new SNSRecord();
  snsRecord.setEventSource("aws:sns");
  snsRecord.setEventVersion("1.0");
  snsRecord.setEventSubscriptionArn("arn");

  snsRecord.setSns(sns);
  snsRecords.add(snsRecord);
  snsEvent.setRecords(snsRecords);

  return snsEvent;
}
 
开发者ID:Nextdoor,项目名称:bender,代码行数:44,代码来源:SNSS3HandlerTest.java

示例6: createSnsEvent

import com.amazonaws.services.lambda.runtime.events.SNSEvent; //导入方法依赖的package包/类
private SNSEvent createSnsEvent(String topicArn, String subject) {
	SNSEvent snsEvent = new SNSEvent();
	snsEvent.setRecords(Collections.singletonList(createSnsRecord(topicArn, subject)));
	return snsEvent;
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:6,代码来源:SnsRequestHandlerIntTest.java


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