Skip to content

Commit ecef020

Browse files
committed
restored the initial branch state
2 parents e84e161 + 29d78d9 commit ecef020

25 files changed

+214
-96
lines changed

app/controllers/SystemInfoController.scala

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@
2121
import java.net.InetAddress
2222

2323
import javax.inject.Inject
24+
import models.SystemInfo
25+
import play.api.libs.json.Json
2426
import play.api.mvc.{Action, AnyContent, BaseController, ControllerComponents}
2527
import play.core.PlayVersion
26-
import play.api.libs.json.Json
28+
2729

2830
class SystemInfoController @Inject()(val controllerComponents: ControllerComponents) extends BaseController {
31+
implicit val systemInfoWrites = Json.writes[SystemInfo]
32+
implicit val systemInfoReads = Json.reads[SystemInfo]
2933

3034
def getInfo: Action[AnyContent] = Action {
31-
Ok(Json.obj("hostName" -> getHostName(), "javaVersion" -> getJvmVersion(), "platformName" -> getPlatformName(), "scalaVersion" -> getScalaVersion()))
35+
36+
val info = SystemInfo(hostName = getHostName(), javaVersion = getJvmVersion(), platformName = getPlatformName(), scalaVersion = getScalaVersion())
37+
val infoJson = Json.toJson(info)
38+
Ok(infoJson)
3239
}
3340

3441
private def getJvmVersion(): String = {
@@ -39,21 +46,21 @@
3946

4047

4148

42-
private def getHostName(): String = {
49+
private def getHostName(): String = {
4350
InetAddress.getLocalHost().getHostName()
44-
}
51+
}
4552

4653

47-
private def getPlatformName(): String = {
54+
private def getPlatformName(): String = {
4855
val os = "os.name";
4956
val version = "os.version";
5057
val osVersion: String = System.getProperty(os) + " " + System.getProperty(version)
5158
osVersion
52-
}
59+
}
5360

5461

5562
private def getScalaVersion(): String = {
5663
PlayVersion.current
57-
}
64+
}
5865

5966
}

