-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
149 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Service } from '@/common/domain/Service'; | ||
|
||
export interface History { | ||
services: Service[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Folder } from '@/springboot/domain/Folder'; | ||
import { History } from '@/common/domain/History'; | ||
|
||
export interface ProjectHistoryService { | ||
get(folder: Folder): Promise<History>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export enum Service { | ||
INITIALIZATION = 'INITIALIZATION', | ||
MAVEN = 'MAVEN', | ||
JAVA_BASE = 'JAVA_BASE', | ||
SPRINGBOOT = 'SPRINGBOOT', | ||
SPRINGBOOT_MVC_WITH_TOMCAT = 'SPRINGBOOT_MVC_WITH_TOMCAT', | ||
ANGULAR = 'ANGULAR', | ||
REACT = 'REACT', | ||
VUE = 'VUE', | ||
FRONTEND_MAVEN_PLUGIN = 'FRONTEND_MAVEN_PLUGIN', | ||
UNKNOWN = 'UNKNOWN', | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/webapp/app/common/secondary/ProjectHistoryRepository.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Folder } from '@/springboot/domain/Folder'; | ||
import { RestHistory, toHistory } from '@/common/secondary/RestHistory'; | ||
import { History } from '@/common/domain/History'; | ||
import { ProjectHistoryService } from '@/common/domain/ProjectHistoryService'; | ||
import { AxiosHttp } from '@/http/AxiosHttp'; | ||
|
||
export default class ProjectHistoryRepository implements ProjectHistoryService { | ||
constructor(private axiosHttp: AxiosHttp) {} | ||
|
||
async get(folder: Folder): Promise<History> { | ||
return this.axiosHttp.get<RestHistory>(`api/projects/history?folder=${folder}`).then(response => toHistory(response.data)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { RestServiceId, toService } from '@/common/secondary/RestServiceId'; | ||
import { History } from '@/common/domain/History'; | ||
|
||
export interface RestHistory { | ||
serviceIds: RestServiceId[]; | ||
} | ||
|
||
export const toHistory = (restHistory: RestHistory): History => ({ | ||
services: restHistory.serviceIds.map(toService), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Service } from '@/common/domain/Service'; | ||
|
||
export type RestServiceId = string; | ||
|
||
export const toService = (restServiceId: RestServiceId): Service => { | ||
switch (restServiceId) { | ||
case 'init': | ||
return Service.INITIALIZATION; | ||
case 'maven': | ||
return Service.MAVEN; | ||
case 'java-base': | ||
return Service.JAVA_BASE; | ||
case 'springboot': | ||
return Service.SPRINGBOOT; | ||
case 'springboot-tomcat': | ||
return Service.SPRINGBOOT_MVC_WITH_TOMCAT; | ||
case 'angular': | ||
return Service.ANGULAR; | ||
case 'react': | ||
return Service.REACT; | ||
case 'vue': | ||
return Service.VUE; | ||
case 'frontend-maven-plugin': | ||
return Service.FRONTEND_MAVEN_PLUGIN; | ||
default: | ||
return Service.UNKNOWN; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/test/javascript/spec/common/domain/ProjectHistoryService.fixture.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import sinon, { SinonStub } from 'sinon'; | ||
import { ProjectHistoryService } from '../../../../../main/webapp/app/common/domain/ProjectHistoryService'; | ||
|
||
export interface ProjectHistoryServiceFixture extends ProjectHistoryService { | ||
get: SinonStub; | ||
} | ||
|
||
export const stubProjectService = (): ProjectHistoryServiceFixture => ({ | ||
get: sinon.stub(), | ||
}); |
21 changes: 21 additions & 0 deletions
21
src/test/javascript/spec/common/secondary/ProjectHistoryRepository.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { stubAxiosHttp } from '../../http/AxiosHttpStub'; | ||
import { createRestHistory } from './RestHistory.fixture'; | ||
import ProjectHistoryRepository from '@/common/secondary/ProjectHistoryRepository'; | ||
import { History } from '@/common/domain/History'; | ||
import { Service } from '@/common/domain/Service'; | ||
|
||
describe('ProjectRepository', () => { | ||
it('should get project history', async () => { | ||
const axiosHttpStub = stubAxiosHttp(); | ||
axiosHttpStub.get.resolves({ data: createRestHistory() }); | ||
const projectHistoryRepository = new ProjectHistoryRepository(axiosHttpStub); | ||
|
||
const history: History = await projectHistoryRepository.get('folder/path'); | ||
|
||
const [uri] = axiosHttpStub.get.getCall(0).args; | ||
expect(uri).toBe('api/projects/history?folder=folder/path'); | ||
expect(history).toEqual<History>({ | ||
services: [Service.INITIALIZATION, Service.JAVA_BASE, Service.MAVEN], | ||
}); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
src/test/javascript/spec/common/secondary/RestHistory.fixture.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { RestHistory } from '../../../../../main/webapp/app/common/secondary/RestHistory'; | ||
|
||
export const createRestHistory = (restHistory?: Partial<RestHistory>): RestHistory => ({ | ||
serviceIds: ['init', 'java-base', 'maven'], | ||
...restHistory, | ||
}); |
14 changes: 14 additions & 0 deletions
14
src/test/javascript/spec/common/secondary/RestHistory.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { RestHistory, toHistory } from '../../../../../main/webapp/app/common/secondary/RestHistory'; | ||
import { History } from '../../../../../main/webapp/app/common/domain/History'; | ||
import { toService } from '../../../../../main/webapp/app/common/secondary/RestServiceId'; | ||
import { createRestHistory } from './RestHistory.fixture'; | ||
|
||
describe('RestHistory', () => { | ||
it('should convert to History', () => { | ||
const restHistory: RestHistory = createRestHistory(); | ||
|
||
expect(toHistory(restHistory)).toEqual<History>({ | ||
services: restHistory.serviceIds.map(toService), | ||
}); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
src/test/javascript/spec/common/secondary/RestServiceId.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Service } from '../../../../../main/webapp/app/common/domain/Service'; | ||
import { toService } from '../../../../../main/webapp/app/common/secondary/RestServiceId'; | ||
|
||
describe('RestServiceId', () => { | ||
it('should convert to Service', () => { | ||
expect(toService('init')).toEqual<Service>(Service.INITIALIZATION); | ||
expect(toService('maven')).toEqual<Service>(Service.MAVEN); | ||
expect(toService('java-base')).toEqual<Service>(Service.JAVA_BASE); | ||
expect(toService('springboot')).toEqual<Service>(Service.SPRINGBOOT); | ||
expect(toService('springboot-tomcat')).toEqual<Service>(Service.SPRINGBOOT_MVC_WITH_TOMCAT); | ||
expect(toService('angular')).toEqual<Service>(Service.ANGULAR); | ||
expect(toService('react')).toEqual<Service>(Service.REACT); | ||
expect(toService('vue')).toEqual<Service>(Service.VUE); | ||
expect(toService('frontend-maven-plugin')).toEqual<Service>(Service.FRONTEND_MAVEN_PLUGIN); | ||
expect(toService('beer')).toEqual<Service>(Service.UNKNOWN); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters