com.consol.citrus.annotations.CitrusResource Java Examples

The following examples show how to use com.consol.citrus.annotations.CitrusResource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultiSqlToSheets_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testMultiSqlMapper(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.given(sql(sampleDb)
            .statements(Arrays.asList("insert into contact (first_name, last_name, company, lead_source) values ('Joe','Jackson','Red Hat','google-sheets')",
                                      "insert into contact (first_name, last_name, company, lead_source) values ('Joanne','Jackson','Red Hat','google-sheets')")));

    runner.when(http().server(googleSheetsApiServer)
                    .receive()
                    .post()
                    .payload("{\"majorDimension\":\"ROWS\",\"values\":[[\"Joe\",\"Red Hat\"],[\"Joanne\",\"Red Hat\"]]}"));

    runner.then(http().server(googleSheetsApiServer)
                    .send()
                    .response(HttpStatus.OK));
}
 
Example #2
Source File: TodoListApi_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testGetTodoList(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.given(sql(sampleDb)
            .statements(Arrays.asList("insert into todo (task, completed) values ('Wash the dog', 0)",
                    "insert into todo (task, completed) values ('Feed the dog', 0)",
                    "insert into todo (task, completed) values ('Play with the dog', 0)")));

    runner.when(http().client(todoListApiClient)
            .send()
            .get("/todos"));

    runner.then(http().client(todoListApiClient)
            .receive()
            .response(HttpStatus.OK)
            .payload("[{\"id\":\"@ignore@\",\"name\":\"Wash the dog\",\"done\":0}," +
                        "{\"id\":\"@ignore@\",\"name\":\"Feed the dog\",\"done\":0}," +
                        "{\"id\":\"@ignore@\",\"name\":\"Play with the dog\",\"done\":0}]"));
}
 
Example #3
Source File: TodoOpenApiV3_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testDeleteTask(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.variable("id", "citrus:randomNumber(4)");

    runner.given(sql(sampleDb)
        .statement("insert into todo (id, task, completed) values (${id}, 'Walk the dog', 0)"));

    runner.when(http().client(todoApiClient)
        .send()
        .delete("/api/${id}"));

    runner.then(http().client(todoApiClient)
        .receive()
        .response(HttpStatus.NO_CONTENT));

    runner.then(query(sampleDb)
        .statement("select count(task) as TASKS_FOUND from todo where id=${id}")
        .validate("TASKS_FOUND", "0"));
}
 
Example #4
Source File: WebHookSplitToDB_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testWebHookToDbBasicFilter(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.when(http().client(webHookClient)
            .send()
            .post()
            .payload(contacts("Microsoft", "Bill", "Johnny")));

    runner.then(http().client(webHookClient)
            .receive()
            .response(HttpStatus.NO_CONTENT));

    verifyRecordsInDb(runner, 0);
}
 
Example #5
Source File: TodoApi_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testGetDone(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.given(sql(sampleDb)
            .statements(Arrays.asList("insert into todo (task, completed) values ('Wash the dog', 0)",
                    "insert into todo (task, completed) values ('Feed the dog', 0)",
                    "insert into todo (task, completed) values ('Play piano', 1)",
                    "insert into todo (task, completed) values ('Play guitar', 1)",
                    "insert into todo (task, completed) values ('Play with the dog', 0)")));

    runner.when(http().client(todoApiClient)
            .send()
            .get("/todos/done"));

    runner.then(http().client(todoApiClient)
            .receive()
            .response(HttpStatus.OK)
            .payload("[{\"name\":\"Play piano\",\"done\":1}," +
                        "{\"name\":\"Play guitar\",\"done\":1}]"));
}
 
