use of com.aliyuncs.fc.response.CreateTriggerResponse in project fc-java-sdk by aliyun.
the class FunctionComputeClientTest method ignoreTestListTriggers.
public void ignoreTestListTriggers() {
final int numTriggers = 5;
final int limit = 2;
// Create service
createService(SERVICE_NAME);
createFunction(FUNCTION_NAME);
// Create multiple trigger under the test function
for (int i = 0; i < numTriggers; i++) {
String prefix = "prefix";
String suffix = "suffix";
CreateTriggerResponse createTResp = createTrigger(TRIGGER_NAME + i, prefix + i, suffix + i);
assertFalse(Strings.isNullOrEmpty(createTResp.getRequestId()));
}
ListTriggersRequest listTReq = new ListTriggersRequest(SERVICE_NAME, FUNCTION_NAME);
listTReq.setLimit(limit);
ListTriggersResponse listTResp = client.listTriggers(listTReq);
int numCalled = 1;
String nextToken = listTResp.getNextToken();
while (nextToken != null) {
listTReq.setNextToken(nextToken);
listTResp = client.listTriggers(listTReq);
nextToken = listTResp.getNextToken();
numCalled++;
}
assertEquals(numTriggers / limit + 1, numCalled);
for (int i = 0; i < numTriggers; i++) {
DeleteTriggerResponse deleteTResp = deleteTrigger(SERVICE_NAME, FUNCTION_NAME, TRIGGER_NAME + i);
assertFalse(Strings.isNullOrEmpty(deleteTResp.getRequestId()));
}
}
use of com.aliyuncs.fc.response.CreateTriggerResponse in project fc-java-sdk by aliyun.
the class FunctionComputeClientTest method createTrigger.
private CreateTriggerResponse createTrigger(String triggerName, String prefix, String suffix) {
CreateTriggerRequest createTReq = new CreateTriggerRequest(SERVICE_NAME, FUNCTION_NAME);
createTReq.setTriggerName(triggerName);
createTReq.setTriggerType(TRIGGER_TYPE_OSS);
createTReq.setInvocationRole(INVOCATION_ROLE);
createTReq.setSourceArn(OSS_SOURCE_ARN);
createTReq.setTriggerConfig(new OSSTriggerConfig(new String[] { "oss:ObjectCreated:*" }, prefix, suffix));
CreateTriggerResponse resp = client.createTrigger(createTReq);
try {
// Add some sleep since OSS notifications create is not strongly consistent
Thread.sleep(5000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
return resp;
}
Aggregations