Skip to content

Commit

Permalink
[TH2-5165] corrected after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita-Smirnov-Exactpro committed Mar 6, 2024
1 parent a578802 commit 31756d3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.exactpro.cradle.filters.FilterForGreater;
import com.exactpro.cradle.filters.FilterForLess;

import javax.annotation.Nonnull;
import java.time.Instant;
import java.util.StringJoiner;

Expand All @@ -39,10 +40,11 @@
import static com.exactpro.cradle.cassandra.dao.messages.GroupedMessageBatchEntity.FIELD_FIRST_MESSAGE_DATE;
import static com.exactpro.cradle.cassandra.dao.messages.GroupedMessageBatchEntity.FIELD_FIRST_MESSAGE_TIME;
import static com.exactpro.cradle.cassandra.dao.messages.GroupedMessageBatchEntity.FIELD_PAGE;
import static java.util.Objects.requireNonNull;

public class CassandraGroupedMessageFilter implements CassandraFilter<GroupedMessageBatchEntity> {
private final String groupName;
private final PageId pageId;
private final @Nonnull String groupName;
private final @Nonnull PageId pageId;

/** limit must be strictly positive ( limit greater than 0 ) */
private final int limit;
Expand All @@ -56,8 +58,8 @@ public CassandraGroupedMessageFilter(PageId pageId,
FilterForLess<Instant> messageTimeTo,
Order order,
int limit) {
this.pageId = pageId;
this.groupName = groupName;
this.pageId = requireNonNull(pageId, "page id can't be null because book and page names are part of partition");
this.groupName = requireNonNull(groupName, "group name can't be null because it is part of partition");
this.messageTimeFrom = messageTimeFrom;
this.messageTimeTo = messageTimeTo;
this.order = order;
Expand Down Expand Up @@ -106,19 +108,19 @@ public BoundStatementBuilder bindParameters(BoundStatementBuilder builder) {
return builder;
}

public PageId getPageId() {
public @Nonnull PageId getPageId() {
return pageId;
}

public String getBook() {
public @Nonnull String getBook() {
return pageId.getBookId().getName();
}

public String getPage() {
public @Nonnull String getPage() {
return pageId.getName();
}

public String getGroupName() {
public @Nonnull String getGroupName() {
return groupName;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.exactpro.cradle.filters.FilterForGreater;
import com.exactpro.cradle.filters.FilterForLess;

import javax.annotation.Nonnull;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -42,16 +43,17 @@
import static com.exactpro.cradle.cassandra.dao.messages.MessageBatchEntity.FIELD_PAGE;
import static com.exactpro.cradle.cassandra.dao.messages.MessageBatchEntity.FIELD_SEQUENCE;
import static com.exactpro.cradle.cassandra.dao.messages.MessageBatchEntity.FIELD_SESSION_ALIAS;
import static java.util.Objects.requireNonNull;

public class CassandraStoredMessageFilter implements CassandraFilter<MessageBatchEntity>
{
public static final String DATE_FROM = "dateFrom", DATE_TO = "dateTo",
TIME_FROM = "timeFrom", TIME_TO = "timeTo",
SEQ_FROM = "seqFrom", SEQ_TO = "seqTo";

private final String sessionAlias;
private final String direction;
private final PageId pageId;
private final @Nonnull String sessionAlias;
private final @Nonnull String direction;
private final @Nonnull PageId pageId;

private final FilterForGreater<Instant> messageTimeFrom;
private final FilterForLess<Instant> messageTimeTo;
Expand All @@ -65,9 +67,9 @@ public class CassandraStoredMessageFilter implements CassandraFilter<MessageBatc
public CassandraStoredMessageFilter(PageId pageId, String sessionAlias, String direction,
FilterForGreater<Instant> messageTimeFrom, FilterForLess<Instant> messageTimeTo, int limit, Order order)
{
this.pageId = pageId;
this.sessionAlias = sessionAlias;
this.direction = direction;
this.pageId = requireNonNull(pageId, "page id can't be null because book and page names are part of partition");
this.sessionAlias = requireNonNull(sessionAlias, "session alias can't be null because it is part of partition");
this.direction = requireNonNull(direction, "direction can't be null because it is part of partition");
this.messageTimeFrom = messageTimeFrom;
this.messageTimeTo = messageTimeTo;
this.sequence = null;
Expand Down Expand Up @@ -125,27 +127,23 @@ public BoundStatementBuilder bindParameters(BoundStatementBuilder builder) {
return builder;
}

public String getBook()
{
public @Nonnull String getBook() {
return pageId.getBookId().getName();
}

public String getPage()
{
public @Nonnull String getPage() {
return pageId.getName();
}

public PageId getPageId() {
public @Nonnull PageId getPageId() {
return pageId;
}

public String getSessionAlias()
{
public @Nonnull String getSessionAlias() {
return sessionAlias;
}

public String getDirection()
{
public @Nonnull String getDirection() {
return direction;
}

Expand All @@ -160,12 +158,9 @@ public FilterForAny<Long> getSequence()
public String toString()
{
List<String> result = new ArrayList<>(10);
if (pageId != null)
result.add("pageId=" + pageId);
if (sessionAlias != null)
result.add("sessionAlias=" + sessionAlias);
if (direction != null)
result.add("direction=" + direction);
result.add("pageId=" + pageId);
result.add("sessionAlias=" + sessionAlias);
result.add("direction=" + direction);
if (messageTimeFrom != null)
result.add("timestamp" + messageTimeFrom);
if (messageTimeTo != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.exactpro.cradle.filters.FilterForLess;
import com.exactpro.cradle.testevents.StoredTestEventId;

import javax.annotation.Nonnull;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -40,6 +41,7 @@
import static com.exactpro.cradle.cassandra.dao.testevents.TestEventEntity.FIELD_SCOPE;
import static com.exactpro.cradle.cassandra.dao.testevents.TestEventEntity.FIELD_START_DATE;
import static com.exactpro.cradle.cassandra.dao.testevents.TestEventEntity.FIELD_START_TIME;
import static java.util.Objects.requireNonNull;

public class CassandraTestEventFilter implements CassandraFilter<TestEventEntity> {
private static final String START_DATE_FROM = "startDateFrom";
Expand All @@ -48,8 +50,8 @@ public class CassandraTestEventFilter implements CassandraFilter<TestEventEntity
private static final String START_TIME_TO = "startTimeTo";
private static final String ID = "id";

private final String scope;
private final PageId pageId;
private final @Nonnull String scope;
private final @Nonnull PageId pageId;
private final FilterForGreater<Instant> startTimestampFrom;
private final FilterForLess<Instant> startTimestampTo;
private final String parentId;
Expand All @@ -63,8 +65,8 @@ public CassandraTestEventFilter(PageId pageId, String scope,
FilterForGreater<Instant> startTimestampFrom, FilterForLess<Instant> startTimestampTo,
StoredTestEventId id,
String parentId, int limit, Order order) {
this.pageId = pageId;
this.scope = scope;
this.pageId = requireNonNull(pageId, "page id can't be null because book and page names are part of partition");
this.scope = requireNonNull(scope, "scope can't be null because it is part of partition");
this.startTimestampFrom = startTimestampFrom;
this.startTimestampTo = startTimestampTo;
this.id = id;
Expand Down Expand Up @@ -139,19 +141,19 @@ public BoundStatementBuilder bindParameters(BoundStatementBuilder builder) {
return builder;
}

public PageId getPageId() {
public @Nonnull PageId getPageId() {
return pageId;
}

public String getBook() {
public @Nonnull String getBook() {
return pageId.getBookId().getName();
}

public String getPage() {
public @Nonnull String getPage() {
return pageId.getName();
}

public String getScope() {
public @Nonnull String getScope() {
return scope;
}

Expand All @@ -178,9 +180,8 @@ public Order getOrder() {
@Override
public String toString() {
List<String> result = new ArrayList<>(10);
result.add("pageId=" + pageId);
if (scope != null)
result.add("scope=" + scope);
result.add("pageId=" + pageId);
result.add("scope=" + scope);
if (startTimestampFrom != null)
result.add("timestampFrom" + startTimestampFrom);
if (startTimestampTo != null)
Expand Down

0 comments on commit 31756d3

Please sign in to comment.