summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/test/test.component.html30
-rw-r--r--src/app/test/test.component.spec.ts193
-rw-r--r--src/app/test/test.component.ts27
3 files changed, 136 insertions, 114 deletions
diff --git a/src/app/test/test.component.html b/src/app/test/test.component.html
index 3519007..c2eb22e 100644
--- a/src/app/test/test.component.html
+++ b/src/app/test/test.component.html
@@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
-->
<simple-notifications [options]="options"></simple-notifications>
@@ -26,7 +25,7 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
<div class="card" style=" margin-bottom: 23px;">
<div class="card-block" style="border-top: 5px solid #6ab344;border-top-right-radius: 7px;border-top-left-radius: 7px;">
- <div class="row">
+ <div class="row" style="padding: 10px 15px">
<div class="col-lg-3 col-sm-6 col-md-4 col-xs-12">
<label>Action:</label>
<input class="form-control" type="text" disabled value="{{action}}" />
@@ -43,7 +42,8 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
<input class="form-control" disabled type="text" [(ngModel)]="this.actionIdentifiers['vserver-id']" />
</div>
-
+ </div>
+ <div class="row" style="padding: 10px 15px">
<div class="col-12">
<div class="input-group">
@@ -98,9 +98,11 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
<div class="col-md-12">
<div class="row justify-content-center" style="padding-top:0.3cm">
- <button style="margin-left:6%;" [disabled]="!enableTestButton" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" type="submit" (click)="testVnf()">Execute Test
+
+ <button style="margin-left:6%;" [disabled]="!enableTestButton" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary"
+ type="submit" (click)="testVnf()">Execute Test
</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
-
+
</div>
</div>
@@ -110,7 +112,7 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
</div>
<div style="padding-left:60%;padding-bottom:0.5cm">
- <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" type="button" [disabled]="!enableDownload" (click)="download()">Download Raw Request/Response
+ <button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" type="button" [disabled]="!enableDownload" (click)="download()">Download Raw Request/Response
</button>
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent" type="button" [disabled]="!enableAbort" (click)="abortTest()">Abort Test
</button>
@@ -121,22 +123,22 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
<div class="card">
<div class="card-block">
- <div class="mdl-dialog__content" style="border:solid 1px grey;overflow:scroll;overflow-x:hidden;overflow-y:hidden;">
+ <div class="mdl-dialog__content" style="border:solid 1px grey;">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label" style="margin-left: 25%">
<input placeholder="Request Id" [(ngModel)]="requestId" class="mdl-textfield__input" id="requestId" required name="requestId">
- </div>
- <button type="submit" [disabled]="!enablePollButton" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" (click)=pollTestStatus()>Poll Test Status
+ </div><br/>
+ <button style="margin-left: 30%" type="submit" [disabled]="!enablePollButton" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--primary" (click)=pollTestStatus()>Poll Test Status
</button>
-
+ <br/><br/>
<div class="col-md-12">
<span style="margin-left: 18.5%"><b>POLL TEST STATUS RESPONSE</b></span>
</div>
<div style="margin-left: 18.5%;height:100px;width:60%;border:solid 2px grey;overflow:scroll;overflow-x:hidden;overflow-y:hidden;">
- <div *ngIf="showStatusResponseDiv">
- <div *ngIf="enableCounterDiv"><b>Poll test no {{pollCounter}}</b></div>
+ <div *ngIf="showStatusResponseDiv">
+ <div *ngIf="enableCounterDiv"><b>Poll test no {{pollCounter}}</b></div>
<table>
<thead></thead>
<tbody>
@@ -168,9 +170,9 @@ ECOMP is a trademark and service mark of AT&T Intellectual Property.
</table>
</div>
<div *ngIf="!showStatusResponseDiv">
- <div *ngIf="enableCounterDiv"><b>Poll test no {{pollCounter}}</b></div>
+ <div *ngIf="enableCounterDiv"><b>Poll test no {{pollCounter}}</b></div>
<span>{{statusResponse}}</span>
- </div>
+ </div>
<div *ngIf="errorResponse">
<p style="height:450px;" disabled class="text-center">
diff --git a/src/app/test/test.component.spec.ts b/src/app/test/test.component.spec.ts
index 830effd..15dde6c 100644
--- a/src/app/test/test.component.spec.ts
+++ b/src/app/test/test.component.spec.ts
@@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
@@ -91,7 +90,7 @@ describe('TestComponent', () => {
component.pollTestStatus();
expect(service).toBeTruthy();
-
+
}));
// Test download Method
@@ -178,9 +177,9 @@ describe('TestComponent', () => {
it('should execute if file extension is XLS, XLSX', () => {
let reader = new FileReader();
- let file = new File(["testing"], "foo.XLS", {type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})
+ let file = new File(["testing"], "foo.XLS", { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" })
let fileExtension = 'XLS';
- let event = { isTrusted: true, type: "change", target: {files: [file]} }
+ let event = { isTrusted: true, type: "change", target: { files: [file] } }
component.upload(event);
@@ -190,10 +189,10 @@ describe('TestComponent', () => {
it('should return an error if file extension is not XLS, XLSX', () => {
let reader = new FileReader();
- let file = new File(["testing"], "foo.doc", {type: ""})
+ let file = new File(["testing"], "foo.doc", { type: "" })
let fileExtension = 'doc';
- let event = { isTrusted: true, type: "change", target: {files: [file]} }
-
+ let event = { isTrusted: true, type: "change", target: { files: [file] } }
+
component.upload(event);
expect(reader instanceof FileReader).toBeTruthy();
@@ -201,7 +200,7 @@ describe('TestComponent', () => {
});
it('Should return an error is files length is not equal to 1', () => {
-
+
});
});
@@ -287,35 +286,35 @@ describe('TestComponent', () => {
});
it('should return response on success', inject([MockBackend], (mockBackend: MockBackend) => {
- let mockData = 'testing';
- let response = new ResponseOptions({
- body: JSON.stringify(mockData)
- });
- const baseResponse = new Response(response);
- mockBackend.connections.subscribe(
- (c: MockConnection) => {
- c.mockRespond(baseResponse)
- }
- );
-
- component.action = 'ConfigModify';
-
- component.testVnf();
+ let mockData = 'testing';
+ let response = new ResponseOptions({
+ body: JSON.stringify(mockData)
+ });
+ const baseResponse = new Response(response);
+ mockBackend.connections.subscribe(
+ (c: MockConnection) => {
+ c.mockRespond(baseResponse)
+ }
+ );
+
+ component.action = 'ConfigModify';
+
+ component.testVnf();
}));
- it('should return an error if fails', inject([HttpUtilService],( httpUtilService: HttpUtilService) => {
- let error = 'Error in connecting to APPC Server';
- let spy = spyOn(httpUtilService, 'post').and.returnValue(Observable.throw(error));
- component.action = 'ConfigModify';
-
- component.testVnf();
+ it('should return an error if fails', inject([HttpUtilService], (httpUtilService: HttpUtilService) => {
+ let error = 'Error in connecting to APPC Server';
+ let spy = spyOn(httpUtilService, 'post').and.returnValue(Observable.throw(error));
+ component.action = 'ConfigModify';
- expect(spy).toHaveBeenCalled();
- expect(component.enableBrowse).toBeTruthy();
- expect(component.enableTestButton).toBeTruthy();
- expect(component.enablePollButton).toBeTruthy();
- expect(component.enableCounterDiv).toBeFalsy();
- }));
+ component.testVnf();
+
+ expect(spy).toHaveBeenCalled();
+ expect(component.enableBrowse).toBeTruthy();
+ expect(component.enableTestButton).toBeTruthy();
+ expect(component.enablePollButton).toBeTruthy();
+ expect(component.enableCounterDiv).toBeFalsy();
+ }));
it('test setTimeout', inject([NgProgress], (ngProgress: NgProgress) => {
let spy = spyOn(ngProgress, 'done');
@@ -334,64 +333,80 @@ describe('TestComponent', () => {
it('should call fake server', inject([MockBackend], (mockBackend: MockBackend) => {
component.requestId = new Date().getTime().toString();
- component.actionIdentifiers['vnf-id'] = 123456;
- let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"FAILED\",\"status\":\"FAILED\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } } ;
- let response = new ResponseOptions({
- body: JSON.stringify(mockData)
- });
- const baseResponse = new Response(response);
- mockBackend.connections.subscribe(
- (c: MockConnection) => c.mockRespond(baseResponse)
- );
-
- component.pollTestStatus();
+ component.actionIdentifiers['vnf-id'] = 123456;
+ let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"FAILED\",\"status\":\"FAILED\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } };
+ let response = new ResponseOptions({
+ body: JSON.stringify(mockData)
+ });
+ const baseResponse = new Response(response);
+ mockBackend.connections.subscribe(
+ (c: MockConnection) => c.mockRespond(baseResponse)
+ );
+
+ component.pollTestStatus();
}));
it('should call fake server if status is success', inject([MockBackend], (mockBackend: MockBackend) => {
- component.requestId = new Date().getTime().toString();
- component.actionIdentifiers['vnf-id'] = 123456;
- let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"SUCCESS\",\"status\":\"SUCCESS\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } } ;
- let response = new ResponseOptions({
- body: JSON.stringify(mockData)
- });
- const baseResponse = new Response(response);
- mockBackend.connections.subscribe(
- (c: MockConnection) => c.mockRespond(baseResponse)
- );
-
- component.pollTestStatus();
- }));
-
- it('should execute else part if timeStamp && status && statusReason are false', inject([MockBackend], (mockBackend: MockBackend) => {
- component.requestId = new Date().getTime().toString();
- component.actionIdentifiers['vnf-id'] = 123456;
- let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"FAILED\",\"status\":\"\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } } ;
- let response = new ResponseOptions({
- body: JSON.stringify(mockData)
- });
- const baseResponse = new Response(response);
- mockBackend.connections.subscribe(
- (c: MockConnection) => c.mockRespond(baseResponse)
- );
-
- component.pollTestStatus();
- }));
-
- it('should return an error if fails', inject([MockBackend], (mockBackend: MockBackend) => {
- let error = 'Error Connecting to APPC server';
- component.requestId = new Date().getTime().toString();
- component.actionIdentifiers['vnf-id'] = 123456;
- let mockData = '';
- let response = new ResponseOptions({
- body: JSON.stringify(mockData)
- });
- const baseResponse = new Response(response);
- mockBackend.connections.subscribe(
- (c: MockConnection) => c.mockError(new Error(error))
- );
-
- component.pollTestStatus();
- }));
+ component.requestId = new Date().getTime().toString();
+ component.actionIdentifiers['vnf-id'] = 123456;
+ let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"SUCCESS\",\"status\":\"SUCCESS\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } };
+ let response = new ResponseOptions({
+ body: JSON.stringify(mockData)
+ });
+ const baseResponse = new Response(response);
+ mockBackend.connections.subscribe(
+ (c: MockConnection) => c.mockRespond(baseResponse)
+ );
+
+ component.pollTestStatus();
+ }));
+
+ it('should check error condition on polling where timestamp and test status are not available', inject([MockBackend], (mockBackend: MockBackend) => {
+ component.requestId = new Date().getTime().toString();
+ component.actionIdentifiers['vnf-id'] = 123456;
+ //let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"FAILED\",\"status\":\"\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } } ;
+ let mockData = { "output": { "common-header": { "timestamp": "2018-03-21T14:20:30.910Z", "api-ver": "2.00", "request-id": "1521642030910", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 }, "originator-id": "CDT", "sub-request-id": "1521642030910" }, "status": { "message": "INVALID INPUT PARAMETER - vserver-id", "code": 301 } } };
+ let response = new ResponseOptions({
+ body: JSON.stringify(mockData)
+ });
+ const baseResponse = new Response(response);
+ mockBackend.connections.subscribe(
+ (c: MockConnection) => c.mockRespond(baseResponse)
+ );
+
+ component.pollTestStatus();
+ }));
+
+ it('should execute else part if timeStamp && status && statusReason are false', inject([MockBackend], (mockBackend: MockBackend) => {
+ component.requestId = new Date().getTime().toString();
+ component.actionIdentifiers['vnf-id'] = 123456;
+ let mockData = { "output": { "common-header": { "originator-id": "CDT", "sub-request-id": "653018029941", "timestamp": "2018-02-12T07:27:21.448Z", "api-ver": "2.00", "request-id": "653018029941", "flags": { "force": "TRUE", "mode": "NORMAL", "ttl": 3600 } }, "payload": "{\"status-reason\":\"FAILED\",\"status\":\"\"}", "status": { "message": "SUCCESS - request has been processed successfully", "code": 400 } } };
+ let response = new ResponseOptions({
+ body: JSON.stringify(mockData)
+ });
+ const baseResponse = new Response(response);
+ mockBackend.connections.subscribe(
+ (c: MockConnection) => c.mockRespond(baseResponse)
+ );
+
+ component.pollTestStatus();
+ }));
+
+ it('should return an error if fails', inject([MockBackend], (mockBackend: MockBackend) => {
+ let error = 'Error Connecting to APPC server';
+ component.requestId = new Date().getTime().toString();
+ component.actionIdentifiers['vnf-id'] = 123456;
+ let mockData = '';
+ let response = new ResponseOptions({
+ body: JSON.stringify(mockData)
+ });
+ const baseResponse = new Response(response);
+ mockBackend.connections.subscribe(
+ (c: MockConnection) => c.mockError(new Error(error))
+ );
+
+ component.pollTestStatus();
+ }));
});
// Test getUrlEndPoint Method
diff --git a/src/app/test/test.component.ts b/src/app/test/test.component.ts
index a7516ec..2fd8525 100644
--- a/src/app/test/test.component.ts
+++ b/src/app/test/test.component.ts
@@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-ECOMP is a trademark and service mark of AT&T Intellectual Property.
============LICENSE_END============================================
*/
@@ -194,7 +193,7 @@ export class TestComponent implements OnInit {
this.showStatusResponseDiv = false;
this.errorResponse = '';
this.statusResponse = '';
- this.enableDownload=true;
+ this.enableDownload = true;
let arrData = (<AOA>(XLSX.utils.sheet_to_json(ws, { blankrows: false })));
@@ -210,10 +209,10 @@ export class TestComponent implements OnInit {
// Refactor
this.payload = this.processUploadedFile(arrData);
this.uploadedFileResult();
- };
+ };
reader.readAsBinaryString(target.files[0]);
-
+
}
else {
@@ -236,7 +235,7 @@ export class TestComponent implements OnInit {
}
}
-processUploadedFile(arrData) {
+ processUploadedFile(arrData) {
let tempPayload = {};
for (var i = 0; i < arrData.length; i++) {
var element = arrData[i];
@@ -252,7 +251,7 @@ processUploadedFile(arrData) {
}
}
-
+
if (element['List Name'] === 'payload') {
var listName1 = element['List Name_1'];
var listName2 = element['List Name_2'];
@@ -280,7 +279,7 @@ processUploadedFile(arrData) {
return tempPayload;
}
- uploadedFileResult() {
+ uploadedFileResult() {
if (this.action && this.actionIdentifiers['vnf-id']) {
this.nService.success('Success', 'SpreadSheet uploaded successfully');
}
@@ -459,23 +458,29 @@ processUploadedFile(arrData) {
}
else {
this.showStatusResponseDiv = false;
+ if (this.subscribe && this.subscribe != undefined) {
+ this.subscribe.unsubscribe();
+ this.enablePollButton = true;
+ }
+
}
-
},
error => {
this.statusResponse = null;
this.showStatusResponseDiv = false;
this.errorResponse = 'Error Connecting to APPC server';
this.enableCounterDiv = false;
- if (this.subscribe && this.subscribe != undefined) this.subscribe.unsubscribe();
+ if (this.subscribe && this.subscribe != undefined) {
+ this.subscribe.unsubscribe();
+ this.enablePollButton = true;
+ }
});
-
}
else {
this.nService.error("Error", "Please enter vnf Id & request Id");
}
-
+
}
getUrlEndPoint(action) {