Skip to content

Commit 10c1056

Browse files
[TH2-5165] bookId, name, start are unique page identifier
1 parent 66beb2a commit 10c1056

File tree

9 files changed

+33
-61
lines changed

9 files changed

+33
-61
lines changed

cradle-cassandra/src/main/java/com/exactpro/cradle/cassandra/dao/books/PageEntity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,7 @@ public Instant getRemoved() {
148148
public PageInfo toPageInfo() {
149149
Instant start = TimeUtils.toInstant(getStartDate(), getStartTime());
150150
return new PageInfo(new PageId(new BookId(book), start, name),
151-
start,
152151
TimeUtils.toInstant(getEndDate(), getEndTime()),
153-
name,
154152
getComment(),
155153
getUpdated(),
156154
getRemoved());

cradle-cassandra/src/test/java/com/exactpro/cradle/cassandra/integration/BaseCradleCassandraTest.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,35 +53,28 @@ public abstract class BaseCradleCassandraTest {
5353
private static final List<PageInfo> DEFAULT_PAGES = List.of(
5454
new PageInfo(
5555
new PageId(DEFAULT_BOOK_ID, DEFAULT_DATA_START, DEFAULT_PAGE_PREFIX + 0),
56-
DEFAULT_DATA_START,
57-
DEFAULT_DATA_START.plus(10, ChronoUnit.MINUTES), DEFAULT_PAGE_PREFIX + 0, ""),
56+
DEFAULT_DATA_START.plus(10, ChronoUnit.MINUTES), ""),
5857
new PageInfo(
5958
new PageId(DEFAULT_BOOK_ID, DEFAULT_DATA_START.plus(10, ChronoUnit.MINUTES), DEFAULT_PAGE_PREFIX + 1),
60-
DEFAULT_DATA_START.plus(10, ChronoUnit.MINUTES),
61-
DEFAULT_DATA_START.plus(20, ChronoUnit.MINUTES), DEFAULT_PAGE_PREFIX + 1, ""),
59+
DEFAULT_DATA_START.plus(20, ChronoUnit.MINUTES), ""),
6260
new PageInfo(
6361
new PageId(DEFAULT_BOOK_ID, DEFAULT_DATA_START.plus(20, ChronoUnit.MINUTES), DEFAULT_PAGE_PREFIX + 2),
64-
DEFAULT_DATA_START.plus(20, ChronoUnit.MINUTES),
65-
DEFAULT_DATA_START.plus(30, ChronoUnit.MINUTES), DEFAULT_PAGE_PREFIX + 2, ""),
62+
DEFAULT_DATA_START.plus(30, ChronoUnit.MINUTES), ""),
6663
new PageInfo(
6764
new PageId(DEFAULT_BOOK_ID, DEFAULT_DATA_START.plus(30, ChronoUnit.MINUTES), DEFAULT_PAGE_PREFIX + 3),
68-
DEFAULT_DATA_START.plus(30, ChronoUnit.MINUTES),
69-
DEFAULT_DATA_START.plus(40, ChronoUnit.MINUTES), DEFAULT_PAGE_PREFIX + 3, ""),
65+
DEFAULT_DATA_START.plus(40, ChronoUnit.MINUTES), ""),
7066
new PageInfo(
7167
new PageId(DEFAULT_BOOK_ID, DEFAULT_DATA_START.plus(40, ChronoUnit.MINUTES), DEFAULT_PAGE_PREFIX + 4),
72-
DEFAULT_DATA_START.plus(40, ChronoUnit.MINUTES),
73-
DEFAULT_DATA_START.plus(50, ChronoUnit.MINUTES), DEFAULT_PAGE_PREFIX + 4, ""),
68+
DEFAULT_DATA_START.plus(50, ChronoUnit.MINUTES), ""),
7469
new PageInfo(
7570
new PageId(DEFAULT_BOOK_ID, DEFAULT_DATA_START.plus(50, ChronoUnit.MINUTES), DEFAULT_PAGE_PREFIX + 5),
76-
DEFAULT_DATA_START.plus(50, ChronoUnit.MINUTES),
77-
DEFAULT_DATA_START.plus(60, ChronoUnit.MINUTES), DEFAULT_PAGE_PREFIX + 5, ""));
71+
DEFAULT_DATA_START.plus(60, ChronoUnit.MINUTES), ""));
7872

7973

8074
protected List<PageInfo> pages = DEFAULT_PAGES;
8175
protected CqlSession session;
8276
protected CassandraCradleStorage storage;
8377
protected Instant dataStart = DEFAULT_DATA_START;
84-
protected Instant dataEnd = DEFAULT_DATA_END;
8578
protected BookId bookId = DEFAULT_BOOK_ID;
8679

