Merge remote-tracking branch 'remotes/origin/master' into submission

# Conflicts:
#	package.json
#	src/app/+item-page/edit-item-page/item-delete/item-delete.component.spec.ts
#	src/app/+item-page/edit-item-page/item-private/item-private.component.spec.ts
#	src/app/+item-page/edit-item-page/item-public/item-public.component.spec.ts
#	src/app/+item-page/edit-item-page/item-reinstate/item-reinstate.component.spec.ts
#	src/app/+item-page/edit-item-page/item-withdraw/item-withdraw.component.spec.ts
#	src/app/+item-page/edit-item-page/simple-item-action/abstract-simple-item-action.component.spec.ts
#	src/app/+search-page/search-service/search.service.spec.ts
#	src/app/core/auth/auth-response-parsing.service.spec.ts
#	src/app/core/auth/auth-response-parsing.service.ts
#	src/app/core/cache/builders/remote-data-build.service.ts
#	src/app/core/cache/response-cache.reducer.spec.ts
#	src/app/core/cache/response-cache.service.spec.ts
#	src/app/core/cache/response.models.ts
#	src/app/core/config/config-response-parsing.service.ts
#	src/app/core/core.effects.ts
#	src/app/core/core.module.ts
#	src/app/core/core.reducers.ts
#	src/app/core/data/base-response-parsing.service.ts
#	src/app/core/data/data.service.ts
#	src/app/core/data/item-data.service.spec.ts
#	src/app/core/data/request.models.ts
#	src/app/core/data/request.service.spec.ts
#	src/app/core/data/request.service.ts
#	src/app/core/integration/integration-response-parsing.service.spec.ts
#	src/app/core/integration/integration-response-parsing.service.ts
#	src/app/core/integration/integration.service.ts
#	src/app/core/metadata/metadata.service.spec.ts
#	src/app/core/registry/registry.service.spec.ts
#	src/app/core/shared/hal-endpoint.service.ts
#	src/app/shared/form/builder/ds-dynamic-form-ui/ds-dynamic-form-control.component.ts
#	src/app/shared/mocks/mock-response-cache.service.ts
#	src/app/shared/shared.module.ts
This commit is contained in:
Giuseppe Digilio
2019-02-19 17:30:33 +01:00
192 changed files with 4412 additions and 1690 deletions

View File

