Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
faderskd committed Oct 30, 2024
1 parent 4e8fd38 commit 8105b77
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import pl.allegro.tech.hermes.api.constraints.OneSourceRetransmission;
import pl.allegro.tech.hermes.api.constraints.ProperTimeRangePresentForTopicRetransmission;
import pl.allegro.tech.hermes.api.constraints.TimeRangeAbsentForViewRetransmission;
import pl.allegro.tech.hermes.api.constraints.TimeRangeForTopicRetransmission;
import pl.allegro.tech.hermes.api.constraints.TimeRangeForViewRetransmission;
import pl.allegro.tech.hermes.api.jackson.OptionalInstantIsoSerializer;

@OneSourceRetransmission
@TimeRangeAbsentForViewRetransmission
@ProperTimeRangePresentForTopicRetransmission
@TimeRangeForViewRetransmission
@TimeRangeForTopicRetransmission
public class OfflineRetransmissionRequest {

private static final List<DateTimeFormatter> formatters =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({TYPE})
@Constraint(validatedBy = ProperTimeRangePresentForTopicRetransmissionValidator.class)
public @interface ProperTimeRangePresentForTopicRetransmission {
@Constraint(validatedBy = TimeRangeForTopicRetransmissionValidator.class)
public @interface TimeRangeForTopicRetransmission {
String message() default
"Must contain both startTimestamp and endTimestamp when source topic is given, startTimestamp must be lower than endTimestamp";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import jakarta.validation.ConstraintValidatorContext;
import pl.allegro.tech.hermes.api.OfflineRetransmissionRequest;

public class ProperTimeRangePresentForTopicRetransmissionValidator
implements ConstraintValidator<
ProperTimeRangePresentForTopicRetransmission, OfflineRetransmissionRequest> {
public class TimeRangeForTopicRetransmissionValidator
implements ConstraintValidator<TimeRangeForTopicRetransmission, OfflineRetransmissionRequest> {

@Override
public boolean isValid(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({TYPE})
@Constraint(validatedBy = TimeRangeAbsentForViewRetransmissionValidator.class)
public @interface TimeRangeAbsentForViewRetransmission {
@Constraint(validatedBy = TimeRangeForViewRetransmissionValidator.class)
public @interface TimeRangeForViewRetransmission {
String message() default
"must not contain startTimestamp and endTimestamp when source view is given";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
import jakarta.validation.ConstraintValidatorContext;
import pl.allegro.tech.hermes.api.OfflineRetransmissionRequest;

public class TimeRangeAbsentForViewRetransmissionValidator
implements ConstraintValidator<
TimeRangeAbsentForViewRetransmission, OfflineRetransmissionRequest> {
public class TimeRangeForViewRetransmissionValidator
implements ConstraintValidator<TimeRangeForViewRetransmission, OfflineRetransmissionRequest> {

@Override
public boolean isValid(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RetransmissionTimeRangeValidatorTest extends Specification {
@Unroll
def "View validator should validate view retransmission request when startTimestamp is '#startTimestamp', endTimestamp is '#endTimestamp'"() {
given:
TimeRangeAbsentForViewRetransmissionValidator validator = new TimeRangeAbsentForViewRetransmissionValidator()
TimeRangeForViewRetransmissionValidator validator = new TimeRangeForViewRetransmissionValidator()
def request = new OfflineRetransmissionRequest(
"someSourceView",
null,
Expand All @@ -44,7 +44,7 @@ class RetransmissionTimeRangeValidatorTest extends Specification {

def "View validator should skip validation for topic retransmission request"() {
given:
TimeRangeAbsentForViewRetransmissionValidator validator = new TimeRangeAbsentForViewRetransmissionValidator()
TimeRangeForViewRetransmissionValidator validator = new TimeRangeForViewRetransmissionValidator()
def invalidTopicRetransmissionRequest = new OfflineRetransmissionRequest(
null,
"someSourceTopic",
Expand All @@ -59,7 +59,7 @@ class RetransmissionTimeRangeValidatorTest extends Specification {
@Unroll
def "Topic validator should validate topic retransmission request when startTimestamp is '#startTimestamp', endTimestamp is '#endTimestamp'"() {
given:
ProperTimeRangePresentForTopicRetransmissionValidator validator = new ProperTimeRangePresentForTopicRetransmissionValidator()
TimeRangeForTopicRetransmissionValidator validator = new TimeRangeForTopicRetransmissionValidator()
def request = new OfflineRetransmissionRequest(
null,
"someSourceTopic",
Expand All @@ -82,7 +82,7 @@ class RetransmissionTimeRangeValidatorTest extends Specification {

def "Topic validator should skip validation for view retransmission request"() {
given:
ProperTimeRangePresentForTopicRetransmissionValidator validator = new ProperTimeRangePresentForTopicRetransmissionValidator()
TimeRangeForTopicRetransmissionValidator validator = new TimeRangeForTopicRetransmissionValidator()
def invalidViewRetransmissionRequest = new OfflineRetransmissionRequest(
"someSourceView",
null,
Expand Down

0 comments on commit 8105b77

Please sign in to comment.