From d5f64fa9fc5a67093885c1d18e09d8fe8c452107 Mon Sep 17 00:00:00 2001
From: Denys Vuika
Date: Tue, 20 Jun 2017 11:47:01 +0100
Subject: [PATCH] [ADF-847] upgrade to use application configuration service
(#1986)
* migrate core lib to use server-side app config
* fix unit tests
* update Search tests
- update tests
- upgrade tests to use TestBed
* update UserInfo tests
* update Social tests
* update tests
* update unit tests
* cleanup old code
* update about page
* update demo shell readme
* dev and prod configurations
---
demo-shell-ng2/README.md | 101 +++++++++---------
.../{app.config.json => app.config-dev.json} | 0
demo-shell-ng2/app.config-prod.json | 7 ++
demo-shell-ng2/app/app.component.html | 2 -
demo-shell-ng2/app/app.component.ts | 23 ----
demo-shell-ng2/app/app.module.ts | 13 ++-
demo-shell-ng2/app/app.routes.ts | 6 +-
.../app/components/about/about.component.html | 19 +++-
.../app/components/about/about.component.ts | 12 ++-
demo-shell-ng2/app/components/index.ts | 1 -
.../login/login-demo.component.html | 10 --
.../components/setting/setting.component.css | 35 ------
.../components/setting/setting.component.html | 48 ---------
.../components/setting/setting.component.ts | 75 -------------
demo-shell-ng2/config/webpack.common.js | 5 +-
.../analytics-report-list.component.spec.ts | 6 +-
...lytics-report-parameters.component.spec.ts | 12 +--
.../src/services/diagrams.service.ts | 4 +-
.../src/services/form.service.spec.ts | 50 ++++-----
.../activiti-tasklist.service.spec.ts | 41 +++----
ng2-components/ng2-alfresco-core/README.md | 41 +++----
.../src/services/alfresco-api.service.ts | 58 ++--------
.../alfresco-authentication.service.spec.ts | 65 +++++------
.../services/alfresco-content.service.spec.ts | 46 ++++----
.../alfresco-settings.service.spec.ts | 39 ++++---
.../src/services/alfresco-settings.service.ts | 30 +++---
.../src/services/app-config.service.ts | 5 +-
.../services/auth-guard-bpm.service.spec.ts | 27 +++--
.../services/auth-guard-ecm.service.spec.ts | 27 +++--
.../src/services/auth-guard.service.spec.ts | 25 +++--
.../src/services/renditions.service.spec.ts | 35 +++---
.../services/document-list.service.spec.ts | 42 +++-----
.../alfresco-search-control.component.spec.ts | 19 +---
.../alfresco-search.component.spec.ts | 44 ++------
.../services/alfresco-search.service.spec.ts | 37 +++----
.../alfresco-thumbnail.service.spec.ts | 38 +++----
.../src/services/rating.service.spec.ts | 36 +++----
.../components/tag-actions.component.spec.ts | 2 +-
.../tag-node-list.component.spec.ts | 2 +-
.../src/services/tag.service.spec.ts | 44 ++++----
.../src/components/upload-button.component.ts | 7 +-
.../src/services/upload.service.spec.ts | 6 +-
.../src/services/bpm-user.service.spec.ts | 37 +++----
.../src/services/ecm-user.service.spec.ts | 45 +++-----
.../src/webscript.component.spec.ts | 2 +-
45 files changed, 469 insertions(+), 760 deletions(-)
rename demo-shell-ng2/{app.config.json => app.config-dev.json} (100%)
create mode 100644 demo-shell-ng2/app.config-prod.json
delete mode 100644 demo-shell-ng2/app/components/setting/setting.component.css
delete mode 100644 demo-shell-ng2/app/components/setting/setting.component.html
delete mode 100644 demo-shell-ng2/app/components/setting/setting.component.ts
diff --git a/demo-shell-ng2/README.md b/demo-shell-ng2/README.md
index 629f71b18b..8df6d4047a 100644
--- a/demo-shell-ng2/README.md
+++ b/demo-shell-ng2/README.md
@@ -1,14 +1,7 @@
-Alfresco Angular 2 Components
-
-
-
-
-
-
-
-
-
+# ADF Demo Application
+
+Please note that this application is not an official product, but a testing and demo application to showcase complex interactions for ADF components.
## Installing
@@ -20,6 +13,53 @@ cd alfresco-ng2-components/demo-shell-ng2/
npm install
```
+## Proxy settings and CORS
+
+To simplify development and reduce the time to get started the application features the following Proxy settings:
+
+- **http://localhost:3000/ecm** is mapped to **http://localhost:8080**
+- **http://localhost:3000/bpm** is mapped to **http://localhost:9999**
+
+The settings above address most common scenarios for running ACS on port 8080 and APS on port 9999 and allow you to skip the CORS configuration.
+
+If you would like to change default proxy settings, please edit the `config/webpack.common.js` file.
+
+## Application settings (server-side)
+
+All server-side application settings are stored in the `app.config-dev.json` and `app.config-prod.json` files.
+By default the configuration files have the content similar to the following one:
+
+```json
+{
+ "ecmHost": "http://localhost:3000/ecm",
+ "bpmHost": "http://localhost:3000/bpm",
+ "application": {
+ "name": "Alfresco"
+ }
+}
+```
+
+You can add any additional settings to the application configuration file if needed.
+
+Configuration files are picked based on environment settings (see `app.module.ts` for more details).
+
+```ts
+let appConfigFile = 'app.config-dev.json';
+if (process.env.ENV === 'production') {
+ appConfigFile = 'app.config-prod.json';
+}
+
+@NgModule({
+ imports: [
+ ...
+ CoreModule.forRoot({
+ appConfigFile: appConfigFile
+ }),
+ ...
+ ]
+})
+```
+
## Development build
```sh
@@ -58,43 +98,4 @@ If you want to run the demo shell with the latest change from the development br
```sh
./npm-clean.sh
./start-linked.sh -install
-```
-
-## Multi-language
-To support a new language you need to create your language file (.json) and add it to `i18n/` folder.
-
-```json
-{
- "username" : "Username",
- "input-required-message": "Required",
- "input-min-message": "Your username needs to be at least 4 characters.",
- "login-button": "Login"
-}
-```
-
-Directory structure:
-```
-.
-├── i18n/
-│ ├── en.json
-│ ├── it.json
-│ └── fr.json
-```
-
-## Custom-files
-
-If you need to add custom files on your project you can add this files in the folders public
-
-```
-.
-├── public/
-│ ├── images/
-│ ├── css/
-│ └── js/
-```
-
-the public folder above wil be copied in the root of your project and you can refer to them for example as
-
- * './images/custom_image.png'
- * './js/custom_script.js'
- * './css/custom_style.css'
+```
\ No newline at end of file
diff --git a/demo-shell-ng2/app.config.json b/demo-shell-ng2/app.config-dev.json
similarity index 100%
rename from demo-shell-ng2/app.config.json
rename to demo-shell-ng2/app.config-dev.json
diff --git a/demo-shell-ng2/app.config-prod.json b/demo-shell-ng2/app.config-prod.json
new file mode 100644
index 0000000000..0e8f560881
--- /dev/null
+++ b/demo-shell-ng2/app.config-prod.json
@@ -0,0 +1,7 @@
+{
+ "ecmHost": "http://localhost:3000/ecm",
+ "bpmHost": "http://localhost:3000/bpm",
+ "application": {
+ "name": "Alfresco"
+ }
+}
diff --git a/demo-shell-ng2/app/app.component.html b/demo-shell-ng2/app/app.component.html
index 4d860b8bcd..3619ac5ec1 100644
--- a/demo-shell-ng2/app/app.component.html
+++ b/demo-shell-ng2/app/app.component.html
@@ -21,7 +21,6 @@
DocumentList
Process Services
Login
- Settings
@@ -60,7 +59,6 @@
Tag
Social
About
- Settings
+
+ Server settings
+ The values below are taken from the AppConfigService and loaded from the '{{ configFile }}' file.
+
+ Alfresco Process Services URL: {{ bpmHost }}
+
+
+
+ Alfresco Content Services URL: {{ ecmHost }}
+
+
-
Current Commit position
-
{{githubUrlCommitAlpha}}
+
Source code
+
You are running the project based on the following commit:
+
Packages
+ Current project is using the following ADF libraries:
diff --git a/demo-shell-ng2/app/components/about/about.component.ts b/demo-shell-ng2/app/components/about/about.component.ts
index 1476afbc68..de70fee740 100644
--- a/demo-shell-ng2/app/components/about/about.component.ts
+++ b/demo-shell-ng2/app/components/about/about.component.ts
@@ -18,7 +18,7 @@
import { Component, OnInit } from '@angular/core';
import { Http } from '@angular/http';
import { ObjectDataTableAdapter } from 'ng2-alfresco-datatable';
-import { LogService } from 'ng2-alfresco-core';
+import { LogService, AppConfigService } from 'ng2-alfresco-core';
@Component({
selector: 'about-page',
@@ -28,10 +28,14 @@ import { LogService } from 'ng2-alfresco-core';
export class AboutComponent implements OnInit {
data: ObjectDataTableAdapter;
-
githubUrlCommitAlpha: string = 'https://github.com/Alfresco/alfresco-ng2-components/commits/';
+ configFile: string = '';
+ ecmHost: string = '';
+ bpmHost: string = '';
+
constructor(private http: Http,
+ private appConfig: AppConfigService,
private logService: LogService) {
}
@@ -62,6 +66,10 @@ export class AboutComponent implements OnInit {
{type: 'text', key: 'version', title: 'Version', sortable: true}
]);
});
+
+ this.configFile = this.appConfig.configFile;
+ this.ecmHost = this.appConfig.get('ecmHost');
+ this.bpmHost = this.appConfig.get('bpmHost');
}
private gitHubLinkCreation(alfrescoPackagesTableRepresentation): void {
diff --git a/demo-shell-ng2/app/components/index.ts b/demo-shell-ng2/app/components/index.ts
index f5fd02e22c..4ba0a934d4 100644
--- a/demo-shell-ng2/app/components/index.ts
+++ b/demo-shell-ng2/app/components/index.ts
@@ -29,5 +29,4 @@ export { SocialComponent } from './social/social.component';
export { AboutComponent } from './about/about.component';
export { FilesComponent } from './files/files.component';
export { FormNodeViewer } from './activiti/form-node-viewer.component';
-export { SettingComponent } from './setting/setting.component';
export { ActivitiAppsView } from './activiti/apps.view';
diff --git a/demo-shell-ng2/app/components/login/login-demo.component.html b/demo-shell-ng2/app/components/login/login-demo.component.html
index 42862b0a41..31d6b66f99 100644
--- a/demo-shell-ng2/app/components/login/login-demo.component.html
+++ b/demo-shell-ng2/app/components/login/login-demo.component.html
@@ -23,16 +23,6 @@
-
-
-
-
- settings
-
-
-
-
-
.mdl-card__title {
- color: #fff;
- background: bottom right 15% no-repeat #1fbcd2;
-}
-
-.setting-card-padding {
- width: 50%;
- display: table-cell;
- vertical-align: middle;
- margin: 0;
-}
-
-.setting-container {
- display: table;
- border-collapse: collapse;
- border-spacing: 0;
- width: 100%;
-}
-
-.icon-margin {
- margin-right: 9px;
-}
-
-.table-row {
- display: table-row;
-}
-
-.adf-setting-input-padding {
- padding-top: 0px !important;
-}
diff --git a/demo-shell-ng2/app/components/setting/setting.component.html b/demo-shell-ng2/app/components/setting/setting.component.html
deleted file mode 100644
index 7c1a19d69c..0000000000
--- a/demo-shell-ng2/app/components/setting/setting.component.html
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
-
-
SETTINGS
-
-
-
- Content Services host URL configuration
-
-
- link
-
-
- ECM Host
- ECM host is not valid!
-
-
-
-
- Process Services host URL configuration
-
-
- link
-
-
- BPM Host
- BPM host is not valid!
-
-
-
-
-
-
-
-
diff --git a/demo-shell-ng2/app/components/setting/setting.component.ts b/demo-shell-ng2/app/components/setting/setting.component.ts
deleted file mode 100644
index 733007344c..0000000000
--- a/demo-shell-ng2/app/components/setting/setting.component.ts
+++ /dev/null
@@ -1,75 +0,0 @@
-/*!
- * @license
- * Copyright 2016 Alfresco Software, Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import { Component, AfterViewChecked } from '@angular/core';
-import { AlfrescoSettingsService, StorageService, LogService } from 'ng2-alfresco-core';
-
-declare var componentHandler: any;
-
-@Component({
- selector: 'alfresco-setting-demo',
- templateUrl: './setting.component.html',
- styleUrls: ['./setting.component.css']
-})
-export class SettingComponent implements AfterViewChecked {
-
- ecmHost: string;
- bpmHost: string;
-
- constructor(private settingsService: AlfrescoSettingsService,
- private storage: StorageService,
- private logService: LogService) {
- this.ecmHost = this.settingsService.ecmHost;
- this.bpmHost = this.settingsService.bpmHost;
- }
-
- ngAfterViewChecked() {
- // workaround for MDL issues with dynamic components
- if (componentHandler) {
- componentHandler.upgradeAllRegistered();
- }
- }
-
- public onChangeECMHost(event: KeyboardEvent): void {
- let value = (event.target).value.trim();
- if (value && this.isValidUrl(value)) {
- this.logService.info(`ECM host: ${value}`);
- this.ecmHost = value;
- this.settingsService.ecmHost = value;
- this.storage.setItem(`ecmHost`, value);
- } else {
- console.error('Ecm address does not match the pattern');
- }
- }
-
- public onChangeBPMHost(event: KeyboardEvent): void {
- let value = (event.target).value.trim();
- if (value && this.isValidUrl(value)) {
- this.logService.info(`BPM host: ${value}`);
- this.bpmHost = value;
- this.settingsService.bpmHost = value;
- this.storage.setItem(`bpmHost`, value);
- } else {
- console.error('Bpm address does not match the pattern');
- }
- }
-
- isValidUrl(url: string) {
- return /^(http|https):\/\/.*/.test(url);
- }
-
-}
diff --git a/demo-shell-ng2/config/webpack.common.js b/demo-shell-ng2/config/webpack.common.js
index 658d4878a4..86bcc82422 100644
--- a/demo-shell-ng2/config/webpack.common.js
+++ b/demo-shell-ng2/config/webpack.common.js
@@ -102,7 +102,10 @@ module.exports = {
to: 'resources/i18n'
},
{
- from: 'app.config.json'
+ from: 'app.config-dev.json'
+ },
+ {
+ from: 'app.config-prod.json'
},
{
from: 'favicon-96x96.png'
diff --git a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.spec.ts b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.spec.ts
index eef9c2e558..5b6f306d45 100644
--- a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.spec.ts
+++ b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-list.component.spec.ts
@@ -90,7 +90,7 @@ describe('AnalyticsReportListComponent', () => {
});
it('should return the default reports when the report list is empty', (done) => {
- jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/reports').andReturn({
+ jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/reports').andReturn({
status: 200,
contentType: 'json',
responseText: []
@@ -98,13 +98,13 @@ describe('AnalyticsReportListComponent', () => {
fixture.detectChanges();
- jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/default-reports').andReturn({
+ jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/default-reports').andReturn({
status: 200,
contentType: 'json',
responseText: []
});
- jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/reports').andReturn({
+ jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/reports').andReturn({
status: 200,
contentType: 'json',
responseText: reportList
diff --git a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-parameters.component.spec.ts b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-parameters.component.spec.ts
index f88e7309eb..ee366e2e98 100644
--- a/ng2-components/ng2-activiti-analytics/src/components/analytics-report-parameters.component.spec.ts
+++ b/ng2-components/ng2-activiti-analytics/src/components/analytics-report-parameters.component.spec.ts
@@ -295,13 +295,13 @@ describe('AnalyticsReportParametersComponent', () => {
done();
});
- jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/report-params/1').andReturn({
+ jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/report-params/1').andReturn({
status: 200,
contentType: 'json',
responseText: analyticParamsMock.reportDefParamProcessDef
});
- jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/process-definitions').andReturn({
+ jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/process-definitions').andReturn({
status: 200,
contentType: 'json',
responseText: analyticParamsMock.reportDefParamProcessDefOptionsNoApp
@@ -326,7 +326,7 @@ describe('AnalyticsReportParametersComponent', () => {
done();
});
- jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/report-params/1').andReturn({
+ jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/report-params/1').andReturn({
status: 200,
contentType: 'json',
responseText: analyticParamsMock.reportDefParamProcessDef
@@ -334,7 +334,7 @@ describe('AnalyticsReportParametersComponent', () => {
let appId = '1';
- jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/api/enterprise/process-definitions?appDefinitionId=' + appId).andReturn({
+ jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/api/enterprise/process-definitions?appDefinitionId=' + appId).andReturn({
status: 200,
contentType: 'json',
responseText: analyticParamsMock.reportDefParamProcessDefOptionsApp
@@ -392,13 +392,13 @@ describe('AnalyticsReportParametersComponent', () => {
done();
});
- jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/report-params/1').andReturn({
+ jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/report-params/1').andReturn({
status: 200,
contentType: 'json',
responseText: analyticParamsMock.reportDefParamProcessDef
});
- jasmine.Ajax.stubRequest('http://localhost:9999/activiti-app/app/rest/reporting/process-definitions').andReturn({
+ jasmine.Ajax.stubRequest('http://localhost:3000/bpm/activiti-app/app/rest/reporting/process-definitions').andReturn({
status: 404,
contentType: 'json',
responseText: []
diff --git a/ng2-components/ng2-activiti-diagrams/src/services/diagrams.service.ts b/ng2-components/ng2-activiti-diagrams/src/services/diagrams.service.ts
index af3da58afe..ca79f0f31b 100644
--- a/ng2-components/ng2-activiti-diagrams/src/services/diagrams.service.ts
+++ b/ng2-components/ng2-activiti-diagrams/src/services/diagrams.service.ts
@@ -30,7 +30,7 @@ export class DiagramsService {
}
getProcessDefinitionModel(processDefinitionId: string): Observable {
- let url = `${this.settingsService.getBPMApiBaseUrl()}/app/rest/process-definitions/${processDefinitionId}/model-json`;
+ let url = `${this.settingsService.bpmHost}/activiti-app/app/rest/process-definitions/${processDefinitionId}/model-json`;
let options = this.getRequestOptions();
return this.http
.get(url, options)
@@ -41,7 +41,7 @@ export class DiagramsService {
}
getRunningProcessDefinitionModel(processInstanceId: string): Observable {
- let url = `${this.settingsService.getBPMApiBaseUrl()}/app/rest/process-instances/${processInstanceId}/model-json`;
+ let url = `${this.settingsService.bpmHost}/activiti-app/app/rest/process-instances/${processInstanceId}/model-json`;
let options = this.getRequestOptions();
return this.http
.get(url, options)
diff --git a/ng2-components/ng2-activiti-form/src/services/form.service.spec.ts b/ng2-components/ng2-activiti-form/src/services/form.service.spec.ts
index b4f606b49f..6cdddbefd1 100644
--- a/ng2-components/ng2-activiti-form/src/services/form.service.spec.ts
+++ b/ng2-components/ng2-activiti-form/src/services/form.service.spec.ts
@@ -15,14 +15,8 @@
* limitations under the License.
*/
-import { ReflectiveInjector } from '@angular/core';
-import {
- AlfrescoAuthenticationService,
- AlfrescoSettingsService,
- AlfrescoApiService,
- StorageService,
- LogService
-} from 'ng2-alfresco-core';
+import { TestBed, async } from '@angular/core/testing';
+import { CoreModule, AlfrescoApiService, LogService } from 'ng2-alfresco-core';
import { Observable } from 'rxjs/Rx';
import { FormService } from './form.service';
import { Response, ResponseOptions } from '@angular/http';
@@ -69,24 +63,26 @@ function createFakeBlob() {
describe('Form service', () => {
- let service, injector, apiService, logService;
+ let service: FormService;
+ let apiService: AlfrescoApiService;
+ let logService: LogService;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CoreModule
+ ],
+ providers: [
+ EcmModelService,
+ FormService
+ ]
+ }).compileComponents();
+ }));
beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoSettingsService,
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- EcmModelService,
- StorageService,
- FormService,
- LogService
- ]);
- });
-
- beforeEach(() => {
- service = injector.get(FormService);
- apiService = injector.get(AlfrescoApiService);
- logService = injector.get(LogService);
+ service = TestBed.get(FormService);
+ apiService = TestBed.get(AlfrescoApiService);
+ logService = TestBed.get(LogService);
});
beforeEach(() => {
@@ -530,7 +526,7 @@ describe('Form service', () => {
function stubCreateForm() {
jasmine.Ajax.stubRequest(
- 'http://localhost:9999/activiti-app/api/enterprise/models'
+ 'http://localhost:3000/bpm/activiti-app/api/enterprise/models'
).andReturn({
status: 200,
statusText: 'HTTP/1.1 200 OK',
@@ -541,7 +537,7 @@ describe('Form service', () => {
function stubGetEcmModel() {
jasmine.Ajax.stubRequest(
- 'http://localhost:8080/alfresco/api/-default-/private/alfresco/versions/1/cmm/activitiFormsModel/types'
+ 'http://localhost:3000/ecm/alfresco/api/-default-/private/alfresco/versions/1/cmm/activitiFormsModel/types'
).andReturn({
status: 200,
statusText: 'HTTP/1.1 200 OK',
@@ -562,7 +558,7 @@ describe('Form service', () => {
function stubAddFieldsToAForm() {
jasmine.Ajax.stubRequest(
- 'http://localhost:9999/activiti-app/api/enterprise/editor/form-models/' + formId
+ 'http://localhost:3000/bpm/activiti-app/api/enterprise/editor/form-models/' + formId
).andReturn({
status: 200,
statusText: 'HTTP/1.1 200 OK',
diff --git a/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.spec.ts b/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.spec.ts
index 9fd3401d8b..ef6ae35845 100644
--- a/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.spec.ts
+++ b/ng2-components/ng2-activiti-tasklist/src/services/activiti-tasklist.service.spec.ts
@@ -15,21 +15,11 @@
* limitations under the License.
*/
-import { ReflectiveInjector } from '@angular/core';
-import { async } from '@angular/core/testing';
-import {
- AlfrescoAuthenticationService,
- AlfrescoSettingsService,
- AlfrescoApiService,
- StorageService,
- LogService
-} from 'ng2-alfresco-core';
+import { TestBed, async } from '@angular/core/testing';
+import { CoreModule } from 'ng2-alfresco-core';
import { ActivitiTaskListService } from './activiti-tasklist.service';
import { TaskDetailsModel } from '../models/task-details.model';
-import {
- FilterRepresentationModel,
- TaskQueryRequestRepresentationModel
-} from '../models/filter.model';
+import { FilterRepresentationModel, TaskQueryRequestRepresentationModel } from '../models/filter.model';
import { Comment } from '../models/comment.model';
import {
fakeFilters,
@@ -56,21 +46,20 @@ declare let jasmine: any;
describe('Activiti TaskList Service', () => {
let service: ActivitiTaskListService;
- let injector;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CoreModule.forRoot()
+ ],
+ providers: [
+ ActivitiTaskListService
+ ]
+ }).compileComponents();
+ }));
beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoSettingsService,
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- ActivitiTaskListService,
- StorageService,
- LogService
- ]);
- });
-
- beforeEach(() => {
- service = injector.get(ActivitiTaskListService);
+ service = TestBed.get(ActivitiTaskListService);
});
beforeEach(() => {
diff --git a/ng2-components/ng2-alfresco-core/README.md b/ng2-components/ng2-alfresco-core/README.md
index 9ed772659e..c7f650bce1 100644
--- a/ng2-components/ng2-alfresco-core/README.md
+++ b/ng2-components/ng2-alfresco-core/README.md
@@ -6,7 +6,6 @@
- [Prerequisites](#prerequisites)
- [Install](#install)
-- [Library content](#library-content)
- [Toolbar Component](#toolbar-component)
* [Properties](#properties)
- [Upload Directive](#upload-directive)
@@ -52,24 +51,6 @@ necessary configuration, see this [page](https://github.com/Alfresco/alfresco-ng
npm install ng2-alfresco-core
```
-## Library content
-
-- Components
- - [Toolbar](#toolbar-component)
- - [Accordion](#accordion-component)
-- Directives
- - [Upload](#upload-directive)
- - [Context Menu](#context-menu-directive)
-- Services
- - [AppConfigService](#appconfigservice), application configuration
- - **LogService**, log service implementation
- - [NotificationService](#notification-service), Notification service implementation
- - [AlfrescoApiService](#alfresco-api-service), provides access to Alfresco JS API instance
- - [AlfrescoAuthenticationService](#authentication-service), main authentication APIs
- - [AlfrescoTranslationService](#alfrescotranslationservice), various i18n-related APIs
- - **ContextMenuService**, global context menu APIs
- - [Renditions Service](#renditions-service)
-
## Toolbar Component
```html
@@ -350,6 +331,28 @@ export class AppComponent {
You custom components can also benefit from the `AppConfigService`,
you can put an unlimited number of settings and optionally a nested JSON hierarchy.
+### Different configurations based on environment settings
+
+The CoreModule allows you to provide custom application configuration path.
+That means you can evaluate the final file name based on conditions, for example environment settings:
+
+```ts
+let appConfigFile = 'app.config-dev.json';
+if (process.env.ENV === 'production') {
+ appConfigFile = 'app.config-prod.json';
+}
+
+@NgModule({
+ imports: [
+ ...
+ CoreModule.forRoot({
+ appConfigFile: appConfigFile
+ }),
+ ...
+ ]
+})
+```
+
## Notification Service
The Notification Service is implemented on top of the Angular 2 Material Design snackbar.
diff --git a/ng2-components/ng2-alfresco-core/src/services/alfresco-api.service.ts b/ng2-components/ng2-alfresco-core/src/services/alfresco-api.service.ts
index 20e5d18ff0..d3a7dfccfe 100644
--- a/ng2-components/ng2-alfresco-core/src/services/alfresco-api.service.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/alfresco-api.service.ts
@@ -19,54 +19,29 @@ import { Injectable } from '@angular/core';
import { AlfrescoApi } from 'alfresco-js-api';
import * as alfrescoApi from 'alfresco-js-api';
import { AlfrescoSettingsService } from './alfresco-settings.service';
+import { AppConfigService } from './app-config.service';
import { StorageService } from './storage.service';
@Injectable()
export class AlfrescoApiService {
private alfrescoApi: AlfrescoApi;
-
private provider: string;
-
- private ticketEcm: string;
-
- private ticketBpm: string;
-
- private hostEcm: string;
-
- private hostBpm: string;
-
- private contextRoot: string;
-
private disableCsrf: boolean;
public getInstance(): AlfrescoApi {
return this.alfrescoApi;
}
- constructor(private settingsService: AlfrescoSettingsService,
+ constructor(private appConfig: AppConfigService,
+ private settingsService: AlfrescoSettingsService,
private storage: StorageService) {
this.provider = this.settingsService.getProviders();
- this.ticketEcm = this.getTicketEcm();
- this.ticketBpm = this.getTicketBpm();
- this.hostEcm = this.settingsService.ecmHost;
- this.hostBpm = this.settingsService.bpmHost;
- this.contextRoot = 'alfresco';
this.disableCsrf = false;
this.init();
- settingsService.bpmHostSubject.subscribe((hostBpm) => {
- this.hostBpm = hostBpm;
- this.init();
- });
-
- settingsService.ecmHostSubject.subscribe((hostEcm) => {
- this.hostEcm = hostEcm;
- this.init();
- });
-
settingsService.csrfSubject.subscribe((disableCsrf) => {
this.disableCsrf = disableCsrf;
this.init();
@@ -81,29 +56,12 @@ export class AlfrescoApiService {
private init() {
this.alfrescoApi = new alfrescoApi({
provider: this.provider,
- ticketEcm: this.ticketEcm,
- ticketBpm: this.ticketBpm,
- hostEcm: this.hostEcm,
- hostBpm: this.hostBpm,
- contextRoot: this.contextRoot,
+ ticketEcm: this.storage.getItem('ticket-ECM'),
+ ticketBpm: this.storage.getItem('ticket-BPM'),
+ hostEcm: this.appConfig.get('ecmHost'),
+ hostBpm: this.appConfig.get('bpmHost'),
+ contextRoot: 'alfresco',
disableCsrf: this.disableCsrf
});
}
-
- /**
- * The method return the ECM ticket stored in the Storage
- * @returns ticket
- */
- private getTicketEcm(): string {
- return this.storage.getItem('ticket-ECM');
- }
-
- /**
- * The method return the BPM ticket stored in the Storage
- * @returns ticket
- */
- private getTicketBpm(): string {
- return this.storage.getItem('ticket-BPM');
- }
-
}
diff --git a/ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.spec.ts
index 8237bc1fba..3e841eaf48 100644
--- a/ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.spec.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/alfresco-authentication.service.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { ReflectiveInjector } from '@angular/core';
+import { TestBed, async } from '@angular/core/testing';
import { AlfrescoSettingsService } from './alfresco-settings.service';
import { AlfrescoAuthenticationService } from './alfresco-authentication.service';
import { AlfrescoApiService } from './alfresco-api.service';
@@ -23,30 +23,39 @@ import { StorageService } from './storage.service';
import { CookieService } from './cookie.service';
import { CookieServiceMock } from './../assets/cookie.service.mock';
import { LogService } from './log.service';
+import { AppConfigModule } from './app-config.service';
declare let jasmine: any;
describe('AlfrescoAuthenticationService', () => {
- let injector;
+ let apiService: AlfrescoApiService;
let authService: AlfrescoAuthenticationService;
let settingsService: AlfrescoSettingsService;
let storage: StorageService;
let cookie: CookieService;
- beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoSettingsService,
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- StorageService,
- { provide: CookieService, useClass: CookieServiceMock },
- LogService
- ]);
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ AppConfigModule
+ ],
+ providers: [
+ AlfrescoSettingsService,
+ AlfrescoApiService,
+ AlfrescoAuthenticationService,
+ StorageService,
+ { provide: CookieService, useClass: CookieServiceMock },
+ LogService
+ ]
+ }).compileComponents();
+ }));
- authService = injector.get(AlfrescoAuthenticationService);
- settingsService = injector.get(AlfrescoSettingsService);
- cookie = injector.get(CookieService);
- storage = injector.get(StorageService);
+ beforeEach(() => {
+ apiService = TestBed.get(AlfrescoApiService);
+ authService = TestBed.get(AlfrescoAuthenticationService);
+ settingsService = TestBed.get(AlfrescoSettingsService);
+ cookie = TestBed.get(CookieService);
+ storage = TestBed.get(StorageService);
storage.clear();
jasmine.Ajax.install();
@@ -350,32 +359,6 @@ describe('AlfrescoAuthenticationService', () => {
});
});
- describe('Setting service change should reflect in the api', () => {
-
- beforeEach(() => {
- settingsService.setProviders('ALL');
- });
-
- it('should host ecm url change be reflected in the api configuration', () => {
- settingsService.ecmHost = '127.99.99.99';
-
- expect(authService.alfrescoApi.getInstance().config.hostEcm).toBe('127.99.99.99');
- });
-
- it('should host bpm url change be reflected in the api configuration', () => {
- settingsService.bpmHost = '127.99.99.99';
-
- expect(authService.alfrescoApi.getInstance().config.hostBpm).toBe('127.99.99.99');
- });
-
- it('should host bpm provider change be reflected in the api configuration', () => {
- settingsService.setProviders('ECM');
-
- expect(authService.alfrescoApi.getInstance().config.provider).toBe('ECM');
- });
-
- });
-
describe('when the setting is both ECM and BPM ', () => {
beforeEach(() => {
diff --git a/ng2-components/ng2-alfresco-core/src/services/alfresco-content.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/alfresco-content.service.spec.ts
index 3920f13fb6..50ef2ac6d0 100644
--- a/ng2-components/ng2-alfresco-core/src/services/alfresco-content.service.spec.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/alfresco-content.service.spec.ts
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-import { ReflectiveInjector } from '@angular/core';
+import { TestBed, async } from '@angular/core/testing';
import { AlfrescoSettingsService } from './alfresco-settings.service';
import { AlfrescoAuthenticationService } from './alfresco-authentication.service';
import { AlfrescoContentService } from './alfresco-content.service';
@@ -24,12 +24,13 @@ import { StorageService } from './storage.service';
import { CookieService } from './cookie.service';
import { CookieServiceMock } from './../assets/cookie.service.mock';
import { LogService } from './log.service';
+import { AppConfigModule } from './app-config.service';
declare let jasmine: any;
describe('AlfrescoContentService', () => {
- let injector, contentService: AlfrescoContentService;
+ let contentService: AlfrescoContentService;
let authService: AlfrescoAuthenticationService;
let settingsService: AlfrescoSettingsService;
let storage: StorageService;
@@ -37,21 +38,30 @@ describe('AlfrescoContentService', () => {
const nodeId = 'fake-node-id';
- beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoApiService,
- AlfrescoContentService,
- AlfrescoAuthenticationService,
- AlfrescoSettingsService,
- StorageService,
- { provide: CookieService, useClass: CookieServiceMock },
- LogService
- ]);
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ AppConfigModule
+ ],
+ declarations: [
+ ],
+ providers: [
+ AlfrescoApiService,
+ AlfrescoContentService,
+ AlfrescoAuthenticationService,
+ AlfrescoSettingsService,
+ StorageService,
+ { provide: CookieService, useClass: CookieServiceMock },
+ LogService
+ ]
+ }).compileComponents();
+ }));
- authService = injector.get(AlfrescoAuthenticationService);
- settingsService = injector.get(AlfrescoSettingsService);
- contentService = injector.get(AlfrescoContentService);
- storage = injector.get(StorageService);
+ beforeEach(() => {
+ authService = TestBed.get(AlfrescoAuthenticationService);
+ settingsService = TestBed.get(AlfrescoSettingsService);
+ contentService = TestBed.get(AlfrescoContentService);
+ storage = TestBed.get(StorageService);
storage.clear();
node = {
@@ -73,7 +83,7 @@ describe('AlfrescoContentService', () => {
it('should return a valid content URL', (done) => {
authService.login('fake-username', 'fake-password').subscribe(() => {
- expect(contentService.getContentUrl(node)).toBe('http://localhost:8080/alfresco/api/' +
+ expect(contentService.getContentUrl(node)).toBe('http://localhost:3000/ecm/alfresco/api/' +
'-default-/public/alfresco/versions/1/nodes/fake-node-id/content?attachment=false&alf_ticket=fake-post-ticket');
done();
});
@@ -88,7 +98,7 @@ describe('AlfrescoContentService', () => {
it('should return a valid thumbnail URL', (done) => {
authService.login('fake-username', 'fake-password').subscribe(() => {
expect(contentService.getDocumentThumbnailUrl(node))
- .toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco' +
+ .toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco' +
'/versions/1/nodes/fake-node-id/renditions/doclib/content?attachment=false&alf_ticket=fake-post-ticket');
done();
});
diff --git a/ng2-components/ng2-alfresco-core/src/services/alfresco-settings.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/alfresco-settings.service.spec.ts
index 64595150c4..82b988856e 100644
--- a/ng2-components/ng2-alfresco-core/src/services/alfresco-settings.service.spec.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/alfresco-settings.service.spec.ts
@@ -15,35 +15,32 @@
* limitations under the License.
*/
+import { TestBed, async } from '@angular/core/testing';
+import { AppConfigModule } from './app-config.service';
import { AlfrescoSettingsService } from './alfresco-settings.service';
describe('AlfrescoSettingsService', () => {
let service: AlfrescoSettingsService;
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ AppConfigModule
+ ],
+ declarations: [
+ ],
+ providers: [
+ AlfrescoSettingsService
+ ]
+ }).compileComponents();
+ }));
+
beforeEach(() => {
- service = new AlfrescoSettingsService();
+ service = TestBed.get(AlfrescoSettingsService);
});
- it('should have default ECM host', () => {
- expect(service.ecmHost).toBe(AlfrescoSettingsService.DEFAULT_ECM_ADDRESS);
- });
-
- it('should change host ECM', () => {
- // this test ensures 'host' getter/setter working properly
- let address = 'http://192.168.0.1';
- service.ecmHost = address;
- expect(service.ecmHost).toBe(address);
- });
-
- it('should have default BPM host', () => {
- expect(service.bpmHost).toBe(AlfrescoSettingsService.DEFAULT_BPM_ADDRESS);
- });
-
- it('should change host BPM', () => {
- // this test ensures 'host' getter/setter working properly
- let address = 'http://192.168.0.1';
- service.bpmHost = address;
- expect(service.bpmHost).toBe(address);
+ it('should be exposed by the module', () => {
+ expect(service).toBeDefined();
});
});
diff --git a/ng2-components/ng2-alfresco-core/src/services/alfresco-settings.service.ts b/ng2-components/ng2-alfresco-core/src/services/alfresco-settings.service.ts
index 55a46de707..f5c0c7b29d 100644
--- a/ng2-components/ng2-alfresco-core/src/services/alfresco-settings.service.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/alfresco-settings.service.ts
@@ -17,31 +17,23 @@
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs/Subject';
+import { AppConfigService } from './app-config.service';
@Injectable()
export class AlfrescoSettingsService {
- static DEFAULT_ECM_ADDRESS: string = 'http://' + window.location.hostname + ':8080';
- static DEFAULT_BPM_ADDRESS: string = 'http://' + window.location.hostname + ':9999';
static DEFAULT_CSRF_CONFIG: boolean = false;
- static DEFAULT_BPM_CONTEXT_PATH: string = '/activiti-app';
-
- private _ecmHost: string = AlfrescoSettingsService.DEFAULT_ECM_ADDRESS;
- private _bpmHost: string = AlfrescoSettingsService.DEFAULT_BPM_ADDRESS;
private _csrfDisabled: boolean = AlfrescoSettingsService.DEFAULT_CSRF_CONFIG;
-
- private _bpmContextPath = AlfrescoSettingsService.DEFAULT_BPM_CONTEXT_PATH;
-
private providers: string = 'ALL'; // ECM, BPM , ALL
- public bpmHostSubject: Subject = new Subject();
- public ecmHostSubject: Subject = new Subject();
public csrfSubject: Subject = new Subject();
public providerSubject: Subject = new Subject();
+ constructor(private appConfig: AppConfigService) {}
+
public get ecmHost(): string {
- return this._ecmHost;
+ return this.appConfig.get('ecmHost');
}
public set csrfDisabled(csrfDisabled: boolean) {
@@ -49,22 +41,24 @@ export class AlfrescoSettingsService {
this._csrfDisabled = csrfDisabled;
}
+ /* @deprecated in 1.6.0 */
public set ecmHost(ecmHostUrl: string) {
- this.ecmHostSubject.next(ecmHostUrl);
- this._ecmHost = ecmHostUrl;
+ console.log('AlfrescoSettingsService.ecmHost is deprecated. Use AppConfigService instead.');
}
public get bpmHost(): string {
- return this._bpmHost;
+ return this.appConfig.get('bpmHost');
}
+ /* @deprecated in 1.6.0 */
public set bpmHost(bpmHostUrl: string) {
- this.bpmHostSubject.next(bpmHostUrl);
- this._bpmHost = bpmHostUrl;
+ console.log('AlfrescoSettingsService.bpmHost is deprecated. Use AppConfigService instead.');
}
+ /* @deprecated in 1.6.0 */
public getBPMApiBaseUrl(): string {
- return this._bpmHost + this._bpmContextPath;
+ console.log('AlfrescoSettingsService.getBPMApiBaseUrl is deprecated.');
+ return this.bpmHost + '/activiti-app';
}
public getProviders(): string {
diff --git a/ng2-components/ng2-alfresco-core/src/services/app-config.service.ts b/ng2-components/ng2-alfresco-core/src/services/app-config.service.ts
index be9db60f0c..9f5be1699b 100644
--- a/ng2-components/ng2-alfresco-core/src/services/app-config.service.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/app-config.service.ts
@@ -16,7 +16,7 @@
*/
import { Injectable, APP_INITIALIZER, NgModule, ModuleWithProviders } from '@angular/core';
-import { Http } from '@angular/http';
+import { HttpModule, Http } from '@angular/http';
import { ObjectUtils } from '../utils/object-utils';
@Injectable()
@@ -70,6 +70,9 @@ export function InitAppConfigServiceProvider(resource: string): any {
}
@NgModule({
+ imports: [
+ HttpModule
+ ],
providers: [
AppConfigService
]
diff --git a/ng2-components/ng2-alfresco-core/src/services/auth-guard-bpm.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/auth-guard-bpm.service.spec.ts
index 12e178125b..8a9b5a872e 100644
--- a/ng2-components/ng2-alfresco-core/src/services/auth-guard-bpm.service.spec.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/auth-guard-bpm.service.spec.ts
@@ -15,6 +15,10 @@
* limitations under the License.
*/
+import { TestBed, async, inject } from '@angular/core/testing';
+import { Router} from '@angular/router';
+import { RouterTestingModule } from '@angular/router/testing';
+
import { AlfrescoSettingsService } from './alfresco-settings.service';
import { AlfrescoAuthenticationService } from './alfresco-authentication.service';
import { AlfrescoApiService } from './alfresco-api.service';
@@ -23,24 +27,29 @@ import { LogService } from './log.service';
import { CookieService } from './cookie.service';
import { CookieServiceMock } from './../assets/cookie.service.mock';
import { AuthGuardBpm } from './auth-guard-bpm.service';
-import { Router} from '@angular/router';
-import { RouterTestingModule } from '@angular/router/testing';
-import { TestBed, async, inject } from '@angular/core/testing';
+import { AppConfigModule } from './app-config.service';
describe('AuthGuardService BPM', () => {
- beforeEach(() => {
+ beforeEach(async(() => {
TestBed.configureTestingModule({
- providers: [AuthGuardBpm,
+ imports: [
+ AppConfigModule,
+ RouterTestingModule
+ ],
+ declarations: [
+ ],
+ providers: [
+ AuthGuardBpm,
AlfrescoSettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
StorageService,
{ provide: CookieService, useClass: CookieServiceMock },
- LogService],
- imports: [RouterTestingModule]
- });
- });
+ LogService
+ ]
+ }).compileComponents();
+ }));
it('if the alfresco js api is logged in should canActivate be true',
async(inject([AuthGuardBpm, Router, AlfrescoSettingsService, StorageService, AlfrescoAuthenticationService], (auth, router, settingsService, storage, authService) => {
diff --git a/ng2-components/ng2-alfresco-core/src/services/auth-guard-ecm.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/auth-guard-ecm.service.spec.ts
index f09502d820..11112e3dcc 100644
--- a/ng2-components/ng2-alfresco-core/src/services/auth-guard-ecm.service.spec.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/auth-guard-ecm.service.spec.ts
@@ -15,6 +15,10 @@
* limitations under the License.
*/
+import { TestBed, async, inject } from '@angular/core/testing';
+import { Router} from '@angular/router';
+import { RouterTestingModule } from '@angular/router/testing';
+
import { AlfrescoSettingsService } from './alfresco-settings.service';
import { AlfrescoAuthenticationService } from './alfresco-authentication.service';
import { AlfrescoApiService } from './alfresco-api.service';
@@ -23,24 +27,29 @@ import { CookieService } from './cookie.service';
import { CookieServiceMock } from './../assets/cookie.service.mock';
import { LogService } from './log.service';
import { AuthGuardEcm } from './auth-guard-ecm.service';
-import { Router} from '@angular/router';
-import { RouterTestingModule } from '@angular/router/testing';
-import { TestBed, async, inject } from '@angular/core/testing';
+import { AppConfigModule } from './app-config.service';
describe('AuthGuardService ECM', () => {
- beforeEach(() => {
+ beforeEach(async(() => {
TestBed.configureTestingModule({
- providers: [AuthGuardEcm,
+ imports: [
+ AppConfigModule,
+ RouterTestingModule
+ ],
+ declarations: [
+ ],
+ providers: [
+ AuthGuardEcm,
AlfrescoSettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
StorageService,
{ provide: CookieService, useClass: CookieServiceMock },
- LogService],
- imports: [RouterTestingModule]
- });
- });
+ LogService
+ ]
+ }).compileComponents();
+ }));
it('if the alfresco js api is logged in should canActivate be true',
async(inject([AuthGuardEcm, Router, AlfrescoSettingsService, StorageService, AlfrescoAuthenticationService], (auth, router, settingsService, storage, authService) => {
diff --git a/ng2-components/ng2-alfresco-core/src/services/auth-guard.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/auth-guard.service.spec.ts
index 8591c23522..3ae547a08f 100644
--- a/ng2-components/ng2-alfresco-core/src/services/auth-guard.service.spec.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/auth-guard.service.spec.ts
@@ -15,6 +15,10 @@
* limitations under the License.
*/
+import { TestBed, async, inject } from '@angular/core/testing';
+import { Router} from '@angular/router';
+import { RouterTestingModule } from '@angular/router/testing';
+
import { AlfrescoSettingsService } from './alfresco-settings.service';
import { AlfrescoAuthenticationService } from './alfresco-authentication.service';
import { AlfrescoApiService } from './alfresco-api.service';
@@ -23,24 +27,27 @@ import { CookieService } from './cookie.service';
import { CookieServiceMock } from './../assets/cookie.service.mock';
import { LogService } from './log.service';
import { AuthGuard } from './auth-guard.service';
-import { Router} from '@angular/router';
-import { RouterTestingModule } from '@angular/router/testing';
-import { TestBed, async, inject } from '@angular/core/testing';
+import { AppConfigModule } from './app-config.service';
describe('AuthGuardService', () => {
- beforeEach(() => {
+ beforeEach(async(() => {
TestBed.configureTestingModule({
- providers: [AuthGuard,
+ imports: [
+ AppConfigModule,
+ RouterTestingModule
+ ],
+ providers: [
+ AuthGuard,
AlfrescoSettingsService,
AlfrescoApiService,
AlfrescoAuthenticationService,
StorageService,
{ provide: CookieService, useClass: CookieServiceMock },
- LogService],
- imports: [RouterTestingModule]
- });
- });
+ LogService
+ ]
+ }).compileComponents();
+ }));
it('if the alfresco js api is logged in should canActivate be true',
async(inject([AuthGuard, Router, AlfrescoSettingsService, StorageService, AlfrescoAuthenticationService], (auth, router, settingsService, storage, authService) => {
diff --git a/ng2-components/ng2-alfresco-core/src/services/renditions.service.spec.ts b/ng2-components/ng2-alfresco-core/src/services/renditions.service.spec.ts
index 9f1db7b36b..370b61bde0 100644
--- a/ng2-components/ng2-alfresco-core/src/services/renditions.service.spec.ts
+++ b/ng2-components/ng2-alfresco-core/src/services/renditions.service.spec.ts
@@ -15,33 +15,40 @@
* limitations under the License.
*/
-import { ReflectiveInjector } from '@angular/core';
+import { TestBed, async } from '@angular/core/testing';
import { AlfrescoApiService } from './alfresco-api.service';
import { RenditionsService } from './renditions.service';
import { AlfrescoSettingsService } from './alfresco-settings.service';
import { StorageService } from './storage.service';
import { LogService } from './log.service';
import { fakeRedition, fakeReditionCreated, fakeReditionsList } from '../assets/renditionsService.mock';
+import { AppConfigModule } from './app-config.service';
declare let jasmine: any;
-declare let AlfrescoApi: any;
describe('RenditionsService', () => {
- let service, injector;
+ let service: RenditionsService;
- beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoApiService,
- RenditionsService,
- AlfrescoSettingsService,
- StorageService,
- LogService
- ]);
- });
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ AppConfigModule
+ ],
+ declarations: [
+ ],
+ providers: [
+ AlfrescoApiService,
+ RenditionsService,
+ AlfrescoSettingsService,
+ StorageService,
+ LogService
+ ]
+ }).compileComponents();
+ }));
beforeEach(() => {
jasmine.Ajax.install();
- service = injector.get(RenditionsService);
+ service = TestBed.get(RenditionsService);
});
afterEach(() => {
@@ -63,7 +70,7 @@ describe('RenditionsService', () => {
it('Create redition service should call the server with the ID passed and the asked encoding', (done) => {
service.createRendition('fake-node-id', 'pdf').subscribe((res) => {
- expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
+ expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/renditions');
done();
});
diff --git a/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.spec.ts b/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.spec.ts
index 1010826a5e..58ae5fb57f 100644
--- a/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.spec.ts
+++ b/ng2-components/ng2-alfresco-documentlist/src/services/document-list.service.spec.ts
@@ -15,30 +15,22 @@
* limitations under the License.
*/
+import { TestBed, async } from '@angular/core/testing';
import {
- AlfrescoSettingsService,
- AlfrescoAuthenticationService,
- AlfrescoApiService,
- StorageService,
+ CoreModule,
CookieService,
- AlfrescoContentService,
LogService,
LogServiceMock
} from 'ng2-alfresco-core';
import { FileNode } from '../assets/document-library.model.mock';
import { CookieServiceMock } from '../../../ng2-alfresco-core/src/assets/cookie.service.mock';
-import { ReflectiveInjector } from '@angular/core';
import { DocumentListService } from './document-list.service';
declare let jasmine: any;
describe('DocumentListService', () => {
- let injector;
let service: DocumentListService;
- let settingsService: AlfrescoSettingsService;
- let authService: AlfrescoAuthenticationService;
- let alfrescoApiService: AlfrescoApiService;
let fakeEntryNode = {
'entry': {
@@ -101,23 +93,21 @@ describe('DocumentListService', () => {
}
};
- beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- AlfrescoSettingsService,
- AlfrescoApiService,
- AlfrescoContentService,
- DocumentListService,
- StorageService,
- { provide: CookieService, useClass: CookieServiceMock },
- { provide: LogService, useClass: LogServiceMock }
- ]);
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CoreModule
+ ],
+ providers: [
+ DocumentListService,
+ { provide: CookieService, useClass: CookieServiceMock },
+ { provide: LogService, useClass: LogServiceMock }
+ ]
+ }).compileComponents();
+ }));
- settingsService = injector.get(AlfrescoSettingsService);
- authService = injector.get(AlfrescoAuthenticationService);
- alfrescoApiService = injector.get(AlfrescoApiService);
- service = injector.get(DocumentListService);
+ beforeEach(() => {
+ service = TestBed.get(DocumentListService);
jasmine.Ajax.install();
});
diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.spec.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.spec.ts
index 81dd7539b0..c64edc8e93 100644
--- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.spec.ts
+++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search-control.component.spec.ts
@@ -21,14 +21,7 @@ import { AlfrescoSearchAutocompleteComponent } from './alfresco-search-autocompl
import { AlfrescoThumbnailService } from './../services/alfresco-thumbnail.service';
import { TranslationMock } from './../assets/translation.service.mock';
import { result } from './../assets/alfresco-search.component.mock';
-import {
- AlfrescoSettingsService,
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- AlfrescoContentService,
- AlfrescoTranslationService,
- CoreModule
-} from 'ng2-alfresco-core';
+import { CoreModule, AlfrescoTranslationService } from 'ng2-alfresco-core';
import { AlfrescoSearchService } from '../services/alfresco-search.service';
describe('AlfrescoSearchControlComponent', () => {
@@ -42,7 +35,7 @@ describe('AlfrescoSearchControlComponent', () => {
window['componentHandler'] = componentHandler;
TestBed.configureTestingModule({
imports: [
- CoreModule
+ CoreModule.forRoot()
],
declarations: [
AlfrescoSearchControlComponent,
@@ -51,10 +44,6 @@ describe('AlfrescoSearchControlComponent', () => {
providers: [
{provide: AlfrescoTranslationService, useClass: TranslationMock},
AlfrescoThumbnailService,
- AlfrescoSettingsService,
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- AlfrescoContentService,
AlfrescoSearchService
]
}).compileComponents().then(() => {
@@ -65,7 +54,7 @@ describe('AlfrescoSearchControlComponent', () => {
}));
it('should setup i18n folder', () => {
- let translationService = fixture.debugElement.injector.get(AlfrescoTranslationService);
+ let translationService = TestBed.get(AlfrescoTranslationService);
spyOn(translationService, 'addTranslationFolder');
fixture.detectChanges();
expect(translationService.addTranslationFolder)
@@ -210,7 +199,7 @@ describe('AlfrescoSearchControlComponent', () => {
});
it('should keep find-as-you-type control visible when user tabs into results', (done) => {
- let searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
+ let searchService = TestBed.get(AlfrescoSearchService);
spyOn(searchService, 'getQueryNodesPromise')
.and.returnValue(Promise.resolve(result));
diff --git a/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.spec.ts b/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.spec.ts
index 557a9b7b10..baaddce661 100644
--- a/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.spec.ts
+++ b/ng2-components/ng2-alfresco-search/src/components/alfresco-search.component.spec.ts
@@ -22,17 +22,7 @@ import { Observable } from 'rxjs/Rx';
import { AlfrescoSearchComponent } from './alfresco-search.component';
import { TranslationMock } from './../assets/translation.service.mock';
import { AlfrescoSearchService } from '../services/alfresco-search.service';
-import {
- AlfrescoSettingsService,
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- AlfrescoTranslationService,
- CoreModule,
- StorageService,
- CookieService,
- LogService
-} from 'ng2-alfresco-core';
-import { CookieServiceMock } from './../../../ng2-alfresco-core/src/assets/cookie.service.mock';
+import { AlfrescoTranslationService, CoreModule } from 'ng2-alfresco-core';
import { DocumentListModule } from 'ng2-alfresco-documentlist';
describe('AlfrescoSearchComponent', () => {
@@ -114,7 +104,7 @@ describe('AlfrescoSearchComponent', () => {
declarations: [AlfrescoSearchComponent], // declare the test component
providers: [
AlfrescoSearchService,
- {provide: AlfrescoTranslationService, useClass: TranslationMock}
+ { provide: AlfrescoTranslationService, useClass: TranslationMock }
]
}).compileComponents().then(() => {
fixture = TestBed.createComponent(AlfrescoSearchComponent);
@@ -143,26 +133,8 @@ describe('AlfrescoSearchComponent', () => {
expect(search.searchTerm).toBe('exampleTerm692');
});
- it('should have a null search term if no query param provided via RouteParams', () => {
- let injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoSearchService,
- AlfrescoAuthenticationService,
- AlfrescoSettingsService,
- AlfrescoApiService,
- StorageService,
- { provide: CookieService, useClass: CookieServiceMock },
- LogService,
- {provide: ActivatedRoute, useValue: {params: Observable.from([{}])}}
- ]);
- let search = new AlfrescoSearchComponent(injector.get(AlfrescoSearchService), null, injector.get(ActivatedRoute));
-
- search.ngOnInit();
-
- expect(search.searchTerm).toBeNull();
- });
-
it('should setup i18n folder', () => {
- let translationService = fixture.debugElement.injector.get(AlfrescoTranslationService);
+ let translationService = TestBed.get(AlfrescoTranslationService);
spyOn(translationService, 'addTranslationFolder');
fixture.detectChanges();
@@ -198,7 +170,7 @@ describe('AlfrescoSearchComponent', () => {
it('should display search results when a search term is provided', (done) => {
- let searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
+ let searchService = TestBed.get(AlfrescoSearchService);
spyOn(searchService, 'getQueryNodesPromise').and.returnValue(Promise.resolve(result));
component.searchTerm = '';
@@ -219,7 +191,7 @@ describe('AlfrescoSearchComponent', () => {
it('should display no result if no result are returned', (done) => {
- let searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
+ let searchService = TestBed.get(AlfrescoSearchService);
spyOn(searchService, 'getQueryNodesPromise')
.and.returnValue(Promise.resolve(noResult));
@@ -241,7 +213,7 @@ describe('AlfrescoSearchComponent', () => {
it('should display an error if an error is encountered running the search', (done) => {
- let searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
+ let searchService = TestBed.get(AlfrescoSearchService);
spyOn(searchService, 'getQueryNodesPromise')
.and.returnValue(Promise.reject(errorJson));
@@ -266,7 +238,7 @@ describe('AlfrescoSearchComponent', () => {
it('should update search results when the search term input is changed', (done) => {
- let searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
+ let searchService = TestBed.get(AlfrescoSearchService);
spyOn(searchService, 'getQueryNodesPromise')
.and.returnValue(Promise.resolve(result));
@@ -298,7 +270,7 @@ describe('AlfrescoSearchComponent', () => {
beforeEach(() => {
debugElement = fixture.debugElement;
- searchService = fixture.debugElement.injector.get(AlfrescoSearchService);
+ searchService = TestBed.get(AlfrescoSearchService);
querySpy = spyOn(searchService, 'getQueryNodesPromise').and.returnValue(Promise.resolve(result));
emitSpy = spyOn(component.preview, 'emit');
});
diff --git a/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.spec.ts b/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.spec.ts
index dc687f9274..10dc10889c 100644
--- a/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.spec.ts
+++ b/ng2-components/ng2-alfresco-search/src/services/alfresco-search.service.spec.ts
@@ -15,17 +15,9 @@
* limitations under the License.
*/
-import { ReflectiveInjector } from '@angular/core';
+import { TestBed, async } from '@angular/core/testing';
import { AlfrescoSearchService } from './alfresco-search.service';
-import {
- AlfrescoAuthenticationService,
- AlfrescoSettingsService,
- AlfrescoApiService,
- StorageService,
- CookieService,
- LogService
-} from 'ng2-alfresco-core';
-import { CookieServiceMock } from './../../../ng2-alfresco-core/src/assets/cookie.service.mock';
+import { CoreModule, AlfrescoApiService } from 'ng2-alfresco-core';
import { fakeApi, fakeSearch, fakeError } from '../assets/alfresco-search.service.mock';
declare let jasmine: any;
@@ -34,20 +26,21 @@ describe('AlfrescoSearchService', () => {
let service: AlfrescoSearchService;
let apiService: AlfrescoApiService;
- let injector: ReflectiveInjector;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CoreModule
+ ],
+ providers: [
+ AlfrescoSearchService
+ ]
+ }).compileComponents();
+ }));
beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoSearchService,
- AlfrescoSettingsService,
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- StorageService,
- { provide: CookieService, useClass: CookieServiceMock },
- LogService
- ]);
- service = injector.get(AlfrescoSearchService);
- apiService = injector.get(AlfrescoApiService);
+ service = TestBed.get(AlfrescoSearchService);
+ apiService = TestBed.get(AlfrescoApiService);
spyOn(apiService, 'getInstance').and.returnValue(fakeApi);
});
diff --git a/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.spec.ts b/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.spec.ts
index 9bb0c46ff1..8ad849eb14 100644
--- a/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.spec.ts
+++ b/ng2-components/ng2-alfresco-search/src/services/alfresco-thumbnail.service.spec.ts
@@ -15,37 +15,27 @@
* limitations under the License.
*/
-import { ReflectiveInjector } from '@angular/core';
+import { TestBed, async } from '@angular/core/testing';
import { AlfrescoThumbnailService } from './alfresco-thumbnail.service';
-import {
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- AlfrescoContentService,
- AlfrescoSettingsService,
- StorageService,
- CookieService,
- LogService
-} from 'ng2-alfresco-core';
-import { CookieServiceMock } from './../../../ng2-alfresco-core/src/assets/cookie.service.mock';
+import { CoreModule } from 'ng2-alfresco-core';
describe('AlfrescoThumbnailService', () => {
- let injector: ReflectiveInjector;
let service: AlfrescoThumbnailService;
- beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- AlfrescoContentService,
- AlfrescoSettingsService,
- AlfrescoThumbnailService,
- StorageService,
- { provide: CookieService, useClass: CookieServiceMock },
- LogService
- ]);
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CoreModule.forRoot()
+ ],
+ providers: [
+ AlfrescoThumbnailService
+ ]
+ }).compileComponents();
+ }));
- service = injector.get(AlfrescoThumbnailService);
+ beforeEach(() => {
+ service = TestBed.get(AlfrescoThumbnailService);
});
it('should return the correct icon for a plain text file', () => {
diff --git a/ng2-components/ng2-alfresco-social/src/services/rating.service.spec.ts b/ng2-components/ng2-alfresco-social/src/services/rating.service.spec.ts
index 474888cf6c..2ae41b60b2 100644
--- a/ng2-components/ng2-alfresco-social/src/services/rating.service.spec.ts
+++ b/ng2-components/ng2-alfresco-social/src/services/rating.service.spec.ts
@@ -15,35 +15,29 @@
* limitations under the License.
*/
-import { ReflectiveInjector } from '@angular/core';
-import {
- AlfrescoAuthenticationService,
- AlfrescoSettingsService,
- AlfrescoApiService,
- StorageService,
- LogService
-} from 'ng2-alfresco-core';
+import { TestBed, async } from '@angular/core/testing';
+import { CoreModule } from 'ng2-alfresco-core';
import { RatingService } from '../services/rating.service';
declare let jasmine: any;
describe('Rating service', () => {
- let service, injector;
+ let service;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CoreModule.forRoot()
+ ],
+ providers: [
+ RatingService
+ ]
+ }).compileComponents();
+ }));
beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoSettingsService,
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- RatingService,
- StorageService,
- LogService
- ]);
- });
-
- beforeEach(() => {
- service = injector.get(RatingService);
+ service = TestBed.get(RatingService);
});
beforeEach(() => {
diff --git a/ng2-components/ng2-alfresco-tag/src/components/tag-actions.component.spec.ts b/ng2-components/ng2-alfresco-tag/src/components/tag-actions.component.spec.ts
index 40b7c31911..783dc42a67 100644
--- a/ng2-components/ng2-alfresco-tag/src/components/tag-actions.component.spec.ts
+++ b/ng2-components/ng2-alfresco-tag/src/components/tag-actions.component.spec.ts
@@ -118,7 +118,7 @@ describe('Test ng2-alfresco-tag Tag actions list', () => {
deleteButton.click();
expect(jasmine.Ajax.requests.at(1).url)
- .toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2');
+ .toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2');
expect(jasmine.Ajax.requests.at(1).method).toBe('DELETE');
jasmine.Ajax.requests.mostRecent().respondWith({
diff --git a/ng2-components/ng2-alfresco-tag/src/components/tag-node-list.component.spec.ts b/ng2-components/ng2-alfresco-tag/src/components/tag-node-list.component.spec.ts
index 47a3d9befd..07a4d13662 100644
--- a/ng2-components/ng2-alfresco-tag/src/components/tag-node-list.component.spec.ts
+++ b/ng2-components/ng2-alfresco-tag/src/components/tag-node-list.component.spec.ts
@@ -117,7 +117,7 @@ describe('Test ng2-alfresco-tag Tag relative node list', () => {
deleteButton.click();
expect(jasmine.Ajax.requests.mostRecent().url).
- toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2');
+ toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/0ee933fa-57fc-4587-8a77-b787e814f1d2');
expect(jasmine.Ajax.requests.mostRecent().method).toBe('DELETE');
jasmine.Ajax.requests.mostRecent().respondWith({
diff --git a/ng2-components/ng2-alfresco-tag/src/services/tag.service.spec.ts b/ng2-components/ng2-alfresco-tag/src/services/tag.service.spec.ts
index 0e8480629b..0dbc338a9f 100644
--- a/ng2-components/ng2-alfresco-tag/src/services/tag.service.spec.ts
+++ b/ng2-components/ng2-alfresco-tag/src/services/tag.service.spec.ts
@@ -15,35 +15,29 @@
* limitations under the License.
*/
-import { ReflectiveInjector } from '@angular/core';
-import {
- AlfrescoAuthenticationService,
- AlfrescoSettingsService,
- AlfrescoApiService,
- StorageService,
- LogService
-} from 'ng2-alfresco-core';
+import { TestBed, async } from '@angular/core/testing';
+import { CoreModule } from 'ng2-alfresco-core';
import { TagService } from '../services/tag.service';
declare let jasmine: any;
describe('Tag service', () => {
- let service, injector;
+ let service: TagService;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CoreModule.forRoot()
+ ],
+ providers: [
+ TagService
+ ]
+ }).compileComponents();
+ }));
beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoSettingsService,
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- TagService,
- StorageService,
- LogService
- ]);
- });
-
- beforeEach(() => {
- service = injector.get(TagService);
+ service = TestBed.get(TagService);
});
beforeEach(() => {
@@ -60,7 +54,7 @@ describe('Tag service', () => {
service.removeTag('fake-node-id', 'fake-tag').subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().method).toBe('DELETE');
expect(jasmine.Ajax.requests.mostRecent().url)
- .toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/fake-tag');
+ .toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags/fake-tag');
done();
});
@@ -73,7 +67,7 @@ describe('Tag service', () => {
service.addTag('fake-node-id', 'fake-tag').subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().method).toBe('POST');
expect(jasmine.Ajax.requests.mostRecent().url)
- .toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags');
+ .toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags');
done();
});
@@ -86,7 +80,7 @@ describe('Tag service', () => {
service.getAllTheTags().subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().method).toBe('GET');
expect(jasmine.Ajax.requests.mostRecent().url)
- .toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/tags');
+ .toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/tags');
done();
});
@@ -99,7 +93,7 @@ describe('Tag service', () => {
service.getTagsByNodeId('fake-node-id').subscribe(() => {
expect(jasmine.Ajax.requests.mostRecent().method).toBe('GET');
expect(jasmine.Ajax.requests.mostRecent().url)
- .toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags');
+ .toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/fake-node-id/tags');
done();
});
diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts
index e62729a367..5091ce1d80 100644
--- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts
+++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.ts
@@ -17,7 +17,7 @@
import { Component, ElementRef, Input, Output, EventEmitter, OnInit, OnChanges, SimpleChanges } from '@angular/core';
import { Observable, Subject } from 'rxjs/Rx';
-import { AlfrescoApiService, AlfrescoContentService, AlfrescoTranslationService, LogService, NotificationService, AlfrescoSettingsService, FileUtils } from 'ng2-alfresco-core';
+import { AlfrescoApiService, AlfrescoContentService, AlfrescoTranslationService, LogService, NotificationService, FileUtils } from 'ng2-alfresco-core';
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
import { UploadService } from '../services/upload.service';
import { FileModel } from '../models/file.model';
@@ -93,7 +93,6 @@ export class UploadButtonComponent implements OnInit, OnChanges {
private translateService: AlfrescoTranslationService,
private logService: LogService,
private notificationService: NotificationService,
- private settingsService: AlfrescoSettingsService,
private apiService: AlfrescoApiService,
private contentService: AlfrescoContentService) {
if (translateService) {
@@ -102,10 +101,6 @@ export class UploadButtonComponent implements OnInit, OnChanges {
}
ngOnInit() {
- this.settingsService.ecmHostSubject.subscribe((hostEcm: string) => {
- this.checkPermission();
- });
-
this.permissionValue.subscribe((permission: boolean) => {
this.hasPermission = permission;
});
diff --git a/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts b/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts
index 20dcd170dc..72d0edf4db 100644
--- a/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts
+++ b/ng2-components/ng2-alfresco-upload/src/services/upload.service.spec.ts
@@ -85,7 +85,7 @@ describe('UploadService', () => {
service.uploadFilesInTheQueue(emitter);
let request = jasmine.Ajax.requests.mostRecent();
- expect(request.url).toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true');
+ expect(request.url).toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true');
expect(request.method).toBe('POST');
jasmine.Ajax.requests.mostRecent().respondWith({
@@ -109,7 +109,7 @@ describe('UploadService', () => {
service.addToQueue(fileFake);
service.uploadFilesInTheQueue(emitter);
expect(jasmine.Ajax.requests.mostRecent().url)
- .toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true');
+ .toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?autoRename=true');
jasmine.Ajax.requests.mostRecent().respondWith({
'status': 404,
@@ -159,7 +159,7 @@ describe('UploadService', () => {
service.uploadFilesInTheQueue(emitter);
let request = jasmine.Ajax.requests.mostRecent();
- expect(request.url).toBe('http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/123/children?autoRename=true');
+ expect(request.url).toBe('http://localhost:3000/ecm/alfresco/api/-default-/public/alfresco/versions/1/nodes/123/children?autoRename=true');
expect(request.method).toBe('POST');
jasmine.Ajax.requests.mostRecent().respondWith({
diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts
index 603718bb20..99a2d4c78e 100644
--- a/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts
+++ b/ng2-components/ng2-alfresco-userinfo/src/services/bpm-user.service.spec.ts
@@ -15,35 +15,30 @@
* limitations under the License.
*/
-import { ReflectiveInjector } from '@angular/core';
-import {
- AlfrescoAuthenticationService,
- AlfrescoSettingsService,
- AlfrescoApiService,
- StorageService,
- LogService
-} from 'ng2-alfresco-core';
+import { TestBed, async } from '@angular/core/testing';
+import { CoreModule } from 'ng2-alfresco-core';
import { BpmUserService } from '../services/bpm-user.service';
import { BpmUserModel } from '../models/bpm-user.model';
+
declare let jasmine: any;
describe('Bpm user service', () => {
- let service, injector;
+ let service: BpmUserService;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CoreModule.forRoot()
+ ],
+ providers: [
+ BpmUserService
+ ]
+ }).compileComponents();
+ }));
beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoSettingsService,
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- BpmUserService,
- StorageService,
- LogService
- ]);
- });
-
- beforeEach(() => {
- service = injector.get(BpmUserService);
+ service = TestBed.get(BpmUserService);
});
beforeEach(() => {
diff --git a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts
index 56d4de3ebd..2158b18f36 100644
--- a/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts
+++ b/ng2-components/ng2-alfresco-userinfo/src/services/ecm-user.service.spec.ts
@@ -15,19 +15,11 @@
* limitations under the License.
*/
+import { TestBed, async } from '@angular/core/testing';
import { EcmUserService } from '../services/ecm-user.service';
import { fakeEcmUser } from '../assets/fake-ecm-user.service.mock';
-import { ReflectiveInjector } from '@angular/core';
-import {
- AlfrescoAuthenticationService,
- AlfrescoContentService,
- AlfrescoSettingsService,
- AlfrescoApiService,
- StorageService,
- CookieService,
- LogService
-} from 'ng2-alfresco-core';
-import { CookieServiceMock } from './../../../ng2-alfresco-core/src/assets/cookie.service.mock';
+import { CoreModule, AlfrescoAuthenticationService, AlfrescoContentService} from 'ng2-alfresco-core';
+
declare let jasmine: any;
describe('EcmUserService', () => {
@@ -35,25 +27,22 @@ describe('EcmUserService', () => {
let service: EcmUserService;
let authService: AlfrescoAuthenticationService;
let contentService: AlfrescoContentService;
- let injector;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ imports: [
+ CoreModule.forRoot()
+ ],
+ providers: [
+ EcmUserService
+ ]
+ }).compileComponents();
+ }));
beforeEach(() => {
- injector = ReflectiveInjector.resolveAndCreate([
- AlfrescoSettingsService,
- AlfrescoApiService,
- AlfrescoAuthenticationService,
- AlfrescoContentService,
- EcmUserService,
- StorageService,
- { provide: CookieService, useClass: CookieServiceMock },
- LogService
- ]);
- });
-
- beforeEach(() => {
- service = injector.get(EcmUserService);
- authService = injector.get(AlfrescoAuthenticationService);
- contentService = injector.get(AlfrescoContentService);
+ service = TestBed.get(EcmUserService);
+ authService = TestBed.get(AlfrescoAuthenticationService);
+ contentService = TestBed.get(AlfrescoContentService);
});
beforeEach(() => {
diff --git a/ng2-components/ng2-alfresco-webscript/src/webscript.component.spec.ts b/ng2-components/ng2-alfresco-webscript/src/webscript.component.spec.ts
index 35fb52315a..d24b89e116 100644
--- a/ng2-components/ng2-alfresco-webscript/src/webscript.component.spec.ts
+++ b/ng2-components/ng2-alfresco-webscript/src/webscript.component.spec.ts
@@ -87,7 +87,7 @@ describe('Test ng2-alfresco-webscript', () => {
component.ngOnChanges(null).then(() => {
fixture.detectChanges();
- expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:8080/alfresco/service/sample/folder/Company%20Home');
+ expect(jasmine.Ajax.requests.mostRecent().url).toBe('http://localhost:3000/ecm/alfresco/service/sample/folder/Company%20Home');
done();
});