diff --git a/src/test/server/service/RatingServiceStub.ts b/src/test/server/service/RatingServiceStub.ts
deleted file mode 100644
index 4d2f285..0000000
--- a/src/test/server/service/RatingServiceStub.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * Tests RatingService
- *
- * Copyright (C) 2010-2019 R-T Specialty, LLC.
- *
- * This file is part of the Liza Data Collection Framework.
- *
- * liza is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-
-'use strict'
-
-
-exports.getStubs = function()
-{
- const program_id = 'foo';
- const program = {
- getId: () => program_id,
- };
-
- // rate reply
- const stub_rate_data = {};
-
- const rater = {
- rate: ( quote, session, indv, callback ) => callback( stub_rate_data ),
- };
-
- const raters = {
- byId: () => rater,
- };
-
- const logger = {
- log: () => {},
- };
-
- const server = {
- sendResponse: () => {},
- sendError: () => {},
- };
-
- const dao = {
- mergeBucket: () => {},
- saveQuoteClasses: () => {},
- setWorksheets: () => {},
- saveQuote: () => {},
- };
-
- const session = {
- isInternal: () => false,
- };
-
- const request = {
- getSession: () => session,
- getSessionIdName: () => {},
- };
- const response = {};
-
- const quote = {
- getProgramId: () => program_id,
- getProgram: () => program,
- getId: () => 0,
- setLastPremiumDate: () => {},
- setRatedDate: () => {},
- getRatedDate: () => 0,
- getLastPremiumDate: () => 0
- };
-
- return {
- program: program,
- stub_rate_data: stub_rate_data,
- rater: rater,
- raters: raters,
- logger: logger,
- server: server,
- dao: dao,
- session: session,
- request: request,
- response: response,
- quote: quote,
- };
-};
diff --git a/test/server/service/RatingServiceTest.ts b/test/server/service/RatingServiceTest.ts
index 8330bea..dfee767 100644
--- a/test/server/service/RatingServiceTest.ts
+++ b/test/server/service/RatingServiceTest.ts
@@ -22,7 +22,19 @@
import { expect } from 'chai';
import { RatingService as Sut } from "../../../src/server/service/RatingService";
-const RatingServiceStub = require( '../../../' ).test.server.service.RatingServiceStub;
+import { ClientActions } from "../../../src/client/action/ClientAction";
+import { PriorityLog } from "../../../src/server/log/PriorityLog";
+import { ProcessManager } from "../../../src/server/rater/ProcessManager";
+import { Program } from "../../../src/program/Program";
+import { QuoteId } from "../../../src/quote/Quote";
+import { Rater, RateResult } from "../../../src/server/rater/Rater";
+import { Server } from "../../../src/server/Server";
+import { ServerDao } from "../../../src/server/db/ServerDao";
+import { ServerSideQuote } from "../../../src/server/quote/ServerSideQuote";
+import { UserRequest } from "../../../src/server/request/UserRequest";
+import { UserResponse } from "../../../src/server/request/UserResponse";
+import { UserSession } from "../../../src/server/request/UserSession";
+
describe( 'RatingService', () =>
{
@@ -40,12 +52,14 @@ describe( 'RatingService', () =>
request,
response,
quote,
- } = RatingServiceStub.getStubs();
+ } = getStubs();
dao.mergeBucket = () =>
{
expect( processed ).to.equal( true );
done();
+
+ return dao;
};
const sut = new class extends Sut
@@ -63,8 +77,8 @@ describe( 'RatingService', () =>
{
let getLastPremiumDateCallCount = 0;
- const last_date = 1234;
- const initial_date = 2345;
+ const last_date = 1234;
+ const initial_date = 2345;
const {
logger,
@@ -74,7 +88,7 @@ describe( 'RatingService', () =>
request,
response,
quote,
- } = RatingServiceStub.getStubs();
+ } = getStubs();
quote.getLastPremiumDate = () =>
{
@@ -93,6 +107,8 @@ describe( 'RatingService', () =>
expect( resp.lastRatedDate ).to.equal( last_date );
done();
+
+ return server;
};
sut.request( request, response, quote, "", () => {} );
@@ -100,3 +116,131 @@ describe( 'RatingService', () =>
} );
} );
+
+
+function getStubs()
+{
+ const program_id = 'foo';
+
+ const program = {
+ getId: () => program_id,
+ ineligibleLockCount: 0,
+ };
+
+ // rate reply
+ const stub_rate_data: RateResult = {
+ _unavailable_all: '0',
+ };
+
+ const rater = new class implements Rater
+ {
+ rate(
+ _quote: ServerSideQuote,
+ _session: UserSession,
+ _indv: string,
+ success: ( data: RateResult, actions: ClientActions ) => void,
+ )
+ {
+ success( stub_rate_data, [] );
+ return this;
+ }
+ };
+
+ const raters = {
+ byId: () => rater,
+ };
+
+ const logger = new class implements PriorityLog
+ {
+ readonly PRIORITY_ERROR: number = 0;
+ readonly PRIORITY_IMPORTANT: number = 1;
+ readonly PRIORITY_DB: number = 2;
+ readonly PRIORITY_INFO: number = 3;
+ readonly PRIORITY_SOCKET: number = 4;
+
+ log(): this
+ {
+ return this;
+ }
+ };
+
+ const server = {
+ sendResponse: () => server,
+ sendError: () => server,
+ };
+
+ const dao = new class implements ServerDao
+ {
+ saveQuote(): this
+ {
+ return this;
+ }
+
+ mergeBucket(): this
+ {
+ return this;
+ }
+
+ saveQuoteClasses(): this
+ {
+ return this;
+ }
+
+ setWorksheets(): this
+ {
+ return this;
+ }
+
+ saveQuoteState(): this
+ {
+ throw new Error( "Unused method" );
+ }
+
+ saveQuoteLockState(): this
+ {
+ throw new Error( "Unused method" );
+ }
+
+ getWorksheet(): this
+ {
+ throw new Error( "Unused method" );
+ }
+ };
+
+ const session = {
+ isInternal: () => false,
+ };
+
+ const request = {
+ getSession: () => session,
+ getSessionIdName: () => {},
+ };
+
+ const response = {};
+
+ const quote = {
+ getProgramId: () => program_id,
+ getProgram: () => program,
+ getId: () => 0,
+ setLastPremiumDate: () => quote,
+ setRatedDate: () => quote,
+ getRatedDate: () => 0,
+ getLastPremiumDate: () => 0,
+ getCurrentStepId: () => 0,
+ setExplicitLock: () => quote,
+ };
+
+ return {
+ program: program,
+ stub_rate_data: stub_rate_data,
+ rater: rater,
+ raters: raters,
+ logger: logger,
+ server: server,
+ dao: dao,
+ session: session,
+ request: request,
+ response: response,
+ quote: quote,
+ };
+};