-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stages): chargement du flux hellowork (#372)
- Loading branch information
Showing
10 changed files
with
135 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
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
15 changes: 15 additions & 0 deletions
15
apps/stages/src/chargement/application-service/charger-flux-hellowork.usecase.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,15 @@ | ||
import { Usecase } from "@shared/src/application-service/usecase"; | ||
|
||
import { FluxChargement } from "@stages/src/chargement/domain/model/flux"; | ||
import { | ||
ChargerOffresDeStageDomainService, | ||
} from "@stages/src/chargement/domain/service/charger-offres-de-stage.domain-service"; | ||
|
||
export class ChargerFluxHellowork implements Usecase { | ||
constructor(private readonly chargerOffresDeStages: ChargerOffresDeStageDomainService) { | ||
} | ||
|
||
public async executer(flux: FluxChargement): Promise<void> { | ||
await this.chargerOffresDeStages.charger(flux); | ||
} | ||
} |
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
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
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
25 changes: 25 additions & 0 deletions
25
apps/stages/src/chargement/infrastructure/sub-command/load-flow-hellowork.sub-command.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,25 @@ | ||
import { CommandRunner, SubCommand } from "nest-commander"; | ||
|
||
import { ChargerFluxHellowork } from "@stages/src/chargement/application-service/charger-flux-hellowork.usecase"; | ||
import { FluxChargement } from "@stages/src/chargement/domain/model/flux"; | ||
import { Configuration } from "@stages/src/chargement/infrastructure/configuration/configuration"; | ||
import { CommandLog } from "@stages/src/chargement/infrastructure/configuration/log.decorator"; | ||
|
||
@SubCommand({ name: LoadFlowHelloworkSubCommand.FLOW_NAME }) | ||
export class LoadFlowHelloworkSubCommand extends CommandRunner { | ||
private static readonly FLOW_NAME = "hellowork"; | ||
|
||
constructor( | ||
private readonly chargerHellowork: ChargerFluxHellowork, | ||
private readonly configuration: Configuration | ||
) { | ||
super(); | ||
} | ||
|
||
@CommandLog(LoadFlowHelloworkSubCommand.FLOW_NAME) | ||
public async run(): Promise<void> { | ||
await this.chargerHellowork.executer( | ||
new FluxChargement(this.configuration.HELLOWORK.NAME, this.configuration.HELLOWORK.TRANSFORMED_FILE_EXTENSION) | ||
); | ||
} | ||
} |
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
35 changes: 35 additions & 0 deletions
35
apps/stages/test/chargement/usecase/charger-flux-hellowork.usecase.test.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,35 @@ | ||
import { expect, StubbedClass, stubClass } from "@test/library"; | ||
|
||
import { ChargerFluxHellowork } from "@stages/src/chargement/application-service/charger-flux-hellowork.usecase"; | ||
import { FluxChargement } from "@stages/src/chargement/domain/model/flux"; | ||
import { | ||
ChargerOffresDeStageDomainService, | ||
} from "@stages/src/chargement/domain/service/charger-offres-de-stage.domain-service"; | ||
|
||
let extension: string; | ||
let nomDuFlux: string; | ||
let flux: FluxChargement; | ||
|
||
let domainService: StubbedClass<ChargerOffresDeStageDomainService>; | ||
let usecase: ChargerFluxHellowork; | ||
|
||
describe("ChargerFluxHelloworkTest", () => { | ||
context("Lorsque je charge le flux Hellowork", () => { | ||
beforeEach(() => { | ||
nomDuFlux = "hellowork"; | ||
extension = ".json"; | ||
|
||
flux = new FluxChargement(nomDuFlux, extension); | ||
|
||
domainService = stubClass(ChargerOffresDeStageDomainService); | ||
usecase = new ChargerFluxHellowork(domainService); | ||
}); | ||
|
||
it("Je charge ce dernier", async () => { | ||
await usecase.executer(flux); | ||
|
||
expect(domainService.charger).to.have.been.calledOnce; | ||
expect(domainService.charger).to.have.been.calledWith(flux); | ||
}); | ||
}); | ||
}); |
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