diff options
28 files changed, 706 insertions, 213 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java index 29cbca18..6003222b 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/ChartJSONHelper.java @@ -995,7 +995,8 @@ public class ChartJSONHelper { } else if (filter == 1 && (dc.isCreateInNewChart()==null || !dc.isCreateInNewChart().booleanValue())) { chartValueCols.add(dc); } - else if(filter == 0) chartValueCols.add(dc); + else if(filter == 0) + chartValueCols.add(dc); } else chartValueCols.add(dc); } // } else @@ -1067,113 +1068,138 @@ public class ChartJSONHelper { */ date = MMDDYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = SECFLAG; + if(date!=null) + formatFlag = SECFLAG; if(date==null) { date = EEEMMDDYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYOFTHEWEEKFLAG; + if(date!=null) + formatFlag = DAYOFTHEWEEKFLAG; } if(date==null) { date = MMDDYYYYHHMMFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MINFLAG; + if(date!=null) + formatFlag = MINFLAG; } if(date==null) { //MMDDYYYYHHFormat.setTimeZone(TimeZone.getTimeZone("UTC")); date = MMDDYYYYHHFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = HOURFLAG; + if(date!=null) + formatFlag = HOURFLAG; } if(date==null) { date = MMDDYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYFLAG; + if(date!=null) + formatFlag = DAYFLAG; } if(date==null) { date = YYYYMMDDFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYFLAG; + if(date!=null) + formatFlag = DAYFLAG; } if(date==null) { date = timestampFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = SECFLAG; + if(date!=null) + formatFlag = SECFLAG; } if(date==null) { date = timestampHrFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = HOURFLAG; + if(date!=null) + formatFlag = HOURFLAG; } if(date==null) { date = timestampDayFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYFLAG; + if(date!=null) + formatFlag = DAYFLAG; } if(date==null) { date = MONYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MONTHFLAG; + if(date!=null) + formatFlag = MONTHFLAG; } if(date==null) { date = MMYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MONTHFLAG; + if(date!=null) + formatFlag = MONTHFLAG; } if(date==null) { date = MMMMMDDYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYFLAG; + if(date!=null) + formatFlag = DAYFLAG; } if(date==null) { date = MONTHYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MONTHFLAG; + if(date!=null) + formatFlag = MONTHFLAG; } if(date==null) { date = YYYYMMDDHHMMSSFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = SECFLAG; + if(date!=null) + formatFlag = SECFLAG; } if(date==null) { date = YYYYMMDDHHMMFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MINFLAG; + if(date!=null) + formatFlag = MINFLAG; } if(date==null) { date = DDMONYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = SECFLAG; + if(date!=null) + formatFlag = SECFLAG; } if(date==null) { date = DDMONYYYYHHMMFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MINFLAG; + if(date!=null) + formatFlag = MINFLAG; } if(date==null) { date = DDMONYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYFLAG; + if(date!=null) + formatFlag = DAYFLAG; } if(date==null) { date = MMDDYYHHMMSSFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = SECFLAG; + if(date!=null) + formatFlag = SECFLAG; } if(date==null) { date = MMDDYYHHMMFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MINFLAG; + if(date!=null) + formatFlag = MINFLAG; } if(date==null) { date = MMDDYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYFLAG; + if(date!=null) + formatFlag = DAYFLAG; } if(date==null) { date = timestampFormat1.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = SECFLAG; + if(date!=null) + formatFlag = SECFLAG; } if(date==null) { date = MMDDYYYYHHMMZFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MINFLAG; + if(date!=null) + formatFlag = MINFLAG; } if(date==null) { date = YYYYFormat.parse(dateStr, new ParsePosition(0)); /* Some random numbers should not satisfy this year format. */ - if(dateStr.length()>4) date = null; - if(date!=null) formatFlag = YEARFLAG; + if(dateStr.length()>4) + date = null; + if(date!=null) + formatFlag = YEARFLAG; } if(date==null) date = null; @@ -1230,112 +1256,137 @@ public class ChartJSONHelper { */ date = MMDDYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = SECFLAG; + if(date!=null) + formatFlag = SECFLAG; if(date==null) { date = EEEMMDDYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYOFTHEWEEKFLAG; + if(date!=null) + formatFlag = DAYOFTHEWEEKFLAG; } if(date==null) { date = MMDDYYYYHHMMFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MINFLAG; + if(date!=null) + formatFlag = MINFLAG; } if(date==null) { //MMDDYYYYHHFormat.setTimeZone(TimeZone.getTimeZone("UTC")); date = MMDDYYYYHHFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = HOURFLAG; + if(date!=null) + formatFlag = HOURFLAG; } if(date==null) { date = MMDDYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYFLAG; + if(date!=null) + formatFlag = DAYFLAG; } if(date==null) { date = YYYYMMDDFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYFLAG; + if(date!=null) + formatFlag = DAYFLAG; } if(date==null) { date = timestampFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = SECFLAG; + if(date!=null) + formatFlag = SECFLAG; } if(date==null) { date = timestampHrFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = HOURFLAG; + if(date!=null) + formatFlag = HOURFLAG; } if(date==null) { date = timestampDayFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYFLAG; + if(date!=null) + formatFlag = DAYFLAG; } if(date==null) { date = MONYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MONTHFLAG; + if(date!=null) + formatFlag = MONTHFLAG; } if(date==null) { date = MMYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MONTHFLAG; + if(date!=null) + formatFlag = MONTHFLAG; } if(date==null) { date = MMMMMDDYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYFLAG; + if(date!=null) + formatFlag = DAYFLAG; } if(date==null) { date = MONTHYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MONTHFLAG; + if(date!=null) + formatFlag = MONTHFLAG; } if(date==null) { date = YYYYMMDDHHMMSSFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = SECFLAG; + if(date!=null) + formatFlag = SECFLAG; } if(date==null) { date = YYYYMMDDHHMMFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MINFLAG; + if(date!=null) + formatFlag = MINFLAG; } if(date==null) { date = DDMONYYYYHHMMSSFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = SECFLAG; + if(date!=null) + formatFlag = SECFLAG; } if(date==null) { date = DDMONYYYYHHMMFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MINFLAG; + if(date!=null) + formatFlag = MINFLAG; } if(date==null) { date = DDMONYYYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYFLAG; + if(date!=null) + formatFlag = DAYFLAG; } if(date==null) { date = MMDDYYHHMMSSFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = SECFLAG; + if(date!=null) + formatFlag = SECFLAG; } if(date==null) { date = MMDDYYHHMMFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MINFLAG; + if(date!=null) + formatFlag = MINFLAG; } if(date==null) { date = MMDDYYFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = DAYFLAG; + if(date!=null) + formatFlag = DAYFLAG; } if(date==null) { date = timestampFormat1.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = SECFLAG; + if(date!=null) + formatFlag = SECFLAG; } if(date==null) { date = MMDDYYYYHHMMZFormat.parse(dateStr, new ParsePosition(0)); - if(date!=null) formatFlag = MINFLAG; + if(date!=null) + formatFlag = MINFLAG; } if(date==null) { date = YYYYFormat.parse(dateStr, new ParsePosition(0)); /* Some random numbers should not satisfy this year format. */ - if(dateStr.length()>4) date = null; - if(date!=null) formatFlag = YEARFLAG; + if(dateStr.length()>4) + date = null; + if(date!=null) + formatFlag = YEARFLAG; } if(date==null) date = null; @@ -1362,8 +1413,10 @@ public class ChartJSONHelper { public boolean getBooleanValue(String s, Boolean defaultValue) { s = nvl(s); - if(s.length()<=0 && defaultValue!=null) return defaultValue.booleanValue(); - else if(s.length()<=0) return false; + if(s.length()<=0 && defaultValue!=null) + return defaultValue.booleanValue(); + else if(s.length()<=0) + return false; else { if(s.toUpperCase().startsWith("Y") || s.toLowerCase().equals("true")) return true; @@ -1468,7 +1521,8 @@ public class ChartJSONHelper { value.append("("); } for(int j = 0 ; j < vals.length; j++) { - if(isMultiValue) value.append("'"); + if(isMultiValue) + value.append("'"); try { if(vals[j] !=null && vals[j].length() > 0) { vals[j] = Utils.oracleSafe(vals[j]); @@ -1483,7 +1537,8 @@ public class ChartJSONHelper { } - if(isMultiValue) value.append("'"); + if(isMultiValue) + value.append("'"); if(j != vals.length -1) { value.append(","); diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java index 178410ab..3af59e56 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java @@ -70,7 +70,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.regex.Matcher; -import java.util.regex.Pattern; +import java.util.regex.Pattern; import org.onap.portalsdk.analytics.error.RaptorRuntimeException; import org.onap.portalsdk.analytics.error.UserDefinedException; @@ -80,7 +80,6 @@ import org.onap.portalsdk.analytics.model.base.IdNameSql; import org.onap.portalsdk.analytics.model.base.IdNameValue; import org.onap.portalsdk.analytics.system.AppUtils; import org.onap.portalsdk.analytics.system.ConnectionUtils; -import org.onap.portalsdk.analytics.system.ExecuteQuery; import org.onap.portalsdk.analytics.system.Globals; import org.onap.portalsdk.analytics.util.DataSet; import org.onap.portalsdk.analytics.util.Utils; diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessor.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessor.java index b0eb81a3..0805b22c 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessor.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormatProcessor.java @@ -274,7 +274,8 @@ public class FormatProcessor extends RaptorObject { } } - if( anyFormatter == null ) anyFormatter = formatter; + if( anyFormatter == null ) + anyFormatter = formatter; // String sValue = convertValue(dv.getDisplayValue()); //if (sValue.length() > 0) { for (Iterator iter = semaphore.getFormatList().getFormat().iterator(); iter @@ -319,7 +320,8 @@ public class FormatProcessor extends RaptorObject { //dr.setFormatId(fmt.getFormatId()); //break; } else { // if - if(!formatModified) formatter = anyFormatter; + if(!formatModified) + formatter = anyFormatter; //if(!((formatter!=null && formatter!=anyFormatter) || (defaultFormatter!=null && formatter!=defaultFormatter))) // formatter = anyFormatter; //formatter.setFormatId(anyFormatter.getFormatId()); diff --git a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/note/note.component.spec.ts b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/note/note.component.spec.ts index 953906df..c06fe51f 100644 --- a/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/note/note.component.spec.ts +++ b/ecomp-sdk/epsdk-app-os/ngappsrc/src/app/pages/welcome-dashboard/note/note.component.spec.ts @@ -60,4 +60,17 @@ describe('NoteComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should test onDismiss method',()=>{ + component.onDismiss("onDismiss"); + }) + + it('should test onFocusOut method',()=>{ + component.onFocusOut("onFocusOut"); + }) + + //it('should test record method',()=>{ + //component.record(4); + // }) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/WEB-INF/conf/sql.properties b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/WEB-INF/conf/sql.properties index c5e4b57b..eba03083 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/WEB-INF/conf/sql.properties +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/WEB-INF/conf/sql.properties @@ -274,17 +274,6 @@ random.string = select ( concat('Z' , round(random() * 1000000000000) ) ) scheduler.user.emails = SELECT au.user_id FROM (SELECT rs.schedule_id, rs.rep_id FROM cr_report_schedule rs WHERE rs.enabled_yn='Y' AND rs.start_date <= now() AND rs.end_date >= now() AND rs.run_date IS NOT NULL AND rs.schedule_id = [p_schedule_id] ) x, cr_report r, fn_user au WHERE x.rep_id = r.rep_id AND au.user_id IN (SELECT rsu.user_id FROM cr_report_schedule_users rsu WHERE rsu.schedule_id = x.schedule_id and rsu.schedule_id = [p_schedule_id] UNION SELECT ur.user_id FROM fn_user_role ur WHERE ur.role_id IN (SELECT rsu2.role_id FROM cr_report_schedule_users rsu2 WHERE rsu2.schedule_id = x.schedule_id and rsu2.schedule_id = [p_schedule_id])) -# my logins - -app.query = SELECT APP_ID, ML_APP_NAME, MOTS_ID from fn_app - -user.log.query = SELECT DISTINCT IFNULL(SBCID, '') CUID, '' AWID, CONCAT('"',IFNULL(SBCID, ''),'"') APPLICATIONUSERID, CONCAT('"',IFNULL(FIRST_NAME, ''),'"') FIRST_NAME, CONCAT('"',substr(IFNULL(MIDDLE_NAME, ''), 0, 1),'"') MIDDLE_INITIAL, CONCAT('"',IFNULL(LAST_NAME, ''),'"') LAST_NAME, IFNULL(DATE_FORMAT(LAST_LOGIN_DATE, '%Y/%m/%d'), '') LAST_LOGON_DATE, DATE_FORMAT(CREATED_DATE, '%Y/%m/%d') ACCOUNT_ACTIVATION_DATE, IFNULL(DATE_FORMAT(MODIFIED_DATE, '%Y/%m/%d'), '') LAST_DATE_ACCOUNT_MODIFIED, '' LAST_PASSWORD_CHANGE_DATE, CONCAT('"',IFNULL(FIRST_NAME, ''),' ',IFNULL(MIDDLE_NAME, ''),' ',IFNULL(LAST_NAME, ''),'"') FULL_USER_NAME, '' NT_ID, IFNULL(EMAIL, '') EMAIL FROM FN_USER FU, FN_USER_ROLE FUR WHERE FU.USER_ID \= FUR.USER_ID and FUR.app_id \= ? and ACTIVE_YN \= 'Y' and sbcid is not null order by 1 - -profile.log.query = SELECT DISTINCT CONCAT('"' , ROLE_NAME , '"') PROFILE_NAME, '""' SECURITY_SETTINGS FROM FN_ROLE FR, FN_USER_ROLE FUR WHERE FUR.ROLE_ID \= FR.ROLE_ID and FR.ACTIVE_YN \= 'Y' and ((FUR.APP_ID \= 1 and FR.ROLE_NAME <> 'Standard User') or (FUR.APP_ID \= ? and FUR.APP_ID <> 1)) ORDER BY 1 - -user.profile.log.query = SELECT DISTINCT IFNULL(SBCID, '') CUID, '' AWID, CONCAT('"' , IFNULL(SBCID, '') , '"') APPLICATIONUSERID , CONCAT('"' , ROLE_NAME , '"') PROFILE_NAME FROM FN_USER A, FN_USER_ROLE B, FN_ROLE C WHERE A.USER_ID \= B.USER_ID AND B.ROLE_ID \= C.ROLE_ID AND A.ACTIVE_YN \= 'Y' AND C.ACTIVE_YN \= 'Y' AND a.sbcid is not null AND ((B.APP_ID \= 1 and C.ROLE_NAME <> 'Standard User') or (B.APP_ID \= ? and B.APP_ID <> 1)) ORDER BY 1 - -all.accounts.log.query = SELECT DISTINCT IFNULL(SBCID, '') CUID, (case when A.ACTIVE_YN\='Y' then 'ACTIVE' else 'INACTIVE' end) ACTIVE_YN, CONCAT('"' , IFNULL(SBCID, '') , '"') APPLICATIONUSERID , IFNULL(DATE_FORMAT(LAST_LOGIN_DATE, '%Y/%m/%d'), '') LAST_LOGON_DATE, '' LAST_PASSWORD_CHANGE_DATE, CONCAT('"' , ROLE_NAME , '"') PROFILE_NAME FROM FN_USER A, FN_USER_ROLE B, FN_ROLE C WHERE A.USER_ID \= B.USER_ID AND B.ROLE_ID \= C.ROLE_ID AND a.sbcid is not null AND ((B.APP_ID \= 1 and C.ROLE_NAME <> 'Standard User') or (B.APP_ID \= ? and B.APP_ID <> 1)) ORDER BY 1 # basic sql diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts index 1253b2be..bd9bea48 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/header/header.component.spec.ts @@ -91,12 +91,6 @@ describe('HeaderComponent', () => { expect(component).toBeTruthy(); }); - it('testing if condition in ngOnInit method',()=>{ - component.cookieService.set('show_app_header','false'); - component.ngOnInit(); - expect(component.showHeader).toBe(false) - }) - describe('should test ngOnInit',()=>{ it('should validate on ngOnInit',()=>{ let spy=spyOn(headerService, 'getTopMenuItems').and.returnValue(Observable.of('you object')); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts index 7f5a43fe..9bbcfc4e 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/components/sidebar/sidebar.component.spec.ts @@ -37,6 +37,7 @@ * * */ + import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { TranslateModule } from '@ngx-translate/core'; @@ -55,13 +56,15 @@ describe('SidebarComponent', () => { let sidebarService: SidebarService; var stubData1={ - "data":'{"data":"cachedRegions"}', - "data2":'{"data2":"cachedRegions2"}' + "data":'"d"', + "data2":'"data2"' }; - + var stubData2={ + "data":'"d"', + "data2":'" "' + }; beforeEach(async(() => { - let sidebarService: SidebarService; TestBed.configureTestingModule({ imports: [ LayoutModule, @@ -87,13 +90,6 @@ describe('SidebarComponent', () => { expect(component).toBeTruthy(); }); - it('testing if condition in ngOnInit method',()=>{ - component.cookieService.set('show_app_header','false'); - component.ngOnInit(); - expect(component.showHeader).toBe(false) - }) - - describe('should test ngOnInit',()=>{ it('should validate on ngOnInit',()=>{ let spy=spyOn(sidebarService,'getLeftMenu').and.returnValue(Observable.of(stubData1)); @@ -102,6 +98,14 @@ describe('SidebarComponent', () => { }) }) + //describe('should test ngOnInit if part',()=>{ + //it('should validate on ngOnInit',()=>{ + //let spy=spyOn(sidebarService,'getLeftMenu').and.returnValue(Observable.of(stubData2)); + // component.ngOnInit(); + //expect(spy).toHaveBeenCalled(); + //}) + //}) + it('should test addExpandClass if element and showMenu variable value are same', () => { component.showMenu= '1'; component.addExpandClass('1'); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.component.spec.ts index 975f72c3..4bc9f5dc 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/layout/layout.component.spec.ts @@ -78,12 +78,6 @@ describe('LayoutComponent', () => { expect(component).toBeTruthy(); }); - it('testing if condition in ngOnInit method',()=>{ - component.cookieService.set('show_app_header','false'); - component.ngOnInit(); - expect(component.showHeader).toBe(false) - }) - it('should test receiveCollapsed method',()=>{ component.receiveCollapsed(true); expect(component.collapedSideBar).toBe(true); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts index eb8b63dd..08e57de2 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts @@ -4,9 +4,7 @@ import { MatPaginatorModule } from '@angular/material/paginator'; import { MatSortModule } from '@angular/material/sort'; import { HttpClientModule } from '@angular/common/http'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; import { NgbModule, NgbModal } from '@ng-bootstrap/ng-bootstrap'; - import { MenusComponent } from './menus.component'; import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; import { AdminService } from '../admin.service'; @@ -14,17 +12,19 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { MenusService } from './menus.service'; import { CookieService } from 'ngx-cookie-service'; -import { MockBackend } from '@angular/http/testing'; -import { BaseRequestOptions, Http } from '@angular/http'; import 'rxjs/add/observable/of'; import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/catch'; +import 'rxjs/add/observable/throw'; describe('MenusComponent', () => { let component: MenusComponent; let fixture: ComponentFixture<MenusComponent>; let modalService: any; let adminService:any; - var stubData={"data":'{"fnMenuItems":{"tableData":{"element":{"active":1}}}}'}; + var stubData={ + "data1":{"data":"cachedRegions"} + } beforeEach(async(() => { TestBed.configureTestingModule({ @@ -56,11 +56,6 @@ describe('MenusComponent', () => { expect(component).toBeTruthy(); }); - // it('should test getFnMenuItems method inside getMenus',()=>{ - // let spy=spyOn(adminService,'getFnMenuItems').and.returnValue(Observable.of(stubData)) - // component.getMenus(); - // expect(spy).toHaveBeenCalled(); - // }) describe('test getMenus',()=>{ it('should test getMenus',()=>{ let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.of('you object')) @@ -76,6 +71,11 @@ describe('MenusComponent', () => { expect(spy).toHaveBeenCalled(); }) }) - + it('should test getParentData method error part ',()=>{ + let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.throw({status:404})); + component.getParentData(); + expect(spy).toHaveBeenCalled(); +}) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts index c39dcdc0..e2b4c720 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts @@ -53,7 +53,7 @@ describe('MenusService', () => { let component:MenusService; let service:AdminService; - var stubData={"data":{"active":"data2"}} + var stubData={"data":['{"active":"data"}','{"separator":"data1"}']}; beforeEach(() =>{ TestBed.configureTestingModule({ @@ -69,6 +69,20 @@ describe('MenusService', () => { expect(component).toBeTruthy(); }); + it('should test updateStatus method',()=>{ + component['updateStatus']('N'); + }) + + it('should test updateBooleanValue method',()=>{ + component['updateBooleanValue'](true); + component['updateBooleanValue'](false); + }) + + it('should test updateParentNameToID method',()=>{ + component.parentList=[{'name':'data'}]; + component['updateParentNameToID']('data'); + }) + it('should test menu',()=>{ console.log(component.menu); expect(component.menu.action).toEqual(null); @@ -90,4 +104,27 @@ describe('MenusService', () => { expect(spy).toHaveBeenCalled(); }) + + it('should test delete method',()=>{ + let spy=spyOn(service,'deleteMenu').and.returnValue(Observable.of("")); + component.delete(stubData); + expect(spy).toHaveBeenCalled(); + }) + + it('should test error part of delete method',()=>{ + let spy=spyOn(service,'deleteMenu').and.returnValue(Observable.throw({status:404})); + component.delete(stubData); + expect(spy).toHaveBeenCalled(); + }) + + it('should test getParentList method',()=>{ + component.getParentList("getParentList"); + expect(component.parentList).toEqual("getParentList"); + }) + + it('should test get method',()=>{ + let spy=spyOn(service,'getFnMenuItems').and.returnValue(Observable.of()); + component.get(); + expect(spy).toHaveBeenCalled(); + }) }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.spec.ts index 7dc3aa9f..0e59f9eb 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.spec.ts @@ -13,7 +13,8 @@ describe('RoleFunctionsService', () => { let component:RoleFunctionsService; let service:AdminService; - var stubData={"data":{"active":"data2"}} + //var stubData=['{"data":'{"active":"data2"}'}'] + //var stubData1='{stubData}' beforeEach(() =>{ TestBed.configureTestingModule({ @@ -39,6 +40,12 @@ describe('RoleFunctionsService', () => { expect(spy).toHaveBeenCalled(); }) + it('should test error part of update method',()=>{ + let spy=spyOn(service,'saveRoleFunction').and.returnValue(Observable.throw({status:404})); + component.update("data"); + expect(spy).toHaveBeenCalled(); +}) + it('should test delete method',()=>{ let spy=spyOn(service,'deleteRoleFunction').and.returnValue(Observable.of('your object')); @@ -46,5 +53,10 @@ describe('RoleFunctionsService', () => { expect(spy).toHaveBeenCalled(); }) + it('should test get method',()=>{ + let spy=spyOn(service,'getRoleFunctionList').and.returnValue(Observable.of()) + component.get(); + expect(spy).toHaveBeenCalled(); + }) });
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts index 8a30f2a3..d03cf4a6 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/new-role/new-role.component.spec.ts @@ -47,19 +47,30 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component'; import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; +import { AdminService } from '../../admin.service'; +import { Observable } from 'rxjs'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; describe('NewRoleComponent', () => { let component: NewRoleComponent; let fixture: ComponentFixture<NewRoleComponent>; let role1 = ""; + let adminService:AdminService; + var _element={ + "selected":false, + "code":"code", + "type":"type", + "action":"action" + }; beforeEach(async(() => { TestBed.configureTestingModule({ - providers: [NgbActiveModal], + providers: [NgbActiveModal,AdminService], schemas: [CUSTOM_ELEMENTS_SCHEMA] , declarations: [ NewRoleComponent, - ConfirmationModalComponent + ConfirmationModalComponent, + InformationModalComponent ], imports: [ FormsModule, @@ -70,7 +81,7 @@ describe('NewRoleComponent', () => { }) TestBed.overrideModule(BrowserDynamicTestingModule,{ set:{ - entryComponents:[ConfirmationModalComponent] + entryComponents:[ConfirmationModalComponent,InformationModalComponent] } }) .compileComponents(); @@ -81,15 +92,45 @@ describe('NewRoleComponent', () => { component = fixture.componentInstance; component.role = role1; fixture.detectChanges(); + adminService=TestBed.get(AdminService); }); it('should create', () => { expect(component).toBeTruthy(); }); + // it('should test ngOnInit method',()=>{ + // component.isEditMode=true; + // component.ociavailableRoleFunctions="tndrijeet"; + // //component.ociavailableRoleFunctions.length=9; + // component.ngOnInit(); + // }) + + // it('should test setSelectedRoleFucntions method',()=>{ + // component.ociavailableRoleFunctions.length={"selected":false}; + // component.setSelectedRoleFucntions("i"); + // }) + + it('should test delRoleFunctionConfirmPopUp method',()=>{ + component.delRoleFunctionConfirmPopUp("indrijeet","kumar"); + }) + + // it('should test if condition in saveChanges method',()=>{ + // component.isEditMode=true; + // //spyOn(adminService,'saveRole').and.returnValue(Observable.of('your object')); + // component.saveChanges() + // }) + + it('should test else condition in saveChanges method',()=>{ + spyOn(adminService,'saveRole').and.returnValue(Observable.of('your object')); + component.saveChanges() + }) + it('should test toggleRoleFunction method',()=>{ - component.ociavailableRoleFunctions=1; - component.toggleRoleFunction("toggleRoleFunction") + component.finalSelectedRoleFunctions="Indrijeet kumar"; + component.ociavailableRoleFunctions="i"; + component.finalSelectedRoleFunctions="k"; + component.toggleRoleFunction(_element) }) it('should test populateTableData method',()=>{ @@ -99,6 +140,8 @@ describe('NewRoleComponent', () => { }) it('should test isRoleAlreadyExist method',()=>{ + // component.availableRoles={"name":"currentRoleName"}; + component.availableRoles={"name":["currentRoleName"]}; component.isRoleAlreadyExist("currentRoleName") }) diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts index dcd637fc..85f62164 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts @@ -47,14 +47,22 @@ import { MatTableModule } from '@angular/material'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { UserService } from 'src/app/shared/services/user/user.service'; import { Observable } from 'rxjs'; -import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { NgbModule, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap'; import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; +import { NewRoleComponent } from './new-role/new-role.component'; +import { DataSource } from '@angular/cdk/table'; +import { AdminService } from '../admin.service'; +import { FormsModule } from '@angular/forms'; +import { HttpClientModule } from '@angular/common/http'; +import { HttpModule } from '@angular/http'; describe('RolesComponent', () => { let component: RolesComponent; let fixture: ComponentFixture<RolesComponent>; let userService: UserService; + let adminService:AdminService; + // var stubData={"result":{"data":'{"data"}',"role":'{"role"}'}}; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -62,16 +70,26 @@ describe('RolesComponent', () => { declarations: [ RolesComponent, InformationModalComponent, + NewRoleComponent + ], + providers:[ + UserService, + DataSource, + AdminService, + HttpClientModule ], imports:[ MatTableModule, + FormsModule, + HttpModule, + HttpClientModule, HttpClientTestingModule, - NgbModule.forRoot() + NgbModule.forRoot(), ] }) TestBed.overrideModule(BrowserDynamicTestingModule,{ set:{ - entryComponents:[InformationModalComponent] + entryComponents:[InformationModalComponent, NewRoleComponent] } }) .compileComponents(); @@ -82,6 +100,7 @@ describe('RolesComponent', () => { component = fixture.componentInstance; fixture.detectChanges(); userService=TestBed.get(UserService); + adminService=TestBed.get(AdminService); }); it('should create', () => { @@ -99,7 +118,19 @@ describe('RolesComponent', () => { }) - // it('should test openAdoleModaldNewR method',()=>{ - // component.openAdoleModaldNewR('dummydata2') - // }) + it('should test openAdoleModaldNewR method',()=>{ + component.toggleRole("") + }) + + it('should test getDismissReason method',()=>{ + component['getDismissReason'](ModalDismissReasons.ESC); + component['getDismissReason'](ModalDismissReasons.BACKDROP_CLICK); + component['getDismissReason'](""); + }) + +it('should test openAddNewRoleModal method',()=>{ + component.openAddNewRoleModal("openAddNewRoleModal"); + component.openAddNewRoleModal('undefined'); +}) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/usage/usage.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/usage/usage.component.spec.ts index 01f31669..f283855d 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/usage/usage.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/usage/usage.component.spec.ts @@ -44,16 +44,23 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { UsageComponent } from './usage.component'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { AdminComponent } from '../admin.component'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs/Observable'; describe('UsageComponent', () => { let component: UsageComponent; let fixture: ComponentFixture<UsageComponent>; + let adminService:AdminComponent; + var stubData={ + "data":'[{"data":"cachedRegions"}]'} beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ UsageComponent ], schemas:[CUSTOM_ELEMENTS_SCHEMA], - imports:[HttpClientTestingModule] + imports:[HttpClientTestingModule], + providers:[AdminComponent] }) .compileComponents(); })); @@ -62,9 +69,17 @@ describe('UsageComponent', () => { fixture = TestBed.createComponent(UsageComponent); component = fixture.componentInstance; fixture.detectChanges(); + adminService=TestBed.get(AdminComponent); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should test ngOnInit method',()=>{ + let spy=spyOn(component.adminService,'getUsageList').and.returnValue(Observable.of(stubData)); + component.ngOnInit(); + expect(spy).toHaveBeenCalled(); + }) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column.service.spec.ts index 22e1cc3d..e663001a 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column.service.spec.ts @@ -12,9 +12,6 @@ describe('ColumnService', () => { imports: [HttpClientTestingModule] })); - // httpClient=TestBed.get(HttpClient); - // httpTestingController=TestBed.get(httpTestingController); - it('should be created', () => { const service: ColumnService = TestBed.get(ColumnService); expect(service).toBeTruthy(); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts index 6d0c2946..d1ed8068 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/definition/dashboard-report-grid/dashboard-report-grid.component.spec.ts @@ -3,10 +3,21 @@ import { FormsModule } from '@angular/forms'; import { DashboardReportGridComponent } from './dashboard-report-grid.component'; import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core'; import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { DashboardReportService } from '../../run/run-report/run-dashboard-report/dashboard-report.service'; +import { DashboardReportGridService } from './dashboard-report-grid.service'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs'; +import { GridsterItem } from 'angular-gridster2'; describe('DashboardReportGridComponent', () => { let component: DashboardReportGridComponent; let fixture: ComponentFixture<DashboardReportGridComponent>; + let service; + let environment = [ + { + baseUrl: 'just for testing' + } + ]; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -15,11 +26,15 @@ describe('DashboardReportGridComponent', () => { imports: [FormsModule, HttpClientTestingModule] }) .compileComponents(); + service = TestBed.get(DashboardReportGridService); + spyOn(service, 'getReportList').and.returnValue(Observable.of(environment)); })); beforeEach(() => { fixture = TestBed.createComponent(DashboardReportGridComponent); component = fixture.componentInstance; + environment ["rows"] = [""]; + component.dashboard ["hasContent"] = [""]; fixture.detectChanges(); }); @@ -28,7 +43,9 @@ describe('DashboardReportGridComponent', () => { }); it('should test ngOnInit method', () => { + spyOn(component, 'ngOnInit').and.callThrough(); component.ngOnInit(); + expect(component.ngOnInit).toHaveBeenCalled(); }); it('should test changedOption method', () => { @@ -47,4 +64,10 @@ describe('DashboardReportGridComponent', () => { component.addItem(); }); + it('should test emptyCellClick method', () => { + let event: MouseEvent; + let item: GridsterItem; + component.emptyCellClick(event, item); + }); + });
\ No newline at end of file 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 88010f96..7cc85b94 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 @@ -1,25 +1,34 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; -import { FormFieldsComponent } from './form-fields.component'; +import { FormFieldsComponent, DialogOverviewExampleDialog } from './form-fields.component'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 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'; import { FormFieldsService } from './form-fields.service'; import 'rxjs/add/observable/of'; import { Observable } from 'rxjs/Observable'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; describe('FormFieldsComponent', () => { let component: FormFieldsComponent; let fixture: ComponentFixture<FormFieldsComponent>; let _formfieldservice: FormFieldsService; + var responseFormFields=[{"orderSeq":3}]; + var formFieldGroupsJSON={"formFieldGroupsJSON":'{"data":"cachedRegions"}'}; + var responseDeleted={"responseDeleted":[{"message":"Formfield Deleted"}]} + var responseDefaultSQL={"data":[{"elemensts":"indrijeet"}]}; + var responsePost={"message":true}; + var stubData=[{m:true}]; beforeEach(async(() => { TestBed.configureTestingModule({ schemas:[CUSTOM_ELEMENTS_SCHEMA], - declarations: [ FormFieldsComponent ], + declarations: [ + FormFieldsComponent, + DialogOverviewExampleDialog + ], imports:[ FormsModule, HttpClientTestingModule, @@ -28,6 +37,11 @@ describe('FormFieldsComponent', () => { BrowserAnimationsModule ] }) + TestBed.overrideModule(BrowserDynamicTestingModule,{ + set:{ + entryComponents:[DialogOverviewExampleDialog] + } + }) .compileComponents(); })); @@ -42,6 +56,21 @@ describe('FormFieldsComponent', () => { expect(component).toBeTruthy(); }); + + it('should test verify method',()=>{ + spyOn(_formfieldservice,'verifySQL').and.returnValue(Observable.of(responseDefaultSQL)) + component.verify("Default"); + expect(component.validateResponseString).toEqual( responseDefaultSQL["data"]["elements"]) + component.verify("value"); + }) + + it('should test ngOnInit method',()=>{ + let spy=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(responseFormFields)) + spyOn(_formfieldservice,'getFormFieldGroupsData').and.returnValue(Observable.of(formFieldGroupsJSON)) + component.ngOnInit(); + expect(spy).toHaveBeenCalled(); + }) + it('should test isFirst method',()=>{ expect(component.isFirst(0)).toBe(true); expect(component.isFirst(2)).toBe(false); @@ -57,6 +86,7 @@ describe('FormFieldsComponent', () => { expect(component.isLast(11)).toEqual(true); }); + it('should test ngDoCheck method for if condition',()=>{ component.sqlAsDefaultValue=true; component.ngDoCheck(); @@ -132,12 +162,13 @@ describe('FormFieldsComponent', () => { 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.predefinedValueList=[{"id":"attrib"}] component.deleteFromList("attrib"); }); @@ -145,9 +176,13 @@ it('should test save method1',()=>{ component.visible="YES"; component.defaultValue=false; + component.mode ="Edit"; + responseFormFields["m"]=1; + let spy1=spyOn(_formfieldservice,'postFormFieldData').and.returnValue(Observable.of(responsePost)); + let spy2=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(stubData)); component.save(); - expect(component.showSpinner).toBe(true); - expect(component.showDialog).toBe(false); + expect(spy1).toHaveBeenCalled(); + expect(spy2).toHaveBeenCalled(); expect(component.finalPOSTObj["validationType"]).toEqual(component.validationType); expect(component.finalPOSTObj["visible"]).toBe(true); expect(component.finalPOSTObj["orderSeq"]).toEqual(component.orderSeq); @@ -168,7 +203,13 @@ it('should test save method1',()=>{ it('should test save method for else part',()=>{ component.visible!="YES"; component.defaultValue!=false; + component.mode ="Edited"; + responseFormFields["m"]=1; + let spy1=spyOn(_formfieldservice,'addFormFieldData').and.returnValue(Observable.of(responsePost)); + let spy2=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of(stubData)); component.save(); + expect(spy1).toHaveBeenCalled(); + expect(spy2).toHaveBeenCalled(); expect(component.finalPOSTObj["visible"]).toBe(false) expect(component.finalPOSTObj["fieldDefalultSQL"]).toEqual(component.fieldDefaultSQL); }) @@ -182,25 +223,33 @@ it('should test openSnackBar method',()=>{ }) it('should test deleteGroup method',()=>{ - component.deleteGroup("string"); + component.Groups=[{"name":"groupName"}]; + component.deleteGroup("groupName"); }) it('should test deleteFormGroup method',()=>{ + component.Groups=[{"formFieldList":{"id":"formFieldId"}}] + //component.Groups=[{"elements":{"formFieldList":{"id":"formFieldId"}}}] component.deleteFromGroup("formgroup"); }) it('should test delete method',()=>{ + responseDeleted["message"]="Formfield Deleted"; + let spy1=spyOn(_formfieldservice,'deleteFormField').and.returnValue(Observable.of(responseDeleted)); + let spy2=spyOn(_formfieldservice,'getListOfFormFields').and.returnValue(Observable.of('you object')) component.delete("delete"); + expect(spy1).toHaveBeenCalled(); + expect(spy2).toHaveBeenCalled(); }) -it('should test verify method',()=>{ -component.verify("Default"); -component.verify("value"); - +it('should test createGroup method',()=>{ + component.openDialog() }) -// it('should test createGroup method',()=>{ -// component.openDialog() -// }) +it('should test createGroup method',()=>{ + let spy=spyOn(component,'openDialog'); + component.createGroup(); + expect(spy).toHaveBeenCalled(); +}) -}); +}) diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts index e2b08a4f..af8e9db7 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts @@ -16,13 +16,7 @@ describe('LogComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ LogComponent ], - imports: [HttpClientTestingModule], - // providers:[LogService,MockBackend,BaseRequestOptions,{ - // porvide:Http,useFactory:(backend:MockBackend,defaultOptions:BaseRequestOptions)=>{ - // return new Http(backend,defaultOptions); - // }, - // deps:[MockBackend,BaseRequestOptions], - // }] + imports: [HttpClientTestingModule] }) .compileComponents(); })); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts index a1906c85..54df7d82 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-form-fields/run-report-form-fields.component.spec.ts @@ -19,7 +19,9 @@ describe('RunReportFormFieldsComponent', () => { { baseUrl: 'just for testing' } - ] + ]; + var responseFormFieldGroups={"formFieldGroupsJSON":'{"Indrijeet":"kumar"}'}; + var respObj={"formFieldList":{"value1":"value1"}}; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -30,12 +32,9 @@ describe('RunReportFormFieldsComponent', () => { }) .compileComponents(); runService = TestBed.get(RunService); - // spyOn(runService, 'getReportData').and.returnValue(Observable.of(environment)); - // spyOn(runService, 'getReportDataWithFormFields').and.returnValue(Observable.of(environment)); spyOn(runService, 'getDefinitionPageDetails').and.returnValue(Observable.of(environment)); spyOn(runService, 'refreshFormFields').and.returnValue(Observable.of(environment)); - // spyOn(runService, 'downloadReportExcel').and.returnValue(Observable.of(environment)); - spyOn(runService, 'getFormFieldGroupsData').and.returnValue(Observable.of(environment)); + })); beforeEach(() => { @@ -127,11 +126,10 @@ describe('RunReportFormFieldsComponent', () => { expect(component.ngOnInit).toHaveBeenCalled(); }); -// it('should test fetchAndPopulateFormFields method', () => { -// spyOn(component, 'fetchAndPopulateFormFields').and.callThrough(); -// component.formFieldGroupObjList = null; -// component.fetchAndPopulateFormFields(1, "test"); -// expect(component.fetchAndPopulateFormFields).toHaveBeenCalled(); -// }); + it('should test fetchAndPopulateFormFields method', () => { + component.formFieldGroupObjList=[{"formFieldList":"formFieldList"}] + spyOn(runService, 'getFormFieldGroupsData').and.returnValue(Observable.of(responseFormFieldGroups)); + component.fetchAndPopulateFormFields(respObj,"value2"); + }); });
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts index 44765d49..fa856c00 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report-result-set/run-report-result-set.component.spec.ts @@ -6,12 +6,21 @@ import { MatTableModule } from '@angular/material/table'; import { RunReportResultSetComponent } from './run-report-result-set.component'; import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { HttpClient } from '@angular/common/http'; import { RouterTestingModule } from '@angular/router/testing'; +import { RunService } from '../run.service'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/catch'; +import 'rxjs/add/observable/throw'; describe('RunReportResultSetComponent', () => { let component: RunReportResultSetComponent; let fixture: ComponentFixture<RunReportResultSetComponent>; + let _runService:RunService; + var response={ + "reportDataColumns":[{"columnTitle":"columnTitle"}], + "reportDataRows":[{"colId":"colId"}] + } beforeEach(async(() => { TestBed.configureTestingModule({ @@ -31,9 +40,26 @@ describe('RunReportResultSetComponent', () => { fixture = TestBed.createComponent(RunReportResultSetComponent); component = fixture.componentInstance; fixture.detectChanges(); + _runService=TestBed.get(RunService); }); it('should compile', () => { expect(component).toBeTruthy(); }); + + it('should test ngOnInit method',()=>{ + component.reportId1="reportId1"; + let spy=spyOn(_runService,'getReportData').and.returnValue(Observable.of(response)); + component.ngOnInit(); + expect(spy).toHaveBeenCalled(); + + }) + + it('should test ngAfterViewInit method',()=>{ + component.reportId1="reportId1"; + let spy=spyOn(_runService,'getReportData').and.returnValue(Observable.of(response)) + component.ngAfterViewInit(); + expect(spy).toHaveBeenCalled(); + }) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-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-report.component.spec.ts index a41b11cd..2aeac4a2 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/run/run-report/run-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-report.component.spec.ts @@ -2,10 +2,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { MatPaginatorModule } from '@angular/material/paginator'; import { MatSortModule } from '@angular/material/sort'; -import { MatTableModule, MatTableDataSource } from '@angular/material/table'; +import { MatTableModule} from '@angular/material/table'; -import { RunReportComponent, PeriodicElement } from './run-report.component'; -import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SimpleChange, SimpleChanges } from '@angular/core'; +import { RunReportComponent} from './run-report.component'; +import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SimpleChanges } from '@angular/core'; import { MatMenuModule } from '@angular/material'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; @@ -24,13 +24,12 @@ describe('RunReportComponent', () => { let runService : RunService; let options1 = {}; let dashboard; - let dashboard2; let responseformfield = 1; let environment = [ { baseUrl: 'just a link' } - ] + ]; beforeEach(async(() => { @@ -49,13 +48,10 @@ describe('RunReportComponent', () => { providers: [RunService] }).compileComponents(); runService = TestBed.get(RunService); - //spyOn(runService, 'getReportDataWithFormFields').and.returnValue(Observable.of(environment)); - //spyOn(runService, 'getReportData').and.returnValue(Observable.of(environment)); spyOn(runService, 'downloadReportExcel').and.returnValue(Observable.of(environment)); })); beforeEach(() => { - //dashboard = {"item":{"hasContent":{"name":"rupi","id":"check#check"}}}; fixture = TestBed.createComponent(RunReportComponent); runService = TestBed.get(RunService); component = fixture.componentInstance; @@ -107,6 +103,7 @@ describe('RunReportComponent', () => { expect(component.NEWdisplayedColumns).toEqual(new Array()); }); + it('should test showError method', () => { let errmsg = "errormessage"; let stcktrace = "stacktrace"; @@ -148,40 +145,40 @@ describe('RunReportComponent', () => { it('should test the ngOnChanges first If condition', () => { change = {}; + component.queryString="queryString"; + component.reportId1="reportId1"; + var response={"errormessage":true} component.reportMode !== "Regular" component.initCnt = 1; component.TriggerFFArr.length = 0; + let spy=spyOn(runService,'getReportDataWithFormFields').and.returnValue(Observable.of(response)); component.ngOnChanges(change); - expect(component.showMoreVert).toEqual(false); + expect(spy).toHaveBeenCalled(); expect(component.initCnt).toEqual(1); expect(component.showDashboardReport).toEqual(false); 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.NEWdisplayedColumns).toEqual(new Array()); expect(component.isReady).toEqual(false); + }); + it('should test initialProcess method', () => { component.DashboardReportObj.length = 1; component.initialProcesses(); }); - // it('should test postFetchingReportDataFn method', () => { - // let response: any; - // component.postFetchingReportDataFn(response); - // }) - - // it('should test ngOnChanges subscribe method', () => { - // spyOn(component, 'ngOnChanges').and.callThrough(); - // component.ngOnChanges(change); - // expect(component.ngOnChanges).toHaveBeenCalled(); + // it('should test postFetchingReportDataFn method',()=>{ + // var response={ + // "reportName":"reportName", + // "reportDataColumns":[{"columnTitle":"columnTitle","colId":"colId"}], + // "reportDataRows":[{"value":"value"}] + // } + // component.displayedColumnsArr=["string"] + // component.postFetchingReportDataFn(response) // }) - // it('should test postFetchingReportDataFn method', () => { - // let obj: any; - // component.postFetchingReportDataFn(obj); - // }) - + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql-validate-success-dialog/sql-validate-success-dialog.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql-validate-success-dialog/sql-validate-success-dialog.component.spec.ts index 9f98ff18..92803321 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql-validate-success-dialog/sql-validate-success-dialog.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql-validate-success-dialog/sql-validate-success-dialog.component.spec.ts @@ -22,4 +22,9 @@ describe('ValidateSuccessComponentComponent', () => { it('should create', () => { expect(component).toBeTruthy(); }); + + it('should test ngOnChanges method',()=>{ + component.tableObj='{"reportDataColumns":"tableObj","reportDataRows":"reportDataRows"}'; + component.ngOnChanges(); + }) }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts index 52082c9f..68085b1e 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/sql/sql.component.spec.ts @@ -16,7 +16,6 @@ describe('SQLComponentComponent', () => { let fixture: ComponentFixture<SQLComponent>; const reportId = "test"; const finalGetObj = {"query":"dummyQuery"}; - let elements = []; let environment = [ { "baseUrl": 'just for test' @@ -32,9 +31,7 @@ describe('SQLComponentComponent', () => { }) .compileComponents(); sqlService = TestBed.get(SqlService); - let response : any; spyOn(sqlService, 'getSQLTabData').and.returnValue(Observable.of(environment)); - spyOn(sqlService, 'postSQLValidateAndSave').and.returnValue(Observable.of(environment)); })); beforeEach(() => { @@ -82,6 +79,27 @@ describe('SQLComponentComponent', () => { expect(component.SQLclosable).toEqual(true); }); + it('should test saveSQL method else condition',()=>{ + component.SQLPostResponse = false; + component.saveSQL(); + }) + + it('should test validate method',()=>{ + component.sqlText="sqlText"; + var response={"data":{"elements":'{"elements":""}'}} + let spy=spyOn(sqlService,'postSQLValidateAndSave').and.returnValue(Observable.of(response)) + component.validate(); + expect(spy).toHaveBeenCalled(); + }) + + it('should test validate method',()=>{ + component.sqlText="sqlText"; + var response={"data":{"elements":'{"query":"query"}'}} + let spy=spyOn(sqlService,'postSQLValidateAndSave').and.returnValue(Observable.of(response)) + component.validate(); + expect(spy).toHaveBeenCalled(); + }) + it('should test closeSaveModal method', () => { component.closeSaveModal(); expect(component.showSaveSQLDialog).toEqual(component.showSaveSQLDialog); @@ -113,10 +131,4 @@ describe('SQLComponentComponent', () => { expect(component.GetValidateResponseString()).toEqual("test"); }); -// it('should test validate method', () => { -// spyOn(component, 'validate').and.callThrough(); -// component.validate(); -// expect(component.validate).toHaveBeenCalled(); -// }); - }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts index 2140e0ae..ab0efdb2 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts @@ -1,4 +1,3 @@ - /* * ============LICENSE_START========================================== * ONAP Portal SDK @@ -17,16 +16,33 @@ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. * * ============LICENSE_END============================================ * * */ + import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + import { SearchComponent } from './search.component'; -import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule } from '@angular/core'; -import { MatTableModule, MatTableDataSource, MatMenuModule, MatSortModule, MatPaginatorModule } from '@angular/material'; +import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule, Component } from '@angular/core'; +import { MatTableModule, MatTableDataSource, MatMenuModule, MatSortModule, MatPaginatorModule, MatDialogModule } from '@angular/material'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; @@ -35,13 +51,23 @@ import { NgbModule, NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; import { NgbModalBackdrop } from '@ng-bootstrap/ng-bootstrap/modal/modal-backdrop'; import { NgModel } from '@angular/forms'; +import { Observable } from 'rxjs'; +import 'rxjs/add/observable/empty'; +import 'rxjs/add/observable/of'; +import { environment } from 'src/environments/environment'; +import { User } from 'src/app/shared/services/user/user'; +import { DataSource } from '@angular/cdk/table'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; + describe('SearchComponent', () => { let component: SearchComponent; let fixture: ComponentFixture<SearchComponent>; + let resp : any; + beforeEach(async(() => { TestBed.configureTestingModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], - declarations: [ SearchComponent , ConfirmationModalComponent], + declarations: [ SearchComponent , ConfirmationModalComponent, InformationModalComponent], imports: [NoopAnimationsModule, MatPaginatorModule, MatSortModule, @@ -49,35 +75,39 @@ describe('SearchComponent', () => { MatMenuModule, HttpClientTestingModule, RouterTestingModule, + MatDialogModule, + NgbModule.forRoot() ] }) + TestBed.overrideModule(BrowserDynamicTestingModule,{ + set:{ + entryComponents:[ConfirmationModalComponent,InformationModalComponent] + } + }) .compileComponents(); })); + beforeEach(() => { fixture = TestBed.createComponent(SearchComponent); component = fixture.componentInstance; + component.response = resp; fixture.detectChanges(); }); + it('should create', () => { expect(component).toBeTruthy(); }); + it('should test getUsers method', () => { component.getUsers(); - expect(component.showSpinner).toEqual(true); - let response; - component.response.subscribe(data => { - expect(response).toEqual(data); - expect(component.result).toEqual(JSON.parse(response.data)); - expect(component.profileList).toEqual(JSON.parse(component.result.profileList)); - expect(component.dataSource).toEqual(new MatTableDataSource(component.profileList)); - expect(component.dataSource.paginator).toEqual(component.paginator); - expect(component.dataSource.sort).toEqual(component.sort); - expect(component.showSpinner).toEqual(false); - }); }); - // it('should test applyFilter method', () => { - // let filterValue = "test" - // component.applyFilter(filterValue); - // expect(component.dataSource.filter).toEqual(filterValue.trim().toLowerCase()); - // }); -});
\ No newline at end of file + + it('should test openConfirmationModal method', () => { + component.openConfirmationModal("just","test"); + }); + + it('should test openInformationModal method', () => { + component.openInformationModal("just","test"); + }); + +}); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts index 97e164df..5178b52b 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts @@ -50,17 +50,27 @@ import { UserService } from 'src/app/shared/services/user/user.service'; import { Observable } from 'rxjs'; import { ActivatedRoute } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; +import { ModalDismissReasons, NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { ProfileService } from '../profile.service'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; +import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; describe('SelfComponent', () => { let component: SelfComponent; let fixture: ComponentFixture<SelfComponent>; let userService:UserService; + let profileService:ProfileService; let tableobj:any=JSON.stringify({"errormessage":"DummyError","stacktrace":"trace"}); + let data={"data":'{"profile":\'{"data":"data"}\'}'}; + //var _element={"_element":true}; + var _element={"_element":{"selected":true}} + + beforeEach(async(() => { TestBed.configureTestingModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA], - declarations: [ SelfComponent ], + declarations: [ SelfComponent,InformationModalComponent ], imports: [ ReactiveFormsModule, FormsModule, @@ -69,9 +79,15 @@ describe('SelfComponent', () => { MatSlideToggleModule, BrowserAnimationsModule, HttpClientTestingModule, - RouterTestingModule + RouterTestingModule, + NgbModule.forRoot() ] }) + TestBed.overrideModule(BrowserDynamicTestingModule,{ + set:{ + entryComponents:[InformationModalComponent ] + } + }) .compileComponents(); })); @@ -80,12 +96,17 @@ describe('SelfComponent', () => { component = fixture.componentInstance; fixture.detectChanges(); userService=TestBed.get(UserService); + profileService=TestBed.get(ProfileService); }); it('should create', () => { expect(component).toBeTruthy(); }); + // it('should test assignProfileDetails method',()=>{ + // component.assignProfileDetails(data); + // }) + describe('should test ngOnInit method',()=>{ it('should test subscribe',()=>{ let spy=spyOn(userService,'getFunctionalMenuStaticDetailSession').and.returnValue(Observable.of('you object')); @@ -94,4 +115,33 @@ describe('SelfComponent', () => { }) }) + it('should test getDismissReason method',()=>{ + component['getDismissReason'](ModalDismissReasons.ESC); + component['getDismissReason'](ModalDismissReasons.BACKDROP_CLICK); + component['getDismissReason'](""); + }) + + it('should test getProfileById method',()=>{ + let spy=spyOn(profileService,'getProfileById').and.callThrough(); + component.getProfileById("indrijeet"); + expect(spy).toHaveBeenCalled(); + }) + + it('should test getSelfProfileDetail method',()=>{ + let spy=spyOn(profileService,'getSelfProfile').and.callThrough(); + component.getSelfProfileDetail(); + expect(spy).toHaveBeenCalled(); + }) + + // // it('should test saveProfile method',()=>{ + // // component.saveProfile() + // // }) + + it('should test toggleRoles method',()=>{ + component.ociavailableRoles=[{"ociavailableRoles":"ociavailableRoles"}]; + component.finalSelectedRoles=[{"finalSelectedRoles":"finalSelectedRoles"}]; + component.toggleRoles(_element); + component.addUserRole(_element); + }) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.spec.ts new file mode 100644 index 00000000..e82a7ebc --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.spec.ts @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + * + * ============LICENSE_END============================================ + * + * + */ + +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { HeaderInterceptor } from './header-interceptor'; + +describe('HeaderInterceptor', () => { + let component: HeaderInterceptor; + let fixture: ComponentFixture<HeaderInterceptor>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + }) + .compileComponents(); + })); + + beforeEach(() => { + component=new HeaderInterceptor() + }); + + it('should create', () => { + expect(component).toBeTruthy(); + component.intercept; + }); +}); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.spec.ts new file mode 100644 index 00000000..cd1fdaa2 --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/services/user/user.spec.ts @@ -0,0 +1,62 @@ + +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * 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. + * + * ============LICENSE_END============================================ + * + * + */ + +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { User } from './user'; + +describe('User', () => { + let component: User; + let fixture: ComponentFixture<User>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + }) + .compileComponents(); + })); + + beforeEach(() => { + component=new User(8) + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java index 54ce2f4f..21c3f21c 100644 --- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java +++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/PortalRestAPICentralServiceImpl.java @@ -85,7 +85,7 @@ public class PortalRestAPICentralServiceImpl implements IPortalRestAPIService { password = portalRestCentralService.getAppCredentials().get(IPortalRestCentralService.CREDENTIALS_PASS); appName = portalRestCentralService.getAppCredentials().get(IPortalRestCentralService.CREDENTIALS_APP); } catch (Exception e) { - throw new ClassCastException("Failed to find or instantiate class "); + throw new ServletException("Failed to instantiate class " + centralClassName, e); } } @@ -211,4 +211,4 @@ public class PortalRestAPICentralServiceImpl implements IPortalRestAPIService { return credentialsMap; } -}
\ No newline at end of file +} |