From d16ee886418d8f1b2ec0c073d5276ab3eff86e16 Mon Sep 17 00:00:00 2001 From: lotte Date: Wed, 17 Jul 2019 16:28:17 +0200 Subject: [PATCH] fixed and tests for equals method --- .../+my-dspace-page/my-dspace-result.model.ts | 2 +- .../models/normalized-eperson.model.ts | 3 +- .../eperson/models/normalized-group.model.ts | 4 +- src/app/core/metadata/metadatafield.model.ts | 2 +- src/app/core/metadata/metadataschema.model.ts | 7 +- .../normalized-metadata-schema.model.ts | 4 +- src/app/core/registry/registry.service.ts | 2 +- src/app/core/shared/browse-entry.model.ts | 13 +--- src/app/core/shared/dspace-object.model.ts | 2 +- .../search/search-sidebar.service.spec.ts | 4 +- .../models/submission-object.model.ts | 3 +- .../core/tasks/models/task-object.model.ts | 3 +- src/app/core/utilities/equals.decorators.ts | 2 +- src/app/core/utilities/equatable.spec.ts | 70 +++++++++++++++++++ src/app/core/utilities/equatable.ts | 10 ++- ...dynamic-lookup-relation-modal.component.ts | 7 +- .../shared/listable-object.model.ts | 3 + ...em-search-result-list-element.component.ts | 10 +-- .../selectable-list.reducer.ts | 6 +- .../search/normalized-search-result.model.ts | 2 +- .../search-labels.component.spec.ts | 10 +-- src/app/shared/search/search-result.model.ts | 2 +- ...rch-switch-configuration.component.spec.ts | 15 ++-- 23 files changed, 128 insertions(+), 58 deletions(-) create mode 100644 src/app/core/utilities/equatable.spec.ts create mode 100644 src/app/shared/object-collection/shared/listable-object.model.ts diff --git a/src/app/+my-dspace-page/my-dspace-result.model.ts b/src/app/+my-dspace-page/my-dspace-result.model.ts index d300ed0bc8..4a4f63aead 100644 --- a/src/app/+my-dspace-page/my-dspace-result.model.ts +++ b/src/app/+my-dspace-page/my-dspace-result.model.ts @@ -5,7 +5,7 @@ import { ListableObject } from '../shared/object-collection/shared/listable-obje /** * Represents a search result object of a certain () DSpaceObject */ -export class MyDSpaceResult implements ListableObject { +export class MyDSpaceResult extends ListableObject { /** * The DSpaceObject that was found */ diff --git a/src/app/core/eperson/models/normalized-eperson.model.ts b/src/app/core/eperson/models/normalized-eperson.model.ts index ad4b20ee80..e9d6f9fccd 100644 --- a/src/app/core/eperson/models/normalized-eperson.model.ts +++ b/src/app/core/eperson/models/normalized-eperson.model.ts @@ -1,7 +1,6 @@ import { autoserialize, deserialize, inheritSerialization } from 'cerialize'; import { CacheableObject } from '../../cache/object-cache.reducer'; -import { ListableObject } from '../../../shared/object-collection/shared/listable-object.model'; import { NormalizedDSpaceObject } from '../../cache/models/normalized-dspace-object.model'; import { EPerson } from './eperson.model'; import { mapsTo, relationship } from '../../cache/builders/build-decorators'; @@ -9,7 +8,7 @@ import { ResourceType } from '../../shared/resource-type'; @mapsTo(EPerson) @inheritSerialization(NormalizedDSpaceObject) -export class NormalizedEPerson extends NormalizedDSpaceObject implements CacheableObject, ListableObject { +export class NormalizedEPerson extends NormalizedDSpaceObject implements CacheableObject { /** * A string representing the unique handle of this EPerson diff --git a/src/app/core/eperson/models/normalized-group.model.ts b/src/app/core/eperson/models/normalized-group.model.ts index f86bec8628..5435bbf1de 100644 --- a/src/app/core/eperson/models/normalized-group.model.ts +++ b/src/app/core/eperson/models/normalized-group.model.ts @@ -1,7 +1,6 @@ import { autoserialize, deserialize, inheritSerialization } from 'cerialize'; import { CacheableObject } from '../../cache/object-cache.reducer'; -import { ListableObject } from '../../../shared/object-collection/shared/listable-object.model'; import { NormalizedDSpaceObject } from '../../cache/models/normalized-dspace-object.model'; import { mapsTo, relationship } from '../../cache/builders/build-decorators'; import { Group } from './group.model'; @@ -9,7 +8,7 @@ import { ResourceType } from '../../shared/resource-type'; @mapsTo(Group) @inheritSerialization(NormalizedDSpaceObject) -export class NormalizedGroup extends NormalizedDSpaceObject implements CacheableObject, ListableObject { +export class NormalizedGroup extends NormalizedDSpaceObject implements CacheableObject { /** * List of Groups that this Group belong to @@ -36,3 +35,4 @@ export class NormalizedGroup extends NormalizedDSpaceObject implements Ca @autoserialize public permanent: boolean; } + diff --git a/src/app/core/metadata/metadatafield.model.ts b/src/app/core/metadata/metadatafield.model.ts index ba28b59d0e..81de2e8938 100644 --- a/src/app/core/metadata/metadatafield.model.ts +++ b/src/app/core/metadata/metadatafield.model.ts @@ -3,7 +3,7 @@ import { autoserialize } from 'cerialize'; import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; import { isNotEmpty } from '../../shared/empty.util'; -export class MetadataField implements ListableObject { +export class MetadataField extends ListableObject { @autoserialize id: number; diff --git a/src/app/core/metadata/metadataschema.model.ts b/src/app/core/metadata/metadataschema.model.ts index 13fb8e8b4e..7e96b5cb27 100644 --- a/src/app/core/metadata/metadataschema.model.ts +++ b/src/app/core/metadata/metadataschema.model.ts @@ -1,16 +1,13 @@ import { autoserialize } from 'cerialize'; import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; +import { CacheableObject } from '../cache/object-cache.reducer'; -export class MetadataSchema implements ListableObject { - @autoserialize +export class MetadataSchema extends ListableObject { id: number; - @autoserialize self: string; - @autoserialize prefix: string; - @autoserialize namespace: string; } diff --git a/src/app/core/metadata/normalized-metadata-schema.model.ts b/src/app/core/metadata/normalized-metadata-schema.model.ts index c121938940..420a9d4dab 100644 --- a/src/app/core/metadata/normalized-metadata-schema.model.ts +++ b/src/app/core/metadata/normalized-metadata-schema.model.ts @@ -1,14 +1,13 @@ import { autoserialize } from 'cerialize'; import { NormalizedObject } from '../cache/models/normalized-object.model'; import { mapsTo } from '../cache/builders/build-decorators'; -import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; import { MetadataSchema } from './metadataschema.model'; /** * Normalized class for a DSpace MetadataSchema */ @mapsTo(MetadataSchema) -export class NormalizedMetadataSchema extends NormalizedObject implements ListableObject { +export class NormalizedMetadataSchema extends NormalizedObject { /** * The unique identifier for this schema */ @@ -32,4 +31,5 @@ export class NormalizedMetadataSchema extends NormalizedObject i */ @autoserialize namespace: string; + } diff --git a/src/app/core/registry/registry.service.ts b/src/app/core/registry/registry.service.ts index 137b4c3a87..ff0e426bef 100644 --- a/src/app/core/registry/registry.service.ts +++ b/src/app/core/registry/registry.service.ts @@ -400,7 +400,7 @@ export class RegistryService { distinctUntilChanged() ); - const serializedSchema = new DSpaceRESTv2Serializer(NormalizedObjectFactory.getConstructor(ResourceType.MetadataSchema)).serialize(schema as NormalizedMetadataSchema); + const serializedSchema = new DSpaceRESTv2Serializer(NormalizedObjectFactory.getConstructor(ResourceType.MetadataSchema)).serialize(schema as any as NormalizedMetadataSchema); const request$ = endpoint$.pipe( take(1), diff --git a/src/app/core/shared/browse-entry.model.ts b/src/app/core/shared/browse-entry.model.ts index 0421ee1c3c..0a61bbee70 100644 --- a/src/app/core/shared/browse-entry.model.ts +++ b/src/app/core/shared/browse-entry.model.ts @@ -1,8 +1,8 @@ import { autoserialize, autoserializeAs } from 'cerialize'; -import { Equatable } from '../utilities/equatable'; -import { hasValue } from '../../shared/empty.util'; +import { ListableObject } from '../../shared/object-collection/shared/listable-object.model'; +import { excludeFromEquals } from '../utilities/equals.decorators'; -export class BrowseEntry implements Equatable { +export class BrowseEntry extends ListableObject { @autoserialize type: string; @@ -19,11 +19,4 @@ export class BrowseEntry implements Equatable { @autoserialize count: number; - equals(other: BrowseEntry): boolean { - if (hasValue(other)) { - return false; - } - return false; - } - } diff --git a/src/app/core/shared/dspace-object.model.ts b/src/app/core/shared/dspace-object.model.ts index 063398b339..33e3e1bb6a 100644 --- a/src/app/core/shared/dspace-object.model.ts +++ b/src/app/core/shared/dspace-object.model.ts @@ -12,7 +12,7 @@ import { hasNoValue } from '../../shared/empty.util'; /** * An abstract model class for a DSpaceObject. */ -export class DSpaceObject implements CacheableObject, ListableObject { +export class DSpaceObject extends ListableObject implements CacheableObject { private _name: string; diff --git a/src/app/core/shared/search/search-sidebar.service.spec.ts b/src/app/core/shared/search/search-sidebar.service.spec.ts index b6ad88ad0d..2abfc7c6a5 100644 --- a/src/app/core/shared/search/search-sidebar.service.spec.ts +++ b/src/app/core/shared/search/search-sidebar.service.spec.ts @@ -1,10 +1,10 @@ import { Store } from '@ngrx/store'; import { SearchSidebarService } from './search-sidebar.service'; -import { AppState } from '../../app.reducer'; import { async, TestBed } from '@angular/core/testing'; import { of as observableOf } from 'rxjs'; import { SearchSidebarCollapseAction, SearchSidebarExpandAction } from '../../../shared/search/search-sidebar/search-sidebar.actions'; -import { HostWindowService } from '../../shared/host-window.service'; +import { AppState } from '../../../app.reducer'; +import { HostWindowService } from '../../../shared/host-window.service'; describe('SearchSidebarService', () => { let service: SearchSidebarService; diff --git a/src/app/core/submission/models/submission-object.model.ts b/src/app/core/submission/models/submission-object.model.ts index 23f75553c5..0b1110fa24 100644 --- a/src/app/core/submission/models/submission-object.model.ts +++ b/src/app/core/submission/models/submission-object.model.ts @@ -1,7 +1,6 @@ import { Observable } from 'rxjs'; import { CacheableObject } from '../../cache/object-cache.reducer'; -import { ListableObject } from '../../../shared/object-collection/shared/listable-object.model'; import { DSpaceObject } from '../../shared/dspace-object.model'; import { EPerson } from '../../eperson/models/eperson.model'; import { RemoteData } from '../../data/remote-data'; @@ -18,7 +17,7 @@ export interface SubmissionObjectError { /** * An abstract model class for a SubmissionObject. */ -export abstract class SubmissionObject extends DSpaceObject implements CacheableObject, ListableObject { +export abstract class SubmissionObject extends DSpaceObject implements CacheableObject { /** * The workspaceitem/workflowitem identifier diff --git a/src/app/core/tasks/models/task-object.model.ts b/src/app/core/tasks/models/task-object.model.ts index 97a1c9f59e..cc48a73514 100644 --- a/src/app/core/tasks/models/task-object.model.ts +++ b/src/app/core/tasks/models/task-object.model.ts @@ -2,14 +2,13 @@ import { Observable } from 'rxjs'; import { CacheableObject } from '../../cache/object-cache.reducer'; import { DSpaceObject } from '../../shared/dspace-object.model'; -import { ListableObject } from '../../../shared/object-collection/shared/listable-object.model'; import { RemoteData } from '../../data/remote-data'; import { Workflowitem } from '../../submission/models/workflowitem.model'; /** * An abstract model class for a TaskObject. */ -export class TaskObject extends DSpaceObject implements CacheableObject, ListableObject { +export class TaskObject extends DSpaceObject implements CacheableObject { /** * The task identifier diff --git a/src/app/core/utilities/equals.decorators.ts b/src/app/core/utilities/equals.decorators.ts index 7088de5149..efa6a6c053 100644 --- a/src/app/core/utilities/equals.decorators.ts +++ b/src/app/core/utilities/equals.decorators.ts @@ -34,6 +34,6 @@ export function fieldsForEquals(...fields: string[]): any { export function getFieldsForEquals(constructor: Function, field: string) { - const fieldMap = excludedFromEquals.get(constructor) || new Map(); + const fieldMap = fieldsForEqualsMap.get(constructor) || new Map(); return fieldMap.get(field); } \ No newline at end of file diff --git a/src/app/core/utilities/equatable.spec.ts b/src/app/core/utilities/equatable.spec.ts new file mode 100644 index 0000000000..6fb7061f23 --- /dev/null +++ b/src/app/core/utilities/equatable.spec.ts @@ -0,0 +1,70 @@ +import { excludeFromEquals, fieldsForEquals } from './equals.decorators'; +import { EquatableObject } from './equatable'; +import { cloneDeep } from 'lodash'; + +class Dog extends EquatableObject { + public name: string; + + @excludeFromEquals + public ballsCaught: number; + + @fieldsForEquals('name', 'age') + public owner: { + name: string; + age: number; + favouriteFood: string; + } +} + +fdescribe('equatable', () => { + let dogRoger: Dog; + let dogMissy: Dog; + + beforeEach(() => { + dogRoger = new Dog(); + dogRoger.name = 'Roger'; + dogRoger.ballsCaught = 6; + dogRoger.owner = { name: 'Tommy', age: 16, favouriteFood: 'spaghetti' }; + + dogMissy = new Dog(); + dogMissy.name = 'Missy'; + dogMissy.ballsCaught = 9; + dogMissy.owner = { name: 'Jenny', age: 29, favouriteFood: 'pizza' }; + }); + + it('should return false when the other object is undefined', () => { + const isEqual = dogRoger.equals(undefined); + expect(isEqual).toBe(false); + }); + + it('should return true when the other object is the exact same object', () => { + const isEqual = dogRoger.equals(dogRoger); + expect(isEqual).toBe(true); + }); + + it('should return true when the other object is an exact copy of the first one', () => { + const copyOfDogRoger = cloneDeep(dogRoger); + const isEqual = dogRoger.equals(copyOfDogRoger); + expect(isEqual).toBe(true); + }); + + it('should return false when the other object differs in all fields', () => { + const isEqual = dogRoger.equals(dogMissy); + expect(isEqual).toBe(false); + }); + + it('should return true when the other object only differs in fields that are marked as excludeFromEquals', () => { + const copyOfDogRoger = cloneDeep(dogRoger); + copyOfDogRoger.ballsCaught = 4; + const isEqual = dogRoger.equals(copyOfDogRoger); + expect(isEqual).toBe(true); + }); + + it('should return false when the other object differs in fields that are not marked as excludeFromEquals', () => { + const copyOfDogRoger = cloneDeep(dogRoger); + copyOfDogRoger.name = 'Elliot'; + const isEqual = dogRoger.equals(copyOfDogRoger); + expect(isEqual).toBe(false); + }); +}); + diff --git a/src/app/core/utilities/equatable.ts b/src/app/core/utilities/equatable.ts index 15dc680514..adc46a06be 100644 --- a/src/app/core/utilities/equatable.ts +++ b/src/app/core/utilities/equatable.ts @@ -12,11 +12,11 @@ function equalsByFields(object1, object2, fieldList): boolean { if (hasNoValue(object1[key]) || hasNoValue(object2[key])) { return true; } - const mapping = getFieldsForEquals(this.constructor, key); + const mapping = getFieldsForEquals(object1.constructor, key); if (hasValue(mapping)) { return !equalsByFields(object1[key], object2[key], mapping); } - if (this[key] instanceof EquatableObject) { + if (object1[key] instanceof EquatableObject) { return !object1[key].equals(object2[key]); } return object1[key] !== object2[key]; @@ -26,6 +26,12 @@ function equalsByFields(object1, object2, fieldList): boolean { export abstract class EquatableObject { equals(other: T): boolean { + if (hasNoValue(other)) { + return false; + } + if (this as any === other) { + return true; + } const excludedKeys = getExcludedFromEqualsFor(this.constructor); const keys = Object.keys(this).filter((key) => excludedKeys.findIndex((excludedKey) => key === excludedKey) < 0); return equalsByFields(this, other, keys); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup-relation/dynamic-lookup-relation-modal.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup-relation/dynamic-lookup-relation-modal.component.ts index 00f5b8e655..0a29f9249c 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup-relation/dynamic-lookup-relation-modal.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/lookup-relation/dynamic-lookup-relation-modal.component.ts @@ -8,15 +8,14 @@ import { PaginatedSearchOptions } from '../../../../../search/paginated-search-o import { DSpaceObject } from '../../../../../../core/shared/dspace-object.model'; import { PaginationComponentOptions } from '../../../../../pagination/pagination-component-options.model'; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'; -import { hasNoValue, hasValue, isNotEmpty } from '../../../../../empty.util'; -import { getSucceededRemoteData } from '../../../../../../core/shared/operators'; -import { concat, map, multicast, take, takeWhile, tap } from 'rxjs/operators'; +import { hasValue } from '../../../../../empty.util'; +import { concat, map, multicast, take, takeWhile } from 'rxjs/operators'; import { Router } from '@angular/router'; import { SEARCH_CONFIG_SERVICE } from '../../../../../../+my-dspace-page/my-dspace-page.component'; import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service'; import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service'; -import { ListableObject } from '../../../../../object-collection/shared/listable-object.model'; import { SelectableListState } from '../../../../../object-list/selectable-list/selectable-list.reducer'; +import { ListableObject } from '../../../../../object-collection/shared/listable-object.model'; const RELATION_TYPE_FILTER_PREFIX = 'f.entityType='; diff --git a/src/app/shared/object-collection/shared/listable-object.model.ts b/src/app/shared/object-collection/shared/listable-object.model.ts new file mode 100644 index 0000000000..1653ac6985 --- /dev/null +++ b/src/app/shared/object-collection/shared/listable-object.model.ts @@ -0,0 +1,3 @@ +import { EquatableObject } from '../../../core/utilities/equatable'; + +export class ListableObject extends EquatableObject{} diff --git a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts index 7df3ab5681..6fe352a11d 100644 --- a/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts +++ b/src/app/shared/object-list/item-list-element/item-types/typed-item-search-result-list-element.component.ts @@ -26,10 +26,12 @@ export class TypedItemSearchResultListElementComponent extends SearchResultListE this.object = obj as ItemSearchResult; this.dso = this.object.indexableObject; } else { - this.object = { - indexableObject: obj as Item, - hitHighlights: new MetadataMap() - }; + this.object = Object.assign( + new ItemSearchResult(), + { + indexableObject: obj as Item, + hitHighlights: new MetadataMap() + }); this.dso = obj as Item; } this.item = this.dso; diff --git a/src/app/shared/object-list/selectable-list/selectable-list.reducer.ts b/src/app/shared/object-list/selectable-list/selectable-list.reducer.ts index 80c6d594d2..61a56bedd8 100644 --- a/src/app/shared/object-list/selectable-list/selectable-list.reducer.ts +++ b/src/app/shared/object-list/selectable-list/selectable-list.reducer.ts @@ -80,13 +80,13 @@ function selectSingle(state: SelectableListState, action: SelectableListSelectSi } function deselect(state: SelectableListState, action: SelectableListDeselectAction) { - const newSelection = state.selection.filter((selected) => hasNoValue(action.payload.find((object) => object.uuid === selected.uuid))); + const newSelection = state.selection.filter((selected) => hasNoValue(action.payload.find((object) => object.equals(selected)))); return Object.assign({}, state, { selection: newSelection }); } function deselectSingle(state: SelectableListState, action: SelectableListDeselectSingleAction) { const newSelection = state.selection.filter((selected) => { - return selected.uuid !== action.payload.uuid + return !selected.equals(action.payload); }); return Object.assign({}, state, { selection: newSelection }); } @@ -101,5 +101,5 @@ function clearSelection(id: string) { function isObjectInSelection(selection: ListableObject[], object: ListableObject) { - return selection.findIndex((selected) => selected.uuid === object.uuid) >= 0 + return selection.findIndex((selected) => selected.equals(object)) >= 0 } diff --git a/src/app/shared/search/normalized-search-result.model.ts b/src/app/shared/search/normalized-search-result.model.ts index 7f5631920a..0956881fda 100644 --- a/src/app/shared/search/normalized-search-result.model.ts +++ b/src/app/shared/search/normalized-search-result.model.ts @@ -5,7 +5,7 @@ import { ListableObject } from '../object-collection/shared/listable-object.mode /** * Represents a normalized version of a search result object of a certain DSpaceObject */ -export class NormalizedSearchResult implements ListableObject { +export class NormalizedSearchResult extends ListableObject { /** * The UUID of the DSpaceObject that was found */ diff --git a/src/app/shared/search/search-labels/search-labels.component.spec.ts b/src/app/shared/search/search-labels/search-labels.component.spec.ts index d28698764c..7849deca6f 100644 --- a/src/app/shared/search/search-labels/search-labels.component.spec.ts +++ b/src/app/shared/search/search-labels/search-labels.component.spec.ts @@ -2,15 +2,15 @@ import { SearchLabelsComponent } from './search-labels.component'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { TranslateModule } from '@ngx-translate/core'; -import { SearchService } from '../search-service/search.service'; import { ChangeDetectionStrategy, NO_ERRORS_SCHEMA } from '@angular/core'; import { FormsModule } from '@angular/forms'; -import { SearchServiceStub } from '../../shared/testing/search-service-stub'; import { Observable, of as observableOf } from 'rxjs'; import { Params } from '@angular/router'; -import { ObjectKeysPipe } from '../../shared/utils/object-keys-pipe'; -import { SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.component'; -import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service-stub'; +import { ObjectKeysPipe } from '../../utils/object-keys-pipe'; +import { SearchServiceStub } from '../../testing/search-service-stub'; +import { SEARCH_CONFIG_SERVICE } from '../../../+my-dspace-page/my-dspace-page.component'; +import { SearchService } from '../../../core/shared/search/search.service'; +import { SearchConfigurationServiceStub } from '../../testing/search-configuration-service-stub'; describe('SearchLabelsComponent', () => { let comp: SearchLabelsComponent; diff --git a/src/app/shared/search/search-result.model.ts b/src/app/shared/search/search-result.model.ts index ee2f1231cb..4afd3d1ccb 100644 --- a/src/app/shared/search/search-result.model.ts +++ b/src/app/shared/search/search-result.model.ts @@ -5,7 +5,7 @@ import { ListableObject } from '../object-collection/shared/listable-object.mode /** * Represents a search result object of a certain () DSpaceObject */ -export class SearchResult implements ListableObject { +export class SearchResult extends ListableObject { /** * The DSpaceObject that was found */ diff --git a/src/app/shared/search/search-switch-configuration/search-switch-configuration.component.spec.ts b/src/app/shared/search/search-switch-configuration/search-switch-configuration.component.spec.ts index 602dee33e6..05108905f2 100644 --- a/src/app/shared/search/search-switch-configuration/search-switch-configuration.component.spec.ts +++ b/src/app/shared/search/search-switch-configuration/search-switch-configuration.component.spec.ts @@ -6,13 +6,16 @@ import { of as observableOf } from 'rxjs'; import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { SearchSwitchConfigurationComponent } from './search-switch-configuration.component'; -import { MYDSPACE_ROUTE, SEARCH_CONFIG_SERVICE } from '../../+my-dspace-page/my-dspace-page.component'; -import { SearchConfigurationServiceStub } from '../../shared/testing/search-configuration-service-stub'; -import { MockTranslateLoader } from '../../shared/mocks/mock-translate-loader'; import { NavigationExtras, Router } from '@angular/router'; -import { RouterStub } from '../../shared/testing/router-stub'; -import { MyDSpaceConfigurationValueType } from '../../+my-dspace-page/my-dspace-configuration-value-type'; -import { SearchService } from '../search-service/search.service'; +import { SearchConfigurationServiceStub } from '../../testing/search-configuration-service-stub'; +import { RouterStub } from '../../testing/router-stub'; +import { SearchService } from '../../../core/shared/search/search.service'; +import { + MYDSPACE_ROUTE, + SEARCH_CONFIG_SERVICE +} from '../../../+my-dspace-page/my-dspace-page.component'; +import { MyDSpaceConfigurationValueType } from '../../../+my-dspace-page/my-dspace-configuration-value-type'; +import { MockTranslateLoader } from '../../mocks/mock-translate-loader'; describe('SearchSwitchConfigurationComponent', () => {