Skip to content

Commit afde98e

Browse files
committed
Remove MongoBackofficeCourseRepository from Backoffice context
1 parent 6b491bf commit afde98e

File tree

13 files changed

+22
-110
lines changed

13 files changed

+22
-110
lines changed

src/Contexts/Backoffice/Courses/infrastructure/persistence/MongoBackofficeCourseRepository.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/apps/backoffice/backend/dependency-injection/Courses/application.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
services:
22

3-
Backoffice.courses.BackofficeCourseRepository:
4-
class: ../../../../../Contexts/Backoffice/Courses/infrastructure/persistence/MongoBackofficeCourseRepository
5-
arguments: ['@Shared.MongoConnectionManager']
3+
Backoffice.courses.ElasticConfig:
4+
factory:
5+
class: ../../../../../Contexts/Backoffice/Courses/infrastructure/persistence/BackofficeElasticConfigFactory
6+
method: 'createConfig'
67

7-
Backoffice.courses.BackofficeCourseRepositoryElastic:
8+
Backoffice.courses.BackofficeCourseRepository:
89
class: ../../../../../Contexts/Backoffice/Courses/infrastructure/persistence/ElasticBackofficeCourseRepository
910
arguments: ['@Shared.ElasticConnectionManager']
1011

src/apps/backoffice/backend/dependency-injection/Shared/application.yaml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,11 @@ services:
33
class: ../../../../../Contexts/Shared/infrastructure/WinstonLogger
44
arguments: []
55

6-
Shared.MongoConnectionManager:
7-
factory:
8-
class: ../../../../../Contexts/Shared/infrastructure/persistence/mongo/MongoClientFactory
9-
method: 'createClient'
10-
arguments: ['mooc', '@Apps.Backoffice.Backend.MongoConfig']
11-
126
Shared.ElasticConnectionManager:
137
factory:
148
class: ../../../../../Contexts/Shared/infrastructure/persistence/elasticsearch/ElasticClientFactory
159
method: 'createClient'
16-
arguments: ['mooc', '@Apps.Backoffice.Backend.ElasticConfig']
10+
arguments: ['mooc', '@Backoffice.courses.ElasticConfig']
1711

1812
Shared.QueryHandlersInformation:
1913
class: ../../../../../Contexts/Shared/infrastructure/QueryBus/QueryHandlersInformation

src/apps/backoffice/backend/dependency-injection/application_test.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,5 @@ imports:
33

44
services:
55
Backoffice.Backend.EnvironmentArranger:
6-
class: ../../../../../tests/Contexts/Shared/infrastructure/mongo/MongoEnvironmentArranger
7-
arguments: ['@Shared.MongoConnectionManager']
8-
9-
Backoffice.Backend.ElasticEnvironmentArranger:
106
class: ../../../../../tests/Contexts/Shared/infrastructure/elastic/ElasticEnvironmentArranger
117
arguments: ['@Shared.ElasticConnectionManager']

src/apps/backoffice/backend/dependency-injection/apps/application.yaml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
services:
2-
Apps.Backoffice.Backend.MongoConfig:
3-
factory:
4-
class: ../../../../../Contexts/Backoffice/Courses/infrastructure/persistence/BackofficeMongoConfigFactory
5-
method: 'createConfig'
6-
7-
Apps.Backoffice.Backend.ElasticConfig:
8-
factory:
9-
class: ../../../../../Contexts/Backoffice/Courses/infrastructure/persistence/BackofficeElasticConfigFactory
10-
method: 'createConfig'
112

123
Apps.Backoffice.Backend.controllers.StatusGetController:
134
class: ../../controllers/StatusGetController
Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@ import { ElasticBackofficeCourseRepository } from '../../../../../src/Contexts/B
44
import { EnvironmentArranger } from '../../../Shared/infrastructure/arranger/EnvironmentArranger';
55
import { BackofficeCourseMother } from '../domain/BackofficeCourseMother';
66

7-
const repository: ElasticBackofficeCourseRepository = container.get(
8-
'Backoffice.courses.BackofficeCourseRepositoryElastic'
9-
);
10-
const environmentArranger: Promise<EnvironmentArranger> = container.get(
11-
'Backoffice.Backend.ElasticEnvironmentArranger'
12-
);
7+
const repository: ElasticBackofficeCourseRepository = container.get('Backoffice.courses.BackofficeCourseRepository');
8+
const environmentArranger: Promise<EnvironmentArranger> = container.get('Backoffice.Backend.EnvironmentArranger');
139

1410
afterEach(async () => {
1511
await (await environmentArranger).arrange();
1612
});
1713

18-
describe('ElasticBackofficeCourseRepository', () => {
14+
describe('BackofficeCourseRepository', () => {
1915
describe('#searchAll', () => {
2016
it('should return the existing courses', async () => {
2117
const courses = [BackofficeCourseMother.random(), BackofficeCourseMother.random()];

tests/Contexts/Backoffice/Courses/infrastructure/MongoBackofficeCourseRepository.test.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ afterAll(async () => {
1414
await (await environmentArranger).close();
1515
});
1616

17-
describe('MongoCourseRepository', () => {
17+
describe('CourseRepository', () => {
1818
describe('#save', () => {
1919
it('should save a course', async () => {
2020
const course = CourseMother.random();
@@ -25,11 +25,12 @@ describe('MongoCourseRepository', () => {
2525

2626
describe('#search', () => {
2727
it('should return an existing course', async () => {
28-
const course = CourseMother.random();
28+
const expectedCourse = CourseMother.random();
29+
await repository.save(expectedCourse);
2930

30-
await repository.save(course);
31+
const course = await repository.search(expectedCourse.id);
3132

32-
expect(course).toEqual(await repository.search(course.id));
33+
expect(expectedCourse).toEqual(course);
3334
});
3435

3536
it('should not return a non existing course', async () => {

tests/Contexts/Mooc/CoursesCounter/infrastructure/MongoCoursesCounterRepository.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@ describe('MongoCoursesCounterRepository', () => {
2525

2626
describe('#search', () => {
2727
it('should return an existing course', async () => {
28-
const counter = CoursesCounterMother.random();
28+
const expectedCounter = CoursesCounterMother.random();
29+
await repository.save(expectedCounter);
2930

30-
await repository.save(counter);
31+
const counter = await repository.search();
3132

32-
expect(counter).toEqual(await repository.search());
33+
expect(expectedCounter).toEqual(counter);
3334
});
3435

3536
it('should not return null if there is no courses counter', async () => {

tests/apps/backoffice/backend/features/step_definitions/controller.steps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import assert from 'assert';
22
import { AfterAll, Before, Given, Then } from 'cucumber';
33
import request from 'supertest';
44
import app from '../../../../../../src/apps/backoffice/backend/app';
5-
import container from '../../../../../../src/apps/backoffice/backend/config/dependency-injection';
5+
import container from '../../../../../../src/apps/backoffice/backend/dependency-injection';
66
import { EnvironmentArranger } from '../../../../../Contexts/Shared/infrastructure/arranger/EnvironmentArranger';
77

88
let _request: request.Test;

0 commit comments

Comments
 (0)