use of com.aliyuncs.fc.request.CreateTriggerRequest in project fc-java-sdk by aliyun.
the class FunctionComputeClientTest method testCreateTriggerValidate.
@Test
public void testCreateTriggerValidate() {
try {
CreateTriggerRequest request = new CreateTriggerRequest(SERVICE_NAME, null);
client.createTrigger(request);
fail("ClientException is expected");
} catch (ClientException e) {
assertTrue(e.getMessage().contains(VALIDATE_MSG));
}
try {
CreateTriggerRequest request = new CreateTriggerRequest(SERVICE_NAME, "");
client.createTrigger(request);
fail("ClientException is expected");
} catch (ClientException e) {
assertTrue(e.getMessage().contains(VALIDATE_MSG));
}
try {
CreateTriggerRequest request = new CreateTriggerRequest(null, FUNCTION_NAME);
client.createTrigger(request);
fail("ClientException is expected");
} catch (ClientException e) {
assertTrue(e.getMessage().contains(VALIDATE_MSG));
}
try {
CreateTriggerRequest request = new CreateTriggerRequest("", FUNCTION_NAME);
client.createTrigger(request);
fail("ClientException is expected");
} catch (ClientException e) {
assertTrue(e.getMessage().contains(VALIDATE_MSG));
}
}
use of com.aliyuncs.fc.request.CreateTriggerRequest 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