app/models/SystemInfo.scala

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
1-
package models
1+
/*
2+
* Copyright (C) 2018 The Delphi Team.
3+
* See the LICENCE file distributed with this work for additional
4+
* information regarding copyright ownership.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
218

3-
class SystemInfo {
19+
package models
420

5-
}
21+
case class SystemInfo(hostName: String, javaVersion: String, platformName: String, scalaVersion: String)

client/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
},
1212
"private": true,
1313
"dependencies": {
14-
"@angular/animations": "^6.1.4",
15-
"@angular/cdk": "^6.4.6",
14+
"@angular/animations": "github:angular/animations-builds",
15+
"@angular/cdk": "github:angular/cdk-builds",
1616
"@angular/common": "^6.1.4",
1717
"@angular/compiler": "^6.1.4",
1818
"@angular/core": "^6.1.4",
@@ -27,6 +27,7 @@
2727
"core-js": "^2.5.4",
2828
"font-awesome": "^4.7.0",
2929
"jquery": "^3.3.1",
30+
"material-design-icons": "^3.0.1",
3031
"popper.js": "^1.14.4",
3132
"rxjs": "^6.2.2",
3233
"rxjs-compat": "^6.2.2",

client/src/app/api/api/api.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {Configuration} from '../configuration';
2323
import {BASE_PATH, INSTANCES, NUMBER_OF_INSTANCES, SYS_INFO} from '../variables';
2424
import {CustomHttpUrlEncodingCodec} from '../encoder';
2525
import {Instance} from '..';
26-
import {SysInfo} from "../model/sysInfo";
26+
import {SysInfo} from '../model/sysInfo';
2727

2828

2929
@Injectable({

client/src/app/api/configuration.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ export class Configuration {
5050
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
5151
*/
5252
public selectHeaderContentType (contentTypes: string[]): string | undefined {
53-
if (contentTypes.length == 0) {
53+
if (contentTypes.length === 0) {
5454
return undefined;
5555
}
5656

57-
let type = contentTypes.find(x => this.isJsonMime(x));
57+
const type = contentTypes.find(x => this.isJsonMime(x));
5858
if (type === undefined) {
5959
return contentTypes[0];
6060
}
@@ -69,11 +69,11 @@ export class Configuration {
6969
* @returns {string} the selected content-type or <code>undefined</code> if no selection could be made.
7070
*/
7171
public selectHeaderAccept(accepts: string[]): string | undefined {
72-
if (accepts.length == 0) {
72+
if (accepts.length === 0) {
7373
return undefined;
7474
}
7575

76-
let type = accepts.find(x => this.isJsonMime(x));
76+
const type = accepts.find(x => this.isJsonMime(x));
7777
if (type === undefined) {
7878
return accepts[0];
7979
}

client/src/app/app.component.spec.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,26 @@
1717
*/
1818

1919
import { TestBed, async } from '@angular/core/testing';
20+
import { Router, RouterOutlet } from '@angular/router';
21+
import { RouterTestingModule } from '@angular/router/testing';
2022
import { AppComponent } from './app.component';
23+
24+
class MockRouter { public navigate() {} }
25+
2126
describe('AppComponent', () => {
2227
beforeEach(async(() => {
2328
TestBed.configureTestingModule({
2429
declarations: [
2530
AppComponent
2631
],
32+
providers: [{provide: Router, useClass: MockRouter },
33+
RouterOutlet],
34+
imports: [ RouterTestingModule ]
2735
}).compileComponents();
2836
}));
2937
it('should create the app', async(() => {
3038
const fixture = TestBed.createComponent(AppComponent);
3139
const app = fixture.debugElement.componentInstance;
3240
expect(app).toBeTruthy();
3341
}));
34-
it(`should have as title 'client'`, async(() => {
35-
const fixture = TestBed.createComponent(AppComponent);
36-
const app = fixture.debugElement.componentInstance;
37-
expect(app.title).toEqual('client');
38-
}));
39-
it('should render title in a h1 tag', async(() => {
40-
const fixture = TestBed.createComponent(AppComponent);
41-
fixture.detectChanges();
42-
const compiled = fixture.debugElement.nativeElement;
43-
expect(compiled.querySelector('h1').textContent).toContain('Welcome to client!');
44-
}));
4542
});

client/src/app/dashboard/crawler/crawler.component.spec.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,28 @@
1616
* limitations under the License.
1717
*/
1818

19-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
20-
19+
import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
20+
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
21+
import { HttpClientModule, HttpClient } from '@angular/common/http';
22+
import { BrowserAnimationsModule} from '@angular/platform-browser/animations';
23+
import { MatTableModule, MatInputModule} from '@angular/material';
24+
import { MatFormFieldModule} from '@angular/material/form-field';
25+
import { MatCheckboxModule} from '@angular/material/checkbox';
26+
import { MatIconModule} from '@angular/material/icon';
27+
import { MatDialogModule} from '@angular/material/dialog';
28+
import { TableAllComponent } from '../table-all/table-all.component';
2129
import { CrawlerComponent } from './crawler.component';
30+
import { ApiService} from '../../api';
2231

2332
describe('CrawlerComponent', () => {
2433
let component: CrawlerComponent;
2534
let fixture: ComponentFixture<CrawlerComponent>;
2635

2736
beforeEach(async(() => {
2837
TestBed.configureTestingModule({
29-
declarations: [ CrawlerComponent ]
38+
declarations: [ CrawlerComponent, TableAllComponent],
39+
imports: [HttpClientTestingModule, HttpClientModule, BrowserAnimationsModule,
40+
MatTableModule, MatInputModule, MatFormFieldModule, MatCheckboxModule, MatIconModule, MatDialogModule]
3041
})
3142
.compileComponents();
3243
}));
@@ -37,7 +48,8 @@ describe('CrawlerComponent', () => {
3748
fixture.detectChanges();
3849
});
3950

40-
it('should create', () => {
41-
expect(component).toBeTruthy();
42-
});
51+
it(`should create`, async(inject([HttpTestingController, ApiService],
52+
(httpClient: HttpTestingController, apiService: ApiService) => {
53+
expect(apiService).toBeTruthy();
54+
})));
4355
});

client/src/app/dashboard/dashboard-card/dashboard-card.component.spec.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
*/
1818

1919
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
20-
20+
import { Router, RouterOutlet } from "@angular/router";
21+
import { RouterModule } from '@angular/router';
2122
import { DashboardCardComponent } from './dashboard-card.component';
2223

2324
describe('DashboardCardComponent', () => {
@@ -26,7 +27,10 @@ describe('DashboardCardComponent', () => {
2627

2728
beforeEach(async(() => {
2829
TestBed.configureTestingModule({
29-
declarations: [ DashboardCardComponent ]
30+
declarations: [ DashboardCardComponent ],
31+
providers: [{provide: Router},
32+
RouterOutlet],
33+
imports: [RouterModule]
3034
})
3135
.compileComponents();
3236
}));

client/src/app/dashboard/dashboard-overview/dashboard-overview.component.spec.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
*/
1818

1919
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
20+
import {Instance} from "../../api";
21+
import { HttpClientModule } from '@angular/common/http';
22+
import { StatusCardComponent } from '../status-card/status-card.component';
23+
import { DashboardCardComponent } from '../dashboard-card/dashboard-card.component';
24+
import { RouterModule } from '@angular/router';
2025
import { DashboardOverviewComponent } from './dashboard-overview.component';
2126

2227
describe('DashboardOverviewComponent', () => {
@@ -25,7 +30,8 @@ describe('DashboardOverviewComponent', () => {
2530

2631
beforeEach(async(() => {
2732
TestBed.configureTestingModule({
28-
declarations: [ DashboardOverviewComponent ]
33+
declarations: [ DashboardOverviewComponent, DashboardCardComponent, StatusCardComponent ],
34+
imports: [RouterModule, HttpClientModule]
2935
})
3036
.compileComponents();
3137
}));

client/src/app/dashboard/dashboard.component.spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,23 @@
1717
*/
1818

1919
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
20-
20+
import { Router, RouterOutlet } from '@angular/router';
21+
import { RouterTestingModule } from '@angular/router/testing';
22+
import { HeaderComponent } from './header/header.component';
2123
import { DashboardComponent } from './dashboard.component';
2224

25+
class MockRouter { public navigate() {} }
26+
2327
describe('DashboardComponent', () => {
2428
let component: DashboardComponent;
2529
let fixture: ComponentFixture<DashboardComponent>;
2630

2731
beforeEach(async(() => {
2832
TestBed.configureTestingModule({
29-
declarations: [ DashboardComponent ]
33+
declarations: [ DashboardComponent, HeaderComponent],
34+
providers: [{provide: Router, useClass: MockRouter },
35+
RouterOutlet],
36+
imports: [ RouterTestingModule ]
3037
})
3138
.compileComponents();
3239
}));

0 commit comments

Comments
 (0)