Merge branch 'w2p-54472_Create-community-and-collection-pages' into w2p-58522_delete-collections-and-communities

This commit is contained in:
lotte
2019-01-07 12:01:15 +01:00

View File

@@ -23,15 +23,57 @@ describe('IntegrationResponseParsingService', () => {
const uuid = 'd9d30c0c-69b7-4369-8397-ca67c888974d'; const uuid = 'd9d30c0c-69b7-4369-8397-ca67c888974d';
const integrationEndpoint = 'https://rest.api/integration/authorities'; const integrationEndpoint = 'https://rest.api/integration/authorities';
const entriesEndpoint = `${integrationEndpoint}/${name}/entries?query=${query}&metadata=${metadata}&uuid=${uuid}`; const entriesEndpoint = `${integrationEndpoint}/${name}/entries?query=${query}&metadata=${metadata}&uuid=${uuid}`;
let validRequest;
beforeEach(() => { let validResponse;
service = new IntegrationResponseParsingService(EnvConfig, objectCacheService);
});
describe('parse', () => { let invalidResponse1;
const validRequest = new IntegrationRequest('69f375b5-19f4-4453-8c7a-7dc5c55aafbb', entriesEndpoint); let invalidResponse2;
let pageInfo;
let definitions;
const validResponse = { function initVars() {
pageInfo = Object.assign(new PageInfo(), { elementsPerPage: 5, totalElements: 5, totalPages: 1, currentPage: 1, self: 'https://rest.api/integration/authorities/type/entries'});
definitions = new PaginatedList(pageInfo,[
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'One',
id: 'One',
otherInformation: undefined,
value: 'One'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Two',
id: 'Two',
otherInformation: undefined,
value: 'Two'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Three',
id: 'Three',
otherInformation: undefined,
value: 'Three'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Four',
id: 'Four',
otherInformation: undefined,
value: 'Four'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Five',
id: 'Five',
otherInformation: undefined,
value: 'Five'
})
]);
validRequest = new IntegrationRequest('69f375b5-19f4-4453-8c7a-7dc5c55aafbb', entriesEndpoint);
validResponse = {
payload: { payload: {
page: { page: {
number: 0, number: 0,
@@ -86,12 +128,12 @@ describe('IntegrationResponseParsingService', () => {
statusCode: '200' statusCode: '200'
}; };
const invalidResponse1 = { invalidResponse1 = {
payload: {}, payload: {},
statusCode: '200' statusCode: '200'
}; };
const invalidResponse2 = { invalidResponse2 = {
payload: { payload: {
page: { page: {
number: 0, number: 0,
@@ -143,45 +185,13 @@ describe('IntegrationResponseParsingService', () => {
}, },
statusCode: '200' statusCode: '200'
}; };
const pageinfo = Object.assign(new PageInfo(), { elementsPerPage: 5, totalElements: 5, totalPages: 1, currentPage: 1 }); }
const definitions = new PaginatedList(pageinfo,[ beforeEach(() => {
Object.assign({}, new AuthorityValueModel(), { initVars();
type: 'authority', service = new IntegrationResponseParsingService(EnvConfig, objectCacheService);
display: 'One', });
id: 'One',
otherInformation: undefined,
value: 'One'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Two',
id: 'Two',
otherInformation: undefined,
value: 'Two'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Three',
id: 'Three',
otherInformation: undefined,
value: 'Three'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Four',
id: 'Four',
otherInformation: undefined,
value: 'Four'
}),
Object.assign({}, new AuthorityValueModel(), {
type: 'authority',
display: 'Five',
id: 'Five',
otherInformation: undefined,
value: 'Five'
})
]);
describe('parse', () => {
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);
expect(response.constructor).toBe(IntegrationSuccessResponse); expect(response.constructor).toBe(IntegrationSuccessResponse);