Skip to content

CARDS-2158: data-entry tests - #1455

Draft
sofi2002sofi wants to merge 2 commits into
devfrom
CARDS-2158-dataentry-test
Draft

CARDS-2158: data-entry tests#1455
sofi2002sofi wants to merge 2 commits into
devfrom
CARDS-2158-dataentry-test

Conversation

@sofi2002sofi

Copy link
Copy Markdown
Contributor

No description provided.

@veronikaslc

veronikaslc commented Jun 15, 2023

Copy link
Copy Markdown
Contributor

Rebased on dev & built, got this output:

`[ERROR] QueryBuilderTest.initForFullTextQuery:277 expected:<0> but was:<-1>

[ERROR] QueryBuilderTest.initForLuceneQuery:311 expected:<0> but was:<-1>

[ERROR] QueryBuilderTest.initForQuickQuerySelectsForms:240 expected:<0> but was:<-1>`

@veronikaslc veronikaslc added the bug Something isn't working label Jun 16, 2023
@sofi2002sofi
sofi2002sofi force-pushed the CARDS-2158-dataentry-test branch from 1f75013 to 0a7ebdb Compare June 21, 2023 21:28
@veronikaslc
veronikaslc force-pushed the CARDS-2158-dataentry-test branch 2 times, most recently from d464df9 to 8e3b7d5 Compare December 6, 2025 06:40
sofi2002sofi and others added 2 commits July 28, 2026 02:19
Co-Authored-By: Michael Lescisin <michael.lescisin@uhn.ca>
Co-Authored-By: veronikaslc <veronika.koltunov@gmail.com>
Bring the revived tests onto the current platform, as far as they compile
and run. This is an intermediate state: the suite builds and runs, but 31
of the 80 tests still fail. It is committed so the migration work is not
lost; see the notes at the end for what remains.

Done:
- migrate the tests to the current platform APIs: jakarta.json,
  jakarta.servlet, the Sling Jakarta request/response mocks, Mockito 5
  (org.mockito.runners.MockitoJUnitRunner and org.mockito.Matchers are
  both long gone), sling-mock 4.0.6 / sling-mock-oak 4.1.0-1.86.0 /
  jcr-mock 1.8.2
- drop the Mockito runner in favor of plain instantiation and plain
  mock() fields, since concurrently running runners collide on Mockito's
  global listener registry under the parallel surefire configuration
- raise the sling-mock resource resolver factory timeout, the default
  500ms is not always enough when several Oak-backed test contexts start
  in parallel
- delete the aggregated-cnd module: it was a byte-for-byte copy of the
  data entry module's own dataentry.cnd, except for a corrupted sling
  namespace URI ("http://sling.apache.org/jcr/sling/1.Bac0"), and it only
  existed to give the tests a jar whose manifest declares the node types.
  Node types should be registered from the real CND instead.
- delete DateUtilsTest: the io.uhndata.cards.DateUtils class it covers no
  longer exists, and the method it tested, getTimezoneForDateString, is
  gone from the codebase entirely
- drop the guava and assertj test dependencies, the obsolete -Werror
  compiler configuration, and a rat exclusion for two theme files that
  were deleted in the meantime
- remove the module's coverage exemption, restoring the default 1.00
  required instruction coverage ratio

Still failing, all because main code moved on since the branch was
written (December 2025), none of them yet diagnosed to a fix:
- PaginationServletTest, 10: the servlet writes an empty body, because
  Filter now normalizes date values through DateUtils.normalize, which
  returns null for the very format PaginationServlet's own javadoc
  documents for date filters ("2020-12-31T00:00-04:00"): DATETIME_FORMATS
  has no offset pattern without seconds. Either DateUtils gains that
  format or the tests stop using it, but note that doGet swallows the
  resulting exception and returns a 200 with no body at all.
- DataImportServletTest, 12: the tests navigate to a form's answers
  positionally and now land on the cards:links child that newer main code
  adds.
- CountServletTest, 5; QueryBuilderTest, 2; ResourceIteratorTest, 1.
- DeleteServletTest, 1: DeleteServlet.sendJsonError NPEs writing a null
  message when the RepositoryException carries none. This one looks like
  a genuine main code bug rather than a stale test.

Coverage has not been extended to 100% yet either; that is the other half
of the remaining work.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sdumitriu
sdumitriu force-pushed the CARDS-2158-dataentry-test branch from 8e3b7d5 to d07d015 Compare July 28, 2026 02:43
JsonObject responseJson = getResponseJsonReader(response);
assertTrue(responseJson.containsKey(ROWS_PROPERTY));
assertTrue(responseJson.get(ROWS_PROPERTY) instanceof JsonArray);
JsonArray rows = responseJson.getJsonArray(ROWS_PROPERTY);
JsonObject responseJson = getResponseJsonReader(response);
assertTrue(responseJson.containsKey(ROWS_PROPERTY));
assertTrue(responseJson.get(ROWS_PROPERTY) instanceof JsonArray);
JsonArray rows = responseJson.getJsonArray(ROWS_PROPERTY);
JsonObject responseJson = getResponseJsonReader(response);
assertTrue(responseJson.containsKey(ROWS_PROPERTY));
assertTrue(responseJson.get(ROWS_PROPERTY) instanceof JsonArray);
JsonArray rows = responseJson.getJsonArray(ROWS_PROPERTY);
return this.context.resourceResolver().adaptTo(Session.class).getNodeByIdentifier(identifier).getPath();
}

private MockSlingJakartaHttpServletRequest mockServletRequest(String resourcePath, boolean isRecursive)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working test-coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants