diff --git a/src/app/core/integration/integration-response-parsing.service.spec.ts b/src/app/core/integration/integration-response-parsing.service.spec.ts index e2e2f92d5a..1351f7b4f5 100644 --- a/src/app/core/integration/integration-response-parsing.service.spec.ts +++ b/src/app/core/integration/integration-response-parsing.service.spec.ts @@ -8,6 +8,8 @@ import { CoreState } from '../core.reducers'; import { IntegrationResponseParsingService } from './integration-response-parsing.service'; import { IntegrationRequest } from '../data/request.models'; import { AuthorityValueModel } from './models/authority-value.model'; +import { PageInfo } from '../shared/page-info.model'; +import { PaginatedList } from '../data/paginated-list'; describe('IntegrationResponseParsingService', () => { let service: IntegrationResponseParsingService; @@ -78,7 +80,7 @@ describe('IntegrationResponseParsingService', () => { }, _links: { - self: 'https://rest.api/integration/authorities/type/entries' + self: { href: 'https://rest.api/integration/authorities/type/entries' } } }, statusCode: '200' @@ -141,39 +143,44 @@ describe('IntegrationResponseParsingService', () => { }, statusCode: '200' }; - - const definitions = [ - Object.assign(new AuthorityValueModel(), { + const pageinfo = Object.assign(new PageInfo(), { elementsPerPage: 5, totalElements: 5, totalPages: 1, currentPage: 1 }); + const definitions = new PaginatedList(pageinfo,[ + Object.assign({}, new AuthorityValueModel(), { + type: 'authority', display: 'One', id: 'One', - otherInformation: {}, + otherInformation: undefined, value: 'One' }), - Object.assign(new AuthorityValueModel(), { + Object.assign({}, new AuthorityValueModel(), { + type: 'authority', display: 'Two', id: 'Two', - otherInformation: {}, + otherInformation: undefined, value: 'Two' }), - Object.assign(new AuthorityValueModel(), { + Object.assign({}, new AuthorityValueModel(), { + type: 'authority', display: 'Three', id: 'Three', - otherInformation: {}, + otherInformation: undefined, value: 'Three' }), - Object.assign(new AuthorityValueModel(), { + Object.assign({}, new AuthorityValueModel(), { + type: 'authority', display: 'Four', id: 'Four', - otherInformation: {}, + otherInformation: undefined, value: 'Four' }), - Object.assign(new AuthorityValueModel(), { + Object.assign({}, new AuthorityValueModel(), { + type: 'authority', display: 'Five', id: 'Five', - otherInformation: {}, + otherInformation: undefined, value: 'Five' }) - ]; + ]); it('should return a IntegrationSuccessResponse if data contains a valid endpoint response', () => { const response = service.parse(validRequest, validResponse); @@ -189,6 +196,8 @@ describe('IntegrationResponseParsingService', () => { it('should return a IntegrationSuccessResponse with data definition', () => { const response = service.parse(validRequest, validResponse); + console.log((response as any).dataDefinition); + console.log(definitions); expect((response as any).dataDefinition).toEqual(definitions); }); diff --git a/src/app/core/integration/integration-response-parsing.service.ts b/src/app/core/integration/integration-response-parsing.service.ts index 5d6ce09114..06c6b9620d 100644 --- a/src/app/core/integration/integration-response-parsing.service.ts +++ b/src/app/core/integration/integration-response-parsing.service.ts @@ -33,7 +33,7 @@ export class IntegrationResponseParsingService extends BaseResponseParsingServic parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse { if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links)) { const dataDefinition = this.process(data.payload, request.href); - return new IntegrationSuccessResponse(dataDefinition[Object.keys(dataDefinition)[0]], data.statusCode, this.processPageInfo(data.payload.page)); + return new IntegrationSuccessResponse(dataDefinition, data.statusCode, this.processPageInfo(data.payload.page)); } else { return new ErrorResponse( Object.assign(