update naming of classes and tests

This commit is contained in:
2025-03-24 09:20:10 -07:00
parent 135a294e5d
commit 619ef9a27f
8 changed files with 26 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
import { NotificationService } from "./services/NotificationService"; import { ETANotificationScheduler } from "./notifications/schedulers/ETANotificationScheduler";
import { GetterSetterRepository } from "./repositories/GetterSetterRepository"; import { GetterSetterRepository } from "./repositories/GetterSetterRepository";
export interface ServerContext { export interface ServerContext {
repository: GetterSetterRepository; repository: GetterSetterRepository;
notificationService: NotificationService; notificationService: ETANotificationScheduler;
} }

View File

@@ -5,7 +5,7 @@ import { MergedResolvers } from "./MergedResolvers";
import { ServerContext } from "./ServerContext"; import { ServerContext } from "./ServerContext";
import { UnoptimizedInMemoryRepository } from "./repositories/UnoptimizedInMemoryRepository"; import { UnoptimizedInMemoryRepository } from "./repositories/UnoptimizedInMemoryRepository";
import { TimedApiBasedRepositoryLoader } from "./loaders/TimedApiBasedRepositoryLoader"; import { TimedApiBasedRepositoryLoader } from "./loaders/TimedApiBasedRepositoryLoader";
import { NotificationService } from "./services/NotificationService"; import { ETANotificationScheduler } from "./notifications/schedulers/ETANotificationScheduler";
import { configDotenv } from "dotenv"; import { configDotenv } from "dotenv";
import { loadTestData } from "./loaders/loadTestData"; import { loadTestData } from "./loaders/loadTestData";
@@ -21,16 +21,16 @@ async function main() {
}); });
const repository = new UnoptimizedInMemoryRepository(); const repository = new UnoptimizedInMemoryRepository();
let notificationService: NotificationService; let notificationService: ETANotificationScheduler;
if (process.argv.length > 2 && process.argv[2] == "integration-testing") { if (process.argv.length > 2 && process.argv[2] == "integration-testing") {
await loadTestData(repository); await loadTestData(repository);
notificationService = new NotificationService(repository, false); notificationService = new ETANotificationScheduler(repository, false);
} else { } else {
const repositoryDataUpdater = new TimedApiBasedRepositoryLoader( const repositoryDataUpdater = new TimedApiBasedRepositoryLoader(
repository repository
); );
await repositoryDataUpdater.start(); await repositoryDataUpdater.start();
notificationService = new NotificationService(repository); notificationService = new ETANotificationScheduler(repository);
} }
notificationService.reloadAPNsTokenIfTimePassed(); notificationService.reloadAPNsTokenIfTimePassed();

View File