Example #6
Source File: TodoApi_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testGetOpenApiSpec(@CitrusResource TestCaseRunner runner) {
    runner.given(waitFor().http()
            .method(HttpMethod.GET.name())
            .seconds(10L)
            .status(HttpStatus.OK.value())
            .url(String.format("http://localhost:%s/actuator/health", integrationContainer.getManagementPort())));

    runner.when(http().client(todoApiClient)
                .send()
                .get("/openapi.json"));

    runner.then(http().client(todoApiClient)
            .receive()
            .response(HttpStatus.OK)
            .contentType(VND_OAI_OPENAPI_JSON)
            .payload(new ClassPathResource("todo-api.json", TodoApi_IT.class)));
}
 
Example #7
Source File: DBToSheets_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testDBToSheets(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.given(sql(sampleDb)
            .statements(Arrays.asList("insert into contact (first_name, last_name, company, lead_source) values ('Joe','Jackson','Red Hat','google-sheets')",
                                      "insert into contact (first_name, last_name, company, lead_source) values ('Joanne','Jackson','Red Hat','google-sheets')")));

    runner.when(http().server(googleSheetsApiServer)
                    .receive()
                    .put()
                    .payload("{\"majorDimension\":\"ROWS\",\"values\":[[\"Joe\",\"Jackson\",\"Red Hat\"],[\"Joanne\",\"Jackson\",\"Red Hat\"]]}"));

    runner.then(http().server(googleSheetsApiServer)
                    .send()
                    .response(HttpStatus.OK));
}
 
Example #8
Source File: ConditionalFlows_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testWebHookToDbBasicFilter(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.when(http().client(webHookClient)
            .send()
            .post()
            .payload(contact("Bill", "Microsoft")));

    runner.then(http().client(webHookClient)
            .receive()
            .response(HttpStatus.NO_CONTENT));

    verifyRecordInDb(runner, "Drink coffee with Bill from Microsoft");
}
 
Example #9
Source File: TodoOpenApiV3_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testGetTask(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.variable("id", "citrus:randomNumber(4)");

    runner.given(sql(sampleDb)
            .statement("insert into todo (id, task, completed) values (${id}, 'Walk the dog', 0)"));

    runner.when(http().client(todoApiClient)
            .send()
            .get("/api/${id}"));

    runner.then(http().client(todoApiClient)
            .receive()
            .response(HttpStatus.OK)
            .payload("{\"id\":${id},\"task\":\"Walk the dog\",\"completed\":0}"));
}
 
Example #10
Source File: TodoListApi_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testAddTodoList(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.given(http().client(todoListApiClient)
            .send()
            .post("/todos")
            .payload("[{\"name\":\"Wash the cat\",\"done\":0}," +
                        "{\"name\":\"Feed the cat\",\"done\":0}," +
                        "{\"name\":\"Play with the cat\",\"done\":0}]"));

    runner.when(http().client(todoListApiClient)
            .receive()
            .response(HttpStatus.CREATED));

    runner.then(query(sampleDb)
            .statement("select task, completed from todo")
            .validate("task", "Wash the cat", "Feed the cat", "Play with the cat")
            .validate("completed", "0", "0", "0"));
}
 
Example #11
Source File: ConditionalFlows_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testWebHookToDbAdvancedFilter(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.when(http().client(webHookClient)
            .send()
            .post()
            .payload(contact("Joanna", "Red Hat")));

    runner.then(http().client(webHookClient)
            .receive()
            .response(HttpStatus.NO_CONTENT));

    verifyRecordInDb(runner, "Meet Joanna from Red Hat");
}
 
Example #12
Source File: CustomPoliciesTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException {		
	description("Import an API to export it afterwards");

	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/api/test/"+this.getClass().getSimpleName()+"-${apiNumber}");
	variable("apiName", this.getClass().getSimpleName()+"-${apiNumber}");
	variable("state", "published");
	


	echo("####### Importing the API, which should exported in the second step #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/test/export/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/test/export/files/customPolicies/custom-policies-issue-156.json");
	createVariable("requestPolicy", "Request policy 1");
	createVariable("responsePolicy", "Response policy 1");
	createVariable("tokenInfoPolicy", "Tokeninfo policy 1");
	createVariable("expectedReturnCode", "0");
	swaggerImport.doExecute(context);
	
	exportAPI(context, false);
	exportAPI(context, true);
}
 
