diff --git a/app/controllers/test/supplementary.controller.js b/app/controllers/check/supplementary.controller.js similarity index 55% rename from app/controllers/test/supplementary.controller.js rename to app/controllers/check/supplementary.controller.js index 09757cd84b..9799a05bb2 100644 --- a/app/controllers/test/supplementary.controller.js +++ b/app/controllers/check/supplementary.controller.js @@ -5,10 +5,10 @@ * @module SupplementaryController */ -const SupplementaryService = require('../../services/supplementary-billing/supplementary.service.js') +const SupplementaryDataService = require('../../services/check/supplementary-data.service.js') async function index (request, h) { - const result = await SupplementaryService.go(request.query.region) + const result = await SupplementaryDataService.go(request.query.region) return h.response(result).code(200) } diff --git a/app/plugins/router.plugin.js b/app/plugins/router.plugin.js index aa68b146b6..fe0929b4d3 100644 --- a/app/plugins/router.plugin.js +++ b/app/plugins/router.plugin.js @@ -13,10 +13,10 @@ const AssetRoutes = require('../routes/assets.routes.js') const BillRunRoutes = require('../routes/bill-runs.routes') +const CheckRoutes = require('../routes/check.routes.js') const FilterRoutesService = require('../services/plugins/filter-routes.service.js') const HealthRoutes = require('../routes/health.routes.js') const RootRoutes = require('../routes/root.routes.js') -const TestRoutes = require('../routes/test.routes.js') const AirbrakeConfig = require('../../config/airbrake.config.js') @@ -24,7 +24,7 @@ const routes = [ ...RootRoutes, ...AssetRoutes, ...HealthRoutes, - ...TestRoutes, + ...CheckRoutes, ...BillRunRoutes ] diff --git a/app/presenters/supplementary.presenter.js b/app/presenters/check/supplementary-data.presenter.js similarity index 87% rename from app/presenters/supplementary.presenter.js rename to app/presenters/check/supplementary-data.presenter.js index 1c6d45bc06..7cb443a968 100644 --- a/app/presenters/supplementary.presenter.js +++ b/app/presenters/check/supplementary-data.presenter.js @@ -1,8 +1,8 @@ 'use strict' /** - * Formats responses from the `SupplementaryService` - * @module SupplementaryPresenter + * Formats responses from the `SupplementaryDataService` + * @module SupplementaryDataPresenter */ function go (data) { diff --git a/app/routes/check.routes.js b/app/routes/check.routes.js new file mode 100644 index 0000000000..8114d6205d --- /dev/null +++ b/app/routes/check.routes.js @@ -0,0 +1,16 @@ +'use strict' + +const SupplementaryController = require('../controllers/check/supplementary.controller.js') + +const routes = [ + { + method: 'GET', + path: '/check/supplementary', + handler: SupplementaryController.index, + options: { + description: 'Used by the delivery team to check the SROC supplementary billing logic' + } + } +] + +module.exports = routes diff --git a/app/routes/test.routes.js b/app/routes/test.routes.js deleted file mode 100644 index 931e8dfdee..0000000000 --- a/app/routes/test.routes.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict' - -const SupplementaryController = require('../controllers/test/supplementary.controller.js') - -const routes = [ - { - method: 'GET', - path: '/test/supplementary', - handler: SupplementaryController.index, - options: { - description: 'Test endpoint which returns all selected charge versions' - } - } -] - -module.exports = routes diff --git a/app/services/supplementary-billing/supplementary.service.js b/app/services/check/supplementary-data.service.js similarity index 53% rename from app/services/supplementary-billing/supplementary.service.js rename to app/services/check/supplementary-data.service.js index 5208fda9f4..ef3ceadada 100644 --- a/app/services/supplementary-billing/supplementary.service.js +++ b/app/services/check/supplementary-data.service.js @@ -1,18 +1,15 @@ 'use strict' /** - * Determines the billing periods, licences and charge versions used to generate an SROC supplementary bill run - * - * WIP: This is currently being used to generate testing data to confirm we are understanding SROC supplementary - * billing. We intend to refactor things so that the service starts representing what is actually required. - * @module SupplementaryService + * Confirms the billing periods, licences and charge versions used to generate an SROC supplementary bill run + * @module SupplementaryDataService */ -const BillingPeriodService = require('./billing-period.service.js') -const FetchChargeVersionsService = require('./fetch-charge-versions.service.js') -const FetchLicencesService = require('./fetch-licences.service.js') -const FetchRegionService = require('./fetch-region.service.js') -const SupplementaryPresenter = require('../../presenters/supplementary.presenter.js') +const BillingPeriodService = require('../supplementary-billing/billing-period.service.js') +const FetchChargeVersionsService = require('../supplementary-billing/fetch-charge-versions.service.js') +const FetchLicencesService = require('../supplementary-billing/fetch-licences.service.js') +const FetchRegionService = require('../supplementary-billing/fetch-region.service.js') +const SupplementaryDataPresenter = require('../../presenters/check/supplementary-data.presenter.js') async function go (naldRegionId) { const region = await FetchRegionService.go(naldRegionId) @@ -29,7 +26,7 @@ async function go (naldRegionId) { } function _response (data) { - return SupplementaryPresenter.go(data) + return SupplementaryDataPresenter.go(data) } module.exports = { diff --git a/test/controllers/test/supplementary.controller.test.js b/test/controllers/check/supplementary.controller.test.js similarity index 73% rename from test/controllers/test/supplementary.controller.test.js rename to test/controllers/check/supplementary.controller.test.js index 2f0f88918a..15a63a0bc7 100644 --- a/test/controllers/test/supplementary.controller.test.js +++ b/test/controllers/check/supplementary.controller.test.js @@ -9,7 +9,7 @@ const { describe, it, beforeEach, after } = exports.lab = Lab.script() const { expect } = Code // Things we need to stub -const SupplementaryService = require('../../../app/services/supplementary-billing/supplementary.service.js') +const SupplementaryDataService = require('../../../app/services/check/supplementary-data.service.js') // For running our service const { init } = require('../../../app/server.js') @@ -25,16 +25,16 @@ describe('Supplementary controller', () => { Sinon.restore() }) - describe('GET /test/supplementary', () => { + describe('GET /check/supplementary', () => { const options = { method: 'GET', - url: '/test/supplementary?region=9' + url: '/check/supplementary?region=9' } let response beforeEach(async () => { - Sinon.stub(SupplementaryService, 'go').resolves({ billingPeriods: [], licences: [], chargeVersions: [] }) + Sinon.stub(SupplementaryDataService, 'go').resolves({ billingPeriods: [], licences: [], chargeVersions: [] }) response = await server.inject(options) }) diff --git a/test/presenters/supplementary.presenter.test.js b/test/presenters/check/supplementary-data.presenter.test.js similarity index 90% rename from test/presenters/supplementary.presenter.test.js rename to test/presenters/check/supplementary-data.presenter.test.js index 80847d2e9d..a61d1c4f32 100644 --- a/test/presenters/supplementary.presenter.test.js +++ b/test/presenters/check/supplementary-data.presenter.test.js @@ -8,7 +8,7 @@ const { describe, it, beforeEach } = exports.lab = Lab.script() const { expect } = Code // Thing under test -const SupplementaryPresenter = require('../../app/presenters/supplementary.presenter.js') +const SupplementaryDataPresenter = require('../../../app/presenters/check/supplementary-data.presenter.js') describe('Supplementary presenter', () => { let data @@ -44,7 +44,7 @@ describe('Supplementary presenter', () => { }) it('correctly presents the data', () => { - const result = SupplementaryPresenter.go(data) + const result = SupplementaryDataPresenter.go(data) expect(result.billingPeriods).to.have.length(1) expect(result.billingPeriods[0]).to.equal(data.billingPeriods[0]) @@ -70,7 +70,7 @@ describe('Supplementary presenter', () => { }) it('correctly presents the data', () => { - const result = SupplementaryPresenter.go(data) + const result = SupplementaryDataPresenter.go(data) expect(result.billingPeriods).to.be.empty() expect(result.licences).to.be.empty() diff --git a/test/services/supplementary-billing/supplementary.service.test.js b/test/services/check/supplementary-data.service.test.js similarity index 89% rename from test/services/supplementary-billing/supplementary.service.test.js rename to test/services/check/supplementary-data.service.test.js index 70d95ed791..7190c3b905 100644 --- a/test/services/supplementary-billing/supplementary.service.test.js +++ b/test/services/check/supplementary-data.service.test.js @@ -15,7 +15,7 @@ const FetchLicencesService = require('../../../app/services/supplementary-billin const FetchRegionService = require('../../../app/services/supplementary-billing/fetch-region.service.js') // Thing under test -const SupplementaryService = require('../../../app/services/supplementary-billing/supplementary.service.js') +const SupplementaryDataService = require('../../../app/services/check/supplementary-data.service.js') describe('Supplementary service', () => { const naldRegionId = 9 @@ -40,7 +40,7 @@ describe('Supplementary service', () => { }) it('always includes the current billing period', async () => { - const result = await SupplementaryService.go(naldRegionId) + const result = await SupplementaryDataService.go(naldRegionId) expect(result.billingPeriods.length).to.equal(1) expect(result.billingPeriods[0]).to.equal(currentBillingPeriod) @@ -63,7 +63,7 @@ describe('Supplementary service', () => { }) it('returns the matching licences', async () => { - const result = await SupplementaryService.go(naldRegionId) + const result = await SupplementaryDataService.go(naldRegionId) expect(result.licences.length).to.equal(1) expect(result.licences[0].licenceId).to.equal(testRecords[0].licenceId) @@ -76,7 +76,7 @@ describe('Supplementary service', () => { }) it('returns no results', async () => { - const result = await SupplementaryService.go(naldRegionId) + const result = await SupplementaryDataService.go(naldRegionId) expect(result.licences).to.be.empty() }) @@ -102,7 +102,7 @@ describe('Supplementary service', () => { }) it('returns the matching charge versions', async () => { - const result = await SupplementaryService.go(naldRegionId) + const result = await SupplementaryDataService.go(naldRegionId) expect(result.chargeVersions.length).to.equal(1) expect(result.chargeVersions[0].chargeVersionId).to.equal(testRecords[0].chargeVersionId) @@ -115,7 +115,7 @@ describe('Supplementary service', () => { }) it('returns no results', async () => { - const result = await SupplementaryService.go(naldRegionId) + const result = await SupplementaryDataService.go(naldRegionId) expect(result.chargeVersions).to.be.empty() })