Search in sources :

Example 11 with PayloadGenerator

use of com.endava.cats.model.generator.PayloadGenerator in project cats by Endava.

the class PayloadGeneratorTest method shouldReturnNotEmailWhenSchemaNull.

@Test
void shouldReturnNotEmailWhenSchemaNull() {
    PayloadGenerator generator = new PayloadGenerator(globalContext, true);
    Assertions.assertThat(generator.isEmailAddress(new Schema<>(), "field")).isFalse();
}
Also used : PayloadGenerator(com.endava.cats.model.generator.PayloadGenerator) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with PayloadGenerator

use of com.endava.cats.model.generator.PayloadGenerator in project cats by Endava.

the class PayloadGeneratorTest method shouldRecognizeIpAddressFromPropertyName.

@ParameterizedTest
@CsvSource({ "ip,true", "ipaddress,true", "hostIp,true", "something,false" })
void shouldRecognizeIpAddressFromPropertyName(String property, boolean expected) {
    StringSchema schema = new StringSchema();
    PayloadGenerator generator = new PayloadGenerator(globalContext, true);
    boolean isIp = generator.isIPV4(schema, property);
    Assertions.assertThat(isIp).isEqualTo(expected);
}
Also used : StringSchema(io.swagger.v3.oas.models.media.StringSchema) PayloadGenerator(com.endava.cats.model.generator.PayloadGenerator) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with PayloadGenerator

use of com.endava.cats.model.generator.PayloadGenerator in project cats by Endava.

the class PayloadGeneratorTest method shouldRecognizeIpAddressFromFormat.

@ParameterizedTest
@CsvSource({ "ip,true", "ipv4,true", "hostIp,false", "something,false" })
void shouldRecognizeIpAddressFromFormat(String format, boolean expected) {
    StringSchema schema = new StringSchema();
    schema.setFormat(format);
    PayloadGenerator generator = new PayloadGenerator(globalContext, true);
    boolean isIp = generator.isIPV4(schema, "field");
    Assertions.assertThat(isIp).isEqualTo(expected);
}
Also used : StringSchema(io.swagger.v3.oas.models.media.StringSchema) PayloadGenerator(com.endava.cats.model.generator.PayloadGenerator) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with PayloadGenerator

use of com.endava.cats.model.generator.PayloadGenerator in project cats by Endava.

the class PayloadGeneratorTest method shouldRecognizeIpV6AddressFromPropertyFormat.

@Test
void shouldRecognizeIpV6AddressFromPropertyFormat() {
    StringSchema schema = new StringSchema();
    schema.setFormat("ipv6");
    PayloadGenerator generator = new PayloadGenerator(globalContext, true);
    boolean isIp = generator.isIPV6(schema, "something");
    Assertions.assertThat(isIp).isTrue();
}
Also used : StringSchema(io.swagger.v3.oas.models.media.StringSchema) PayloadGenerator(com.endava.cats.model.generator.PayloadGenerator) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

PayloadGenerator (com.endava.cats.model.generator.PayloadGenerator)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 StringSchema (io.swagger.v3.oas.models.media.StringSchema)8 QuarkusTest (io.quarkus.test.junit.QuarkusTest)6 Test (org.junit.jupiter.api.Test)6 CsvSource (org.junit.jupiter.params.provider.CsvSource)5 Map (java.util.Map)3 OpenAPIParser (io.swagger.parser.OpenAPIParser)1 OpenAPI (io.swagger.v3.oas.models.OpenAPI)1 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)1 Schema (io.swagger.v3.oas.models.media.Schema)1 ParseOptions (io.swagger.v3.parser.core.models.ParseOptions)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 TreeMap (java.util.TreeMap)1