Example #13
Source File: WebHookToDB_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testWebHookToDbAdvancedFilter(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.when(http().client(webHookClient)
            .send()
            .post()
            .payload(contact("Unknown", "Red Hat")));

    runner.then(http().client(webHookClient)
            .receive()
            .response(HttpStatus.NO_CONTENT));

    verifyRecordsInDb(runner, 0);
}
 
Example #14
Source File: MethodLevelInvalidProfileTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void runInboundProfileValidation(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Make sure only valid profile names are referenced");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/invalid-sec-profile-api-${apiNumber}");
	variable("apiName", "Invalid-SecProfile-API-${apiNumber}");
	
	echo("####### Try to replicate an API having invalid profiles referenced #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/methodLevel/method-level-inbound-invalidProfileRefercence.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "73");
	createVariable("securityProfileName1", "APIKeyBased${apiNumber}");
	createVariable("securityProfileName2", "SomethingWrong${apiNumber}");
	swaggerImport.doExecute(context);
}
 
Example #15
Source File: MethodLevelInvalidProfileTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void runOutboundProfileValidation(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Make sure only valid profile names are referenced");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/invalid-authn-profile-api-${apiNumber}");
	variable("apiName", "Invalid AuthN-Profile-API-${apiNumber}");
	
	echo("####### Try to replicate an API having invalid profiles referenced #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/methodLevel/method-level-outboundbound-invalidProfileReference.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "73");
	createVariable("authenticationProfileName1", "HTTP Basic");
	createVariable("authenticationProfileName2", "SomethingWrong");
	swaggerImport.doExecute(context);
}
 
Example #16
Source File: InboundMethodLevelInvalidOperationTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Make sure, the error that an invalid operationId is given is properly handled.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/basic-method-level-api-${apiNumber}");
	variable("apiName", "Basic Method-Level-API-${apiNumber}");
	
	echo("####### Try to replicate an API having Method-Level settings declared #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/methodLevel/method-level-inbound-invalidOperation.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "72");
	createVariable("securityProfileName", "APIKeyBased${apiNumber}");
	swaggerImport.doExecute(context);
}
 
Example #17
Source File: WebHookToDB_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testWebHookToDbBasicFilter(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.when(http().client(webHookClient)
            .send()
            .post()
            .payload(contact("Bill", "Microsoft")));

    runner.then(http().client(webHookClient)
            .receive()
            .response(HttpStatus.NO_CONTENT));

    verifyRecordsInDb(runner, 0);
}
 
Example #18
Source File: OrgAdminTriesToPublishTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	
	description("But OrgAdmins should not being allowed to register published APIs.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/org-admin-published-${apiNumber}");
	variable("apiName", "OrgAdmin-Published-${apiNumber}");
	variable("ignoreAdminAccount", "true"); // This tests simulate to use only an Org-Admin-Account
	variable("allowOrgAdminsToPublish", "false"); // Disable OrgAdmins to publish APIs

	echo("####### Calling the tool with a Non-Admin-User. #######");
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/2_initially_published.json");
	createVariable("expectedReturnCode", "17");
	createVariable("apiManagerUser", "${oadminUsername1}"); // This is an org-admin user
	createVariable("apiManagerPass", "${oadminPassword1}");
	swaggerImport.doExecute(context);
}
 
Example #19
Source File: WebHookToDB_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testWebHookToDb(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.when(http().client(webHookClient)
            .send()
            .post()
            .payload(contact("John", "Red Hat")));

    runner.then(http().client(webHookClient)
            .receive()
            .response(HttpStatus.NO_CONTENT));

    verifyRecordsInDb(runner, 1);
}
 
