1
0

Reverted object cache method names back to the original UUID convention.

This commit is contained in:
Michael W Spalti
2019-10-30 14:23:50 -07:00
parent d309b2081c
commit 0dd765d84a
6 changed files with 13 additions and 13 deletions

View File

@@ -75,15 +75,15 @@ export class ObjectCacheService {
/** /**
* Get an observable of the object with the specified UUID * Get an observable of the object with the specified UUID
* *
* @param id * @param uuid
* The UUID of the object to get * The UUID of the object to get
* @return Observable<NormalizedObject<T>> * @return Observable<NormalizedObject<T>>
* An observable of the requested object in normalized form * An observable of the requested object in normalized form
*/ */
getObjectByID<T extends CacheableObject>(id: string): getObjectByUUID<T extends CacheableObject>(uuid: string):
Observable<NormalizedObject<T>> { Observable<NormalizedObject<T>> {
return this.store.pipe( return this.store.pipe(
select(selfLinkFromUuidSelector(id)), select(selfLinkFromUuidSelector(uuid)),
mergeMap((selfLink: string) => this.getObjectBySelfLink(selfLink) mergeMap((selfLink: string) => this.getObjectBySelfLink(selfLink)
) )
) )
@@ -189,17 +189,17 @@ export class ObjectCacheService {
/** /**
* Check whether the object with the specified UUID is cached * Check whether the object with the specified UUID is cached
* *
* @param id * @param uuid
* The UUID of the object to check * The UUID of the object to check
* @return boolean * @return boolean
* true if the object with the specified UUID is cached, * true if the object with the specified UUID is cached,
* false otherwise * false otherwise
*/ */
hasById(id: string): boolean { hasByUUID(uuid: string): boolean {
let result: boolean; let result: boolean;
this.store.pipe( this.store.pipe(
select(selfLinkFromUuidSelector(id)), select(selfLinkFromUuidSelector(uuid)),
take(1) take(1)
).subscribe((selfLink: string) => result = this.hasBySelfLink(selfLink)); ).subscribe((selfLink: string) => result = this.hasBySelfLink(selfLink));

View File

@@ -95,7 +95,7 @@ describe('ComColDataService', () => {
function initMockObjectCacheService(): ObjectCacheService { function initMockObjectCacheService(): ObjectCacheService {
return jasmine.createSpyObj('objectCache', { return jasmine.createSpyObj('objectCache', {
getObjectByID: cold('d-', { getObjectByUUID: cold('d-', {
d: { d: {
_links: { _links: {
[LINK_NAME]: scopedEndpoint [LINK_NAME]: scopedEndpoint
@@ -160,7 +160,7 @@ describe('ComColDataService', () => {
it('should fetch the scope Community from the cache', () => { it('should fetch the scope Community from the cache', () => {
scheduler.schedule(() => service.getBrowseEndpoint(options).subscribe()); scheduler.schedule(() => service.getBrowseEndpoint(options).subscribe());
scheduler.flush(); scheduler.flush();
expect(objectCache.getObjectByID).toHaveBeenCalledWith(scopeID); expect(objectCache.getObjectByUUID).toHaveBeenCalledWith(scopeID);
}); });
it('should return the endpoint to fetch resources within the given scope', () => { it('should return the endpoint to fetch resources within the given scope', () => {

View File

@@ -49,7 +49,7 @@ export abstract class ComColDataService<T extends CacheableObject> extends DataS
); );
const successResponses = responses.pipe( const successResponses = responses.pipe(
filter((response) => response.isSuccessful), filter((response) => response.isSuccessful),
mergeMap(() => this.objectCache.getObjectByID(options.scopeID)), mergeMap(() => this.objectCache.getObjectByUUID(options.scopeID)),
map((nc: NormalizedCommunity) => nc._links[linkPath]), map((nc: NormalizedCommunity) => nc._links[linkPath]),
filter((href) => isNotEmpty(href)) filter((href) => isNotEmpty(href))
); );

View File

@@ -149,7 +149,7 @@ export abstract class DataService<T extends CacheableObject> {
findById(id: string): Observable<RemoteData<T>> { findById(id: string): Observable<RemoteData<T>> {
const hrefObs = this.halService.getEndpoint(this.linkPath).pipe( const hrefObs = this.halService.getEndpoint(this.linkPath).pipe(
map((endpoint: string) => this.getIDHref(endpoint, encodeURIComponent(id)))) map((endpoint: string) => this.getIDHref(endpoint, encodeURIComponent(id))));
hrefObs.pipe( hrefObs.pipe(
find((href: string) => hasValue(href))) find((href: string) => hasValue(href)))

View File

@@ -298,7 +298,7 @@ describe('RequestService', () => {
describe('in the ObjectCache', () => { describe('in the ObjectCache', () => {
beforeEach(() => { beforeEach(() => {
(objectCache.hasBySelfLink as any).and.returnValue(true); (objectCache.hasBySelfLink as any).and.returnValue(true);
(objectCache.hasById as any).and.returnValue(true); (objectCache.hasByUUID as any).and.returnValue(true);
spyOn(serviceAsAny, 'hasByHref').and.returnValue(false); spyOn(serviceAsAny, 'hasByHref').and.returnValue(false);
}); });

View File

@@ -4,12 +4,12 @@ export function getMockObjectCacheService(): ObjectCacheService {
return jasmine.createSpyObj('objectCacheService', [ return jasmine.createSpyObj('objectCacheService', [
'add', 'add',
'remove', 'remove',
'getByID', 'getByUUID',
'getBySelfLink', 'getBySelfLink',
'getRequestHrefBySelfLink', 'getRequestHrefBySelfLink',
'getRequestHrefByUUID', 'getRequestHrefByUUID',
'getList', 'getList',
'hasById', 'hasByUUID',
'hasBySelfLink' 'hasBySelfLink'
]); ]);