use of org.wso2.carbon.apimgt.rest.api.common.codegen.DynamicHtmlGen in project carbon-apimgt by wso2.
the class DynamicHtmlGenTestCase method testToApiName.
@Test
public void testToApiName() throws Exception {
DynamicHtmlGen htmlGen = new DynamicHtmlGen();
final String originalTag = "API (Collection)";
String sanitised = htmlGen.sanitizeTag(originalTag);
Assert.assertEquals(sanitised, "APICollection");
String retrievedTag = htmlGen.toApiName(sanitised);
Assert.assertEquals(retrievedTag, originalTag);
sanitised = htmlGen.toApiFilename(originalTag);
Assert.assertEquals(sanitised, "APICollection");
}
use of org.wso2.carbon.apimgt.rest.api.common.codegen.DynamicHtmlGen in project carbon-apimgt by wso2.
the class DynamicHtmlGenTestCase method testFromParameter.
@Test
public void testFromParameter() throws Exception {
Parameter parameter = new QueryParameter();
parameter.setName("query");
final String description = "Sample parameter description";
parameter.setDescription(description);
DynamicHtmlGen htmlGen = new DynamicHtmlGen();
CodegenParameter modified = htmlGen.fromParameter(parameter, new HashSet<>());
Assert.assertEquals(modified.description, description);
}
use of org.wso2.carbon.apimgt.rest.api.common.codegen.DynamicHtmlGen in project carbon-apimgt by wso2.
the class DynamicHtmlGenTestCase method testPreprocessSwagger.
@Test
public void testPreprocessSwagger() throws Exception {
DynamicHtmlGen htmlGen = new DynamicHtmlGen();
Swagger swagger = new Swagger();
Path path = new Path();
Operation operation = new Operation();
List<String> tags = new ArrayList<>();
tags.add("tag1");
tags.add("tag2");
tags.add("tag3");
tags.add("tag4");
operation.setTags(tags);
path.setGet(operation);
swagger.path("get_sample", path);
htmlGen.preprocessSwagger(swagger);
List<String> processedTags = swagger.getPath("get_sample").getGet().getTags();
Assert.assertEquals(processedTags.size(), 1);
Assert.assertEquals(processedTags.get(0), "tag1");
}
use of org.wso2.carbon.apimgt.rest.api.common.codegen.DynamicHtmlGen in project carbon-apimgt by wso2.
the class DynamicHtmlGenTestCase method testFromOperation.
@Test
public void testFromOperation() throws Exception {
Operation operation = new Operation();
final String summary = "Sample operation summary";
final String description = "Sample operation description";
operation.setDescription(description);
operation.setSummary(summary);
DynamicHtmlGen htmlGen = new DynamicHtmlGen();
CodegenOperation modified = htmlGen.fromOperation("/apis", "GET", operation, null, null);
Assert.assertEquals(modified.summary, summary);
Assert.assertEquals(modified.notes, description);
}
use of org.wso2.carbon.apimgt.rest.api.common.codegen.DynamicHtmlGen in project carbon-apimgt by wso2.
the class DynamicHtmlGenTestCase method testEscapeQuotationMark.
@Test
public void testEscapeQuotationMark() throws Exception {
DynamicHtmlGen htmlGen = new DynamicHtmlGen();
final String stringToEscape = "\"";
String result = htmlGen.escapeQuotationMark(stringToEscape);
// Shouldn't be escaped
Assert.assertEquals(result, stringToEscape);
}
Aggregations