Example #20
Source File: TodoOpenApiV3_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testUpdateTask(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.variable("id", "citrus:randomNumber(4)");

    runner.given(sql(sampleDb)
        .statement("insert into todo (id, task, completed) values (${id}, 'Walk the dog', 0)"));

    runner.when(http().client(todoApiClient)
        .send()
        .put("/api/${id}")
        .payload("{\"id\":${id},\"task\":\"WALK THE DOG\",\"completed\":1}"));

    runner.then(http().client(todoApiClient)
        .receive()
        .response(HttpStatus.OK)
        .payload("{\"id\":${id},\"task\":\"WALK THE DOG\",\"completed\":1}"));

    runner.then(query(sampleDb)
        .statement("select task, completed from todo where id=${id}")
        .validate("TASK", "WALK THE DOG")
        .validate("COMPLETED", "1"));
}
 
Example #21
Source File: AMQToHttp_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testHttpToAMQ(@CitrusResource TestCaseRunner runner) {
    runner.given(send().endpoint(todoJms)
            .payload("{\"id\": \"1\", \"name\":\"Learn some #golang\", \"done\": 1}"));

    runner.when(http().server(todoApiServer)
            .receive()
            .post()
            .payload("{\"id\": \"1\", \"task\":\"Learn some #golang\", \"completed\": 1}"));

    runner.then(http().server(todoApiServer)
            .send()
            .response(HttpStatus.CREATED));

}
 
Example #22
Source File: Webhook2DB_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testWebhook2Db(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.given(http().client(webHookClient)
            .send()
            .post()
            .payload("{\"task\":\"My new task!\"}"));

    runner.when(http().client(webHookClient)
            .receive()
            .response(HttpStatus.NO_CONTENT));

    runner.then(query(sampleDb)
            .statement("select count(*) as found_records from todo where task = 'My new task!'")
            .validate("found_records", String.valueOf(1)));
}
 
Example #23
Source File: TodoApiV2ApiKeyInHeader_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testApiConnectorUsingApiKey(@CitrusResource TestCaseRunner runner) {
    runner.variable("id", "citrus:randomNumber(4)");
    runner.variable("task", "Syndesis rocks!");

    runner.run(echo("List all tasks"));

    runner.when(http().server(todoApiServer)
        .receive()
        .get("/api")
        .header("keyName", "secret"));

    runner.then(http().server(todoApiServer)
        .send()
        .response(HttpStatus.OK)
        .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
        .payload("[{\"id\": ${id}, \"task\":\"${task}\", \"completed\": 0}]"));
}
 
Example #24
Source File: TodoApiV2BasicAuth_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testApiConnectorUsingBasicAuth(@CitrusResource TestCaseRunner runner) {
    runner.variable("id", "citrus:randomNumber(4)");
    runner.variable("task", "Syndesis rocks!");

    runner.run(echo("List all tasks"));

    runner.when(http().server(todoApiServer)
        .receive()
        .get("/api")
        .header("Authorization", "Basic citrus:encodeBase64('syndesis:secret')"));

    runner.then(http().server(todoApiServer)
        .send()
        .response(HttpStatus.OK)
        .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
        .payload("[{\"id\": ${id}, \"task\":\"${task}\", \"completed\": 0}]"));
}
 
Example #25
Source File: TodoApiV2ApiKeyInQuery_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testApiConnectorUsingApiKey(@CitrusResource TestCaseRunner runner) {
    runner.variable("id", "citrus:randomNumber(4)");
    runner.variable("task", "Syndesis rocks!");

    runner.run(echo("List all tasks"));

    runner.when(http().server(todoApiServer)
        .receive()
        .get("/api")
        .queryParam("keyName", "citrus:urlEncode('secret', 'UTF-8')"));

    runner.then(http().server(todoApiServer)
        .send()
        .response(HttpStatus.OK)
        .contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
        .payload("[{\"id\": ${id}, \"task\":\"${task}\", \"completed\": 0}]"));
}
 
Example #26
Source File: TodoApi_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testGetById(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.given(sql(sampleDb)
            .statement("insert into todo (id, task, completed) values (9999, 'Walk the dog', 0)"));

    runner.when(http().client(todoApiClient)
            .send()
            .get("/todo/9999"));

    runner.then(http().client(todoApiClient)
            .receive()
            .response(HttpStatus.OK)
            .payload("{\"name\":\"Walk the dog\",\"done\":0}"));
}
 