@@ -3,10 +3,8 @@ import { ActionsSubject, Store } from '@ngrx/store';
import { cold, getTestScheduler, hot } from 'jasmine-marbles';
import { of as observableOf } from 'rxjs';
import { getMockObjectCacheService } from '../../shared/mocks/mock-object-cache.service';
import { getMockResponseCacheService } from '../../shared/mocks/mock-response-cache.service';
import { defaultUUID, getMockUUIDService } from '../../shared/mocks/mock-uuid.service';
import { ObjectCacheService } from '../cache/object-cache.service';
import { ResponseCacheService } from '../cache/response-cache.service';
import { CoreState } from '../core.reducers';
import { UUIDService } from '../shared/uuid.service';
import { RequestConfigureAction, RequestExecuteAction } from './request.actions';
@@ -29,7 +27,6 @@ describe('RequestService', () => {
let service: RequestService;
let serviceAsAny: any;
let objectCache: ObjectCacheService;
let responseCache: ResponseCacheService;
let uuidService: UUIDService;
let store: Store<CoreState>;
@@ -49,10 +46,6 @@ describe('RequestService', () => {
objectCache = getMockObjectCacheService();
(objectCache.hasBySelfLink as any).and.returnValue(false);
responseCache = getMockResponseCacheService();
(responseCache.has as any).and.returnValue(false);
(responseCache.get as any).and.returnValue(observableOf(undefined));
uuidService = getMockUUIDService();
store = new Store<CoreState>(new BehaviorSubject({}), new ActionsSubject(), null);
@@ -65,7 +58,6 @@ describe('RequestService', () => {
service = new RequestService(
objectCache,
responseCache,
uuidService,
store
);
@@ -178,11 +170,8 @@ describe('RequestService', () => {
it('should return an Observable of undefined', () => {
const result = service.getByUUID(testUUID);
const expected = cold('b', {
b: undefined
});
expect(result).toBeObservable(expected);
scheduler.expectObservable(result).toBe('b', { b: undefined });
});
});
@@ -314,7 +303,7 @@ describe('RequestService', () => {
describe('when the request is cached', () => {
describe('in the ObjectCache', () => {
beforeEach(() => {
(objectCache.hasBySelfLink as any).and.returnValues(true);
(objectCache.hasBySelfLink as any).and.returnValue(true);
});
it('should return true', () => {
@@ -326,12 +315,13 @@ describe('RequestService', () => {
});
describe('in the responseCache', () => {
beforeEach(() => {
(responseCache.has as any).and.returnValues(true);
spyOn(serviceAsAny, 'isReusable').and.returnValue(observableOf(true));
spyOn(serviceAsAny, 'getByHref').and.returnValue(observableOf(undefined));
});
describe('and it\'s a DSOSuccessResponse', () => {
beforeEach(() => {
(responseCache.get as any).and.returnValues(observableOf({
(serviceAsAny.getByHref as any).and.returnValue(observableOf({
response: {
isSuccessful: true,
resourceSelfLinks: [
@@ -353,6 +343,7 @@ describe('RequestService', () => {
});
it('should return false if not all top level links in the response are cached in the object cache', () => {
(objectCache.hasBySelfLink as any).and.returnValues(false, true, false);
spyOn(service, 'isPending').and.returnValue(false);
const result = serviceAsAny.isCachedOrPending(testGetRequest);
const expected = false;
@@ -360,11 +351,12 @@ describe('RequestService', () => {
expect(result).toEqual(expected);
});
});
describe('and it isn\'t a DSOSuccessResponse', () => {
beforeEach(() => {
(objectCache.hasBySelfLink as any).and.returnValues(false);
(responseCache.has as any).and.returnValues(true);
(responseCache.get as any).and.returnValues(observableOf({
(objectCache.hasBySelfLink as any).and.returnValue(false);
(service as any).isReusable.and.returnValue(observableOf(true));
(serviceAsAny.getByHref as any).and.returnValue(observableOf({
response: {
isSuccessful: true
}
@@ -505,4 +497,105 @@ describe('RequestService', () => {
});
});
describe('isReusable', () => {
describe('when the given UUID is has no value', () => {
let reusable;
beforeEach(() => {
const uuid = undefined;
reusable = serviceAsAny.isReusable(uuid);
});
it('return an observable emitting false', () => {
reusable.subscribe((isReusable) => expect(isReusable).toBe(false));
})
});
describe('when the given UUID has a value, but no cached entry is found', () => {
let reusable;
beforeEach(() => {
spyOn(service, 'getByUUID').and.returnValue(observableOf(undefined));
const uuid = 'a45bb291-1adb-40d9-b2fc-7ad9080607be';
reusable = serviceAsAny.isReusable(uuid);
});
it('return an observable emitting false', () => {
reusable.subscribe((isReusable) => expect(isReusable).toBe(false));
})
});
describe('when the given UUID has a value, a cached entry is found, but it has no response', () => {
let reusable;
beforeEach(() => {
spyOn(service, 'getByUUID').and.returnValue(observableOf({ response: undefined }));
const uuid = '53c9b814-ad8b-4567-9bc1-d9bb6cfba6c8';
reusable = serviceAsAny.isReusable(uuid);
});
it('return an observable emitting false', () => {
reusable.subscribe((isReusable) => expect(isReusable).toBe(false));
})
});
describe('when the given UUID has a value, a cached entry is found, but its response was not successful', () => {
let reusable;
beforeEach(() => {
spyOn(service, 'getByUUID').and.returnValue(observableOf({ response: { isSuccessful: false } }));
const uuid = '694c9b32-7b2e-4788-835b-ef3fc2252e6c';
reusable = serviceAsAny.isReusable(uuid);
});
it('return an observable emitting false', () => {
reusable.subscribe((isReusable) => expect(isReusable).toBe(false));
})
});
describe('when the given UUID has a value, a cached entry is found, its response was successful, but the response is outdated', () => {
let reusable;
const now = 100000;
const timeAdded = 99899;
const msToLive = 100;
beforeEach(() => {
spyOn(Date.prototype, 'getTime').and.returnValue(now);
spyOn(service, 'getByUUID').and.returnValue(observableOf({
response: {
isSuccessful: true,
timeAdded: timeAdded
},
request: {
responseMsToLive: msToLive
}
}));
const uuid = 'f9b85788-881c-4994-86b6-bae8dad024d2';
reusable = serviceAsAny.isReusable(uuid);
});
it('return an observable emitting false', () => {
reusable.subscribe((isReusable) => expect(isReusable).toBe(false));
})
});
describe('when the given UUID has a value, a cached entry is found, its response was successful, and the response is not outdated', () => {
let reusable;
const now = 100000;
const timeAdded = 99999;
const msToLive = 100;
beforeEach(() => {
spyOn(Date.prototype, 'getTime').and.returnValue(now);
spyOn(service, 'getByUUID').and.returnValue(observableOf({
response: {
isSuccessful: true,
timeAdded: timeAdded
},
request: {
responseMsToLive: msToLive
}
}));
const uuid = 'f9b85788-881c-4994-86b6-bae8dad024d2';
reusable = serviceAsAny.isReusable(uuid);
});
it('return an observable emitting true', () => {
reusable.subscribe((isReusable) => expect(isReusable).toBe(true));
})
})
})
});