diff --git a/@here/olp-sdk-dataservice-api/lib/lookup-api.ts b/@here/olp-sdk-dataservice-api/lib/lookup-api.ts index 4b14a812..f07bae8f 100644 --- a/@here/olp-sdk-dataservice-api/lib/lookup-api.ts +++ b/@here/olp-sdk-dataservice-api/lib/lookup-api.ts @@ -101,28 +101,6 @@ export async function platformAPI( return builder.request(urlBuilder, options); } -/** - * @deprecated This method is deprecated and is not used. Please used getPlatformAPIList() - * Return the list of the HERE APIs. This response is valid for the time specified by 'Cache-Control' header. - * - * @summary Return the list of the HERE APIs. - */ -export async function platformAPIList( - builder: RequestBuilder -): Promise { - const baseUrl = "/platform/apis"; - - const urlBuilder = new UrlBuilder(builder.baseUrl + baseUrl); - - const headers: { [header: string]: string } = {}; - const options: RequestOptions = { - method: "GET", - headers - }; - - return builder.request(urlBuilder, options); -} - /** * Return the list of the HERE APIs. This response is valid for the time specified by 'Cache-Control' header. * @@ -179,35 +157,6 @@ export async function resourceAPI( return builder.request(urlBuilder, options); } -/** - * @deprecated This method is deprecated and is not used. Please used getResourceAPIList() - * Return the list of APIs for a given resource identified by hrn. This response is valid for the time specified by 'Cache-Control' header. - * - * @summary Return the list of APIs for a given resource. - * @param hrn The HRN identifying the resource - * @param region If you want to look up a specific region for a given resource. - */ -export async function resourceAPIList( - builder: RequestBuilder, - params: { hrn: string; region?: string } -): Promise { - const baseUrl = "/resources/{hrn}/apis".replace( - "{hrn}", - UrlBuilder.toString(params["hrn"]) - ); - - const urlBuilder = new UrlBuilder(builder.baseUrl + baseUrl); - urlBuilder.appendQuery("region", params["region"]); - - const headers: { [header: string]: string } = {}; - const options: RequestOptions = { - method: "GET", - headers - }; - - return builder.request(urlBuilder, options); -} - /** * Return the list of APIs for a given resource identified by hrn. This response is valid for the time specified by 'Cache-Control' header. * diff --git a/@here/olp-sdk-dataservice-api/lib/stream-api.ts b/@here/olp-sdk-dataservice-api/lib/stream-api.ts index 8526d35c..e1c814a6 100644 --- a/@here/olp-sdk-dataservice-api/lib/stream-api.ts +++ b/@here/olp-sdk-dataservice-api/lib/stream-api.ts @@ -166,58 +166,6 @@ export interface StreamOffset { * StreamApi */ -/** - * @deprecated This function will be removed by 09.2020. Please use doCommitOffsets. - * After reading data, you should commit the offset of the last message read from each partition so - * that your application can resume reading new messages from the correct partition in the event that there is a - * disruption to the subscription, such as an application crash. An offset can also be useful if you delete a subscription - * then recreate a subscription for the same layer, because the new subscription can start reading data from the offset. - * To read messages already committed, use the /seek endpoint, then use /partitions. - * The base path to use is the value of 'nodeBaseURL' returned from /subscribe POST request. - * - * @summary Commits offsets of the last message read - * @param layerId The ID of the stream layer. - * @param commitOffsets The offsets to commit. It should be same as the offset of the message you wish to commit. - * Do not pass offset + 1 as mentioned in Kafka Consumer documentation. The service adds one to the offset you specify. - * @param subscriptionId The subscriptionId received in the response of the /subscribe request (required if mode=parallel). - * @param mode The subscription mode of this subscriptionId (as provided in /subscribe POST API). - * @param xCorrelationId The correlation-id (value of Response Header 'X-Correlation-Id') from prior step in process. - * See the [API Reference](https://developer.here.com/olp/documentation/data-api/api-reference.html) for the `stream` API - */ -export async function commitOffsets( - builder: RequestBuilder, - params: { - layerId: string; - commitOffsets: CommitOffsetsRequest; - subscriptionId?: string; - mode?: "serial" | "parallel"; - xCorrelationId?: string; - } -): Promise { - const baseUrl = "/layers/{layerId}/offsets".replace( - "{layerId}", - UrlBuilder.toString(params["layerId"]) - ); - - const urlBuilder = new UrlBuilder(builder.baseUrl + baseUrl); - urlBuilder.appendQuery("subscriptionId", params["subscriptionId"]); - urlBuilder.appendQuery("mode", params["mode"]); - - const headers: { [header: string]: string } = {}; - const options: RequestOptions = { - method: "PUT", - headers - }; - headers["Content-Type"] = "application/json"; - if (params["commitOffsets"] !== undefined) { - options.body = JSON.stringify(params["commitOffsets"]); - } - if (params["xCorrelationId"] !== undefined) { - headers["X-Correlation-Id"] = params["xCorrelationId"] as string; - } - return builder.request(urlBuilder, options); -} - /** * After reading data, you should commit the offset of the last message read from each partition so * that your application can resume reading new messages from the correct partition in the event that there is a diff --git a/@here/olp-sdk-dataservice-api/test/LookupApi.test.ts b/@here/olp-sdk-dataservice-api/test/LookupApi.test.ts index 5636fa18..32f14629 100644 --- a/@here/olp-sdk-dataservice-api/test/LookupApi.test.ts +++ b/@here/olp-sdk-dataservice-api/test/LookupApi.test.ts @@ -51,24 +51,6 @@ describe("lookupAPI", function() { expect(result).to.be.equal("success"); }); - it("platformAPIList", async function() { - const builder = { - baseUrl: "http://mocked.url", - request: async (urlBuilder: UrlBuilder, options: any) => { - expect(urlBuilder.url).to.be.equal( - "http://mocked.url/platform/apis" - ); - expect(options.method).to.be.equal("GET"); - return Promise.resolve("success"); - } - }; - const result = await LookupApi.platformAPIList( - (builder as unknown) as RequestBuilder - ); - - expect(result).to.be.equal("success"); - }); - it("resourceAPI", async function() { const params = { hrn: "mocked-hrn", @@ -93,27 +75,4 @@ describe("lookupAPI", function() { expect(result).to.be.equal("success"); }); - - it("resourceAPIList", async function() { - const params = { - hrn: "mocked-hrn", - region: "mocked-region" - }; - const builder = { - baseUrl: "http://mocked.url", - request: async (urlBuilder: UrlBuilder, options: any) => { - expect(urlBuilder.url).to.be.equal( - "http://mocked.url/resources/mocked-hrn/apis?region=mocked-region" - ); - expect(options.method).to.be.equal("GET"); - return Promise.resolve("success"); - } - }; - const result = await LookupApi.resourceAPIList( - (builder as unknown) as RequestBuilder, - params - ); - - expect(result).to.be.equal("success"); - }); }); diff --git a/@here/olp-sdk-dataservice-api/test/StreamApi.test.ts b/@here/olp-sdk-dataservice-api/test/StreamApi.test.ts index d3ca2eee..c2809d1b 100644 --- a/@here/olp-sdk-dataservice-api/test/StreamApi.test.ts +++ b/@here/olp-sdk-dataservice-api/test/StreamApi.test.ts @@ -28,34 +28,6 @@ chai.use(sinonChai); const expect = chai.expect; describe("StreamApi", function() { - it("Should commitOffsets works as expected", async function() { - const builder = { - baseUrl: "http://mocked.url", - request: async (urlBuilder: UrlBuilder, options: any) => { - expect(urlBuilder.url).to.be.equal( - "http://mocked.url/layers/mocked-id/offsets?subscriptionId=test-subscriptionId&mode=serial" - ); - expect(options.method).to.be.equal("PUT"); - return Promise.resolve(); - } - } as RequestBuilder; - - await StreamApi.commitOffsets(builder, { - layerId: "mocked-id", - subscriptionId: "test-subscriptionId", - xCorrelationId: "test-xCorrelationId", - mode: "serial", - commitOffsets: { - offsets: [ - { - partition: 25, - offset: 3 - } - ] - } - }); - }); - it("Should doCommitOffsets works as expected", async function() { const builder = { baseUrl: "http://mocked.url", diff --git a/@here/olp-sdk-dataservice-read/lib/client/DataRequest.ts b/@here/olp-sdk-dataservice-read/lib/client/DataRequest.ts index 02a296d2..25cdc0e3 100644 --- a/@here/olp-sdk-dataservice-read/lib/client/DataRequest.ts +++ b/@here/olp-sdk-dataservice-read/lib/client/DataRequest.ts @@ -101,32 +101,6 @@ export class DataRequest { return this; } - /** - * @deprecated This method is deprecated and is not used. If you need to set the version, - * initialize the version client with the new constructor. Otherwise, the latest version will be used. - * - * Gets a catalog version for the request. - * - * @return The catalog version number. - */ - public getVersion(): number | undefined { - return this.version; - } - - /** - * @deprecated This method is deprecated and is not used. If you need to set the version, - * initialize the version client with the new constructor. Otherwise, the latest version will be used. - * - * Sets the provided catalog version. - * - * @param version The catalog version number. - * @returns The updated [[DataRequest]] instance that you can use to chain methods. - */ - public withVersion(version: number): DataRequest { - this.version = version; - return this; - } - /** * An optional free-form tag that is used for grouping billing records together. * diff --git a/@here/olp-sdk-dataservice-read/lib/client/IndexLayerClient.ts b/@here/olp-sdk-dataservice-read/lib/client/IndexLayerClient.ts index 886d4ba5..4c2a543b 100644 --- a/@here/olp-sdk-dataservice-read/lib/client/IndexLayerClient.ts +++ b/@here/olp-sdk-dataservice-read/lib/client/IndexLayerClient.ts @@ -47,62 +47,28 @@ export class IndexLayerClient { /** * HRN of the catalog. - * @deprecated This field will be marked as private by 08.2020. */ - hrn: string; + private hrn: string; /** * The ID of the layer. - * @deprecated This field will be marked as private by 08.2020. */ - layerId: string; + private layerId: string; /** * The [[OlpClientSettings]] instance. - * @deprecated This field will be marked as private by 08.2020. */ - settings: OlpClientSettings; - - /** - * @deprecated Please use the overloaded constructor of IndexLayerClient. - * - * Creates the [[IndexLayerClient]] instance. - * - * @param catalogHrn The HERE Resource Name (HRN) of the catalog from which you want to get partitions metadata and data. - * @param layerId The ID of the layer. - * @param settings The [[OlpClientSettings]] instance. - * @return The [[IndexLayerClient]] instance. - */ - constructor(catalogHrn: HRN, layerId: string, settings: OlpClientSettings); + private settings: OlpClientSettings; /** * Creates the [[IndexLayerClient]] instance with IndexLayerClientParams. * * @param params parameters for use to initialize IndexLayerClient. */ - constructor(params: IndexLayerClientParams); - - /** - * Implementation for handling both constuctors. - */ - constructor( - paramsOrHrn: IndexLayerClientParams | HRN, - layerId?: string, - settings?: OlpClientSettings - ) { - if (paramsOrHrn instanceof HRN) { - this.hrn = paramsOrHrn.toString(); - if (layerId && settings instanceof OlpClientSettings) { - this.layerId = layerId; - this.settings = settings; - } else { - throw new Error("Unsupported parameters"); - } - } else { - this.hrn = paramsOrHrn.catalogHrn.toString(); - this.layerId = paramsOrHrn.layerId; - this.settings = paramsOrHrn.settings; - } + constructor(params: IndexLayerClientParams) { + this.hrn = params.catalogHrn.toString(); + this.layerId = params.layerId; + this.settings = params.settings; } /** diff --git a/@here/olp-sdk-dataservice-read/lib/client/QuadKeyPartitionsRequest.ts b/@here/olp-sdk-dataservice-read/lib/client/QuadKeyPartitionsRequest.ts index 31f8245a..09c652aa 100644 --- a/@here/olp-sdk-dataservice-read/lib/client/QuadKeyPartitionsRequest.ts +++ b/@here/olp-sdk-dataservice-read/lib/client/QuadKeyPartitionsRequest.ts @@ -36,21 +36,6 @@ export class QuadKeyPartitionsRequest { private billingTag?: string; private additionalFields?: AdditionalFields; - /** - * @deprecated This method is deprecated and is not used. If you need to set the version, then - * initialize the version client with not deprecated constructor, in other case the latest version will be used. - * - * The version of the catalog against which you want to run the query. - * It must be a valid catalog version. - * - * @param version Specify the catalog version or, if you want to use the latest catalog version, set to undefined. - * @returns The updated [[QuadKeyPartitionsRequest]] instance that you can use to chain methods. - */ - public withVersion(version?: number): QuadKeyPartitionsRequest { - this.version = version; - return this; - } - /** * A geometric area represented as a HERE tile. * @@ -105,18 +90,6 @@ export class QuadKeyPartitionsRequest { return this; } - /** - * @deprecated This method is deprecated and is not used. If you need to set the version, then - * initialize the version client with not deprecated constructor, in other case the latest version will be used. - * - * The configured catalog version for the request. - * - * @return The catalog version number. - */ - public getVersion(): number | undefined { - return this.version; - } - /** * Gets the configured [[QuadKey]] object for the request. * diff --git a/@here/olp-sdk-dataservice-read/lib/client/StatisticsRequest.ts b/@here/olp-sdk-dataservice-read/lib/client/StatisticsRequest.ts index 599464fd..cc20b0a7 100644 --- a/@here/olp-sdk-dataservice-read/lib/client/StatisticsRequest.ts +++ b/@here/olp-sdk-dataservice-read/lib/client/StatisticsRequest.ts @@ -78,11 +78,9 @@ export class StatisticsRequest { /** * Gets a tile level for the request. - * @deprecated Please use getDataLevel(): number | undefined * @return The requested tile level string. */ - public getDataLevel(): string | undefined; - public getDataLevel(): number | string | undefined { + public getDataLevel(): number | undefined { return this.dataLevel; } /** @@ -133,14 +131,10 @@ export class StatisticsRequest { /** * A setter for the provided `dataLevel` string. * - * @deprecated Please set dataLevel as a number * @param dataLevel dataLevel Specify the tile level about which you want to get statistical data. * @returns The updated [[StatisticsRequest]] instance that you can use to chain methods. */ - // tslint:disable-next-line: unified-signatures - public withDataLevel(dataLevel: string): StatisticsRequest; - - public withDataLevel(dataLevel: string | number) { + public withDataLevel(dataLevel: number) { this.dataLevel = Number(dataLevel); return this; } diff --git a/@here/olp-sdk-dataservice-read/lib/client/VersionedLayerClient.ts b/@here/olp-sdk-dataservice-read/lib/client/VersionedLayerClient.ts index 02926584..15d4a4eb 100644 --- a/@here/olp-sdk-dataservice-read/lib/client/VersionedLayerClient.ts +++ b/@here/olp-sdk-dataservice-read/lib/client/VersionedLayerClient.ts @@ -61,67 +61,34 @@ export class VersionedLayerClient { /** * HRN of the catalog. - * @deprecated This field will be marked as private by 08.2020. */ - hrn: string; + private hrn: string; /** * The ID of the layer. - * @deprecated This field will be marked as private by 08.2020. */ - layerId: string; + private layerId: string; /** * The [[OlpClientSettings]] instance. - * @deprecated This field will be marked as private by 08.2020. */ - settings: OlpClientSettings; + private settings: OlpClientSettings; // Layer version. private version?: number; - /** - * @deprecated Please use the overloaded constructor of VersionLayerClient. - * - * Creates the [[VersionedLayerClient]] instance. - * - * @param catalogHrn The HERE Resource Name (HRN) of the catalog from which you want to get partitions metadata and data. - * @param layerId The ID of the layer. - * @param settings The [[OlpClientSettings]] instance. - */ - constructor(catalogHrn: HRN, layerId: string, settings: OlpClientSettings); - /** * Creates the [[VersionedLayerClient]] instance with VersionedLayerClientParams. * * @param params parameters for use to initialize VersionLayerClient. */ - constructor(params: VersionedLayerClientParams); + constructor(params: VersionedLayerClientParams) { + this.hrn = params.catalogHrn.toString(); + this.layerId = params.layerId; + this.settings = params.settings; - /** - * Implementation for handling both constuctors. - */ - constructor( - paramsOrHrn: VersionedLayerClientParams | HRN, - layerId?: string, - settings?: OlpClientSettings - ) { - if (paramsOrHrn instanceof HRN) { - this.hrn = paramsOrHrn.toString(); - if (layerId && settings instanceof OlpClientSettings) { - this.layerId = layerId; - this.settings = settings; - } else { - throw new Error("Unsupported parameters"); - } - } else { - this.hrn = paramsOrHrn.catalogHrn.toString(); - this.layerId = paramsOrHrn.layerId; - this.settings = paramsOrHrn.settings; - - if (paramsOrHrn.version !== undefined && paramsOrHrn.version >= 0) { - this.version = paramsOrHrn.version; - } + if (params.version !== undefined && params.version >= 0) { + this.version = params.version; } } @@ -184,25 +151,15 @@ export class VersionedLayerClient { } const partitionId = dataRequest.getPartitionId(); - let usingVersion: number | undefined; - const dataRequestVersion = dataRequest.getVersion(); - - if (dataRequestVersion !== undefined) { - usingVersion = dataRequestVersion; - } else { - usingVersion = this.version; - } - if (usingVersion === undefined) { + if (this.version === undefined) { // fetch the latest version and lock it to the instance. - usingVersion = await this.getLatestVersion( + this.version = await this.getLatestVersion( dataRequest.getBillingTag() ).catch(error => Promise.reject(error)); - - this.version = usingVersion; } - if (usingVersion === undefined) { + if (this.version === undefined) { return Promise.reject( new Error( `Unable to retrieve latest version. Please provide version to the DataRequest or lock version in the constructor` @@ -213,7 +170,6 @@ export class VersionedLayerClient { if (partitionId) { const partitionIdDataHandle = await this.getDataHandleByPartitionId( partitionId, - usingVersion, dataRequest.getFetchOption(), dataRequest.getBillingTag() ).catch(error => Promise.reject(error)); @@ -226,9 +182,9 @@ export class VersionedLayerClient { const quadKey = dataRequest.getQuadKey(); if (quadKey) { - const quadKeyPartitionsRequest = new QuadKeyPartitionsRequest() - .withQuadKey(quadKey) - .withVersion(usingVersion); + const quadKeyPartitionsRequest = new QuadKeyPartitionsRequest().withQuadKey( + quadKey + ); const quadTreeIndexResponse = await this.getPartitions( quadKeyPartitionsRequest @@ -303,25 +259,14 @@ export class VersionedLayerClient { request: QuadKeyPartitionsRequest | PartitionsRequest, abortSignal?: AbortSignal ): Promise { - let usingVersion: number | undefined; - const requestVersion = request.getVersion(); - - if (requestVersion !== undefined) { - usingVersion = requestVersion; - } else { - usingVersion = this.version; - } - - if (usingVersion === undefined) { + if (this.version === undefined) { // fetch the latest version and lock it to the instance. - usingVersion = await this.getLatestVersion( + this.version = await this.getLatestVersion( request.getBillingTag() ).catch(error => Promise.reject(error)); - - this.version = usingVersion; } - if (usingVersion === undefined) { + if (this.version === undefined) { return Promise.reject( new Error( `Unable to retrieve latest version. Please provide version to the Request or lock version in the constructor` @@ -345,7 +290,7 @@ export class VersionedLayerClient { "versioned" ) .withQuadKey(quadKey) - .withVersion(usingVersion) + .withVersion(this.version) .withDepth(request.getDepth()) .withAdditionalFields(request.getAdditionalFields()); @@ -357,13 +302,12 @@ export class VersionedLayerClient { if (request.getPartitionIds()) { const queryClient = new QueryClient(this.settings); - - request.withVersion(usingVersion); return queryClient.getPartitionsById( request, this.layerId, HRN.fromString(this.hrn), - abortSignal + abortSignal, + this.version ); } @@ -372,7 +316,8 @@ export class VersionedLayerClient { const partitions = cache.get( request, this.hrn.toString(), - this.layerId + this.layerId, + this.version ); if (partitions) { const additionalFields = request.getAdditionalFields(); @@ -409,7 +354,7 @@ export class VersionedLayerClient { ).catch(error => Promise.reject(error)); const metadata = await MetadataApi.getPartitions(metaRequestBilder, { - version: usingVersion, + version: this.version, layerId: this.layerId, additionalFields: request.getAdditionalFields(), billingTag: request.getBillingTag() @@ -423,7 +368,8 @@ export class VersionedLayerClient { request, this.hrn.toString(), this.layerId, - metadata.partitions + metadata.partitions, + this.version ); } return Promise.resolve(metadata); @@ -438,7 +384,6 @@ export class VersionedLayerClient { */ private async getDataHandleByPartitionId( partitionId: string, - version: number, fetchOption: FetchOptions, billingTag?: string ): Promise { @@ -446,7 +391,6 @@ export class VersionedLayerClient { const partitionsRequest = new PartitionsRequest() .withPartitionIds([partitionId]) - .withVersion(version) .withFetchOption(fetchOption); if (billingTag) { @@ -456,7 +400,9 @@ export class VersionedLayerClient { const metadata = await queryClient.getPartitionsById( partitionsRequest, this.layerId, - HRN.fromString(this.hrn) + HRN.fromString(this.hrn), + undefined, + this.version ); return metadata.partitions && metadata.partitions[0] && diff --git a/@here/olp-sdk-dataservice-read/lib/client/VolatileLayerClient.ts b/@here/olp-sdk-dataservice-read/lib/client/VolatileLayerClient.ts index b6614d8c..9449af8f 100644 --- a/@here/olp-sdk-dataservice-read/lib/client/VolatileLayerClient.ts +++ b/@here/olp-sdk-dataservice-read/lib/client/VolatileLayerClient.ts @@ -64,61 +64,28 @@ export class VolatileLayerClient { /** * HRN of the catalog. - * @deprecated This field will be marked as private by 08.2020. */ - hrn: string; + private hrn: string; /** * The ID of the layer. - * @deprecated This field will be marked as private by 08.2020. */ - layerId: string; + private layerId: string; /** * The [[OlpClientSettings]] instance. - * @deprecated This field will be marked as private by 08.2020. - */ - settings: OlpClientSettings; - - /** - * @deprecated Please use the overloaded constructor of VolatileLayerClient. - * - * Creates the [[VolatileLayerClient]] instance. - * - * @param catalogHrn The HERE Resource Name of the catalog from which you want to get partitions metadata and data. - * @param layerId The ID of the layer. - * @param settings The [[OlpClientSettings]] instance. */ - constructor(catalogHrn: HRN, layerId: string, settings: OlpClientSettings); + private settings: OlpClientSettings; /** * Creates the [[VolatileLayerClient]] instance with VolatileLayerClientParams. * * @param params parameters for use to initialize VolatileLayerClient. */ - constructor(params: VolatileLayerClientParams); - - /** - * Implementation for handling both constuctors. - */ - constructor( - paramsOrHrn: VolatileLayerClientParams | HRN, - layerId?: string, - settings?: OlpClientSettings - ) { - if (paramsOrHrn instanceof HRN) { - this.hrn = paramsOrHrn.toString(); - if (layerId && settings instanceof OlpClientSettings) { - this.layerId = layerId; - this.settings = settings; - } else { - throw new Error("Unsupported parameters"); - } - } else { - this.hrn = paramsOrHrn.catalogHrn.toString(); - this.layerId = paramsOrHrn.layerId; - this.settings = paramsOrHrn.settings; - } + constructor(params: VolatileLayerClientParams) { + this.hrn = params.catalogHrn.toString(); + this.layerId = params.layerId; + this.settings = params.settings; } /** diff --git a/@here/olp-sdk-dataservice-read/test/unit/DataRequest.test.ts b/@here/olp-sdk-dataservice-read/test/unit/DataRequest.test.ts index d887a5fc..4a095305 100644 --- a/@here/olp-sdk-dataservice-read/test/unit/DataRequest.test.ts +++ b/@here/olp-sdk-dataservice-read/test/unit/DataRequest.test.ts @@ -55,7 +55,6 @@ describe("DataRequest", function() { mockedPartitionId ); const dataRequestWithDataLevel = dataRequest.withQuadKey(mockedQuadKey); - const dataRequestWithTimemap = dataRequest.withVersion(mockedVersion); const dataRequestWithBillTag = dataRequest.withBillingTag(billingTag); expect(dataRequestWithCatalogHrn.getDataHandle()).to.be.equal( @@ -67,7 +66,6 @@ describe("DataRequest", function() { expect(dataRequestWithDataLevel.getQuadKey()).to.be.equal( mockedQuadKey ); - expect(dataRequestWithTimemap.getVersion()).to.be.equal(mockedVersion); expect(dataRequestWithBillTag.getBillingTag()).to.be.equal(billingTag); }); @@ -76,13 +74,11 @@ describe("DataRequest", function() { .withDataHandle(mockedDataHandle) .withPartitionId(mockedPartitionId) .withQuadKey(mockedQuadKey) - .withVersion(mockedVersion) .withBillingTag(billingTag); expect(dataRequest.getDataHandle()).to.be.equal(mockedDataHandle); expect(dataRequest.getPartitionId()).to.be.equal(mockedPartitionId); expect(dataRequest.getQuadKey()).to.be.equal(mockedQuadKey); - expect(dataRequest.getVersion()).to.be.equal(mockedVersion); expect(dataRequest.getBillingTag()).to.be.equal(billingTag); }); }); diff --git a/@here/olp-sdk-dataservice-read/test/unit/IndexLayerClient.test.ts b/@here/olp-sdk-dataservice-read/test/unit/IndexLayerClient.test.ts index d3779fb3..63a1d0f7 100644 --- a/@here/olp-sdk-dataservice-read/test/unit/IndexLayerClient.test.ts +++ b/@here/olp-sdk-dataservice-read/test/unit/IndexLayerClient.test.ts @@ -36,7 +36,6 @@ describe("IndexLayerClient", function() { let getIndexStub: sinon.SinonStub; let getBaseUrlRequestStub: sinon.SinonStub; let indexLayerClient: dataServiceRead.IndexLayerClient; - let indexLayerClientNew: dataServiceRead.IndexLayerClient; const mockedHRN = dataServiceRead.HRN.fromString( "hrn:here:data:::mocked-hrn" ); @@ -48,18 +47,13 @@ describe("IndexLayerClient", function() { let settings = sandbox.createStubInstance( dataServiceRead.OlpClientSettings ); - indexLayerClient = new dataServiceRead.IndexLayerClient( - mockedHRN, - mockedLayerId, - (settings as unknown) as dataServiceRead.OlpClientSettings - ); const indexLayerClientParams = { catalogHrn: mockedHRN, layerId: mockedLayerId, settings: (settings as unknown) as dataServiceRead.OlpClientSettings }; - indexLayerClientNew = new dataServiceRead.IndexLayerClient( + indexLayerClient = new dataServiceRead.IndexLayerClient( indexLayerClientParams ); }); @@ -347,25 +341,7 @@ describe("IndexLayerClient", function() { }); it("IndexLayerClient instance should be initialized with IndexLayerClientParams", async function() { - assert.isDefined(indexLayerClientNew); - assert.equal(indexLayerClientNew["hrn"], "hrn:here:data:::mocked-hrn"); - }); - - it("IndexLayerClient should throw Error when setted unsuported parameters", async function() { - let settings1 = sandbox.createStubInstance( - dataServiceRead.OlpClientSettings - ); - - assert.throws( - function() { - new dataServiceRead.IndexLayerClient( - mockedHRN, - "", - (settings1 as unknown) as dataServiceRead.OlpClientSettings - ); - }, - Error, - "Unsupported parameters" - ); + assert.isDefined(indexLayerClient); + assert.equal(indexLayerClient["hrn"], "hrn:here:data:::mocked-hrn"); }); }); diff --git a/@here/olp-sdk-dataservice-read/test/unit/QuadKeyPartitionsRequest.test.ts b/@here/olp-sdk-dataservice-read/test/unit/QuadKeyPartitionsRequest.test.ts index ec764984..18232017 100644 --- a/@here/olp-sdk-dataservice-read/test/unit/QuadKeyPartitionsRequest.test.ts +++ b/@here/olp-sdk-dataservice-read/test/unit/QuadKeyPartitionsRequest.test.ts @@ -49,9 +49,6 @@ describe("QuadKeyPartitionsRequest", function() { it("Should set parameters", function() { const quadKeyPartitionsRequest = new QuadKeyPartitionsRequest(); - const quadKeyPartitionsRequestWithVersion = quadKeyPartitionsRequest.withVersion( - mockedVersion - ); const quadKeyPartitionsRequestWithDepth = quadKeyPartitionsRequest.withDepth( mockedDepth ); @@ -64,10 +61,6 @@ describe("QuadKeyPartitionsRequest", function() { const quadKeyPartitionsRequestWithAddFields = quadKeyPartitionsRequest.withAdditionalFields( ["dataSize", "checksum", "compressedDataSize", "crc"] ); - - expect(quadKeyPartitionsRequestWithVersion.getVersion()).to.be.equal( - mockedVersion - ); expect(quadKeyPartitionsRequestWithDepth.getDepth()).to.be.equal( mockedDepth ); @@ -84,7 +77,6 @@ describe("QuadKeyPartitionsRequest", function() { it("Should get parameters with chain", function() { const quadKeyPartitionsRequest = new QuadKeyPartitionsRequest() - .withVersion(mockedVersion) .withDepth(mockedDepth) .withQuadKey(mockedQuadKey) .withBillingTag(billingTag) @@ -95,9 +87,6 @@ describe("QuadKeyPartitionsRequest", function() { "crc" ]); - expect(quadKeyPartitionsRequest.getVersion()).to.be.equal( - mockedVersion - ); expect(quadKeyPartitionsRequest.getDepth()).to.be.equal(mockedDepth); expect(quadKeyPartitionsRequest.getQuadKey()).to.be.equal( mockedQuadKey diff --git a/@here/olp-sdk-dataservice-read/test/unit/VersionedLayerClient.test.ts b/@here/olp-sdk-dataservice-read/test/unit/VersionedLayerClient.test.ts index 2b1ffb35..9e99736b 100644 --- a/@here/olp-sdk-dataservice-read/test/unit/VersionedLayerClient.test.ts +++ b/@here/olp-sdk-dataservice-read/test/unit/VersionedLayerClient.test.ts @@ -40,9 +40,6 @@ describe("VersionedLayerClient", function() { let getVersionStub: sinon.SinonStub; let getBaseUrlRequestStub: sinon.SinonStub; let versionedLayerClient: dataServiceRead.VersionedLayerClient; - let versionedLayerClientWithVersion: dataServiceRead.VersionedLayerClient; - let versionedLayerClientWithoutVersion: dataServiceRead.VersionedLayerClient; - let versionedLayerClientTest: dataServiceRead.VersionedLayerClient; const mockedHRN = dataServiceRead.HRN.fromString( "hrn:here:data:::mocked-hrn" ); @@ -74,11 +71,6 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("token") }); - versionedLayerClient = new dataServiceRead.VersionedLayerClient( - mockedHRN, - mockedLayerId, - settings - ); const versionedLayerClientParams = { catalogHrn: mockedHRN, @@ -87,7 +79,7 @@ describe("VersionedLayerClient", function() { version: 5 }; - versionedLayerClientWithVersion = new dataServiceRead.VersionedLayerClient( + versionedLayerClient = new dataServiceRead.VersionedLayerClient( versionedLayerClientParams ); @@ -96,10 +88,6 @@ describe("VersionedLayerClient", function() { layerId: mockedLayerId, settings }; - - versionedLayerClientWithoutVersion = new dataServiceRead.VersionedLayerClient( - versionedLayerClientParamsWithoutVersion - ); }); beforeEach(function() { @@ -121,31 +109,10 @@ describe("VersionedLayerClient", function() { assert.isDefined(versionedLayerClient); }); - it("VersionedLayerClient should throw Error when setted unsuported parameters", async function() { - let settings1 = sandbox.createStubInstance( - dataServiceRead.OlpClientSettings - ); - - assert.throws( - function() { - new dataServiceRead.VersionedLayerClient( - mockedHRN, - "", - (settings1 as unknown) as dataServiceRead.OlpClientSettings - ); - }, - Error, - "Unsupported parameters" - ); - }); - it("VersionedLayerClient instance should be initialized with VersionedLayerClientParams", async function() { - assert.isDefined(versionedLayerClientWithVersion); - assert.equal(versionedLayerClientWithVersion["version"], 5); - assert.equal( - versionedLayerClientWithVersion["hrn"], - "hrn:here:data:::mocked-hrn" - ); + assert.isDefined(versionedLayerClient); + assert.equal(versionedLayerClient["version"], 5); + assert.equal(versionedLayerClient["hrn"], "hrn:here:data:::mocked-hrn"); }); it("Should method getData provide data with dataHandle parameter", async function() { @@ -247,9 +214,9 @@ describe("VersionedLayerClient", function() { } ); - const dataRequest = new dataServiceRead.DataRequest() - .withPartitionId("42") - .withVersion(2); + const dataRequest = new dataServiceRead.DataRequest().withPartitionId( + "42" + ); const response = await versionedLayerClient.getData( (dataRequest as unknown) as dataServiceRead.DataRequest @@ -299,9 +266,9 @@ describe("VersionedLayerClient", function() { } ); - const dataRequest = new dataServiceRead.DataRequest() - .withQuadKey(dataServiceRead.quadKeyFromMortonCode("23618403")) - .withVersion(42); + const dataRequest = new dataServiceRead.DataRequest().withQuadKey( + dataServiceRead.quadKeyFromMortonCode("23618403") + ); const response = await versionedLayerClient.getData( (dataRequest as unknown) as dataServiceRead.DataRequest @@ -324,9 +291,9 @@ describe("VersionedLayerClient", function() { }); it("Should method getData return Error with correct partitionId and wrong version parameter", async function() { - const dataRequest = new dataServiceRead.DataRequest() - .withVersion(100500) - .withPartitionId("42"); + const dataRequest = new dataServiceRead.DataRequest().withPartitionId( + "42" + ); const mockedPartitionsIdData = { status: 400, @@ -376,9 +343,9 @@ describe("VersionedLayerClient", function() { } ); - const dataRequest = new dataServiceRead.DataRequest() - .withPartitionId("42") - .withVersion(2); + const dataRequest = new dataServiceRead.DataRequest().withPartitionId( + "42" + ); const response = await versionedLayerClient .getData((dataRequest as unknown) as dataServiceRead.DataRequest) @@ -389,9 +356,9 @@ describe("VersionedLayerClient", function() { }); it("Should method getData return Error with correct quadKey and wrong version parameter", async function() { - const dataRequest = new dataServiceRead.DataRequest() - .withVersion(100500) - .withQuadKey(dataServiceRead.quadKeyFromMortonCode("23618403")); + const dataRequest = new dataServiceRead.DataRequest().withQuadKey( + dataServiceRead.quadKeyFromMortonCode("23618403") + ); const mockedPartitionsIdData = { status: 400, @@ -431,9 +398,9 @@ describe("VersionedLayerClient", function() { } ); - const dataRequest = new dataServiceRead.DataRequest() - .withQuadKey(dataServiceRead.quadKeyFromMortonCode("1111")) - .withVersion(42); + const dataRequest = new dataServiceRead.DataRequest().withQuadKey( + dataServiceRead.quadKeyFromMortonCode("1111") + ); const response = await versionedLayerClient .getData((dataRequest as unknown) as dataServiceRead.DataRequest) @@ -469,9 +436,9 @@ describe("VersionedLayerClient", function() { } ); - const dataRequest = new dataServiceRead.DataRequest() - .withPartitionId("42") - .withVersion(2); + const dataRequest = new dataServiceRead.DataRequest().withPartitionId( + "42" + ); const abortController = new AbortController(); @@ -848,9 +815,9 @@ describe("VersionedLayerClient", function() { it("Should getPartitions with quadKey error be handled", async function() { const mockedErrorResponse = "Bad response"; - const quadRrequest = new dataServiceRead.DataRequest() - .withQuadKey(dataServiceRead.quadKeyFromMortonCode("23618403")) - .withVersion(42); + const quadRrequest = new dataServiceRead.DataRequest().withQuadKey( + dataServiceRead.quadKeyFromMortonCode("23618403") + ); getVersionStub.callsFake(() => Promise.reject({ @@ -1007,7 +974,6 @@ describe("VersionedLayerClient", function() { request: dataServiceRead.PartitionsRequest, signal: AbortSignal ) { - expect(request.getVersion()).to.be.equal(5); expect(request.getPartitionIds()).contains("23605706"); expect(request.getAdditionalFields()).contains("dataSize"); return Promise.resolve(mockedPartitions); @@ -1024,7 +990,7 @@ describe("VersionedLayerClient", function() { .withPartitionIds(["23605706"]) .withAdditionalFields(["dataSize"]); - const partitions = await versionedLayerClientWithVersion.getPartitions( + const partitions = await versionedLayerClient.getPartitions( partitionsRequest ); expect(partitions).equals(mockedPartitions); @@ -1132,32 +1098,6 @@ describe("VersionedLayerClient with locked version 0 in constructor", function() expect(client["version"]).to.be.equal(0); }); - it("Method getPartitions should call queryClient.getPartitionsById with PartitionsRequest.getVersion() === 0", async function() { - const QueryClientStub = sandbox.stub(dataServiceRead, "QueryClient"); - - class MockedQueryClient { - getPartitionsById( - request: dataServiceRead.PartitionsRequest, - signal: AbortSignal - ) { - expect(request.getVersion()).to.be.equal(0); - } - } - - QueryClientStub.callsFake( - (settings: dataServiceRead.OlpClientSettings) => { - return new MockedQueryClient(); - } - ); - - await client.getPartitions( - new dataServiceRead.PartitionsRequest().withPartitionIds([ - "test-id1", - "test-id2" - ]) - ); - }); - it("Method getPartitions should call MetadataApi.getPartitions with param version === 0", async function() { // @ts-ignore class VersionedLayerClientTest extends dataServiceRead.VersionedLayerClient { diff --git a/@here/olp-sdk-dataservice-read/test/unit/VolatileLayerClient.test.ts b/@here/olp-sdk-dataservice-read/test/unit/VolatileLayerClient.test.ts index 000f21dd..cb7f977f 100644 --- a/@here/olp-sdk-dataservice-read/test/unit/VolatileLayerClient.test.ts +++ b/@here/olp-sdk-dataservice-read/test/unit/VolatileLayerClient.test.ts @@ -43,7 +43,6 @@ describe("VolatileLayerClient", function() { let getQuadTreeIndexStub: sinon.SinonStub; let getBaseUrlRequestStub: sinon.SinonStub; let volatileLayerClient: dataServiceRead.VolatileLayerClient; - let volatileLayerClientNew: dataServiceRead.VolatileLayerClient; const mockedHRN = dataServiceRead.HRN.fromString( "hrn:here:data:::mocked-hrn" ); @@ -76,18 +75,13 @@ describe("VolatileLayerClient", function() { environment: "here", getToken: () => Promise.resolve("token") }); - volatileLayerClient = new dataServiceRead.VolatileLayerClient( - mockedHRN, - mockedLayerId, - settings - ); const volatileLayerClientParams = { catalogHrn: mockedHRN, layerId: mockedLayerId, settings }; - volatileLayerClientNew = new dataServiceRead.VolatileLayerClient( + volatileLayerClient = new dataServiceRead.VolatileLayerClient( volatileLayerClientParams ); }); @@ -478,11 +472,11 @@ describe("VolatileLayerClient", function() { let settings = sandbox.createStubInstance( dataServiceRead.OlpClientSettings ); - const volatileClient = new dataServiceRead.VolatileLayerClient( - mockedHRN, - "mockedLayerId", - (settings as unknown) as dataServiceRead.OlpClientSettings - ); + const volatileClient = new dataServiceRead.VolatileLayerClient({ + catalogHrn: mockedHRN, + layerId: mockedLayerId, + settings: settings as any + }); const dataRequest = new dataServiceRead.DataRequest().withPartitionId( "42" @@ -617,29 +611,8 @@ describe("VolatileLayerClient", function() { }); it("VolatileLayerClient instance should be initialized with VolatileLayerClientParams", async function() { - assert.isDefined(volatileLayerClientNew); - assert.equal( - volatileLayerClientNew["hrn"], - "hrn:here:data:::mocked-hrn" - ); - }); - - it("VolatileLayerClient should throw Error when setted unsuported parameters", async function() { - let settings1 = sandbox.createStubInstance( - dataServiceRead.OlpClientSettings - ); - - assert.throws( - function() { - new dataServiceRead.VolatileLayerClient( - mockedHRN, - "", - (settings1 as unknown) as dataServiceRead.OlpClientSettings - ); - }, - Error, - "Unsupported parameters" - ); + assert.isDefined(volatileLayerClient); + assert.equal(volatileLayerClient["hrn"], "hrn:here:data:::mocked-hrn"); }); it("Method QueryApi.getPartitionsById should be called with param additionalFields and run getPartitions method with additionalFields", async function() { @@ -677,7 +650,7 @@ describe("VolatileLayerClient", function() { .withPartitionIds(["23605706"]) .withAdditionalFields(["dataSize"]); - const partitions = await volatileLayerClientNew.getPartitions( + const partitions = await volatileLayerClient.getPartitions( partitionsRequest ); expect(partitions).equals(mockedPartitions); diff --git a/tests/integration/api-breaks/DataRequest.test.ts b/tests/integration/api-breaks/DataRequest.test.ts index 97101359..a3625e71 100644 --- a/tests/integration/api-breaks/DataRequest.test.ts +++ b/tests/integration/api-breaks/DataRequest.test.ts @@ -82,8 +82,6 @@ describe("DataRequest", function() { assert.isDefined(request); expect(request).to.be.instanceOf(DataRequest); - assert.isFunction(request.withVersion); - assert.isFunction(request.getVersion); assert.isFunction(request.withQuadKey); assert.isFunction(request.getQuadKey); assert.isFunction(request.withPartitionId); diff --git a/tests/integration/api-breaks/IndexLayerClient.test.ts b/tests/integration/api-breaks/IndexLayerClient.test.ts index ef6f9010..fe6ea8f0 100644 --- a/tests/integration/api-breaks/IndexLayerClient.test.ts +++ b/tests/integration/api-breaks/IndexLayerClient.test.ts @@ -91,19 +91,16 @@ describe("IndexLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new IndexLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new IndexLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); assert.isDefined(layerClient); expect(layerClient).to.be.instanceOf(IndexLayerClient); assert.isFunction(layerClient.getData); assert.isFunction(layerClient.getPartitions); - assert.isDefined(layerClient.hrn); - assert.isDefined(layerClient.layerId); - assert.isDefined(layerClient.settings); }); it("Shoud be initialized with IndexLayerClientParams", async function() { @@ -120,9 +117,6 @@ describe("IndexLayerClient", function() { assert.isFunction(layerClient.getData); assert.isFunction(layerClient.getPartitions); - assert.isDefined(layerClient.hrn); - assert.isDefined(layerClient.layerId); - assert.isDefined(layerClient.settings); }); it("getPartitions method with IndexQueryRequest", async function() { diff --git a/tests/integration/api-breaks/LookupApi.test.ts b/tests/integration/api-breaks/LookupApi.test.ts index 1fd98134..7023e605 100644 --- a/tests/integration/api-breaks/LookupApi.test.ts +++ b/tests/integration/api-breaks/LookupApi.test.ts @@ -83,12 +83,6 @@ describe("LookupApi", function() { expect(result).to.be.equal("success"); }); - it("Test platformAPIList method without params", async function() { - const result = await LookupApi.platformAPIList(mockedRequestBuilder); - - expect(result).to.be.equal("success"); - }); - it("Test getPlatformAPIList method without params", async function() { const result = await LookupApi.getPlatformAPIList(mockedRequestBuilder); @@ -120,33 +114,6 @@ describe("LookupApi", function() { expect(result).to.be.equal("success"); }); - it("Test resourceAPIList method with all required params", async function() { - const params = { - hrn: "mocked-hrn" - }; - - const result = await LookupApi.resourceAPIList( - mockedRequestBuilder, - params - ); - - expect(result).to.be.equal("success"); - }); - - it("Test resourceAPIList method with all required and optional params", async function() { - const params = { - hrn: "mocked-hrn", - region: "mocked-region" - }; - - const result = await LookupApi.resourceAPIList( - mockedRequestBuilder, - params - ); - - expect(result).to.be.equal("success"); - }); - it("Test getResourceAPIList method with all required params", async function() { const params = { hrn: "mocked-hrn" diff --git a/tests/integration/api-breaks/QuadKeyPartitionsRequest.test.ts b/tests/integration/api-breaks/QuadKeyPartitionsRequest.test.ts index 0ab65e7d..aa8d63c2 100644 --- a/tests/integration/api-breaks/QuadKeyPartitionsRequest.test.ts +++ b/tests/integration/api-breaks/QuadKeyPartitionsRequest.test.ts @@ -84,9 +84,6 @@ describe("QuadKeyPartitionsRequest", function() { const request = new QuadKeyPartitionsRequest(); assert.isDefined(request); expect(request).to.be.instanceOf(QuadKeyPartitionsRequest); - - assert.isFunction(request.withVersion); - assert.isFunction(request.getVersion); assert.isFunction(request.withDepth); assert.isFunction(request.getDepth); assert.isFunction(request.withQuadKey); diff --git a/tests/integration/api-breaks/StreamApi.test.ts b/tests/integration/api-breaks/StreamApi.test.ts index dd201a07..7aacbfd3 100644 --- a/tests/integration/api-breaks/StreamApi.test.ts +++ b/tests/integration/api-breaks/StreamApi.test.ts @@ -272,44 +272,6 @@ describe("StreamApi", function() { assert.isDefined(params); }); - it("Test commitOffsets method with all required params", async function() { - const params = { - layerId: "mocked-id", - commitOffsets: { - offsets: [ - { - partition: 25, - offset: 3 - } - ] - } - }; - - const result = await StreamApi.commitOffsets(mockedRequestBuilder, params); - - expect(result).to.be.equal("success"); - }); - - it("Test commitOffsets method with all required and optional params", async function() { - const params = { - layerId: "mocked-id", - subscriptionId: "test-subscriptionId", - xCorrelationId: "test-xCorrelationId", - commitOffsets: { - offsets: [ - { - partition: 25, - offset: 3 - } - ] - } - }; - - const result = await StreamApi.commitOffsets(mockedRequestBuilder, params); - - expect(result).to.be.equal("success"); - }); - it("Test doCommitOffsets method with all required params", async function() { const params = { layerId: "mocked-id", diff --git a/tests/integration/api-breaks/VersionedLayerClient.test.ts b/tests/integration/api-breaks/VersionedLayerClient.test.ts index e4f44a4a..e7c2f57b 100644 --- a/tests/integration/api-breaks/VersionedLayerClient.test.ts +++ b/tests/integration/api-breaks/VersionedLayerClient.test.ts @@ -103,19 +103,16 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VersionedLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VersionedLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); assert.isDefined(layerClient); expect(layerClient).to.be.instanceOf(VersionedLayerClient); assert.isFunction(layerClient.getData); assert.isFunction(layerClient.getPartitions); - assert.isDefined(layerClient.hrn); - assert.isDefined(layerClient.layerId); - assert.isDefined(layerClient.settings); }); it("Shoud be initialized with VersionedLayerClientParams", async function() { @@ -132,9 +129,6 @@ describe("VersionedLayerClient", function() { assert.isFunction(layerClient.getData); assert.isFunction(layerClient.getPartitions); - assert.isDefined(layerClient.hrn); - assert.isDefined(layerClient.layerId); - assert.isDefined(layerClient.settings); }); it("getPartitions method with QuadKeyPartitionsRequest", async function() { diff --git a/tests/integration/api-breaks/VolatileLayerClient.test.ts b/tests/integration/api-breaks/VolatileLayerClient.test.ts index bf595911..91b7d1a8 100644 --- a/tests/integration/api-breaks/VolatileLayerClient.test.ts +++ b/tests/integration/api-breaks/VolatileLayerClient.test.ts @@ -102,19 +102,16 @@ describe("VolatileLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VolatileLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VolatileLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); assert.isDefined(layerClient); expect(layerClient).to.be.instanceOf(VolatileLayerClient); assert.isFunction(layerClient.getData); assert.isFunction(layerClient.getPartitions); - assert.isDefined(layerClient.hrn); - assert.isDefined(layerClient.layerId); - assert.isDefined(layerClient.settings); }); it("Shoud be initialized with VolatileLayerClientParams", async function() { @@ -131,9 +128,6 @@ describe("VolatileLayerClient", function() { assert.isFunction(layerClient.getData); assert.isFunction(layerClient.getPartitions); - assert.isDefined(layerClient.hrn); - assert.isDefined(layerClient.layerId); - assert.isDefined(layerClient.settings); }); it("getPartitions method with QuadKeyPartitionsRequest", async function() { diff --git a/tests/integration/bundles/umd/olp-sdk-dataservice-api-testCases.ts b/tests/integration/bundles/umd/olp-sdk-dataservice-api-testCases.ts index 832c4fc2..0683bbda 100644 --- a/tests/integration/bundles/umd/olp-sdk-dataservice-api-testCases.ts +++ b/tests/integration/bundles/umd/olp-sdk-dataservice-api-testCases.ts @@ -108,9 +108,7 @@ export const OlpSdkDataserviceApiTestCases: { callback: function() { assert(LookupApi !== undefined); assert(LookupApi.platformAPI !== undefined); - assert(LookupApi.platformAPIList !== undefined); assert(LookupApi.resourceAPI !== undefined); - assert(LookupApi.resourceAPIList !== undefined); } }, { diff --git a/tests/integration/olp-sdk-dataservice-read/Handling-versions.test.ts b/tests/integration/olp-sdk-dataservice-read/Handling-versions.test.ts index 95deb9dc..ee9ca434 100644 --- a/tests/integration/olp-sdk-dataservice-read/Handling-versions.test.ts +++ b/tests/integration/olp-sdk-dataservice-read/Handling-versions.test.ts @@ -67,324 +67,6 @@ describe("Handling versions in the requests classes and clients", function() { }); }); - it("Should use version 0 for getPartitions with PartitionsRequest.withVersion(0).withPartitionIds(['23605706']);", async function() { - const mockedResponses = new Map(); - - mockedResponses.set( - `https://api-lookup.data.api.platform.here.com/lookup/v1/resources/hrn:here:data::olp-here:rib-2/apis`, - new Response( - JSON.stringify([ - { - api: "query", - version: "v1", - baseURL: "https://query.data.api.platform.here.com/query/v1", - parameters: { - additionalProp1: "string", - additionalProp2: "string", - additionalProp3: "string" - } - } - ]), - { headers } - ) - ); - - const mockedPartitions = { - partitions: [ - { - checksum: "291f66029c232400e3403cd6e9cfd36e", - compressedDataSize: 1024, - dataHandle: "1b2ca68f-d4a0-4379-8120-cd025640510c", - dataSize: 1024, - crc: "c3f276d7", - partition: "23605706" - } - ], - next: "/uri/to/next/page" - }; - - mockedResponses.set( - `https://query.data.api.platform.here.com/query/v1/layers/topology-geometry/partitions?partition=23605706&version=0`, - new Response(JSON.stringify(mockedPartitions), { headers }) - ); - - // Setup the fetch to use mocked responses. - fetchMock.withMockedResponses(mockedResponses); - - const client = new VersionedLayerClient({ - catalogHrn: HRN.fromString("hrn:here:data::olp-here:rib-2"), - layerId: "topology-geometry", - version: 142, - settings - }); - - const rq = new PartitionsRequest() - .withVersion(0) - .withPartitionIds(["23605706"]); - - await client.getPartitions(rq); - - const callsToApi = fetchStub.getCalls(); - const callToQueryApi = callsToApi[1]; - - expect(callsToApi.length).equals(2); // First to lookup api, second to the Query API. - expect(callToQueryApi.args[0]).equals( - "https://query.data.api.platform.here.com/query/v1/layers/topology-geometry/partitions?partition=23605706&version=0&" + - SENT_WITH_PARAM - ); - }); - - it("Should use version 0 for getPartitions with QuadKeyPartitionsRequest.withVersion(0).withQuadKey(quadKeyFromMortonCode(23605706));", async function() { - const mockedResponses = new Map(); - - mockedResponses.set( - `https://api-lookup.data.api.platform.here.com/lookup/v1/resources/hrn:here:data::olp-here:rib-2/apis`, - new Response( - JSON.stringify([ - { - api: "query", - version: "v1", - baseURL: "https://query.data.api.platform.here.com/query/v1", - parameters: { - additionalProp1: "string", - additionalProp2: "string", - additionalProp3: "string" - } - } - ]), - { headers } - ) - ); - - const mockedPartitions = { - parentQuads: [ - { - additionalMetadata: "string", - checksum: "string", - compressedDataSize: 0, - dataHandle: "675911FF6236B7C7604BF8B105F1BB58", - dataSize: 0, - partition: "73982", - version: 0 - } - ], - subQuads: [ - { - additionalMetadata: "string", - checksum: "291f66029c232400e3403cd6e9cfd36e", - compressedDataSize: 200, - dataHandle: "1b2ca68f-d4a0-4379-8120-cd025640510c", - dataSize: 1024, - subQuadKey: "string", - version: 1 - } - ] - }; - - mockedResponses.set( - `https://query.data.api.platform.here.com/query/v1/layers/topology-geometry/versions/0/quadkeys/23605706/depths/0`, - new Response(JSON.stringify(mockedPartitions), { headers }) - ); - - // Setup the fetch to use mocked responses. - fetchMock.withMockedResponses(mockedResponses); - - const client = new VersionedLayerClient({ - catalogHrn: HRN.fromString("hrn:here:data::olp-here:rib-2"), - layerId: "topology-geometry", - version: 142, - settings - }); - - const rq = new QuadKeyPartitionsRequest() - .withVersion(0) - .withQuadKey(quadKeyFromMortonCode(23605706)); - - await client.getPartitions(rq); - - const callsToApi = fetchStub.getCalls(); - const callToQueryApi = callsToApi[1]; - - expect(callsToApi.length).equals(2); // First to lookup api, second to the Query API. - expect(callToQueryApi.args[0]).equals( - "https://query.data.api.platform.here.com/query/v1/layers/topology-geometry/versions/0/quadkeys/23605706/depths/0?" + - SENT_WITH_PARAM - ); - }); - - it("Should use version 0 for getData with DataRequest.withVersion(0).withQuadKey(quadKeyFromMortonCode(23605706));", async function() { - const mockedResponses = new Map(); - - mockedResponses.set( - `https://api-lookup.data.api.platform.here.com/lookup/v1/resources/hrn:here:data::olp-here:rib-2/apis`, - new Response( - JSON.stringify([ - { - api: "query", - version: "v1", - baseURL: "https://query.data.api.platform.here.com/query/v1", - parameters: { - additionalProp1: "string", - additionalProp2: "string", - additionalProp3: "string" - } - }, - { - api: "blob", - version: "v1", - baseURL: "https://blob.data.api.platform.here.com/blob/v1", - parameters: { - additionalProp1: "string", - additionalProp2: "string", - additionalProp3: "string" - } - } - ]), - { headers } - ) - ); - - const mockedPartitions = { - parentQuads: [ - { - additionalMetadata: "string", - checksum: "string", - compressedDataSize: 0, - dataHandle: "675911FF6236B7C7604BF8B105F1BB58", - dataSize: 0, - partition: "73982", - version: 0 - } - ], - subQuads: [ - { - additionalMetadata: "string", - checksum: "291f66029c232400e3403cd6e9cfd36e", - compressedDataSize: 200, - dataHandle: "1b2ca68f-d4a0-4379-8120-cd025640510c", - dataSize: 1024, - subQuadKey: "string", - version: 1 - } - ] - }; - - mockedResponses.set( - `https://query.data.api.platform.here.com/query/v1/layers/topology-geometry/versions/0/quadkeys/23605706/depths/0`, - new Response(JSON.stringify(mockedPartitions), { headers }) - ); - - mockedResponses.set( - `https://blob.data.api.platform.here.com/blob/v1/layers/topology-geometry/data/1b2ca68f-d4a0-4379-8120-cd025640510c`, - new Response(Buffer.alloc(42), { headers }) - ); - - // Setup the fetch to use mocked responses. - fetchMock.withMockedResponses(mockedResponses); - - const client = new VersionedLayerClient({ - catalogHrn: HRN.fromString("hrn:here:data::olp-here:rib-2"), - layerId: "topology-geometry", - version: 142, - settings - }); - - const rq = new DataRequest() - .withVersion(0) - .withQuadKey(quadKeyFromMortonCode(23605706)); - - await client.getData(rq); - - const callsToApi = fetchStub.getCalls(); - const callToQueryApi = callsToApi[1]; - - expect(callsToApi.length).equals(3); // 1 - lookup api, 1 - the Query API, 1 - blob API - expect(callToQueryApi.args[0]).equals( - "https://query.data.api.platform.here.com/query/v1/layers/topology-geometry/versions/0/quadkeys/23605706/depths/0?" + - SENT_WITH_PARAM - ); - }); - - it("Should use version 0 for getData with DataRequest.withVersion(0).withPartitionId('23605706');", async function() { - const mockedResponses = new Map(); - - mockedResponses.set( - `https://api-lookup.data.api.platform.here.com/lookup/v1/resources/hrn:here:data::olp-here:rib-2/apis`, - new Response( - JSON.stringify([ - { - api: "query", - version: "v1", - baseURL: "https://query.data.api.platform.here.com/query/v1", - parameters: { - additionalProp1: "string", - additionalProp2: "string", - additionalProp3: "string" - } - }, - { - api: "blob", - version: "v1", - baseURL: "https://blob.data.api.platform.here.com/blob/v1", - parameters: { - additionalProp1: "string", - additionalProp2: "string", - additionalProp3: "string" - } - } - ]), - { headers } - ) - ); - - const mockedPartitions = { - partitions: [ - { - checksum: "291f66029c232400e3403cd6e9cfd36e", - compressedDataSize: 1024, - dataHandle: "1b2ca68f-d4a0-4379-8120-cd025640510c", - dataSize: 1024, - crc: "c3f276d7", - partition: "23605706" - } - ], - next: "/uri/to/next/page" - }; - - mockedResponses.set( - `https://query.data.api.platform.here.com/query/v1/layers/topology-geometry/partitions?partition=23605706&version=0`, - new Response(JSON.stringify(mockedPartitions), { headers }) - ); - - mockedResponses.set( - `https://blob.data.api.platform.here.com/blob/v1/layers/topology-geometry/data/1b2ca68f-d4a0-4379-8120-cd025640510c`, - new Response(Buffer.alloc(42), { headers }) - ); - - // Setup the fetch to use mocked responses. - fetchMock.withMockedResponses(mockedResponses); - - const client = new VersionedLayerClient({ - catalogHrn: HRN.fromString("hrn:here:data::olp-here:rib-2"), - layerId: "topology-geometry", - version: 142, - settings - }); - - const rq = new DataRequest().withVersion(0).withPartitionId("23605706"); - - await client.getData(rq); - - const callsToApi = fetchStub.getCalls(); - const callToQueryApi = callsToApi[1]; - - expect(callsToApi.length).equals(3); // 1 - lookup api, 1 - the Query API, 1 - blob API - expect(callToQueryApi.args[0]).equals( - "https://query.data.api.platform.here.com/query/v1/layers/topology-geometry/partitions?partition=23605706&version=0&" + - SENT_WITH_PARAM - ); - }); - it("Should use locked version 142 for getPartitions with PartitionsRequest.withPartitionIds(['23605706']);", async function() { const mockedResponses = new Map(); diff --git a/tests/integration/olp-sdk-dataservice-read/IndexLayerClient.test.ts b/tests/integration/olp-sdk-dataservice-read/IndexLayerClient.test.ts index 3060805c..4e38b39b 100644 --- a/tests/integration/olp-sdk-dataservice-read/IndexLayerClient.test.ts +++ b/tests/integration/olp-sdk-dataservice-read/IndexLayerClient.test.ts @@ -62,11 +62,11 @@ describe("IndexLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const indexClient = new IndexLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const indexClient = new IndexLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); assert.isDefined(indexClient); expect(indexClient).to.be.instanceOf(IndexLayerClient); }); @@ -77,11 +77,11 @@ describe("IndexLayerClient", function() { getToken: () => Promise.resolve("test-token-string") }); try { - const indexClient = new IndexLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "", + const indexClient = new IndexLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "", settings - ); + }); } catch (error) { expect(error.message).equal("Unsupported parameters"); } @@ -155,11 +155,11 @@ describe("IndexLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const indexClient = new IndexLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const indexClient = new IndexLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); // Setup IndexQueryRequest with query parameter const request = new IndexQueryRequest().withQueryString("hour_from>0"); @@ -186,11 +186,11 @@ describe("IndexLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const indexClient = new IndexLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const indexClient = new IndexLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); const request = new IndexQueryRequest().withHugeResponse(true); const response = indexClient.getPartitions(request).catch(error => { expect(error.message).equal("Please provide correct query"); @@ -202,11 +202,11 @@ describe("IndexLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const indexClient = new IndexLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const indexClient = new IndexLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); const response = indexClient.getData({}).catch(error => { expect(error.message).equal("No data handle for this partition"); }); @@ -257,11 +257,11 @@ describe("IndexLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const indexClient = new IndexLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const indexClient = new IndexLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); const data = await indexClient.getData(mockedModel); diff --git a/tests/integration/olp-sdk-dataservice-read/StatisticsClient.test.ts b/tests/integration/olp-sdk-dataservice-read/StatisticsClient.test.ts index 54f71931..72cd2eac 100644 --- a/tests/integration/olp-sdk-dataservice-read/StatisticsClient.test.ts +++ b/tests/integration/olp-sdk-dataservice-read/StatisticsClient.test.ts @@ -209,7 +209,7 @@ describe("StatisticsClient", function() { const statisticsRequest = new StatisticsRequest() .withCatalogHrn(mockedHRN) .withLayerId(mockedLayerId) - .withDataLevel("3") + .withDataLevel(3) .withTypemap(CoverageDataType.TIMEMAP); const summaryResponse = await statisticsClient.getStatistics( @@ -256,7 +256,7 @@ describe("StatisticsClient", function() { const statisticsRequest = new StatisticsRequest() .withCatalogHrn(mockedHRN) .withLayerId(mockedLayerId) - .withDataLevel("3") + .withDataLevel(3) .withTypemap(CoverageDataType.SIZEMAP); const summaryResponse = await statisticsClient.getStatistics( @@ -303,7 +303,7 @@ describe("StatisticsClient", function() { const statisticsRequest = new StatisticsRequest() .withCatalogHrn(mockedHRN) .withLayerId(mockedLayerId) - .withDataLevel("3") + .withDataLevel(3) .withTypemap(CoverageDataType.BITMAP); const summaryResponse = await statisticsClient.getStatistics( diff --git a/tests/integration/olp-sdk-dataservice-read/VersionedLayerClient.test.ts b/tests/integration/olp-sdk-dataservice-read/VersionedLayerClient.test.ts index 3bf3d275..a55b42fc 100644 --- a/tests/integration/olp-sdk-dataservice-read/VersionedLayerClient.test.ts +++ b/tests/integration/olp-sdk-dataservice-read/VersionedLayerClient.test.ts @@ -69,11 +69,11 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VersionedLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VersionedLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); assert.isDefined(layerClient); expect(layerClient).to.be.instanceOf(VersionedLayerClient); }); @@ -84,11 +84,11 @@ describe("VersionedLayerClient", function() { getToken: () => Promise.resolve("test-token-string") }); try { - const layerClient = new VersionedLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "", + const layerClient = new VersionedLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "", settings - ); + }); } catch (error) { expect(error.message).equal("Unsupported parameters"); } @@ -207,11 +207,11 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VersionedLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VersionedLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); // Setup PartitionsRequest to filter response by partition IDs 100 and 1000. const request = new PartitionsRequest().withPartitionIds(["100", "1000"]); @@ -330,11 +330,11 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VersionedLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VersionedLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); // Setup PartitionsRequest without any parameters const request = new PartitionsRequest(); @@ -414,11 +414,11 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VersionedLayerClient( - testHRN, - testLayerId, + const layerClient = new VersionedLayerClient({ + catalogHrn: testHRN, + layerId: testLayerId, settings - ); + }); const request = new DataRequest().withDataHandle(mockedDataHandle); const data = await layerClient.getData(request); @@ -509,11 +509,11 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VersionedLayerClient( - testHRN, - testLayerId, + const layerClient = new VersionedLayerClient({ + catalogHrn: testHRN, + layerId: testLayerId, settings - ); + }); const request = new DataRequest().withPartitionId(mockedPartitionId); const data = await layerClient.getData(request); @@ -522,88 +522,6 @@ describe("VersionedLayerClient", function() { expect(fetchStub.callCount).to.be.equal(4); }); - it("Shoud be fetched data with PartitionId and version", async function() { - const mockedResponses = new Map(); - const mockedPartitionId = "0000042"; - const mockedData = Buffer.alloc(42); - const mockedPartitionsIdData = { - partitions: [ - { - version: 1, - partition: "0000042", - dataHandle: "3C3BE24A341D82321A9BA9075A7EF498.123" - }, - { - version: 42, - partition: "0000013", - dataHandle: "3C3BE24A341D82321A9BA9075A7EF498.123" - } - ] - }; - - mockedResponses.set( - `https://query.data.api.platform.here.com/query/v1/layers/test-layed-id/partitions?partition=0000042&version=42`, - new Response(JSON.stringify(mockedPartitionsIdData), { headers }) - ); - - // Set the response from lookup api with the info about Metadata service. - mockedResponses.set( - `https://api-lookup.data.api.platform.here.com/lookup/v1/resources/hrn:here:data:::test-hrn/apis`, - new Response( - JSON.stringify([ - { - api: "blob", - version: "v1", - baseURL: "https://blob.data.api.platform.here.com/blob/v1", - parameters: { - additionalProp1: "string", - additionalProp2: "string", - additionalProp3: "string" - } - }, - { - api: "query", - version: "v1", - baseURL: "https://query.data.api.platform.here.com/query/v1", - parameters: { - additionalProp1: "string", - additionalProp2: "string", - additionalProp3: "string" - } - } - ]), - { headers } - ) - ); - - // Set the response of mocked partitions from metadata service. - mockedResponses.set( - `https://blob.data.api.platform.here.com/blob/v1/layers/test-layed-id/data/3C3BE24A341D82321A9BA9075A7EF498.123`, - new Response(mockedData, { headers }) - ); - - // Setup the fetch to use mocked responses. - fetchMock.withMockedResponses(mockedResponses); - - const settings = new OlpClientSettings({ - environment: "here", - getToken: () => Promise.resolve("test-token-string") - }); - const layerClient = new VersionedLayerClient( - testHRN, - testLayerId, - settings - ); - const request = new DataRequest() - .withPartitionId(mockedPartitionId) - .withVersion(42); - - const data = await layerClient.getData(request); - - assert.isDefined(data); - expect(fetchStub.callCount).to.be.equal(3); // 1 - lookup, 1 - query, 1 - blob - }); - it("Shoud be fetched data with QuadKey", async function() { const mockedResponses = new Map(); const mockedQuadKey = quadKeyFromMortonCode("23618403"); @@ -688,11 +606,11 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VersionedLayerClient( - testHRN, - testLayerId, + const layerClient = new VersionedLayerClient({ + catalogHrn: testHRN, + layerId: testLayerId, settings - ); + }); const request = new DataRequest().withQuadKey(mockedQuadKey); const data = await layerClient.getData(request); @@ -701,90 +619,6 @@ describe("VersionedLayerClient", function() { expect(fetchStub.callCount).to.be.equal(4); }); - it("Shoud be fetched data with QuadKey and Version", async function() { - const mockedResponses = new Map(); - const mockedQuadKey = quadKeyFromMortonCode("23618403"); - const mockedData = Buffer.alloc(42); - const mockedQuadKeyTreeData = { - subQuads: [ - { - version: 12, - subQuadKey: "1", - dataHandle: "c9116bb9-7d00-44bf-9b26-b4ab4c274665" - } - ], - parentQuads: [ - { - version: 12, - partition: "23618403", - dataHandle: "da51785a-54b0-40cd-95ac-760f56fe5457" - } - ] - }; - - mockedResponses.set( - `https://query.data.api.platform.here.com/query/v1/layers/test-layed-id/versions/42/quadkeys/23618403/depths/0`, - new Response(JSON.stringify(mockedQuadKeyTreeData), { headers }) - ); - - // Set the response from lookup api with the info about Metadata service. - mockedResponses.set( - `https://api-lookup.data.api.platform.here.com/lookup/v1/resources/hrn:here:data:::test-hrn/apis`, - new Response( - JSON.stringify([ - { - api: "blob", - version: "v1", - baseURL: "https://blob.data.api.platform.here.com/blob/v1", - parameters: { - additionalProp1: "string", - additionalProp2: "string", - additionalProp3: "string" - } - }, - { - api: "query", - version: "v1", - baseURL: "https://query.data.api.platform.here.com/query/v1", - parameters: { - additionalProp1: "string", - additionalProp2: "string", - additionalProp3: "string" - } - } - ]), - { headers } - ) - ); - - // Set the response of mocked partitions from metadata service. - mockedResponses.set( - `https://blob.data.api.platform.here.com/blob/v1/layers/test-layed-id/data/c9116bb9-7d00-44bf-9b26-b4ab4c274665`, - new Response(mockedData, { headers }) - ); - - // Setup the fetch to use mocked responses. - fetchMock.withMockedResponses(mockedResponses); - - const settings = new OlpClientSettings({ - environment: "here", - getToken: () => Promise.resolve("test-token-string") - }); - const layerClient = new VersionedLayerClient( - testHRN, - testLayerId, - settings - ); - const request = new DataRequest() - .withQuadKey(mockedQuadKey) - .withVersion(42); - - const data = await layerClient.getData(request); - - assert.isDefined(data); - expect(fetchStub.callCount).to.be.equal(3); // 1 - lookup, 1 - query, 1 - blob - }); - it("Shoud read partitions metadata by QuadKey for specific VersionLayer", async function() { const mockedResponses = new Map(); @@ -874,19 +708,17 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VersionedLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", - settings - ); + const layerClient = new VersionedLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", + settings, + version: mockedVersion + }); const quadKeyPartitionsRequest = new QuadKeyPartitionsRequest(); assert.isDefined(quadKeyPartitionsRequest); expect(quadKeyPartitionsRequest).be.instanceOf(QuadKeyPartitionsRequest); - const quadKeyPartitionsRequestWithVersion = quadKeyPartitionsRequest.withVersion( - mockedVersion - ); const quadKeyPartitionsRequestWithDepth = quadKeyPartitionsRequest.withDepth( mockedDepth ); @@ -896,10 +728,6 @@ describe("VersionedLayerClient", function() { const quadKeyPartitionsRequestWithBillTag = quadKeyPartitionsRequest.withBillingTag( billingTag ); - - expect(quadKeyPartitionsRequestWithVersion.getVersion()).to.be.equal( - mockedVersion - ); expect(quadKeyPartitionsRequestWithDepth.getDepth()).to.be.equal( mockedDepth ); @@ -984,11 +812,11 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VersionedLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VersionedLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); const requestWithAdditionalFields = new PartitionsRequest() .withAdditionalFields(["dataSize", "checksum", "compressedDataSize"]) @@ -1090,11 +918,11 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VersionedLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VersionedLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); const quadKeyPartitionsRequest = new QuadKeyPartitionsRequest(); assert.isDefined(quadKeyPartitionsRequest); @@ -1296,11 +1124,11 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VersionedLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VersionedLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); const requestWithoutAdditionalFields = new PartitionsRequest() .withFetchOption(FetchOptions.OnlineIfNotFound) @@ -1414,11 +1242,11 @@ describe("VersionedLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VersionedLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VersionedLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); const requestWithAdditionalFields = new PartitionsRequest() .withAdditionalFields(["dataSize", "checksum", "compressedDataSize"]) diff --git a/tests/integration/olp-sdk-dataservice-read/VolatileLayerClient.test.ts b/tests/integration/olp-sdk-dataservice-read/VolatileLayerClient.test.ts index 276db6cb..3d62e263 100644 --- a/tests/integration/olp-sdk-dataservice-read/VolatileLayerClient.test.ts +++ b/tests/integration/olp-sdk-dataservice-read/VolatileLayerClient.test.ts @@ -68,11 +68,11 @@ describe("VolatileLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VolatileLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VolatileLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); assert.isDefined(layerClient); expect(layerClient).to.be.instanceOf(VolatileLayerClient); }); @@ -83,11 +83,11 @@ describe("VolatileLayerClient", function() { getToken: () => Promise.resolve("test-token-string") }); try { - const layerClient = new VolatileLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "", + const layerClient = new VolatileLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "", settings - ); + }); } catch (error) { expect(error.message).equal("Unsupported parameters"); } @@ -154,11 +154,11 @@ describe("VolatileLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VolatileLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VolatileLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); // Setup PartitionsRequest to filter response by partition IDs 100 and 1000. const request = new PartitionsRequest().withPartitionIds(["100", "1000"]); @@ -258,11 +258,11 @@ describe("VolatileLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VolatileLayerClient( - testHRN, - testVolatileLayerId, + const layerClient = new VolatileLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); const request = new DataRequest().withPartitionId(mockedPartitionId); @@ -332,11 +332,11 @@ describe("VolatileLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VolatileLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VolatileLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); // Setup PartitionsRequest without any parameters const request = new PartitionsRequest(); @@ -410,11 +410,11 @@ describe("VolatileLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VolatileLayerClient( - testHRN, - testVolatileLayerId, + const layerClient = new VolatileLayerClient({ + catalogHrn: testHRN, + layerId: testVolatileLayerId, settings - ); + }); const request = new DataRequest().withDataHandle(mockedDataHandle); const data = await layerClient.getData(request); @@ -505,11 +505,11 @@ describe("VolatileLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VolatileLayerClient( - testHRN, - testVolatileLayerId, + const layerClient = new VolatileLayerClient({ + catalogHrn: testHRN, + layerId: testVolatileLayerId, settings - ); + }); const request = new DataRequest().withQuadKey(mockedQuadKey); const data = await layerClient.getData(request); @@ -606,11 +606,11 @@ describe("VolatileLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VolatileLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VolatileLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); const quadKeyPartitionsRequest = new QuadKeyPartitionsRequest(); assert.isDefined(quadKeyPartitionsRequest); @@ -703,11 +703,11 @@ describe("VolatileLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VolatileLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VolatileLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); const requestWithAdditionalFields = new PartitionsRequest().withAdditionalFields( ["dataSize", "checksum", "compressedDataSize"] @@ -808,11 +808,11 @@ describe("VolatileLayerClient", function() { environment: "here", getToken: () => Promise.resolve("test-token-string") }); - const layerClient = new VolatileLayerClient( - HRN.fromString("hrn:here:data:::test-hrn"), - "test-layed-id", + const layerClient = new VolatileLayerClient({ + catalogHrn: HRN.fromString("hrn:here:data:::test-hrn"), + layerId: "test-layed-id", settings - ); + }); const quadKeyPartitionsRequest = new QuadKeyPartitionsRequest(); assert.isDefined(quadKeyPartitionsRequest); diff --git a/tests/performance/getDataMemoryTest.ts b/tests/performance/getDataMemoryTest.ts index 37f5df41..191339e4 100644 --- a/tests/performance/getDataMemoryTest.ts +++ b/tests/performance/getDataMemoryTest.ts @@ -42,11 +42,11 @@ export async function getDataMemoryTest(params: TestParams) { let countFailedRequests = 0; const endTimestamp = new Date(new Date().getTime() + 1000 * runTimeSeconds); - const layerClient = new VersionedLayerClient( - HRN.fromString("hrn:local:data::olp-here:mocked-catalog"), - "mocked-layer", + const layerClient = new VersionedLayerClient({ + catalogHrn: HRN.fromString("hrn:local:data::olp-here:mocked-catalog"), + layerId: "mocked-layer", settings - ); + }); const dataRequest = new DataRequest(); diff --git a/tests/performance/getDataPartitionsTest.ts b/tests/performance/getDataPartitionsTest.ts index 4729f568..7a0c06f6 100644 --- a/tests/performance/getDataPartitionsTest.ts +++ b/tests/performance/getDataPartitionsTest.ts @@ -42,11 +42,11 @@ export async function getPartitionsMemoryTest(params: TestParams) { let countFailedRequests = 0; const endTimestamp = new Date(new Date().getTime() + 1000 * runTimeSeconds); - const layerClient = new VersionedLayerClient( - HRN.fromString("hrn:local:data::olp-here:mocked-catalog"), - "mocked-layer", + const layerClient = new VersionedLayerClient({ + catalogHrn: HRN.fromString("hrn:local:data::olp-here:mocked-catalog"), + layerId: "mocked-layer", settings - ); + }); const partitionsRequest = new PartitionsRequest();