Conversation
- Added JUnit 5 annotations to BitrepositoryTestSuite - Added GlobalSuiteExtension to implement JUnit 5 extension points for suite-level setup and teardown. - Ensured consistency and correctness of test suite configuration and setup methods. This commit updates the test suite configuration to use JUnit 5 annotations, allowing for more flexible and powerful test suite management.
…-testng-with-junit
…junit' into BITMAG-1244-junit-bitrepository-core # Conflicts: # bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java # bitrepository-core/src/test/java/org/bitrepository/protocol/bus/ActiveMQMessageBusTest.java # bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusNumberOfListenersStressTest.java
…n choose to include the test or not
…n install can't run because it gives errors in the module bitrepository-client, which hasn't been converted to junit 5 yet.
…use the codebase is now using junit since there was a security vulnerability with TestNG
…accept # Conflicts: # bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java
…gured. The task is almost done but not there yet. To emulate jaccept a try to report during test as jaccept does, but that task is also not done yet.
…get/allure-results folder which are used to create the final report that are shown to the user. That report is created by using mvn allure:serve
…source folder were removed. Made minor corrections, so now all tests succeed. There are a few tests that were disabled.
…lureLifecycle errors.
…ls to use String.format instead of StringBuilder
…odern types instead.
…g' into BITMAG-1247-date-time-modernizing # Conflicts: # bitrepository-client/src/test/java/org/bitrepository/client/TestEventHandler.java # bitrepository-client/src/test/java/org/bitrepository/modify/deletefile/DeleteFileClientComponentTest.java # bitrepository-client/src/test/java/org/bitrepository/modify/deletefile/DeleteFileClientTestWrapper.java # bitrepository-core/src/main/java/org/bitrepository/common/utils/CalendarUtils.java # bitrepository-core/src/test/java/org/bitrepository/common/utils/FileUtilsTest.java # bitrepository-core/src/test/java/org/bitrepository/protocol/bus/ActiveMQMessageBusTest.java # bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MessageReceiver.java # bitrepository-core/src/test/java/org/bitrepository/protocol/fileexchange/LocalFileExchangeTest.java # bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusTimeToSendMessagesStressTest.java # bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/component/IntegrityServiceComponentTest.java # bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/PillarIntegrationTest.java # bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/deletefile/DeleteFileRequestIT.java # bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfile/GetFileRequestIT.java # bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/putfile/IdentifyPillarsForPutFileIT.java # bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/model/PillarFileManager.java # bitrepository-reference-pillar/src/test/resources/logback-test.xml # bitrepository-service/src/test/java/org/bitrepository/service/audit/AuditTrailContributorDatabaseMigrationTest.java
|
Did you somehow forget the use of Also some timer task code uses old methods. Since we already have an issue to rewrite our timer tasks, I suggest you can let it be for now. |
ole-v-v
left a comment
There was a problem hiding this comment.
A strong pull request demonstrating a good command of java.time. We will be very happy about this change.
For naming new methods, when you add Instant to some previous method name. consider deleting Date or Time from the name to evade redundancy and the name becoming overly long.
| private TimeZone localTimeZone = TimeZone.getDefault(); | ||
| private ZoneId localZoneId = ZoneId.systemDefault(); |
There was a problem hiding this comment.
Having both of a TimeZone and a ZoneId is redundant. I’d prefer just the modern ZoneId (with conversions as necessary). Granted, you are meticulously making sure that the two always refer to the same time zone, so the code works correctly also with the redundancy.
| * @return The startDate; | ||
| */ | ||
| public Date getStartDate() { | ||
| public Instant getStartDateInstant() { |
There was a problem hiding this comment.
We could also just name it getStartInstant()? Or even just getStart()?? I believe an alarm starts at a point in time, so I don’t think the word “date” adds anything helpful here? Similarly for getEnd[Date]Instant().
Optional, if we want to take it a step further, we may rename constructor and method parameters and even instance variables to just start and end (leaving Date out from the names), or similar.
There was a problem hiding this comment.
Changed the name to start and end
| @@ -44,12 +45,12 @@ public class AlarmDatabaseExtractionModel { | |||
| /** | |||
| * @see #getStartDate(). | |||
There was a problem hiding this comment.
I suggest referring to the new getStartDateInstant() instead. Similarly for end instant below.
|
|
||
| /** | ||
| * @param startDate The startDate. | ||
| * @see #getStartDate() |
There was a problem hiding this comment.
I suggest referring to the new getStartDateInstant() instead. Similarly for end instant below.
| * @param componentID [OPTIONAL] The id of the component. | ||
| * @param alarmCode [OPTIONAL] The alarm code. | ||
| * @param minDate [OPTIONAL] The earliest date for the alarms. | ||
| * @param maxDate [OPTIONAL] The latest date for the alarms. | ||
| * @param fileID [OPTIONAL] The id of the file, which the alarms are connected. | ||
| * @param collectionID the ID of the collection. Perhaps it is optional | ||
| * @param count [OPTIONAL] The maximum number of alarms to retrieve from the store. |
There was a problem hiding this comment.
You’ve got quite impressive Javadoc comments on methods that you have deprecated.
While the caller needs to know which parameters are allowed to be null, for my part I’m not fond of using all caps (except in abbreviations, when referring to constants declared in shouting case and similar). I would probably use wording along “The ID of the component or null for all components” (if this is the intended meaning; if you don’t know, then just “or null”).
There was a problem hiding this comment.
Removed (OPTIONAL) and added with null
| public Instant getNextRunInstant(JobID jobId) { | ||
| if (intervalTasks.containsKey(jobId)) { | ||
| return intervalTasks.get(jobId).getNextRunInstant(); | ||
| } else return null; |
There was a problem hiding this comment.
May use this occasion to put return statement on its own line enclosed in curly braces. Or depending on taste leave out else and just put the return statement on its own line.
| if (nextRun != null && (getNextRunInstant() == null || | ||
| getNextRunInstant().toEpochMilli() <= System.currentTimeMillis())) { |
There was a problem hiding this comment.
I would prefer:
if (nextRun != null &&
(getNextRunInstant() == null || ! getNextRunInstant().isAfter(Instant.now()))) {
Breaking the line at a higher level of the Boolean expression and using “not after” to mean “before or equal to” (may also spell it out).
| } | ||
|
|
||
| /** | ||
| * @return The duration of the workflow if it has been started, else 0. |
There was a problem hiding this comment.
May use this occasion for adding to the documentation that the duration is in milliseconds. Or even provide a method that returns a Duration object.
| return System.currentTimeMillis() - start.toEpochMilli(); | ||
| } else { | ||
| return finish.getTime() - start.getTime(); | ||
| return finish.toEpochMilli() - start.toEpochMilli(); |
There was a problem hiding this comment.
My suggestion:
return ChronoUnit.MILLIS.between(start, finish);
| DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.ROOT); | ||
| Instant summertimeTS = ZonedDateTime.parse("2015-10-25T02:59:54.000+02:00", formatter).toInstant(); |
There was a problem hiding this comment.
Leave out the formatter and just do
Instant summertimeTS = OffsetDateTime.parse("2015-10-25T02:59:54.000+02:00").toInstant();
Same for the standard time case below. (This is testing java.time, which we should not want to consider our job; let it be.)
| // @Tag("regressiontest") | ||
| // public void onePillarRespondingWithPartialPutAllowed() throws Exception { | ||
| // addReference("<a href=https://sbforge.org/jira/browse/BITMAG-598>" + | ||
| // "BITMAG-598 It should be possible to putFiles, even though only a subset of the pillars are available</a>"); | ||
| // addDescription("Tests the handling of missing identification responses from one pillar, " + | ||
| // "when partial put are allowed"); | ||
| // addFixture("Sets the identification timeout to 100 ms and allow partial puts."); | ||
| // | ||
| // settingsForCUT.getRepositorySettings().getClientSettings() | ||
| // .setIdentificationTimeoutDuration(datatypeFactory.newDuration(100)); | ||
| // settingsForCUT.getReferenceSettings().getPutFileSettings().setPartialPutsAllow(true); | ||
| // TestEventHandler testEventHandler = new TestEventHandler(); | ||
| // PutFileClient putClient = createPutFileClient(); | ||
| // | ||
| // addStep("Request the putting of a file through the PutClient", | ||
| // "A identification request should be dispatched."); | ||
| // putClient.putFile(collectionID, httpServerConfiguration.getURL(DEFAULT_FILE_ID), DEFAULT_FILE_ID, 0, null, | ||
| // null, testEventHandler, null); | ||
| // Assertions.assertEquals(OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); | ||
| // IdentifyPillarsForPutFileRequest receivedIdentifyRequestMessage = | ||
| // collectionReceiver.waitForMessage(IdentifyPillarsForPutFileRequest.class); | ||
| // |
There was a problem hiding this comment.
Right. Allow me to suggest you stick in a comment saying approximately what the above reply says. And then move on.
ole-v-v
left a comment
There was a problem hiding this comment.
A strong pull request demonstrating a good command of java.time. We will be very happy about this change.
For naming new methods, when you add Instant to some previous method name. consider deleting Date or Time from the name to evade redundancy and the name becoming overly long.
This PR addresses the long-standing technical debt of using legacy Java date/time classes.
The legacy date/time API is confusing, error-prone, mutable, and not thread-safe. It has been replaced by modern, immutable, thread-safe, and highly explicit API
Removal of XMLGregorianCalendar, though, awaits clarification, but will be done as soon as possible