-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlobalObjects.js
69 lines (53 loc) · 2.11 KB
/
GlobalObjects.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const Controller = require('./src/Controller');
const Mediator = require('./src/Mediator');
const AdminRepository = require('./src/Repository/AdminRepository');
const MockAdminRepository = require('./src/Repository/Mock/MockAdminRepository');
// GRPC SETUP
const grpc = require('grpc');
const protoLoader = require('@grpc/proto-loader');
const PROTO_PATH = __dirname + '/proto/ubc.proto';
const packageDefinition = protoLoader.loadSync(PROTO_PATH, { keepCase: true, longs: String, enums: String, defaults: true, oneofs: true });
const ubc_package = grpc.loadPackageDefinition(packageDefinition).ubc_package;
// GRPC SETUP
class GlobalObjects {
constructor() {
this.unreturnableContentForResult = "globalObjectsUnreturnableContent";
this.done = false;
this.result = this.unreturnableContentForResult; // Result object that will be filled during tests.
this.controller = new Controller();
this.mediator = new Mediator();
this.adminRepository = new AdminRepository();
this.client = new ubc_package.AuthService(process.env.AUTH_SERVICE_ADDR || "0.0.0.0:50051", grpc.credentials.createInsecure());
}
// Mock everything...
mock() {
this.mediator.mock();
this.adminRepository = new MockAdminRepository();
}
enterIntegratedTestingEnvironment() {
this.mediator.enterIntegratedTestingEnvironment();
this.adminRepository.enterIntegratedTestingEnvironment();
}
cleanUp() {
//TODO: Client cleanup
this.mediator.cleanUp();
this.adminRepository.cleanUp();
}
resetResult() {
this.result = this.unreturnableContentForResult;
}
setScenario(scenario) {
this.scenario = scenario;
}
setScenarioTester(scenarioTester) {
this.scenarioTester = scenarioTester;
}
reset() {
this.result = this.unreturnableContentForResult; // Result object that will be filled during tests.
this.controller = new Controller();
this.mediator = new Mediator();
this.adminRepository = new AdminRepository();
this.client = new ubc_package.AuthService(process.env.AUTH_SERVICE_ADDR || "0.0.0.0:50051", grpc.credentials.createInsecure());
}
}
module.exports = GlobalObjects;