Skip to content

Commit

Permalink
Removed getter
Browse files Browse the repository at this point in the history
  • Loading branch information
rg911 committed Jun 3, 2020
1 parent 55ace31 commit 97d042a
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 60 deletions.
4 changes: 2 additions & 2 deletions e2e/infrastructure/BlockHttp.spec.ts
Expand Up @@ -99,7 +99,7 @@ describe('BlockHttp', () => {
describe('searchBlock', () => {
it('should return block info given height and limit', async () => {
const blocksInfo = await blockRepository.search({}).toPromise();
expect(blocksInfo.getData().length).to.be.greaterThan(0);
expect(blocksInfo.data.length).to.be.greaterThan(0);
});
});

Expand All @@ -109,7 +109,7 @@ describe('BlockHttp', () => {
const blockInfoStreamer = await streamer.search({ pageSize: 20 }).pipe(take(20), toArray()).toPromise();
const blocksInfo = await blockRepository.search({ pageSize: 20 }).toPromise();
expect(blockInfoStreamer.length).to.be.greaterThan(0);
deepEqual(blockInfoStreamer, blocksInfo.getData());
deepEqual(blockInfoStreamer, blocksInfo.data);
});
});

Expand Down
6 changes: 3 additions & 3 deletions e2e/infrastructure/MosaicHttp.spec.ts
Expand Up @@ -164,8 +164,8 @@ describe('MosaicHttp', () => {
describe('searchMosaics', () => {
it('should call searchMosaics successfully', async () => {
const mosaics = await mosaicRepository.search({ ownerAddress: account.address }).toPromise();
expect(mosaics.getData().length).to.be.greaterThan(0);
expect(mosaics.getData().find((m) => m.id.toHex() === mosaicId.toHex()) !== undefined).to.be.true;
expect(mosaics.data.length).to.be.greaterThan(0);
expect(mosaics.data.find((m) => m.id.toHex() === mosaicId.toHex()) !== undefined).to.be.true;
});
});

Expand All @@ -179,7 +179,7 @@ describe('MosaicHttp', () => {
const mosaics = await mosaicRepository.search({ ownerAddress: account.address, pageSize: 3 }).toPromise();
expect(mosaicsStreamer.length).to.be.greaterThan(0);
expect(mosaicsStreamer.find((m) => m.id.toHex() === mosaicId.toHex()) !== undefined).to.be.true;
deepEqual(mosaics.getData(), mosaicsStreamer);
deepEqual(mosaics.data, mosaicsStreamer);
});
});

Expand Down
6 changes: 3 additions & 3 deletions e2e/infrastructure/TransactionHttp.spec.ts
Expand Up @@ -1460,13 +1460,13 @@ describe('TransactionHttp', () => {
describe('searchTransactions', () => {
it('should return transaction info given address', async () => {
const transactions = await transactionRepository.search({ address: account.address } as TransactionSearchCriteria).toPromise();
expect(transactions.getData().length).to.be.greaterThan(0);
expect(transactions.data.length).to.be.greaterThan(0);
});
it('should return transaction info given height', async () => {
const transactions = await transactionRepository
.search({ height: UInt64.fromUint(1) } as TransactionSearchCriteria)
.toPromise();
expect(transactions.getData().length).to.be.greaterThan(0);
expect(transactions.data.length).to.be.greaterThan(0);
});
});

Expand All @@ -1478,7 +1478,7 @@ describe('TransactionHttp', () => {
.toPromise();
const transactions = await streamer.search({ address: account.address, pageSize: 3 }).pipe(take(3), toArray()).toPromise();
expect(transactions.length).to.be.greaterThan(0);
deepEqual(transactionsNoStreamer.getData(), transactions);
deepEqual(transactionsNoStreamer.data, transactions);
});
});
});
35 changes: 0 additions & 35 deletions src/infrastructure/Page.ts
Expand Up @@ -39,39 +39,4 @@ export class Page<T> {
) {
this.isLastPage = this.pageNumber >= this.totalPages;
}

/**
* @return The page data.
*/
public getData(): T[] {
return this.data;
}

/**
* @return the current page number starting from 1.
*/
public getPageNumber(): number {
return this.pageNumber;
}

/**
* @return the page size.
*/
public getPageSize(): number {
return this.pageSize;
}