8780
/*

cradle-cassandra/src/test/java/com/exactpro/cradle/cassandra/resultset/PagesInIntervalIteratorProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class PagesInIntervalIteratorProviderTest {
3333

3434
@Test
3535
public void defaultPageVsIncludedInterval() {
36-
PageInfo pageInfo = new PageInfo(new PageId(bookId, Instant.EPOCH, "test-page"), Instant.EPOCH,null, "test-page", null);
36+
PageInfo pageInfo = new PageInfo(new PageId(bookId, Instant.EPOCH, "test-page"), null, null);
3737

3838
assertTrue(checkInterval(pageInfo, pageInfo.getId().getStart(), Instant.now()), "in.st = p.st, in.en = p.en");
3939
assertTrue(checkInterval(pageInfo, pageInfo.getId().getStart().plusNanos(1), Instant.now()), "in.st = p.st + 1, in.en = p.en");
@@ -46,7 +46,7 @@ public void defaultPageVsIncludedInterval() {
4646
@Test
4747
public void onePageVsIntervals() {
4848
Instant now = Instant.now();
49-
PageInfo pageInfo = new PageInfo(new PageId(bookId, now, "test-page"), now, now.plusSeconds(1), "test-page", null);
49+
PageInfo pageInfo = new PageInfo(new PageId(bookId, now, "test-page"), now.plusSeconds(1), null);
5050

5151
assertTrue(checkInterval(pageInfo, pageInfo.getId().getStart(), pageInfo.getEnded()), "in.st = p.st, in.en = p.en");
5252
assertTrue(checkInterval(pageInfo, pageInfo.getId().getStart().plusNanos(1), pageInfo.getEnded()), "in.st = p.st + 1, in.en = p.en");

cradle-core/src/main/java/com/exactpro/cradle/CradleStorage.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,6 @@ public BookInfo addPages(BookId bookId, List<PageToAdd> pages) throws CradleStor
498498
* @param bookId ID of the book whose pages to refresh
499499
* @return refreshed book information
500500
* @throws CradleStorageException if given bookId is unknown
501-
* @throws IOException if page data reading failed
502501
*/
503502
public BookInfo refreshPages(BookId bookId) throws CradleStorageException {
504503
logger.info("Refreshing pages of book '{}'", bookId);
@@ -1604,19 +1603,15 @@ private List<PageInfo> checkAndConvertPages(List<PageToAdd> pages, BookInfo book
16041603
}
16051604

16061605
result.add(new PageInfo(new PageId(bookId, prevPage.getStart(), prevPage.getName()),
1607-
prevPage.getStart(),
16081606
checkCollisionAndGetPageEnd(book, prevPage, page.getStart()),
1609-
prevPage.getName(),
16101607
prevPage.getComment()));
16111608
}
16121609
prevPage = page;
16131610
}
16141611

16151612
if (prevPage != null) {
16161613
result.add(new PageInfo(new PageId(bookId, prevPage.getStart(), prevPage.getName()),
1617-
prevPage.getStart(),
16181614
checkCollisionAndGetPageEnd(book, prevPage, null),
1619-
prevPage.getName(),
16201615
prevPage.getComment()));
16211616
}
16221617

cradle-core/src/main/java/com/exactpro/cradle/PageId.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@ public Instant getStart() {
4949
return start;
5050
}
5151

52-
/**
53-
* @deprecated name has been moved to {@link PageInfo#getName()}
54-
*/
55-
@Deprecated
5652
public String getName()
5753
{
5854
return name;
@@ -62,7 +58,7 @@ public String getName()
6258
@Override
6359
public int hashCode()
6460
{
65-
return Objects.hash(bookId, start);
61+
return Objects.hash(bookId, start, name);
6662
}
6763

6864
@Override
@@ -75,13 +71,17 @@ public boolean equals(Object obj)
7571
if (getClass() != obj.getClass())
7672
return false;
7773
PageId other = (PageId) obj;
78-
return Objects.equals(bookId, other.bookId) && Objects.equals(start, other.start);
74+
return Objects.equals(bookId, other.bookId) &&
75+
Objects.equals(start, other.start) &&
76+
Objects.equals(name, other.name);
7977
}
8078

8179

8280
@Override
8381
public String toString()
8482
{
85-
return EscapeUtils.escape(bookId.toString())+DELIMITER+EscapeUtils.escape(start.toString());
83+
return EscapeUtils.escape(bookId.toString())+DELIMITER+
84+
EscapeUtils.escape(start.toString())+DELIMITER+
85+
EscapeUtils.escape(name);
8686
}
8787
}

