fixed some tests after merge

This commit is contained in:
lotte
2018-08-09 11:50:42 +02:00
parent 9d318e334b
commit a4855ce9ea
3 changed files with 23 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
import { IDToUUIDSerializer } from './it-to-uuid-serializer'; import { IDToUUIDSerializer } from './id-to-uuid-serializer';
describe('IDToUUIDSerializer', () => { describe('IDToUUIDSerializer', () => {
let serializer: IDToUUIDSerializer; let serializer: IDToUUIDSerializer;

View File

@@ -8,6 +8,8 @@ import { CoreState } from '../core.reducers';
import { IntegrationResponseParsingService } from './integration-response-parsing.service'; import { IntegrationResponseParsingService } from './integration-response-parsing.service';
import { IntegrationRequest } from '../data/request.models'; import { IntegrationRequest } from '../data/request.models';
import { AuthorityValueModel } from './models/authority-value.model'; import { AuthorityValueModel } from './models/authority-value.model';
import { PageInfo } from '../shared/page-info.model';
import { PaginatedList } from '../data/paginated-list';
describe('IntegrationResponseParsingService', () => { describe('IntegrationResponseParsingService', () => {
let service: IntegrationResponseParsingService; let service: IntegrationResponseParsingService;
@@ -78,7 +80,7 @@ describe('IntegrationResponseParsingService', () => {
}, },
_links: { _links: {
self: 'https://rest.api/integration/authorities/type/entries' self: { href: 'https://rest.api/integration/authorities/type/entries' }
} }
}, },
statusCode: '200' statusCode: '200'
@@ -141,39 +143,44 @@ describe('IntegrationResponseParsingService', () => {
}, },
statusCode: '200' statusCode: '200'
}; };
const pageinfo = Object.assign(new PageInfo(), { elementsPerPage: 5, totalElements: 5, totalPages: 1, currentPage: 1 });
const definitions = [ const definitions = new PaginatedList(pageinfo,[
Object.assign(new AuthorityValueModel(), { Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'One', display: 'One',
id: 'One', id: 'One',
otherInformation: {}, otherInformation: undefined,
value: 'One' value: 'One'
}), }),
Object.assign(new AuthorityValueModel(), { Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Two', display: 'Two',
id: 'Two', id: 'Two',
otherInformation: {}, otherInformation: undefined,
value: 'Two' value: 'Two'
}), }),
Object.assign(new AuthorityValueModel(), { Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Three', display: 'Three',
id: 'Three', id: 'Three',
otherInformation: {}, otherInformation: undefined,
value: 'Three' value: 'Three'
}), }),
Object.assign(new AuthorityValueModel(), { Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Four', display: 'Four',
id: 'Four', id: 'Four',
otherInformation: {}, otherInformation: undefined,
value: 'Four' value: 'Four'
}), }),
Object.assign(new AuthorityValueModel(), { Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Five', display: 'Five',
id: 'Five', id: 'Five',
otherInformation: {}, otherInformation: undefined,
value: 'Five' value: 'Five'
}) })
]; ]);
it('should return a IntegrationSuccessResponse if data contains a valid endpoint response', () => { it('should return a IntegrationSuccessResponse if data contains a valid endpoint response', () => {
const response = service.parse(validRequest, validResponse); const response = service.parse(validRequest, validResponse);

View File

@@ -33,7 +33,7 @@ export class IntegrationResponseParsingService extends BaseResponseParsingServic
parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse { parse(request: RestRequest, data: DSpaceRESTV2Response): RestResponse {
if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links)) { if (isNotEmpty(data.payload) && isNotEmpty(data.payload._links)) {
const dataDefinition = this.process<IntegrationModel,IntegrationType>(data.payload, request.href); const dataDefinition = this.process<IntegrationModel,IntegrationType>(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 { } else {
return new ErrorResponse( return new ErrorResponse(
Object.assign( Object.assign(