From: elinuxhenrik Date: Wed, 3 Feb 2021 14:55:33 +0000 (+0100) Subject: Add gateway calls for producer in ei service X-Git-Tag: 2.2.0~101 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=27a30792480f7397800e28a6f01678a561d71d2d;p=portal%2Fnonrtric-controlpanel.git Add gateway calls for producer in ei service Change-Id: I438afb4c849f0be57c477941abb7cabaaa67c945 Signed-off-by: elinuxhenrik Issue-ID: NONRTRIC-408 --- diff --git a/webapp-frontend/src/app/interfaces/ei.types.ts b/webapp-frontend/src/app/interfaces/ei.types.ts index 2b0d92d..814c099 100644 --- a/webapp-frontend/src/app/interfaces/ei.types.ts +++ b/webapp-frontend/src/app/interfaces/ei.types.ts @@ -32,4 +32,16 @@ export interface EIProducer { ei_producer_id: string; ei_producer_types: string[]; status: string; +} + +export interface ProducerRegistrationInfo { + supported_ei_types: String[] +} + +export enum OperationalState { + ENABLED, + DISABLED +} +export interface ProducerStatus { + opState: OperationalState } \ No newline at end of file diff --git a/webapp-frontend/src/app/services/ei/ei.service.spec.ts b/webapp-frontend/src/app/services/ei/ei.service.spec.ts index ca77d0c..5bf7d3d 100644 --- a/webapp-frontend/src/app/services/ei/ei.service.spec.ts +++ b/webapp-frontend/src/app/services/ei/ei.service.spec.ts @@ -20,7 +20,7 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing' import { TestBed } from '@angular/core/testing'; -import { EIJob } from '../../interfaces/ei.types'; +import { EIJob, ProducerStatus, OperationalState, ProducerRegistrationInfo } from '../../interfaces/ei.types'; import { EIService } from './ei.service'; describe('EIService', () => { @@ -42,7 +42,7 @@ describe('EIService', () => { expect(service).toBeTruthy(); }); - describe('#getEIProducers', () => { + describe('#getProducerIds', () => { let expectedEIProducerIds: String[]; beforeEach(() => { @@ -66,7 +66,7 @@ describe('EIService', () => { }); }); - describe('#EIJobs', () => { + describe('#getJobsForProducer', () => { let expectedEIJobs: EIJob[]; beforeEach(() => { @@ -92,4 +92,56 @@ describe('EIService', () => { httpTestingController.verify(); }); }); + + describe('#getProducer', () => { + let expectedProducer: ProducerRegistrationInfo; + + beforeEach(() => { + service = TestBed.get(EIService); + httpTestingController = TestBed.get(HttpTestingController); + expectedProducer = { + supported_ei_types: [ 'type1', 'type2' ] + } as ProducerRegistrationInfo; + }); + + it('should return producer', () => { + service.getProducer('producer1').subscribe( + producer => expect(producer).toEqual(expectedProducer, 'should return expected producer'), + fail + ); + + const req = httpTestingController.expectOne(basePath + '/' + service.eiProducersPath + '/producer1'); + expect(req.request.method).toEqual('GET'); + + req.flush(expectedProducer); //Return expected producer + + httpTestingController.verify(); + }); + }); + + describe('#getProducerStatus', () => { + let expectedProducerStatus: ProducerStatus; + + beforeEach(() => { + service = TestBed.get(EIService); + httpTestingController = TestBed.get(HttpTestingController); + expectedProducerStatus = { + opState: OperationalState.ENABLED + } as ProducerStatus; + }); + + it('should return producer status', () => { + service.getProducerStatus('producer1').subscribe( + producerStatus => expect(producerStatus).toEqual(expectedProducerStatus, 'should return expected producer'), + fail + ); + + const req = httpTestingController.expectOne(basePath + '/' + service.eiProducersPath + '/producer1/' + service.eiProducerStatusPath); + expect(req.request.method).toEqual('GET'); + + req.flush(expectedProducerStatus); //Return expected status + + httpTestingController.verify(); + }); + }); }); diff --git a/webapp-frontend/src/app/services/ei/ei.service.ts b/webapp-frontend/src/app/services/ei/ei.service.ts index 3be9b8b..19c5836 100644 --- a/webapp-frontend/src/app/services/ei/ei.service.ts +++ b/webapp-frontend/src/app/services/ei/ei.service.ts @@ -20,8 +20,8 @@ import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; -import { Observable, of } from 'rxjs'; -import { EIJob, EIProducer } from '../../interfaces/ei.types'; +import { Observable } from 'rxjs'; +import { EIJob, EIProducer, ProducerStatus, ProducerRegistrationInfo } from '../../interfaces/ei.types'; /** * Services for calling the EI endpoints. @@ -32,8 +32,9 @@ import { EIJob, EIProducer } from '../../interfaces/ei.types'; export class EIService { private basePath = '/ei-producer/v1'; - eiJobsPath = 'eijobs'; - eiProducersPath = 'eiproducers'; + readonly eiJobsPath = 'eijobs'; + readonly eiProducersPath = 'eiproducers'; + readonly eiProducerStatusPath = 'status'; private buildPath(...args: any[]) { let result = this.basePath; @@ -57,6 +58,16 @@ export class EIService { return this.httpClient.get(url); } + getProducer(producerId: String): Observable { + const url = this.buildPath(this.eiProducersPath, producerId); + return this.httpClient.get(url); + } + + getProducerStatus(producerId: String): Observable { + const url = this.buildPath(this.eiProducersPath, producerId, this.eiProducerStatusPath); + return this.httpClient.get(url); + } + getEIProducers(): Observable { const url = this.buildPath(this.eiProducersPath); return this.httpClient.get(url);