Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI: Avoid null/empty value conflicts and duplicates in generated test cases #202

Merged
merged 10 commits into from
Jul 27, 2021
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"schema": {
"type": "array",
"uniqueItems": false,
"minItems": 1,
"items": {
"type": "object"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
"style": "form",
"schema": {
"type": "array",
"minItems": 1,
"items": {
"type": "string"
"type": "string",
"minLength": 1
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void getPosts_IdsDefined_Is_No() {
public void getPosts_IdsType_Is_Null() {
given()
.baseUri( forTestServer())
.queryParam( "ids", "")
.queryParam( "ids", (String) null)
.when()
.request( "GET", "/posts")
.then()
Expand All @@ -71,19 +71,6 @@ public void getPosts_IdsType_Is_NotArray() {
;
}

@Test
public void getPosts_IdsItemsSize_Is_0() {
given()
.baseUri( forTestServer())
.queryParam( "ids", "")
.when()
.request( "GET", "/posts")
.then()
// ids.Items.Size=0
.statusCode( isBadRequest())
;
}

@Test
public void getPosts_IdsItemsSize_Is_5() {
given()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void headPost_UserAttributesType_Is_Null() {
given()
.baseUri( forTestServer( "http://localhost:12306"))
.queryParam( "post?[post-references]", "0,2")
.queryParam( "user attributes", "")
.queryParam( "user attributes", (String) null)
.when()
.request( "HEAD", "/post")
.then()
Expand Down Expand Up @@ -114,7 +114,7 @@ public void headPost_UserAttributesValuePropertiesUserTypeType_Is_Null() {
given()
.baseUri( forTestServer( "http://localhost:12306"))
.queryParam( "post?[post-references]", "0,2")
.queryParam( "user attributes[user-type]", "")
.queryParam( "user attributes[user-type]", (String) null)
.when()
.request( "HEAD", "/post")
.then()
Expand Down Expand Up @@ -171,7 +171,7 @@ public void headPost_PostDefined_Is_No() {
public void headPost_PostType_Is_Null() {
given()
.baseUri( forTestServer( "http://localhost:12306"))
.queryParam( "post?", "")
.queryParam( "post?", (String) null)
.queryParam( "user attributes[user-type]", "VIP!")
.when()
.request( "HEAD", "/post")
Expand Down Expand Up @@ -212,7 +212,7 @@ public void headPost_PostValuePropertiesPostReferencesDefined_Is_No() {
public void headPost_PostValuePropertiesPostReferencesType_Is_Null() {
given()
.baseUri( forTestServer( "http://localhost:12306"))
.queryParam( "post?[post-references]", "")
.queryParam( "post?[post-references]", (String) null)
.queryParam( "user attributes[user-type]", "VIP!")
.when()
.request( "HEAD", "/post")
Expand Down Expand Up @@ -399,7 +399,7 @@ public void patchPost_PostMarksDefined_Is_No() {
public void patchPost_PostMarksType_Is_Null() {
given()
.baseUri( forTestServer( "http://localhost:12306"))
.queryParam( "Post Marks", "")
.queryParam( "Post Marks", (String) null)
.when()
.request( "PATCH", "/post")
.then()
Expand All @@ -421,19 +421,6 @@ public void patchPost_PostMarksType_Is_NotArray() {
;
}

@Test
public void patchPost_PostMarksItemsSize_Is_0() {
given()
.baseUri( forTestServer( "http://localhost:12306"))
.queryParam( "Post Marks", "")
.when()
.request( "PATCH", "/post")
.then()
// Post-Marks.Items.Size=0
.statusCode( isBadRequest())
;
}

@Test
public void patchPost_PostMarksItemsSize_Is_4() {
given()
Expand Down Expand Up @@ -537,7 +524,7 @@ public void putPost_PostIdDefined_Is_No() {
public void putPost_PostIdType_Is_Null() {
given()
.baseUri( forTestServer( "http://localhost:12306"))
.queryParam( "postId", "")
.queryParam( "postId", (String) null)
.contentType( "application/x-www-form-urlencoded")
.formParam( "approved", "false")
.formParam( "reviewer", "Larry Moe")
Expand Down Expand Up @@ -659,7 +646,7 @@ public void putPost_BodyApplicationXWwwFormUrlencodedValuePropertiesApprovedType
.baseUri( forTestServer( "http://localhost:12306"))
.queryParam( "postId", "218911377319422868.8")
.contentType( "application/x-www-form-urlencoded")
.formParam( "approved", "")
.formParam( "approved", (String) null)
.formParam( "reviewer", "Larry Moe")
.when()
.request( "PUT", "/post")
Expand Down Expand Up @@ -707,7 +694,7 @@ public void putPost_BodyApplicationXWwwFormUrlencodedValuePropertiesReviewerType
.queryParam( "postId", "167771822150204639.4")
.contentType( "application/x-www-form-urlencoded")
.formParam( "approved", "false")
.formParam( "reviewer", "")
.formParam( "reviewer", (String) null)
.when()
.request( "PUT", "/post")
.then()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void patchPost_PostMarksDefined_Is_No() {
public void patchPost_PostMarksType_Is_Null() {
given()
.baseUri( forTestServer())
.queryParam( "Post Marks", "")
.queryParam( "Post Marks", (String) null)
.when()
.request( "PATCH", "/post")
.then()
Expand All @@ -96,19 +96,6 @@ public void patchPost_PostMarksType_Is_NotArray() {
;
}

@Test
public void patchPost_PostMarksItemsSize_Is_0() {
given()
.baseUri( forTestServer())
.queryParam( "Post Marks", "")
.when()
.request( "PATCH", "/post")
.then()
// Post-Marks.Items.Size=0
.statusCode( isBadRequest())
;
}

@Test
public void patchPost_PostMarksItemsSize_Is_4() {
given()
Expand Down Expand Up @@ -201,7 +188,7 @@ public void tracePostsAttributes_AttributesDefined_Is_No() {
public void tracePostsAttributes_AttributesType_Is_Null() {
given()
.baseUri( forTestServer())
.pathParam( "attributes", ";attributes")
.pathParam( "attributes", "")
.when()
.request( "TRACE", "/posts/{attributes}")
.then()
Expand All @@ -214,7 +201,7 @@ public void tracePostsAttributes_AttributesType_Is_Null() {
public void tracePostsAttributes_AttributesType_Is_NotObject() {
given()
.baseUri( forTestServer())
.pathParam( "attributes", ";attributes=")
.pathParam( "attributes", ";attributes")
.when()
.request( "TRACE", "/posts/{attributes}")
.then()
Expand All @@ -240,7 +227,7 @@ public void tracePostsAttributes_AttributesValuePropertiesApprovedDefined_Is_No(
public void tracePostsAttributes_AttributesValuePropertiesApprovedType_Is_Null() {
given()
.baseUri( forTestServer())
.pathParam( "attributes", ";approved=;likes=586639729")
.pathParam( "attributes", ";approved;likes=586639729")
.when()
.request( "TRACE", "/posts/{attributes}")
.then()
Expand Down Expand Up @@ -279,7 +266,7 @@ public void tracePostsAttributes_AttributesValuePropertiesLikesDefined_Is_No() {
public void tracePostsAttributes_AttributesValuePropertiesLikesType_Is_Null() {
given()
.baseUri( forTestServer())
.pathParam( "attributes", ";approved=false;likes=")
.pathParam( "attributes", ";approved=false;likes")
.when()
.request( "TRACE", "/posts/{attributes}")
.then()
Expand Down Expand Up @@ -318,7 +305,7 @@ public void tracePostsAttributes_AttributesValuePropertiesLikesValue_Is_M1() {
public void tracePostsAttributes_AttributesValuePropertiesSubjectType_Is_Null() {
given()
.baseUri( forTestServer())
.pathParam( "attributes", ";approved=false;subject=;likes=538838946")
.pathParam( "attributes", ";approved=false;subject;likes=538838946")
.when()
.request( "TRACE", "/posts/{attributes}")
.then()
Expand All @@ -344,7 +331,7 @@ public void tracePostsAttributes_AttributesValuePropertiesSubjectValue_Is_Other(
public void tracePostsAttributes_AttributesValuePropertiesAdditional_Is_Yes() {
given()
.baseUri( forTestServer())
.pathParam( "attributes", ";approved=false;likes=156717470;qm=105;vskmwx=;ibjhzcukoxbvngqs=418.7")
.pathParam( "attributes", ";approved=false;likes=156717470;qm=105;vskmwx;ibjhzcukoxbvngqs=418.7")
.when()
.request( "TRACE", "/posts/{attributes}")
.then()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void tracePosts_PostIdDefined_Is_No() {
public void tracePosts_PostIdType_Is_Null() {
given()
.baseUri( forTestServer())
.cookie( "postId", "")
.cookie( "postId", null)
.when()
.request( "TRACE", "/posts")
.then()
Expand All @@ -84,19 +84,6 @@ public void tracePosts_PostIdType_Is_NotArray() {
;
}

@Test
public void tracePosts_PostIdItemsSize_Is_0() {
given()
.baseUri( forTestServer())
.cookie( "postId", "")
.when()
.request( "TRACE", "/posts")
.then()
// postId.Items.Size=0
.statusCode( isBadRequest())
;
}

@Test
public void tracePosts_PostIdItemsSize_Is_3() {
given()
Expand Down Expand Up @@ -202,7 +189,7 @@ public void tracePostsAttributes_AttributesDefined_Is_No() {
public void tracePostsAttributes_AttributesType_Is_Null() {
given()
.baseUri( forTestServer())
.pathParam( "attributes", ";attributes")
.pathParam( "attributes", "")
.when()
.request( "TRACE", "/posts/{attributes}")
.then()
Expand Down Expand Up @@ -241,7 +228,7 @@ public void tracePostsAttributes_AttributesValuePropertiesApprovedDefined_Is_No(
public void tracePostsAttributes_AttributesValuePropertiesApprovedType_Is_Null() {
given()
.baseUri( forTestServer())
.pathParam( "attributes", ";approved=;likes=127128009")
.pathParam( "attributes", ";approved;likes=127128009")
.when()
.request( "TRACE", "/posts/{attributes}")
.then()
Expand Down Expand Up @@ -280,7 +267,7 @@ public void tracePostsAttributes_AttributesValuePropertiesLikesDefined_Is_No() {
public void tracePostsAttributes_AttributesValuePropertiesLikesType_Is_Null() {
given()
.baseUri( forTestServer())
.pathParam( "attributes", ";approved=false;likes=")
.pathParam( "attributes", ";approved=false;likes")
.when()
.request( "TRACE", "/posts/{attributes}")
.then()
Expand Down Expand Up @@ -319,7 +306,7 @@ public void tracePostsAttributes_AttributesValuePropertiesLikesValue_Is_M1() {
public void tracePostsAttributes_AttributesValuePropertiesSubjectType_Is_Null() {
given()
.baseUri( forTestServer())
.pathParam( "attributes", ";approved=false;subject=;likes=279878075")
.pathParam( "attributes", ";approved=false;subject;likes=279878075")
.when()
.request( "TRACE", "/posts/{attributes}")
.then()
Expand All @@ -345,7 +332,7 @@ public void tracePostsAttributes_AttributesValuePropertiesSubjectValue_Is_Other(
public void tracePostsAttributes_AttributesValuePropertiesAdditional_Is_Yes() {
given()
.baseUri( forTestServer())
.pathParam( "attributes", ";approved=false;likes=776704486;wuf=")
.pathParam( "attributes", ";approved=false;likes=776704486;wuf")
.when()
.request( "TRACE", "/posts/{attributes}")
.then()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void getPosts_IdsDefined_Is_No() {
public void getPosts_IdsType_Is_Null() {
given()
.baseUri( forTestServer())
.queryParam( "ids", "")
.queryParam( "ids", (String) null)
.when()
.request( "GET", "/posts")
.then()
Expand All @@ -71,19 +71,6 @@ public void getPosts_IdsType_Is_NotArray() {
;
}

@Test
public void getPosts_IdsItemsSize_Is_0() {
given()
.baseUri( forTestServer())
.queryParam( "ids", "")
.when()
.request( "GET", "/posts")
.then()
// ids.Items.Size=0
.statusCode( isBadRequest())
;
}

@Test
public void getPosts_IdsItemsSize_Is_5() {
given()
Expand Down Expand Up @@ -437,7 +424,7 @@ public void postPosts_ApprovedDefined_Is_No() {
public void postPosts_ApprovedType_Is_Null() {
given()
.baseUri( forTestServer())
.cookie( "approved", "")
.cookie( "approved", null)
.when()
.request( "POST", "/posts")
.then()
Expand Down Expand Up @@ -702,7 +689,7 @@ public void putPosts_PostIdDefined_Is_No() {
public void putPosts_PostIdType_Is_Null() {
given()
.baseUri( forTestServer())
.cookie( "postId", "")
.cookie( "postId", null)
.contentType( "text/plain")
.request().body( "{\"text\":\"\",\"email\":\"7@N.com\"}")
.when()
Expand Down Expand Up @@ -749,7 +736,7 @@ public void putPosts_PostIdValuePropertiesCountryDefined_Is_No() {
public void putPosts_PostIdValuePropertiesCountryType_Is_Null() {
given()
.baseUri( forTestServer())
.cookie( "country", "")
.cookie( "country", null)
.cookie( "region", "E")
.contentType( "text/plain")
.request().body( "{\"text\":\"\",\"email\":\"`@h.edu\"}")
Expand Down Expand Up @@ -797,7 +784,7 @@ public void putPosts_PostIdValuePropertiesRegionType_Is_Null() {
given()
.baseUri( forTestServer())
.cookie( "country", "E")
.cookie( "region", "")
.cookie( "region", null)
.contentType( "text/plain")
.request().body( "{\"text\":\"\",\"email\":\"-@q.edu\"}")
.when()
Expand Down Expand Up @@ -1084,7 +1071,7 @@ public void tracePosts_PostIdDefined_Is_No() {
public void tracePosts_PostIdType_Is_Null() {
given()
.baseUri( forTestServer())
.cookie( "postId", "")
.cookie( "postId", null)
.when()
.request( "TRACE", "/posts")
.then()
Expand All @@ -1106,19 +1093,6 @@ public void tracePosts_PostIdType_Is_NotArray() {
;
}

@Test
public void tracePosts_PostIdItemsSize_Is_0() {
given()
.baseUri( forTestServer())
.cookie( "postId", "")
.when()
.request( "TRACE", "/posts")
.then()
// postId.Items.Size=0
.statusCode( isBadRequest())
;
}

@Test
public void tracePosts_PostIdItemsSize_Is_3() {
given()
Expand Down
Loading