fix: Fix format check in test package
feat: Add 406 mapper
Resolves #66 (closed)
Merge request reports
Activity
requested review from @malowe
129 .setResponseContentType(invalidFormat) 130 .setStatusCode(406) 131 .build(); 132 } 133 134 /** 135 * Creates a EndpointTestCase object with the desired path, params, and request 136 * format. Used to test an invalid request body format. Status code 406 137 * (Not Acceptable) is assumed. 138 * 139 * @param path the endpoint URL 140 * @param params the request path/query parameters 118 141 * @param invalidFormat the invalid request format 119 142 * @return the desired endpoint test case 120 143 */ 121 public static EndpointTestCase buildInvalidFormatCase(String path, String[] params, ContentType invalidFormat) { Please retain the original call method that just calls the request format method for now. I plan on introducing all of the breaking changes at once for 0.8, and this would break a lot of tests. Also add a deprecation note to it to make sure we don't miss it
Edited by Martin Lowechanged this line in version 3 of the diff
added 2 commits
added 1 commit
- 64885a16 - feat: Re-add original buildInvalidFormatCase + add deprecation for 0.8
195 207 testDef.getBodyValidationParams()) 196 208 .statusCode(testDef.getStatusCode()); 197 209 198 // check format when set 199 if (checkFormat) { 210 LOGGER.info("EXPECTED CODE: {}", testDef.getStatusCode()); 211 212 // Check format when set. Expect the non-200 to have no headers 213 if (checkFormat && testDef.getStatusCode().intValue() / 100 == 2) { 214 LOGGER.info("EXPECTED CODE: {}", testDef.getStatusCode()); changed this line in version 4 of the diff
added 1 commit
- 87ffe286 - feat: Add custom exception, check for status code fialures, add tests to cover
158 Assertions.assertThrows(StatusCodeAssertionError.class, preparedTest::run); 159 } 160 161 /** 162 * Similar to 163 * {@link EndpointTestBuilderTest#run_failure_checkFormatInspectsResponseFormat_invalidFormat} 164 * but instead we are sending 'content-Type: application/xml' instead of 165 * checking if the resource can accept xml. Both are fail conditions 166 */ 167 @Test 168 void run_failure_checkFormatInspectsRequestFormat() { 169 EndpointTestBuilder preparedTest = EndpointTestBuilder.from(FAILURE_SEND_XML_BODY).doGet(buildSample()) 170 .andCheckFormat(); 171 172 Assertions.assertThrows(AssertionError.class, preparedTest::run); 173 } changed this line in version 5 of the diff
61 .buildSuccessCase("test/delete/with-body?returned_status={code}", new String[] { "200" }, 62 SchemaNamespaceHelper.TEST_MODEL_SCHEMA_PATH); 63 64 private static final EndpointTestCase SUCCESS_GET_XML_WITH_BODY = TestCaseHelper 65 .prepareTestCase("test/get/with-body/xml?returned_status={code}", new String[] { "200" }, 66 SchemaNamespaceHelper.TEST_MODEL_SCHEMA_PATH) 67 .setResponseContentType(ContentType.XML) 68 .build(); 69 private static final EndpointTestCase FAILURE_GET_XML_INVALID_FORMAT = TestCaseHelper 70 .buildInvalidResponseFormatCase("test/get/with-body/xml?returned_status={code}", new String[] { "200" }, 71 ContentType.JSON); 72 private static final EndpointTestCase FAILURE_GET_XML_INVALID_CODE = TestCaseHelper 73 .buildInvalidResponseFormatCase("test/get/with-body/xml?returned_status={code}", new String[] { "200" }, 74 ContentType.XML); 75 private static final EndpointTestCase FAILURE_SEND_XML_BODY = TestCaseHelper.buildInvalidRequestFormatCase( 76 "test/get/with-body/xml?returned_status={code}", new String[] { "200" }, ContentType.XML); changed this line in version 5 of the diff
added 1 commit
- dc729b87 - feat: Add additional AssertionErrors + add error content-type check + fix tests
added 1 commit
- 4692e421 - feat: Add assertion error messages, reorder checks in run, remove error type,...
added 10 commits
-
ccb72798 - 1 commit from branch
eclipsefdn/it/api:main
- adba8e50 - fix: Fix format check
- 3e6b4cff - feat: Add invalid request test
- 0e84b4af - feat: Add NotSupportedMapper
- b9a52b5c - feat: Re-add original buildInvalidFormatCase + add deprecation for 0.8
- fcb7c68b - feat: Add custom exception, check for status code fialures, add tests to cover
- ab53261e - fix: Weird formatter issue
- f4accfc9 - feat: Add additional AssertionErrors + add error content-type check + fix tests
- 7c92097f - feat: Add assertion error messages, reorder checks in run, remove error type,...
- 7df3f767 - Merge branch 'zacharysabourin/main/66' of...
Toggle commit list-
ccb72798 - 1 commit from branch
110 112 } 111 113 112 114 /** 113 * Creates a EndpointTestCase object with the desired path, params, and request format. Used to test an invalid request 114 * body format. Status code 500 (Internal Error) is assumed. 115 * Creates a EndpointTestCase object with the desired path, params, and request format. Used to test an invalid request body format. 116 * Status code 500 (Internal Error) is assumed. 115 117 * 116 118 * @param path the endpoint URL 117 119 * @param params the request path/query parameters 118 120 * @param invalidFormat the invalid request format 119 121 * @return the desired endpoint test case 122 * @deprecated Will be replaced by {@link this#buildInvalidRequestFormatCase(String, String[], ContentType)} 120 123 */ 124 @Deprecated(since = "0.8") changed this line in version 9 of the diff
added 1 commit
- 14acc820 - feat: Remove custom errors + modify tests accordingly
I've tested this locally with:
- mailing-list (some minor changes to invalid format tests, expected)
- profile (no changes made)
- openvsx (one test change from 500 -> 406, expected)
- git-eca (one test change, expected)
Everything appears to be stable :)
Edited by Zachary Sabourin