Skip to content

Commit bdaf597

Browse files
authored
Sorting parameter list - chaoshandleroptions (#334)
1 parent 130f3c0 commit bdaf597

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

docs/ChaosHandlerSamples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ client
6666
// OverRiding to Random mode, providing the chaos percentage as 60(percentage times the error would be generated from handler)
6767
client
6868
.api("/me")
69-
.middlewareOptions([new MicrosoftGraph.ChaosHandlerOptions(MicrosoftGraph.ChaosStrategy.RANDOM, undefined, "I generated the error", 60)])
69+
.middlewareOptions([new MicrosoftGraph.ChaosHandlerOptions(MicrosoftGraph.ChaosStrategy.RANDOM, "I generated the error", undefined, 60)])
7070
.get()
7171
.then((res) => {
7272
console.log(res);

spec/development/workload/PageIterator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ describe("PageIterator", function() {
113113
return true;
114114
};
115115

116-
const middlewareOptions = [new ChaosHandlerOptions(ChaosStrategy.MANUAL, 200, "middleware options for pageIterator", 0, responseBody)];
116+
const middlewareOptions = [new ChaosHandlerOptions(ChaosStrategy.MANUAL, "middleware options for pageIterator", 200, 0, responseBody)];
117117
const requestOptions = { middlewareOptions };
118118

119119
const client = Client.initWithMiddleware(clientOptions);

spec/middleware/ChaosHandler.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe("ChaosHandler.ts", () => {
5858
};
5959

6060
it("Should return a valid response object for MANUAL case", () => {
61-
chaosHandler["createResponse"](new ChaosHandlerOptions(ChaosStrategy.MANUAL, 404), cxt);
61+
chaosHandler["createResponse"](new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Manual response", 404), cxt);
6262
assert.isDefined(cxt.response);
6363
});
6464

@@ -90,7 +90,7 @@ describe("ChaosHandler.ts", () => {
9090
});
9191

9292
it("Should send the request to the graph", async () => {
93-
handler["sendRequest"](new ChaosHandlerOptions(ChaosStrategy.RANDOM, undefined, "I generated the error", 100), cxt);
93+
handler["sendRequest"](new ChaosHandlerOptions(ChaosStrategy.RANDOM, "I generated the error", undefined, 100), cxt);
9494
assert.isDefined(cxt.response);
9595
});
9696
});
@@ -143,13 +143,13 @@ describe("ChaosHandler.ts", () => {
143143
const tempChaosHandlerManualRegex = new ChaosHandler(tempManualOptionsRegex, manualMap);
144144

145145
it("Should set a statusCode for MANUAL mode", () => {
146-
const tempOptions = new ChaosHandlerOptions(ChaosStrategy.MANUAL, 404);
146+
const tempOptions = new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Set status code", 404);
147147
chaosHandler["setStatusCode"](tempOptions, "https://graph.microsoft.com/v1.0/me", RequestMethod.GET);
148148
assert.isDefined(tempOptions.statusCode);
149149
});
150150

151151
it("Should set a statusCode for RANDOM mode", () => {
152-
const tempOptions = new ChaosHandlerOptions(ChaosStrategy.RANDOM, undefined, "I generated the error", 100);
152+
const tempOptions = new ChaosHandlerOptions(ChaosStrategy.RANDOM, "I generated the error", undefined, 100);
153153
chaosHandler["setStatusCode"](tempOptions, "https://graph.microsoft.com/v1.0/me", RequestMethod.POST);
154154
assert.isDefined(tempOptions.statusCode);
155155
});
@@ -167,7 +167,7 @@ describe("ChaosHandler.ts", () => {
167167

168168
describe("getOptions", () => {
169169
it("Should return the options in the context object", () => {
170-
const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, 405);
170+
const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Get options", 405);
171171
const cxt: Context = {
172172
request: "url",
173173
middlewareControl: new MiddlewareControl([options]),
@@ -240,7 +240,7 @@ describe("ChaosHandler.ts", () => {
240240
});
241241

242242
it("Should return response for Manual Request Level case", async () => {
243-
const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, 200);
243+
const options = new ChaosHandlerOptions(ChaosStrategy.MANUAL, "Manual Request level case", 200);
244244
const cxt: Context = {
245245
request: "https://graph.microsoft.com/v1.0/me",
246246
options: {

src/middleware/options/ChaosHandlerOptions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ export class ChaosHandlerOptions implements MiddlewareOptions {
6060
* @constructor
6161
* To create an instance of Testing Handler Options
6262
* @param {ChaosStrategy} ChaosStrategy - Specifies the startegy used for the Testing Handler -> RAMDOM/MANUAL
63-
* @param {number?} statusCode - The statusCode to be returned in the response
6463
* @param {string} statusMessage - The Message to be returned in the response
64+
* @param {number?} statusCode - The statusCode to be returned in the response
6565
* @param {number?} chaosPercentage - The percentage of randomness/chaos in the handler
6666
* @param {any?} responseBody - The response body to be returned in the response
6767
* @returns An instance of ChaosHandlerOptions
6868
*/
69-
public constructor(chaosStrategy: ChaosStrategy = ChaosStrategy.RANDOM, statusCode?: number, statusMessage: string = "Some error Happened", chaosPercentage?: number, responseBody?: any) {
69+
public constructor(chaosStrategy: ChaosStrategy = ChaosStrategy.RANDOM, statusMessage: string = "Some error Happened", statusCode?: number, chaosPercentage?: number, responseBody?: any) {
7070
this.chaosStrategy = chaosStrategy;
7171
this.statusCode = statusCode;
7272
this.statusMessage = statusMessage;

0 commit comments

Comments
 (0)