|
| 1 | +package com.axway.apim.test.description; |
| 2 | + |
| 3 | +import org.springframework.beans.factory.annotation.Autowired; |
| 4 | +import org.springframework.http.HttpStatus; |
| 5 | +import org.testng.annotations.Test; |
| 6 | + |
| 7 | +import com.axway.apim.test.ImportTestAction; |
| 8 | +import com.consol.citrus.annotations.CitrusTest; |
| 9 | +import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner; |
| 10 | +import com.consol.citrus.functions.core.RandomNumberFunction; |
| 11 | +import com.consol.citrus.message.MessageType; |
| 12 | + |
| 13 | +@Test |
| 14 | +public class LocalMarkdownDescriptionTestIT extends TestNGCitrusTestDesigner { |
| 15 | + |
| 16 | + @Autowired |
| 17 | + private ImportTestAction swaggerImport; |
| 18 | + |
| 19 | + @CitrusTest |
| 20 | + public void importAPIWithLocalMarkdown() { |
| 21 | + description("Import an API with a local markdown file"); |
| 22 | + |
| 23 | + variable("apiNumber", RandomNumberFunction.getRandomNumber(3, true)); |
| 24 | + variable("apiPath", "/localmarkdown-api-${apiNumber}"); |
| 25 | + variable("apiName", "LocalMarkDown-API-${apiNumber}"); |
| 26 | + |
| 27 | + echo("####### Importing API: '${apiName}' on path: '${apiPath}' #######"); |
| 28 | + |
| 29 | + createVariable(ImportTestAction.API_DEFINITION, "/com/axway/apim/test/files/basic/petstore.json"); |
| 30 | + createVariable(ImportTestAction.API_CONFIG, "/com/axway/apim/test/files/description/1_api_with_local_mark_down.json"); |
| 31 | + createVariable("state", "unpublished"); |
| 32 | + createVariable("descriptionType", "markdownLocal"); |
| 33 | + createVariable("markdownLocal", "MyLocalMarkdown.md"); |
| 34 | + createVariable("expectedReturnCode", "0"); |
| 35 | + action(swaggerImport); |
| 36 | + |
| 37 | + echo("####### Validate API: '${apiName}' has a description based on given local markdown file #######"); |
| 38 | + http().client("apiManager").send().get("/proxies").name("api").header("Content-Type", "application/json"); |
| 39 | + |
| 40 | + http().client("apiManager").receive().response(HttpStatus.OK).messageType(MessageType.JSON) |
| 41 | + .validate("$.[?(@.path=='${apiPath}')].name", "${apiName}") |
| 42 | + .validate("$.[?(@.path=='${apiPath}')].state", "unpublished") |
| 43 | + .validate("$.[?(@.path=='${apiPath}')].descriptionType", "manual") |
| 44 | + .validate("$.[?(@.path=='${apiPath}')].descriptionManual", "THIS IS THE API-DESCRIPTION FROM A LOCAL MARKDOWN!") |
| 45 | + .extractFromPayload("$.[?(@.path=='${apiPath}')].id", "apiId"); |
| 46 | + } |
| 47 | + |
| 48 | +} |
0 commit comments