diff options
Diffstat (limited to 'ecomp-sdk')
3 files changed, 160 insertions, 22 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtilsTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtilsTest.java index 1a7d2a8e..9d9f9124 100644 --- a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtilsTest.java +++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/system/fusion/RemoteDbUtilsTest.java @@ -70,4 +70,15 @@ public class RemoteDbUtilsTest { } + @Test + public void testClearConnection() + { + RemoteDbUtils remoteDbUtils=new RemoteDbUtils(); + try { + remoteDbUtils.clearConnection(connection); + } + catch(NullPointerException e) { + } + } + } diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts index 1dab68ba..8d9003fc 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/form-fields/form-fields.component.spec.ts @@ -6,6 +6,7 @@ import { FormsModule } from '@angular/forms'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { MatDialogModule, MatSnackBarModule } from '@angular/material'; import { CommonModule } from '@angular/common'; +import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; describe('FormFieldsComponent', () => { let component: FormFieldsComponent; @@ -15,7 +16,13 @@ describe('FormFieldsComponent', () => { TestBed.configureTestingModule({ schemas:[CUSTOM_ELEMENTS_SCHEMA], declarations: [ FormFieldsComponent ], - imports:[FormsModule,HttpClientTestingModule,MatDialogModule,MatSnackBarModule] + imports:[ + FormsModule, + HttpClientTestingModule, + MatDialogModule, + MatSnackBarModule, + // BrowserAnimationsModule + ] }) .compileComponents(); })); @@ -50,4 +57,102 @@ describe('FormFieldsComponent', () => { } }); + it('should test setDisplayMode method',()=>{ + component.setDisplayMode("setDisplayMode"); + }); + + it('should test edit method',()=>{ + component.edit("Id"); + + }) + + it('should test add method',()=>{ + component.add(); + expect(component.showDialog).toBe(true); + expect(component.closable).toBe(true); + expect(component.validationType).toEqual(""); + expect(component.visible).toEqual("YES"); + expect(component.message).toBe(""); + expect(component.groupFormField).toBe(false); + expect(component.fieldType).toBe(""); + expect(component.fieldSQL).toBe(""); + expect(component.fieldName).toBe(""); + expect(component.fieldId).toBe(""); + expect(component.fieldDefaultSQL).toBe(''); + expect(component.errorStackTrace).toBe(""); + expect(component.errorMessage).toBe(""); + expect(component.defaultValue).toBe(false); + expect(component.predefinedValueList).toEqual([]); + expect(component.showDialog).toBe(true); + expect(component.closable).toBe(true); + expect(component.mode).toEqual("Add"); + }); + + it('should test close method1',()=>{ + component.showDialog=true; + component.close(); + expect(component.showDialog).toBe(false); + expect(component.closable).toBe(false); + }); + + it('should test close method2',()=>{ + component.showDialog=false; + component.close(); + expect(component.showDialog).toBe(true); + expect(component.closable).toBe(false); +}); + + it('should test loseValidateModal method1',()=>{ + component.showDialog1=true; + component.closeValidateModal(); + expect(component.showDialog1).toBe(false); + expect(component.showVerifySpinner).toBe(false); + }) + + it('should test loseValidateModal method2',()=>{ + component.showDialog1=false; + component.closeValidateModal(); + expect(component.showDialog1).toBe(true); + expect(component.showVerifySpinner).toBe(false); +}); + +it('should test addToList method',()=>{ + component.addToList("attrib") + { + expect(component.predefinedValueList.pop()).toEqual({id:'attrib', name:'attrib',selected:false}); + } +}); + +it('should test deleteFromList method',()=>{ +component.deleteFromList("attrib"); +}); + +it('should test save method',()=>{ + component.save(); + expect(component.showSpinner).toBe(true); + expect(component.showDialog).toBe(false); + expect(component.finalPOSTObj["validationType"]).toEqual(component.validationType); + if(component.visible=="YES") + expect(component.finalPOSTObj["visible"]).toBe(true); + else + expect(component.finalPOSTObj["visible"]).toBe(false); + expect(component.finalPOSTObj["orderSeq"]).toEqual(component.orderSeq); + expect(component.finalPOSTObj["message"]).toEqual(component.message); + expect(component.finalPOSTObj["groupFormField"]).toEqual(component.groupFormField); + expect(component.finalPOSTObj["fieldType"]).toEqual(component.fieldType); + expect(component.finalPOSTObj["fieldSQL"]).toEqual(component.fieldSQL); + expect(component.finalPOSTObj["fieldName"]).toEqual(component.fieldName); + expect(component.finalPOSTObj["fieldId"]).toEqual(component.fieldId); + expect(component.finalPOSTObj["errorStackTrace"]).toEqual(component.errorStackTrace); + expect(component.finalPOSTObj["errorMessage"]).toEqual(component.errorMessage); + expect(component.finalPOSTObj["defaultValue"]).toEqual(component.defaultValue); + if(component.defaultValue===false) + expect(component.finalPOSTObj["fieldDefaultSQL"]).toBe(null); + else + expect(component.finalPOSTObj["fieldDefalultSQL"]).toEqual(component.fieldDefaultSQL); + expect(component.finalPOSTObj["predefinedValueList"]).toEqual(component.predefinedValueList); + +}); + + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts index 96dcdbaa..9e1cd459 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-dashboard-report/run-dashboard-report.component.spec.ts @@ -6,6 +6,12 @@ import { RouterModule } from '@angular/router'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { DashboardReportService } from './dashboard-report.service'; +import { MockBackend, MockConnection } from '@angular/http/testing'; +import { Http, BaseRequestOptions } from '@angular/http'; +import { Observable } from 'rxjs'; +import 'rxjs/add/observable/empty'; +import 'rxjs/add/observable/of'; +import { environment } from 'src/environments/environment'; describe('RunDashboardReportComponent', () => { let component: RunDashboardReportComponent; @@ -17,7 +23,13 @@ describe('RunDashboardReportComponent', () => { schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [ RunDashboardReportComponent ], imports: [MatTableModule, RouterTestingModule, HttpClientTestingModule], - providers: [DashboardReportService] + providers:[DashboardReportService, MockBackend, BaseRequestOptions, { + provide: Http, + useFactory: (backend: MockBackend, defaultOptions: BaseRequestOptions) => { + return new Http(backend, defaultOptions); + }, + deps: [MockBackend, BaseRequestOptions], + }] }) .compileComponents(); dashboardService = TestBed.get(DashboardReportService); @@ -49,10 +61,13 @@ describe('RunDashboardReportComponent', () => { expect(component.dataSource.paginator).toEqual(component.paginator); }); - it('should test ngOnChanges method', () => { - component.initialQueryString !== component.queryString; + it('should test ngOnChanges methods if condition', () => { + + component.hitCnt = 1; + component.queryString = "testing" + component.initialQueryString === "test"; component.initCounter > 0; - component.runButtonHitCounter !== component.hitCnt; + component.runButtonHitCounter === 2; component.ngOnChanges(); expect(component.initialQueryString).toEqual(component.queryString); @@ -67,26 +82,33 @@ describe('RunDashboardReportComponent', () => { }); - it('should test afterViewInitProcesses method', () => { - component.afterViewInitProcesses(); - expect(component.displayedColumnsArr).toEqual(new Array()); - expect(component.displayedRowObj).toEqual(new Array()); - expect(component.displayedColumns).toEqual(new Array()); - expect(component.formFieldList).toEqual(new Array()); - expect(component.showSpinner).toEqual(true); - expect(component.isReady).toEqual(false); - expect(component.NEWdisplayedColumns).toEqual(new Array()); - - dashboardService.getReportDataWithFormFields("dummy", "test").subscribe((Response) => { - expect(component.formFieldPresent).toEqual(false); - expect(component.responseFormFieldListLength).toEqual(0); - expect(component.reportName).toEqual(Response["reportName"]); - }); - }); - it('should test applyFilter method', () => { component.applyFilter("testing"); expect(component.dataSource.filter).toEqual("testing".trim().toLowerCase()); }); + + it('should test afterViewInitProcesses method', () => { + component.afterViewInitProcesses(); + expect(component.displayedColumnsArr).toEqual(new Array()); + expect(component.displayedRowObj).toEqual(new Array()); + expect(component.displayedColumns).toEqual(new Array()); + expect(component.formFieldList).toEqual(new Array()); + expect(component.showSpinner).toEqual(true); + expect(component.isReady).toEqual(false); + expect(component.NEWdisplayedColumns).toEqual(new Array()); + }); + + describe('Should test afterViewInitProcesses', () => { + it('should validate on afterViewInitProcesses subscribe return', () => { + let spy = spyOn(dashboardService, 'getReportDataWithFormFields') + .and.returnValue(Observable.of()); + component.afterViewInitProcesses(); + // expect(component.formFieldPresent).toEqual(false); + // expect(component.responseFormFieldListLength).toEqual(0); + expect(spy).toHaveBeenCalled(); + + }); +}); + });
\ No newline at end of file |