@@ -1,8 +1,8 @@
import { GetterRepository } from "../repositories/GetterRepository"; import { GetterRepository } from "../../repositories/GetterRepository";
import jwt from "jsonwebtoken"; import jwt from "jsonwebtoken";
import fs from "fs"; import fs from "fs";
import { TupleKey } from "../types/TupleKey"; import { TupleKey } from "../../types/TupleKey";
import { IEta } from "../entities/entities"; import { IEta } from "../../entities/entities";
import http2 from "http2"; import http2 from "http2";
export interface ScheduledNotificationData { export interface ScheduledNotificationData {
@@ -17,7 +17,7 @@ interface APNsUrl {
host: string; host: string;
} }
export class NotificationService { export class ETANotificationScheduler {
public readonly secondsThresholdForNotificationToFire = 180; public readonly secondsThresholdForNotificationToFire = 180;
private apnsToken: string | undefined = undefined; private apnsToken: string | undefined = undefined;
@@ -113,7 +113,7 @@ export class NotificationService {
throw new Error("APNS_BUNDLE_ID environment variable is not set correctly"); throw new Error("APNS_BUNDLE_ID environment variable is not set correctly");
} }
const { path, host } = NotificationService.getAPNsFullUrlToUse(deviceId); const { path, host } = ETANotificationScheduler.getAPNsFullUrlToUse(deviceId);
const headers = { const headers = {
':method': 'POST', ':method': 'POST',

View File

@@ -2094,9 +2094,9 @@ export const fetchSystemDataSuccessfulResponse = {
"logo": 1, "logo": 1,
"goRoutePlannerEnabled": "0", "goRoutePlannerEnabled": "0",
"goColor": null, "goColor": null,
"goSupportEmail": "transit.services@pepperdine.edu", "goSupportEmail": "transit.schedulers@pepperdine.edu",
"goAuthenticationType": "0", "goAuthenticationType": "0",
"email": "transit.services@pepperdine.edu" "email": "transit.schedulers@pepperdine.edu"
}, },
{ {
"fullname": "Perimeter Summit Shuttle", "fullname": "Perimeter Summit Shuttle",
@@ -3347,4 +3347,4 @@ export const fetchSystemDataSuccessfulResponse = {
"fromCache": 1, "fromCache": 1,
"myip": "206.211.154.147" "myip": "206.211.154.147"
} }
}; };

View File

@@ -1,9 +1,9 @@
import { beforeEach, describe, expect, it, jest } from "@jest/globals"; import { beforeEach, describe, expect, it, jest } from "@jest/globals";
import { NotificationService } from "../../src/services/NotificationService"; import { ETANotificationScheduler } from "../../../src/notifications/schedulers/ETANotificationScheduler";
import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository"; import { UnoptimizedInMemoryRepository } from "../../../src/repositories/UnoptimizedInMemoryRepository";
import http2 from "http2"; import http2 from "http2";
import { IEta, IShuttle, IStop } from "../../src/entities/entities"; import { IEta, IShuttle, IStop } from "../../../src/entities/entities";
import { addMockShuttleToRepository, addMockStopToRepository } from "../testHelpers/repositorySetupHelpers"; import { addMockShuttleToRepository, addMockStopToRepository } from "../../testHelpers/repositorySetupHelpers";
import EventEmitter = require("node:events"); import EventEmitter = require("node:events");
jest.mock("http2"); jest.mock("http2");
@@ -55,13 +55,13 @@ function mockHttp2Connect(status: number) {
(http2.connect as jest.Mock) = jest.fn(() => new MockClient()); (http2.connect as jest.Mock) = jest.fn(() => new MockClient());
} }
describe("NotificationService", () => { describe("ETANotificationScheduler", () => {
let repository: UnoptimizedInMemoryRepository let repository: UnoptimizedInMemoryRepository
let notificationService: NotificationService; let notificationService: ETANotificationScheduler;
beforeEach(() => { beforeEach(() => {
repository = new UnoptimizedInMemoryRepository(); repository = new UnoptimizedInMemoryRepository();
notificationService = new NotificationService(repository); notificationService = new ETANotificationScheduler(repository);
// Ensure that tests don't hit the server // Ensure that tests don't hit the server
process.env = { process.env = {
@@ -192,7 +192,7 @@ describe("NotificationService", () => {
it('should return the production URL when APNS_IS_PRODUCTION is set to "1"', () => { it('should return the production URL when APNS_IS_PRODUCTION is set to "1"', () => {
process.env.APNS_IS_PRODUCTION = "1"; process.env.APNS_IS_PRODUCTION = "1";
const deviceId = 'testDeviceId'; const deviceId = 'testDeviceId';
const result = NotificationService.getAPNsFullUrlToUse(deviceId); const result = ETANotificationScheduler.getAPNsFullUrlToUse(deviceId);
const { fullUrl, host, path } = result; const { fullUrl, host, path } = result;
expect(fullUrl).toBe(`https://api.push.apple.com/3/device/${deviceId}`); expect(fullUrl).toBe(`https://api.push.apple.com/3/device/${deviceId}`);
@@ -203,7 +203,7 @@ describe("NotificationService", () => {
it('should return the sandbox URL when APNS_IS_PRODUCTION is set to something other than 1', () => { it('should return the sandbox URL when APNS_IS_PRODUCTION is set to something other than 1', () => {
process.env.APNS_IS_PRODUCTION = "0"; process.env.APNS_IS_PRODUCTION = "0";
const deviceId = 'testDeviceId'; const deviceId = 'testDeviceId';
const result = NotificationService.getAPNsFullUrlToUse(deviceId); const result = ETANotificationScheduler.getAPNsFullUrlToUse(deviceId);
const { fullUrl, host, path } = result; const { fullUrl, host, path } = result;
expect(fullUrl).toBe(`https://api.development.push.apple.com/3/device/${deviceId}`); expect(fullUrl).toBe(`https://api.development.push.apple.com/3/device/${deviceId}`);

View File

@@ -2,7 +2,7 @@ import { describe, expect, it } from "@jest/globals";
import { generateMockSystems } from "../testHelpers/mockDataGenerators"; import { generateMockSystems } from "../testHelpers/mockDataGenerators";
import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers"; import { setupTestServerContext, setupTestServerHolder } from "../testHelpers/apolloTestServerHelpers";
import assert = require("node:assert"); import assert = require("node:assert");
import { ScheduledNotificationData } from "../../src/services/NotificationService"; import { ScheduledNotificationData } from "../../src/notifications/schedulers/ETANotificationScheduler";
import { addMockShuttleToRepository, addMockStopToRepository } from "../testHelpers/repositorySetupHelpers"; import { addMockShuttleToRepository, addMockStopToRepository } from "../testHelpers/repositorySetupHelpers";
// See Apollo documentation for integration test guide // See Apollo documentation for integration test guide

View File

@@ -4,7 +4,7 @@ import { MergedResolvers } from "../../src/MergedResolvers";
import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository"; import { UnoptimizedInMemoryRepository } from "../../src/repositories/UnoptimizedInMemoryRepository";
import { beforeEach } from "@jest/globals"; import { beforeEach } from "@jest/globals";
import { ServerContext } from "../../src/ServerContext"; import { ServerContext } from "../../src/ServerContext";
import { NotificationService } from "../../src/services/NotificationService"; import { ETANotificationScheduler } from "../../src/notifications/schedulers/ETANotificationScheduler";
function setUpTestServer() { function setUpTestServer() {
@@ -26,7 +26,7 @@ export function setupTestServerContext() {
beforeEach(() => { beforeEach(() => {
context.repository = new UnoptimizedInMemoryRepository(); context.repository = new UnoptimizedInMemoryRepository();
context.notificationService = new NotificationService(context.repository); context.notificationService = new ETANotificationScheduler(context.repository);
}); });
return context as ServerContext; return context as ServerContext;