-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve timerange validation for retransmission from view #1916
base: master
Are you sure you want to change the base?
Improve timerange validation for retransmission from view #1916
Conversation
@@ -80,4 +82,11 @@ public OfflineRetransmissionRequest getRequest() { | |||
public String toString() { | |||
return "OfflineRetransmissionTask{" + "taskId='" + taskId + '\'' + ", request=" + request + '}'; | |||
} | |||
|
|||
private static String parseTimestamp(@Nullable Instant startTimestamp) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just timestamp
as a parameter name since there is passed both startTimestamp
and endTimestamp
to this function, WDYT?
import jakarta.validation.ConstraintValidatorContext; | ||
import pl.allegro.tech.hermes.api.OfflineRetransmissionRequest; | ||
|
||
public class ProperTimeRangePresentForTopicRetransmissionValidator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can remove Present
and Proper
from this name? I think that context would rename the same and we would shorten it a little bit 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({TYPE}) | ||
@Constraint(validatedBy = TimeRangeAbsentForViewRetransmissionValidator.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is personal opinion, but I think that we can remove Absent
from this name. I am not familiar with the pattern of specifying how the validator should behave, and what it should accept in its name. Thanks to this the name would be shorter and more readable in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, fixed
|
||
import java.time.Instant | ||
|
||
class RetransmissionTimeRangeValidatorTest extends Specification { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well written tests 😎
What's changed?
When requesting retransmission from view, the user has already prepared proper events, so they should not provide additional time range for this retransmission. For simplicity of logic, the rules are as follows:
Basic validation for retransmission (proper parameters, timerange validation, empty checks etc.) is done via Jakarta constraint validators. Any other validation related to persistent state in Zookeeper is done later in the retransmission service.
What's new
As a part of the PR, I've also added possibility of attaching link to the offline retransmission from view documentation, visible in retransmission popup.