Skip to content
Snippets Groups Projects

fix: Fix format check in test package

4 unresolved threads

feat: Add 406 mapper

Resolves #66 (closed)

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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) {
  • Zachary Sabourin added 2 commits

    added 2 commits

    • fbe2a556 - feat: Add invalid request test
    • 31153ba1 - feat: Add NotSupportedMapper

    Compare with previous version

  • added 1 commit

    • 64885a16 - feat: Re-add original buildInvalidFormatCase + add deprecation for 0.8

    Compare with previous version

  • 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());
  • added 1 commit

    • 87ffe286 - feat: Add custom exception, check for status code fialures, add tests to cover

    Compare with previous version

  • 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 }
  • 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);
  • added 1 commit

    Compare with previous version

  • added 1 commit

    • dc729b87 - feat: Add additional AssertionErrors + add error content-type check + fix tests

    Compare with previous version

  • added 1 commit

    • 4692e421 - feat: Add assertion error messages, reorder checks in run, remove error type,...

    Compare with previous version

  • Zachary Sabourin marked this merge request as draft

    marked this merge request as draft

  • Zachary Sabourin added 10 commits

    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...

    Compare with previous version

  • 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")
  • added 1 commit

    • 14acc820 - feat: Remove custom errors + modify tests accordingly

    Compare with previous version

  • Zachary Sabourin marked this merge request as ready

    marked this merge request as ready

  • 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
  • Martin Lowe approved this merge request

    approved this merge request

  • merged

  • Please register or sign in to reply
    Loading