Skip to content

Commit

Permalink
Add unit test for issue #98
Browse files Browse the repository at this point in the history
  • Loading branch information
en-milie committed Feb 10, 2024
1 parent 2422565 commit aef13c2
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/test/java/com/endava/cats/factory/FuzzingDataFactoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.endava.cats.generator.format.api.ValidDataFormat;
import com.endava.cats.http.HttpMethod;
import com.endava.cats.json.JsonUtils;
import com.endava.cats.model.CatsField;
import com.endava.cats.model.FuzzingData;
import com.endava.cats.openapi.OpenApiUtils;
import com.google.gson.JsonParser;
Expand Down Expand Up @@ -308,4 +309,13 @@ void shouldGenerateValidDataWhenPrimitiveArrays() throws Exception {
void shouldThrowExceptionWhenSchemeDoesNotExist() {
Assertions.assertThatThrownBy(() -> setupFuzzingData("/pet-types", "src/test/resources/petstore-no-schema.yml")).isInstanceOf(IllegalArgumentException.class);
}

@Test
void shouldGetAllFieldsWhenSchemaDoesNotExist() throws Exception {
List<FuzzingData> dataList = setupFuzzingData("/rest/1/pdf/", "src/test/resources/issue98.json");
Assertions.assertThat(dataList).hasSize(1);
FuzzingData data = dataList.get(0);
Set<CatsField> fields = data.getAllFieldsAsCatsFields();
Assertions.assertThat(fields).hasSize(4);
}
}
77 changes: 77 additions & 0 deletions src/test/resources/issue98.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"openapi":"3.0.3",
"info":{
"title":"fasf",
"description":"ASFAFSAF",
"license":{
"name":""
},
"version":"1.1.0"
},
"paths":{
"/rest/1/pdf/":{
"post":{
"tags":[
"crate::pdf_creator::routes"
],
"operationId":"create_pdf",
"requestBody":{
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/ReportRequestQuery2"
}
}
},
"required":true
},
"responses":{
"200":{
"description":"Create PDF",
"content":{
"text/plain":{
"schema":{
"type":"string"
}
}
}
}
}
}
}
},
"components":{
"schemas":{
"Category":{
"type":"string",
"enum":[
"STATIC",
"KINETIC"
]
},
"ReportRequestQuery2":{
"type":"object",
"required":[
"report_type",
"report_uuid",
"language",
"data"
],
"properties":{
"data":{
"$ref":"#/components/schemas/ReportData2"
},
"language":{
"$ref":"#/components/schemas/Languages"
},
"report_type":{
"$ref":"#/components/schemas/ReportSymbol"
},
"report_uuid":{
"type":"string"
}
}
}
}
}
}

0 comments on commit aef13c2

Please sign in to comment.