Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
e6be3d6
update to version 2.2.0
nikithauc Nov 30, 2020
a67b348
Merge pull request #360 from microsoftgraph/nikithauc/Release-2.2.0
nikithauc Nov 30, 2020
2e0d321
- moves msal dependency to runtime deps
baywet Dec 1, 2020
1c7ef46
2.2.1
baywet Dec 1, 2020
9ab641d
Merge pull request #363 from microsoftgraph/hotfix/msal-dependency
nikithauc Dec 1, 2020
434b79e
Update to 3.0.0
nikithauc Aug 2, 2021
9114591
Merge branch 'master' into release/3.0.0
nikithauc Aug 2, 2021
a3ee95d
Merge pull request #492 from microsoftgraph/release/3.0.0
nikithauc Aug 9, 2021
1001c98
upgrade to 3.0.1
nikithauc Nov 15, 2021
9a8444c
Merge branch 'master' into release/version-3.0.1
nikithauc Nov 15, 2021
5cf1dec
Merge pull request #532 from microsoftgraph/release/version-3.0.1
nikithauc Nov 15, 2021
253d3c1
Merge branch 'master' into release/3.0.2
nikithauc Feb 9, 2022
6e7a8bc
3.0.2
nikithauc Feb 9, 2022
0fe66a9
Merge pull request #623 from microsoftgraph/release/3.0.2
nikithauc Feb 9, 2022
025db4c
Merge branch 'master' into release/3.0.2-latest
nikithauc Feb 9, 2022
7f90118
Merge pull request #624 from microsoftgraph/release/3.0.2-latest
nikithauc Feb 9, 2022
48395a6
Patch release version 3.0.3 (#1021)
nikithauc Oct 27, 2022
797cb1b
Merge branch 'main' into nikithauc/build-pipeline-main
nikithauc Nov 2, 2022
5ddc625
update package.json
nikithauc Nov 2, 2022
58c4847
delete and recreate lock file
nikithauc Nov 2, 2022
56aae20
retry package-lock
nikithauc Nov 3, 2022
758bab9
Merge pull request #1034 from microsoftgraph/nikithauc/build-pipeline…
nikithauc Nov 3, 2022
160bcf3
Merge branch 'main' into nikithauc/build-contents-read-main
nikithauc Nov 3, 2022
54da278
Merge pull request #1036 from microsoftgraph/nikithauc/build-contents…
nikithauc Nov 3, 2022
c03eb36
Hotfix - Page iterator reset counter (#1046)
nikithauc Nov 10, 2022
916a945
v 3.0.4 (#1047)
nikithauc Nov 10, 2022
c67eff0
Merge branch 'main' into release/3.0.5
nikithauc Jan 18, 2023
6a4fbbb
update version
nikithauc Jan 18, 2023
e121c60
Merge branch 'dev' into release/3.0.5
nikithauc Jan 18, 2023
c633d51
Merge pull request #1142 from microsoftgraph/release/3.0.5
nikithauc Jan 30, 2023
859b100
Update ci-build-production.yml
nikithauc Jan 30, 2023
d331c76
Merge pull request #1159 from microsoftgraph/nikithauc/remove-node12
nikithauc Jan 30, 2023
1eeccac
Merge branch 'main' into dev
koros Sep 4, 2023
1c9704b
Merge branch 'dev' of https://github.com/microsoftgraph/msgraph-sdk-j…
koros Sep 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .azure-pipelines/ci-build-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ stages:
vmImage: windows-latest
strategy:
matrix:
Node 14:
NODE_VERSION: '14.x'
Node 16:
NODE_VERSION: '16.x'
Node 18:
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ test/development/secrets.ts
testResult.xml
test-results.xml

test-esm/lib/*
test-esm/lib/*
3 changes: 2 additions & 1 deletion src/tasks/PageIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class PageIterator {
* @private
* Member holding the current position on the collection
*/
private cursor: number
private cursor: number;

/**
* @public
Expand Down Expand Up @@ -161,6 +161,7 @@ export class PageIterator {

const response: PageCollection = await graphRequest.get();
this.collection = response.value;
this.cursor = 0;
this.nextLink = response["@odata.nextLink"];
this.deltaLink = response["@odata.deltaLink"];
}
Expand Down
86 changes: 85 additions & 1 deletion test/common/tasks/PageIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { assert } from "chai";

import { Client } from "../../../src/index";
import { ChaosHandler, ChaosHandlerOptions, ChaosStrategy, Client, ClientOptions } from "../../../src/index";
import { PageIterator, PageIteratorCallback } from "../../../src/tasks/PageIterator";
import { getClient } from "../../test-helper";

Expand Down Expand Up @@ -134,4 +134,88 @@ describe("PageIterator.ts", () => {
assert.isTrue(pageIterator.isComplete());
});
});
describe("Test iteration using ChaosHandler", () => {
it("testing with 5000 results in initial and next page", async () => {
const middleware = new ChaosHandler();

const getPageCollection = () => {
const initialPageResultValues: any[] = [];
for (let i = 0; i < 5000; i++) {
initialPageResultValues[i] = { event: "value" + i };
}
return {
value: initialPageResultValues,
"@odata.nextLink": "nextURL",
additionalContent: "additional content",
};
};
const clientOptions: ClientOptions = {
middleware,
};

const nextPageResultValues: any[] = [];

for (let i = 0; i < 5000; i++) {
nextPageResultValues[i] = { event: "valueNext" + i };
}
const responseBody = { value: nextPageResultValues };
let countNextPageResult = 0;
const callback: PageIteratorCallback = (data) => {

if (data["event"] === "valueNext" + countNextPageResult) {
countNextPageResult++;
}

return true;
};

const middlewareOptions = [new ChaosHandlerOptions(ChaosStrategy.MANUAL, "middleware options for pageIterator", 200, 0, JSON.stringify(responseBody), new Headers({ "Content-Type": "application/json", "content-length": "100" }))];
const requestOptions = { middlewareOptions };

const client = Client.initWithMiddleware(clientOptions);
const pageIterator = new PageIterator(client, getPageCollection(), callback, requestOptions);
await pageIterator.iterate();

assert.equal(countNextPageResult, 5000);
});

it("Evaluate next page result being fetched", async () => {
const middleware = new ChaosHandler();
const getPageCollection = () => {
return {
value: [{ event1: "value1" }, { event2: "value2" }],
"@odata.nextLink": "nextURL",
additionalContent: "additional content",
};
};
const clientOptions: ClientOptions = {
middleware,
};
const responseBody = { value: [{ event3: "value3" }, { event4: "value4" }] };
let counter = 1;
let countNextPageResult = 0;
const callback: PageIteratorCallback = (data) => {
assert.equal(data["event" + counter], "value" + counter);

if (data["event" + counter] === "value3") {
countNextPageResult++;
}

if (data["event" + counter] === "value4") {
countNextPageResult++;
}
counter++;
return true;
};

const middlewareOptions = [new ChaosHandlerOptions(ChaosStrategy.MANUAL, "middleware options for pageIterator", 200, 0, JSON.stringify(responseBody), new Headers({ "Content-Type": "application/json", "content-length": "100" }))];
const requestOptions = { middlewareOptions };

const client = Client.initWithMiddleware(clientOptions);
const pageIterator = new PageIterator(client, getPageCollection(), callback, requestOptions);
await pageIterator.iterate();

assert.equal(countNextPageResult, 2);
});
});
});
33 changes: 0 additions & 33 deletions test/development/workload/PageIterator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
import { Event } from "@microsoft/microsoft-graph-types";
import { assert } from "chai";

import { Client, ClientOptions } from "../../../src";
import { ChaosHandler } from "../../../src/middleware/ChaosHandler";
import { ChaosHandlerOptions } from "../../../src/middleware/options/ChaosHandlerOptions";
import { ChaosStrategy } from "../../../src/middleware/options/ChaosStrategy";
import { GraphRequestOptions, PageIterator, PageIteratorCallback } from "../../../src/tasks/PageIterator";
import { getClient } from "../test-helper";
const client = getClient();
Expand Down Expand Up @@ -91,33 +87,4 @@ describe("PageIterator", () => {
assert.isTrue(pageIterator.isComplete());
}
}).timeout(30 * 1000);

// TODO - Temporariliy commenting this test.
it("setting middleware with pageIterator", async () => {
const middleware = new ChaosHandler();
const getPageCollection = () => {
return {
value: [],
"@odata.nextLink": "nextURL",
additionalContent: "additional content",
};
};
const clientOptions: ClientOptions = {
middleware,
};
const responseBody = { value: [{ event1: "value1" }, { event2: "value2" }] };
let counter = 1;
const callback: PageIteratorCallback = (data) => {
assert.equal(data["event" + counter], "value" + counter);
counter++;
return true;
};

const middlewareOptions = [new ChaosHandlerOptions(ChaosStrategy.MANUAL, "middleware options for pageIterator", 200, 0, JSON.stringify(responseBody), new Headers({ "Content-Type": "application/json", "content-length": "100" }))];
const requestOptions = { middlewareOptions };

const client = Client.initWithMiddleware(clientOptions);
const pageIterator = new PageIterator(client, getPageCollection(), callback, requestOptions);
await pageIterator.iterate();
});
});