/**
* @return the total entries.
*/
public getTotalEntries(): number {
return this.totalEntries;
}

/**
* @return the total pages.
*/
public getTotalPages(): number {
return this.totalPages;
}
}
4 changes: 2 additions & 2 deletions src/infrastructure/paginationStreamer/PaginationStreamer.ts
Expand Up @@ -57,9 +57,9 @@ export class PaginationStreamer<E, C extends SearchCriteria> {
return observable.pipe(
flatMap((page) => {
if (page.isLastPage) {
return from(page.getData());
return from(page.data);
} else {
return concat(from(page.getData()), this.searchInternal(criteria, pageNumber + 1));
return concat(from(page.data), this.searchInternal(criteria, pageNumber + 1));
}
}),
);
Expand Down
2 changes: 1 addition & 1 deletion test/infrastructure/BlockHttp.spec.ts
Expand Up @@ -127,7 +127,7 @@ describe('BlockHttp', () => {
}),
);
const blockInfos = await blockRepository.search({ signerPublicKey: blockDTO.signerPublicKey }).toPromise();
assertBlockInfo(blockInfos.getData()[0]);
assertBlockInfo(blockInfos.data[0]);
});

it('getMerkleTransaction', async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/infrastructure/MosaicHttp.spec.ts
Expand Up @@ -105,7 +105,7 @@ describe('MosaicHttp', () => {
Promise.resolve({ response, body }),
);
const mosaicsInfo = await mosaicRepository.search({ ownerAddress: address }).toPromise();
assertMosaicInfo(mosaicsInfo.getData()[0]);
assertMosaicInfo(mosaicsInfo.data[0]);
});

it('getMosaic - Error', async () => {
Expand Down
8 changes: 4 additions & 4 deletions test/infrastructure/Page.spec.ts
Expand Up @@ -32,10 +32,10 @@ describe('Page', () => {
1,
1,
);
expect(page.getData().length).to.be.equal(1);
expect(page.getPageNumber()).to.be.equal(1);
expect(page.getPageSize()).to.be.equal(1);
expect(page.getTotalEntries()).to.be.equal(1);
expect(page.data.length).to.be.equal(1);
expect(page.pageNumber).to.be.equal(1);
expect(page.pageSize).to.be.equal(1);
expect(page.totalEntries).to.be.equal(1);
expect(page.isLastPage).to.be.true;

page = new Page<Transaction>(
Expand Down
18 changes: 9 additions & 9 deletions test/infrastructure/TransactionHttp.spec.ts
Expand Up @@ -172,17 +172,17 @@ describe('TransactionHttp', () => {

const transactions = await transactionHttp.search({ address: account.address }).toPromise();

expect(transactions.getData().length).to.be.equal(1);
expect(transactions.getData()[0].type.valueOf()).to.be.equal(TransactionType.TRANSFER.valueOf());
expect(((transactions.getData()[0] as TransferTransaction).recipientAddress as Address).plain()).to.be.equal(
expect(transactions.data.length).to.be.equal(1);
expect(transactions.data[0].type.valueOf()).to.be.equal(TransactionType.TRANSFER.valueOf());
expect(((transactions.data[0] as TransferTransaction).recipientAddress as Address).plain()).to.be.equal(
Address.createFromEncoded('906415867F121D037AF447E711B0F5E4D52EBBF066D96860EB').plain(),
);
expect(transactions.getData()[0].transactionInfo?.id).to.be.equal('id');
expect(transactions.getData()[0].transactionInfo?.hash).to.be.equal('hash');
expect(transactions.data[0].transactionInfo?.id).to.be.equal('id');
expect(transactions.data[0].transactionInfo?.hash).to.be.equal('hash');

expect(transactions.getPageNumber()).to.be.equal(1);
expect(transactions.getPageSize()).to.be.equal(1);
expect(transactions.getTotalEntries()).to.be.equal(1);
expect(transactions.getTotalPages()).to.be.equal(1);
expect(transactions.pageNumber).to.be.equal(1);
expect(transactions.pageSize).to.be.equal(1);
expect(transactions.totalEntries).to.be.equal(1);
expect(transactions.totalPages).to.be.equal(1);
});
});

0 comments on commit 97d042a

Please sign in to comment.