Example #27
Source File: NoAPIDefinitionConfiguredIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("If no api-definition is passed as argument and no apiDefinition attribute is found in configuration file, the tool must fail with a dedicated return code.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/my-no-api-def-${apiNumber}");
	variable("apiName", "No-API-DEF-CONFIGURED-${apiNumber}");

	echo("####### Calling the tool with a Non-Admin-User. #######");
	createVariable(ImportTestAction.API_DEFINITION,  "");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/basic/minimal-config.json");
	createVariable("status", "unpublished");
	createVariable("expectedReturnCode", String.valueOf(ErrorCode.NO_API_DEFINITION_CONFIGURED.getCode()));
	swaggerImport.doExecute(context);
}
 
Example #28
Source File: TodoApi_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testGetOpen(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.given(sql(sampleDb)
            .statements(Arrays.asList("insert into todo (task, completed) values ('Wash the dog', 0)",
                    "insert into todo (task, completed) values ('Feed the dog', 0)",
                    "insert into todo (task, completed) values ('Play piano', 1)",
                    "insert into todo (task, completed) values ('Play guitar', 1)",
                    "insert into todo (task, completed) values ('Play with the dog', 0)")));

    runner.when(http().client(todoApiClient)
            .send()
            .get("/todos/open"));

    runner.then(http().client(todoApiClient)
            .receive()
            .response(HttpStatus.OK)
            .payload("[{\"name\":\"Wash the dog\",\"done\":0}," +
                        "{\"name\":\"Feed the dog\",\"done\":0}," +
                        "{\"name\":\"Play with the dog\",\"done\":0}]"));
}
 
Example #29
Source File: InvalidQuotaConfigTestIT.java    From apimanager-swagger-promote with Apache License 2.0 6 votes vote down vote up
@CitrusTest
@Test @Parameters("context")
public void run(@Optional @CitrusResource TestContext context) throws IOException, AppException {
	swaggerImport = new ImportTestAction();
	description("Try to import an API with invalid quota configuration.");
	
	variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true));
	variable("apiPath", "/invalid-quota-api-${apiNumber}");
	variable("apiName", "Invalid Quota-API-${apiNumber}");

	echo("####### Trying to import API: '${apiName}' on path: '${apiPath}' with invalid quota config #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/quota/issue-109-invalid-quota-config-1.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "71");
	swaggerImport.doExecute(context);
	
	echo("####### Trying to import API: '${apiName}' on path: '${apiPath}' with invalid quota config #######");		
	createVariable(ImportTestAction.API_DEFINITION,  "/com/axway/apim/test/files/basic/petstore.json");
	createVariable(ImportTestAction.API_CONFIG,  "/com/axway/apim/test/files/quota/issue-109-invalid-quota-config-2.json");
	createVariable("state", "unpublished");
	createVariable("expectedReturnCode", "71");
	swaggerImport.doExecute(context);
}
 
Example #30
Source File: TodoApi_IT.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
@CitrusTest
public void testGetAll(@CitrusResource TestCaseRunner runner) {
    cleanupDatabase(runner);

    runner.given(sql(sampleDb)
            .statements(Arrays.asList("insert into todo (task, completed) values ('Wash the dog', 0)",
                    "insert into todo (task, completed) values ('Feed the dog', 0)",
                    "insert into todo (task, completed) values ('Play with the dog', 0)")));

    runner.when(http().client(todoApiClient)
            .send()
            .get("/todos"));

    runner.then(http().client(todoApiClient)
            .receive()
            .response(HttpStatus.OK)
            .payload("[{\"name\":\"Wash the dog\",\"done\":0}," +
                        "{\"name\":\"Feed the dog\",\"done\":0}," +
                        "{\"name\":\"Play with the dog\",\"done\":0}]"));
}