Skip to content

Commit 72016b0

Browse files
committed
Simplify comments
1 parent e361bae commit 72016b0

8 files changed

Lines changed: 16 additions & 42 deletions

File tree

src/test/java/com/axiope/webapp/dev/ViteDevServerProxyServletMimeTypeTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55

66
import org.junit.jupiter.api.Test;
77

8-
/**
9-
* inferFallbackContentType is a pure function of the request path, so it lives here rather than
10-
* alongside the proxying tests, where it would inherit an unrelated HTTP-exchange fixture.
11-
*/
8+
/** Separate from the proxying tests: inferFallbackContentType needs no mocks. */
129
public class ViteDevServerProxyServletMimeTypeTest {
1310

1411
private final ViteDevServerProxyServlet servlet =

src/test/java/com/researchspace/files/service/ExternalFileServiceTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ public void before() throws Exception {
5959
anyUser, "anyToken - this is a mock API call");
6060
}
6161

62-
// Was annotated @Before (now @BeforeEach) despite being named after() and documented as tidy-up,
63-
// so it has never run as teardown. A no-op today because the setFileStore(localFs) call it pairs
64-
// with is commented out in before(); kept and corrected so restoring that line stays safe.
62+
// A no-op while the setFileStore(localFs) call it pairs with stays commented out in before().
6563
@AfterEach
6664
public void restoreFileStore() throws Exception {
6765
getTargetObject(mediaMgr, MediaManagerImpl.class).setFileStore(fileStore);

src/test/java/com/researchspace/service/impl/ZipCopyTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ public class ZipCopyTest {
1919
// https://stackoverflow.com/questions/50594360/gzipinputstream-works-with-fileinputstream-but-not-inputstream/50610474#50610474
2020
@Test
2121
public void classPathAndFileReadsAreTheSameBytes() throws IOException {
22-
// readAllBytes rather than a fixed-size buffer: a buffer larger than the zip zero-pads both
23-
// sides equally and a buffer smaller than it compares only a prefix, so either way a
24-
// difference in the tail passes unnoticed once the file outgrows the number.
2522
try (InputStream fromClasspath = fromClasspath()) {
2623
assertArrayEquals(
2724
fromClasspath.readAllBytes(),

src/test/java/com/researchspace/slack/SlackPosterTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
import org.springframework.http.ResponseEntity;
2020
import org.springframework.web.client.RestTemplate;
2121

22-
// @Disabled rather than gated on -Dnightly like the other real-connection tests: this one needs a
23-
// secret webhook URL that no environment supplies, so a nightly gate would never fire either.
2422
@Disabled("requires correct real secret webhook")
2523
public class SlackPosterTest extends SpringTransactionalTest {
2624

src/test/java/com/researchspace/testutils/DatabaseCleaner.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ public void setDataSource(DataSource dataSource) {
2222
/** Manually deletes records and folders from tables. */
2323
public static void cleanUp() {
2424
if (jdbcTemplate == null) {
25-
// Nothing was ever injected, so no context loaded in this fork and there is nothing to clean.
26-
// Callers already skip this on a fast run; this covers the other way @AfterAll can be reached
27-
// without a context, namely a context *load failure*, which Jupiter follows with @AfterAll
28-
// where JUnit 4 skipped @AfterClass. Without this, that NPEs here and hides the Spring error.
25+
// No context loaded, so nothing to clean. Jupiter runs @AfterAll even when the context failed
26+
// to load, and without this that NPEs here and hides the underlying Spring error.
2927
return;
3028
}
3129
// delete from Batch tables

src/test/java/com/researchspace/testutils/WithSpringContext.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,13 @@
99
import org.springframework.test.context.junit.jupiter.SpringExtension;
1010

1111
/**
12-
* Wires a test class into the Spring TestContext framework.
13-
*
14-
* <p>This is the composed-annotation equivalent of extending a Spring base class. JUnit 4 needed a
15-
* base class because a runner is class-level and cannot be composed, which is why Spring shipped
16-
* {@code AbstractJUnit4SpringContextTests}; Jupiter registers the equivalent behaviour through an
17-
* extension instead, so the single superclass a test gets to spend stays free.
18-
*
19-
* <p>Deliberately adds nothing but the extension. In particular it declares no
20-
* {@code @TestExecutionListeners}: naming any set here would replace Spring's defaults for every
21-
* annotated class that does not declare its own, silently dropping listeners such as {@code
22-
* ServletTestExecutionListener} and {@code TransactionalTestExecutionListener}.
23-
*
24-
* <p>Combine it with a context annotation such as {@link DefaultTestContext}, or with
12+
* Wires a test class into the Spring TestContext framework, leaving its single superclass free.
13+
* Combine with a context annotation such as {@link DefaultTestContext}, or
2514
* {@code @ContextConfiguration} directly.
15+
*
16+
* <p>Do not add {@code @TestExecutionListeners} here: naming any set replaces Spring's defaults for
17+
* every annotated class that does not declare its own, silently dropping listeners such as {@code
18+
* TransactionalTestExecutionListener}.
2619
*/
2720
@ExtendWith(SpringExtension.class)
2821
@Retention(RetentionPolicy.RUNTIME)

src/test/java/com/researchspace/webapp/controller/ScheduledMaintenanceControllerMVCIT.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,9 @@ private void initMaintenanceTestUsers() {
7878

7979
private void initDates() {
8080
if (dateNextHour == null) {
81-
// The trailing -00:00 in the pattern is a literal, and the server parses these strings as
82-
// UTC. Formatting must therefore happen in UTC too, otherwise local wall-clock time is
83-
// labelled as UTC and every relative date is shifted by the machine's offset: in a
84-
// negative-offset zone the "future" maintenance dates below land in the past.
81+
// The -00:00 in the pattern is a literal and the server parses these as UTC, so format in
82+
// UTC too or local wall-clock time gets labelled UTC and every date below shifts by the
83+
// machine's offset.
8584
dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.000-00:00");
8685
dateFormat.setTimeZone(TimeZone.getTimeZone(ZoneOffset.UTC));
8786

@@ -189,11 +188,8 @@ public void testCreateUpdateDeleteScheduledMaintenance() throws Exception {
189188
@Test
190189
public void testActiveMaintenanceCreateRetrieveFinishNow() throws Exception {
191190
String testMessage = "test maintenance message";
192-
// The start date is posted as an absolute instant but the server renders it back in the user's
193-
// timezone (SessionTimeZoneUtils, which falls back to the JVM default when the session carries
194-
// no preference, as it does here), so the expected strings have to be derived rather than
195-
// hard-coded or the test only passes under UTC. Everything below comes from this one instant:
196-
// a second literal for the posted form of it would silently drift out of sync with it.
191+
// Rendered back in the session's timezone, which falls back to the JVM default here, so the
192+
// expected strings are derived from this one instant rather than hard-coded under UTC.
197193
Instant start = Instant.parse("2015-01-01T00:00:01Z");
198194
String oldDateString = dateFormat.format(Date.from(start));
199195
DateTimeFormatter clientFormat =

src/test/java/com/researchspace/webapp/controller/WorkspaceControllerTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,7 @@ public void setUp() throws Exception {
143143
}
144144

145145
private void clearUsersCustomFormsAddedToMenu() {
146-
// Map<?, ?> rather than Map<Long, Boolean>: clear() takes no type parameter, so the wildcard
147-
// cast is one the compiler can check, leaving no unchecked warning to suppress.
146+
// Map<?, ?> keeps the cast checkable; clear() needs no type parameter.
148147
((Map<?, ?>)
149148
ReflectionTestUtils.getField(
150149
WorkspaceController.class, "USERS_CUSTOM_FORMS_ADDED_TO_MENU"))
@@ -364,8 +363,6 @@ private Long getAValidRecordId() throws Exception {
364363
workspaceController.listRootFolder(
365364
"", model, mockPrincipal, request, session, response, new WorkspaceSettings());
366365
assertTrue((Boolean) model.getAttribute("publish_allowed"));
367-
// Wildcard plus an explicit element cast: both are checkable, so neither needs suppressing.
368-
// Erasure put the same checkcast on Record at the getId() call before, so this is equivalent.
369366
ISearchResults<?> res = (ISearchResults<?>) model.asMap().get("searchResults");
370367
Long recordId = ((Record) res.getResults().get(0)).getId();
371368
tss.clear();

0 commit comments

Comments
 (0)