use of com.endava.cats.model.generator.PayloadGenerator in project cats by Endava.
the class PayloadGeneratorTest method shouldRecognizeEmail.
@ParameterizedTest
@CsvSource({ "email,true", "emailAddress,true", "notEmail,true", "myEmailAddress,true", "randomField,false" })
void shouldRecognizeEmail(String property, boolean expected) {
StringSchema schema = new StringSchema();
PayloadGenerator generator = new PayloadGenerator(globalContext, true);
boolean isEmail = generator.isEmailAddress(schema, property);
Assertions.assertThat(isEmail).isEqualTo(expected);
}
use of com.endava.cats.model.generator.PayloadGenerator in project cats by Endava.
the class PayloadGeneratorTest method shouldRecognizeIpV6AddressFromPropertyName.
@Test
void shouldRecognizeIpV6AddressFromPropertyName() {
StringSchema schema = new StringSchema();
PayloadGenerator generator = new PayloadGenerator(globalContext, true);
boolean isIp = generator.isIPV6(schema, "ipv6");
Assertions.assertThat(isIp).isTrue();
}
use of com.endava.cats.model.generator.PayloadGenerator in project cats by Endava.
the class PayloadGeneratorTest method givenASimpleOpenAPIContract_whenGeneratingAPayload_thenTheExampleIsProperlyGenerated.
@Test
void givenASimpleOpenAPIContract_whenGeneratingAPayload_thenTheExampleIsProperlyGenerated() throws Exception {
PayloadGenerator generator = setupPayloadGenerator();
List<Map<String, String>> example = generator.generate(null, "Pet");
String exampleJson = example.get(0).get("example");
Assertions.assertThat(exampleJson).contains("ALL_OF").contains("breedONE_OF#/components/schemas/Husky").contains("breedONE_OF#/components/schemas/Labrador");
}
use of com.endava.cats.model.generator.PayloadGenerator in project cats by Endava.
the class PayloadGeneratorTest method shouldRecognizeUrlFromPropertyName.
@ParameterizedTest
@CsvSource({ "url,true", "uri,true", "addressurl,true", "addressuri,true", "not,false" })
void shouldRecognizeUrlFromPropertyName(String property, boolean expected) {
StringSchema schema = new StringSchema();
PayloadGenerator generator = new PayloadGenerator(globalContext, true);
boolean isIp = generator.isURI(schema, property);
Assertions.assertThat(isIp).isEqualTo(expected);
}
use of com.endava.cats.model.generator.PayloadGenerator in project cats by Endava.
the class PayloadGeneratorTest method shouldGenerateFromAllOfAndPreserveRootElement.
@Test
void shouldGenerateFromAllOfAndPreserveRootElement() throws Exception {
PayloadGenerator generator = setupPayloadGenerator();
List<Map<String, String>> example = generator.generate(null, "MiniPet");
String exampleJson = example.get(0).get("example");
Assertions.assertThat(exampleJson).contains("color").contains("red").contains("green").contains("blue");
}
Aggregations