cradle-core/src/main/java/com/exactpro/cradle/PageInfo.java

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,24 @@
2525
public class PageInfo
2626
{
2727
private final PageId id;
28-
private final Instant started;
2928
private final Instant ended;
30-
private final String name;
3129
private final String comment;
3230
private final Instant updated;
3331
private final Instant removed;
3432

35-
public PageInfo(PageId id, Instant started, Instant ended, String name, String comment, Instant updated, Instant removed)
33+
public PageInfo(PageId id, Instant ended, String comment, Instant updated, Instant removed)
3634
{
3735
this.id = id;
38-
this.started = started;
3936
this.ended = ended;
40-
this.name = name;
4137
this.comment = comment;
4238
this.updated = updated;
4339
this.removed = removed;
4440
}
4541

46-
public PageInfo(PageId id, Instant started, Instant ended, String name, String comment)
42+
public PageInfo(PageId id, Instant ended, String comment)
4743
{
4844
this.id = id;
49-
this.started = started;
5045
this.ended = ended;
51-
this.name = name;
5246
this.comment = comment;
5347
this.updated = null;
5448
this.removed = null;
@@ -59,24 +53,12 @@ public PageId getId()
5953
{
6054
return id;
6155
}
62-
/**
63-
* @deprecated name has been moved to {@link PageId#getStart()}
64-
*/
65-
@Deprecated
66-
public Instant getStarted()
67-
{
68-
return started;
69-
}
70-
56+
7157
public Instant getEnded()
7258
{
7359
return ended;
7460
}
7561

76-
public String getName() {
77-
return name;
78-
}
79-
8062
public String getComment()
8163
{
8264
return comment;
@@ -90,13 +72,23 @@ public Instant getRemoved() {
9072
return removed;
9173
}
9274

75+
76+
public Instant getStarted()
77+
{
78+
return id.getStart();
79+
}
80+
81+
public String getName() {
82+
return id.getName();
83+
}
84+
9385
public static PageInfo ended(PageInfo page, Instant endTimestamp)
9486
{
95-
return page == null ? null : new PageInfo(page.getId(), page.getId().getStart(), endTimestamp, page.getName(), page.getComment(), page.getUpdated(), page.getRemoved());
87+
return page == null ? null : new PageInfo(page.getId(), endTimestamp, page.getComment(), page.getUpdated(), page.getRemoved());
9688
}
9789

9890
public boolean isValidFor(Instant timestamp) {
99-
return (started == null || !started.isAfter(timestamp)) &&
91+
return (getStarted() == null || !getStarted().isAfter(timestamp)) &&
10092
(ended == null || ended.isAfter(timestamp));
10193
}
10294

@@ -117,7 +109,6 @@ public String toString() {
117109
return "PageInfo{" +
118110
"id=" + id +
119111
", ended=" + ended +
120-
", name='" + name + '\'' +
121112
", comment='" + comment + '\'' +
122113
", updated=" + updated +
123114
", removed=" + removed +

cradle-core/src/test/java/com/exactpro/cradle/BookInfoTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public void lazyPageAddTest() {
8585
}
8686
}
8787

88-
@SuppressWarnings("deprecation")
8988
@Test
9089
public void removePageTest() {
9190
List<PageInfo> operateSource = new ArrayList<>(PAGES);
@@ -148,6 +147,6 @@ private static BookInfo createBookInfo(List<PageInfo> pages) {
148147
}
149148

150149
private static PageInfo createPageInfo(Instant start, @Nullable Instant end) {
151-
return new PageInfo(new PageId(BOOK_ID, start, start.toString()), start, end, "test-name", "test-comment");
150+
return new PageInfo(new PageId(BOOK_ID, start, start.toString()), end, "test-comment");
152151
}
153152
}

cradle-core/src/test/java/com/exactpro/cradle/testevents/EventBatchTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void prepareBatch() throws CradleStorageException {
7272
}
7373

7474
@DataProvider(name = "batch invalid events")
75-
public Object[][] batchInvalidEvents() throws CradleStorageException {
75+
public Object[][] batchInvalidEvents() {
7676
Object[][] batchEvents = new Object[][]
7777
{
7878
{validEvent().parentId(null), //No parent ID
@@ -205,7 +205,7 @@ public void duplicateIds() throws CradleStorageException {
205205
batch.addTestEvent(eventBuilder.id(eventId).name(DUMMY_NAME).parentId(batch.getParentId()).build());
206206
}
207207

208-
@Test(expectedExceptions = {CradleStorageException.class}, expectedExceptionsMessageRegExp = ".* '.*\\:XXX' .* stored in this batch .*")
208+
@Test(expectedExceptions = {CradleStorageException.class}, expectedExceptionsMessageRegExp = ".* '.*:XXX' .* stored in this batch .*")
209209
public void externalReferences() throws CradleStorageException {
210210
StoredTestEventId parentId = new StoredTestEventId(BOOK, SCOPE, START_TIMESTAMP, "1");
211211
batch.addTestEvent(eventBuilder.id(parentId)
@@ -299,8 +299,6 @@ private static BookInfo createBookInfo() {
299299
List<PageInfo> pages = List.of(new PageInfo(
300300
new PageId(null, START_TIMESTAMP, null),
301301
START_TIMESTAMP,
302-
START_TIMESTAMP,
303-
null,
304302
null)
305303
);
306304
return new BookInfo(

cradle-core/src/test/java/com/exactpro/cradle/testevents/EventSingleTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ private static BookInfo createBookInfo() {
128128
List<PageInfo> pages = List.of(new PageInfo(
129129
new PageId(null, START_TIMESTAMP, null),
130130
START_TIMESTAMP,
131-
START_TIMESTAMP,
132-
null,
133131
null)
134132
);
135133
return new BookInfo(

0 commit comments

Comments
 (0)