-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: se desinscrire du service linky (#653)
Co-authored-by: dlamande <[email protected]>
- Loading branch information
Showing
13 changed files
with
151 additions
and
11 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
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
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
src/domaines/serviceRecherche/linky/seDesinscrireDuService.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 { ServiceRechercheLinkyRepository } from '@/domaines/serviceRecherche/linky/ports/serviceRechercheLinky.repository'; | ||
import { LinkyEvent } from '@/domaines/services/linkyEventBusImpl'; | ||
import { EventBus } from '@/shell/eventBus'; | ||
|
||
export class SeDesinscrireDuServiceUsecase { | ||
constructor( | ||
private serviceRechercheLinkyRepository: ServiceRechercheLinkyRepository, | ||
private readonly eventBus: EventBus<LinkyEvent>, | ||
) {} | ||
|
||
async execute(utilisateurId: string) { | ||
await this.serviceRechercheLinkyRepository.seDesabonner(utilisateurId); | ||
this.eventBus.publish(LinkyEvent.DESABONNEMENT); | ||
} | ||
} |
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
24 changes: 24 additions & 0 deletions
24
tests/serviceRecherche/linky/adapters/serviceRechercheLinky.repository.spy.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,24 @@ | ||
import { InformationCompteur } from '@/domaines/serviceRecherche/linky/obtenirInformationCompteur.usecase'; | ||
import { ServiceRechercheLinkyRepository } from '@/domaines/serviceRecherche/linky/ports/serviceRechercheLinky.repository'; | ||
import { ConsommationElectriqueGlobal } from '@/domaines/serviceRecherche/linky/recupererConsommationElectrique.usecase'; | ||
|
||
export class SpyServiceRechercheLinky implements ServiceRechercheLinkyRepository { | ||
private _seDesabonnerDuServiceAEteAppele: boolean = false; | ||
|
||
get seDesabonnerDuServiceAEteAppele(): boolean { | ||
return this._seDesabonnerDuServiceAEteAppele; | ||
} | ||
|
||
recupererConsommationElectrique(_idUtilsateur: string): Promise<ConsommationElectriqueGlobal> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
recupererInformationCompteur(_idUtilsateur: string): Promise<InformationCompteur> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
seDesabonner(_idUtilsateur: string): Promise<void> { | ||
this._seDesabonnerDuServiceAEteAppele = true; | ||
return Promise.resolve(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
tests/serviceRecherche/linky/seDesinscrireDuService.usecase.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,20 @@ | ||
import { SeDesinscrireDuServiceUsecase } from '@/domaines/serviceRecherche/linky/seDesinscrireDuService.usecase'; | ||
import { SpyLinkyEventBus } from '../../services/adapters/spyLinkyEventBus'; | ||
import { LinkyEvent } from '@/domaines/services/linkyEventBusImpl'; | ||
import { SpyServiceRechercheLinky } from './adapters/serviceRechercheLinky.repository.spy'; | ||
|
||
describe('Fichier de tests concernant la désinscirption au service linky', () => { | ||
it("En donnant un id d'utilisateur, doit appeler le repo et publier un evenement", async () => { | ||
// GIVEN | ||
const serviceRepositorySpy = new SpyServiceRechercheLinky(); | ||
const linkyEventBusSpy = new SpyLinkyEventBus(); | ||
const seDesinscrireDuServiceUsecase = new SeDesinscrireDuServiceUsecase(serviceRepositorySpy, linkyEventBusSpy); | ||
|
||
// WHEN | ||
await seDesinscrireDuServiceUsecase.execute('utilisateurId'); | ||
|
||
// THEN | ||
expect(serviceRepositorySpy.seDesabonner).toBeTruthy(); | ||
expect(linkyEventBusSpy.eventName).toBe(LinkyEvent.DESABONNEMENT); | ||
}); | ||
}); |
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