diff --git a/lib/database/adapters/RunTypeAdapter.js b/lib/database/adapters/RunTypeAdapter.js index e519b3fb5d..431fb02534 100644 --- a/lib/database/adapters/RunTypeAdapter.js +++ b/lib/database/adapters/RunTypeAdapter.js @@ -29,12 +29,10 @@ class RunTypeAdapter { * @param {SequelizeRunType} databaseObject Object to convert. * @returns {RunType} Converted entity object. */ - toEntity({ id, name, createdAt, updatedAt }) { + toEntity({ id, name }) { return { id, name, - createdAt: new Date(createdAt).getTime(), - updatedAt: new Date(updatedAt).getTime(), }; } diff --git a/lib/domain/dtos/GetAllRunTypesDto.js b/lib/domain/dtos/GetAllRunTypesDto.js index 44b75de78b..46787bec49 100644 --- a/lib/domain/dtos/GetAllRunTypesDto.js +++ b/lib/domain/dtos/GetAllRunTypesDto.js @@ -13,10 +13,8 @@ */ const Joi = require('joi'); -const PaginationDto = require('./PaginationDto'); const QueryDto = Joi.object({ - page: PaginationDto, token: Joi.string(), }); diff --git a/lib/domain/entities/RunType.js b/lib/domain/entities/RunType.js index fc8f347afe..a5a6a34691 100644 --- a/lib/domain/entities/RunType.js +++ b/lib/domain/entities/RunType.js @@ -16,7 +16,5 @@ * * @property {number} id * @property {string} name - * @property {string} createdAt - * @property {string} updatedAt * @property {Run[]} runs */ diff --git a/lib/server/api-docs/API.md b/lib/server/api-docs/API.md index 3d61711ca7..6a9bccd0a2 100644 --- a/lib/server/api-docs/API.md +++ b/lib/server/api-docs/API.md @@ -287,3 +287,41 @@ Responses: ```bash curl -g "$BOOKKEEPING_URL/api/detectors?token=$TOKEN" ``` + +## Run types + +Types of runs (e.g. calibration kinds). + +### `GET /runTypes` - List run types + +Operation id: `listRunTypes` + +Returns the run types ordered by name, **descending**. Not paginated: there are few run types, and the result is capped to the maximum number of +items of the API (5000 by default). Pagination parameters are rejected. + +Responses: + +- `200`: The run types. +- `400`: The request failed validation. HTTP status is 400 although each error's `status` field is `"422"`. `source.pointer` has the form `/data/attributes//`. + +```bash +curl -g "$BOOKKEEPING_URL/api/runTypes?token=$TOKEN" +``` + +### `GET /runTypes/{runTypeId}` - Get a run type by id + +Operation id: `getRunType` + +| Parameter | In | Type | Required | Notes | +| --- | --- | --- | --- | --- | +| `runTypeId` | path | integer | yes | Run type identifier. | + +Responses: + +- `200`: The run type. +- `400`: The request failed validation. HTTP status is 400 although each error's `status` field is `"422"`. `source.pointer` has the form `/data/attributes//`. +- `404`: No run type has this id. + +```bash +curl -g "$BOOKKEEPING_URL/api/runTypes/1?token=$TOKEN" +``` diff --git a/lib/server/api-docs/index.html b/lib/server/api-docs/index.html index f1bdc02e32..591258d62b 100644 --- a/lib/server/api-docs/index.html +++ b/lib/server/api-docs/index.html @@ -488,6 +488,53 @@

Detectors

curl -g "$BOOKKEEPING_URL/api/detectors?token=$TOKEN"
 
+

Run types

+

Types of runs (e.g. calibration kinds).

+
+

GET /runTypes - List run types

+ +

Operation id: listRunTypes

+

Returns the run types ordered by name, descending. Not paginated: there are few run types, and the result is capped to the maximum number of +items of the API (5000 by default). Pagination parameters are rejected.

+

Responses:

+
    +
  • 200: The run types.
  • +
  • 400: The request failed validation. HTTP status is 400 although each error's status field is "422". source.pointer has the form /data/attributes/<query|params|body>/<field>.
  • +
+
curl -g "$BOOKKEEPING_URL/api/runTypes?token=$TOKEN"
+
+
+
+

GET /runTypes/{runTypeId} - Get a run type by id

+ +

Operation id: getRunType

+ + + + + + + + + + + + + + + + + +
ParameterInTypeRequiredNotes
runTypeIdpathintegeryesRun type identifier.
+

Responses:

+
    +
  • 200: The run type.
  • +
  • 400: The request failed validation. HTTP status is 400 although each error's status field is "422". source.pointer has the form /data/attributes/<query|params|body>/<field>.
  • +
  • 404: No run type has this id.
  • +
+
curl -g "$BOOKKEEPING_URL/api/runTypes/1?token=$TOKEN"
+
+
Generated from openapi.yaml by npm run docs:api · ALICE Bookkeeping · internal use only
diff --git a/lib/server/api-docs/openapi.yaml b/lib/server/api-docs/openapi.yaml index 58605ae0b4..700d80fd25 100644 --- a/lib/server/api-docs/openapi.yaml +++ b/lib/server/api-docs/openapi.yaml @@ -43,6 +43,8 @@ tags: description: Addresses of the external services Bookkeeping links to. - name: Detectors description: Detectors of the ALICE experiment. + - name: Run types + description: Types of runs (e.g. calibration kinds). paths: /tags: @@ -310,6 +312,53 @@ paths: - { id: 17, name: ACO, type: PHYSICAL } - { id: 21, name: GLO, type: QC } + /runTypes: + get: + tags: [Run types] + operationId: listRunTypes + summary: List run types + description: | + Returns the run types ordered by name, **descending**. Not paginated: there are few run types, and the result is capped to the maximum number of + items of the API (5000 by default). Pagination parameters are rejected. + responses: + '200': + description: The run types. + content: + application/json: + schema: { $ref: '#/components/schemas/RunTypeListResponse' } + example: + data: + - { id: 3, name: CALIBRATION_VCASN_TUNING } + - { id: 1, name: NONE } + '400': { $ref: '#/components/responses/ValidationError' } + + /runTypes/{runTypeId}: + get: + tags: [Run types] + operationId: getRunType + summary: Get a run type by id + parameters: + - name: runTypeId + in: path + required: true + description: Run type identifier. + schema: { type: integer, minimum: 1 } + responses: + '200': + description: The run type. + content: + application/json: + schema: { $ref: '#/components/schemas/RunTypeResponse' } + '400': { $ref: '#/components/responses/ValidationError' } + '404': + description: No run type has this id. + content: + application/json: + schema: { $ref: '#/components/schemas/ErrorResponse' } + example: + errors: + - { status: 404, title: Not found, detail: Run type with this id (999999999) could not be found } + components: securitySchemes: jwtQuery: @@ -326,6 +375,7 @@ components: description: Tag identifier. schema: { type: integer, minimum: 1 } + responses: ValidationError: description: | @@ -472,3 +522,21 @@ components: data: type: array items: { $ref: '#/components/schemas/Detector' } + RunType: + type: object + required: [id, name] + properties: + id: { type: integer } + name: { type: string, description: 'Run type name, e.g. `NONE` or `CALIBRATION_THR_SCAN`.' } + RunTypeResponse: + type: object + required: [data] + properties: + data: { $ref: '#/components/schemas/RunType' } + RunTypeListResponse: + type: object + required: [data] + properties: + data: + type: array + items: { $ref: '#/components/schemas/RunType' } diff --git a/lib/server/controllers/runTypes.controller.js b/lib/server/controllers/runTypes.controller.js index 8ea5bdd7c1..d563750e32 100644 --- a/lib/server/controllers/runTypes.controller.js +++ b/lib/server/controllers/runTypes.controller.js @@ -12,23 +12,13 @@ * or submit itself to any jurisdiction. */ -const { - runType: { - GetAllRunTypesUseCase, - GetRunTypeUseCase, - }, -} = require('../../usecases'); -const { - dtos: { - GetAllRunTypesDto, - GetRunTypeDto, - }, -} = require('../../domain'); +const { dtos: { GetAllRunTypesDto, GetRunTypeDto } } = require('../../domain'); const { dtoValidator } = require('../utilities'); -const { ApiConfig } = require('../../config/index.js'); +const { runTypeService } = require('../services/runType/RunTypeService.js'); +const { updateExpressResponseFromNativeError } = require('../express/updateExpressResponseFromNativeError.js'); /** - * Get all runs. + * Get all run types. * * @param {Object} request The *request* object represents the HTTP request and has properties for the request query * string, parameters, body, HTTP headers, and so on. @@ -42,25 +32,15 @@ const listRunTypes = async (request, response) => { return; } - const { count, runTypes } = await new GetAllRunTypesUseCase() - .execute(value); - - const { query: { page: { limit = ApiConfig.pagination.limit } = {} } } = value; - const totalPages = Math.ceil(count / limit); - - response.status(200).json({ - data: runTypes, - meta: { - page: { - pageCount: totalPages, - totalCount: count, - }, - }, - }); + try { + response.status(200).json({ data: await runTypeService.getAll() }); + } catch (error) { + updateExpressResponseFromNativeError(response, error); + } }; /** - * Get run. + * Get a run type. * * @param {Object} request The *request* object represents the HTTP request and has properties for the request query * string, parameters, body, HTTP headers, and so on. @@ -74,22 +54,10 @@ const getRunTypeById = async (request, response) => { return; } - const runType = await new GetRunTypeUseCase() - .execute(value); - - if (runType === null) { - response.status(404).json({ - errors: [ - { - status: '404', - title: `Run with this id (${value.params.runTypeId}) could not be found`, - }, - ], - }); - } else { - response.status(200).json({ - data: runType, - }); + try { + response.status(200).json({ data: await runTypeService.getOneOrFail({ id: value.params.runTypeId }) }); + } catch (error) { + updateExpressResponseFromNativeError(response, error); } }; diff --git a/lib/server/services/runType/RunTypeService.js b/lib/server/services/runType/RunTypeService.js new file mode 100644 index 0000000000..ae0fd92501 --- /dev/null +++ b/lib/server/services/runType/RunTypeService.js @@ -0,0 +1,50 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +const { runTypeAdapter } = require('../../../database/adapters/index.js'); +const { ApiConfig } = require('../../../config/index.js'); +const { getAllRunTypes } = require('./getAllRunTypes.js'); +const { getRunTypeOrFail } = require('./getRunTypeOrFail.js'); + +/** + * Global service to read run types + */ +class RunTypeService { + /** + * Return the run types sorted by name (descending) + * + * Run types are not paginated, but the result is capped to the maximum number of items of the API as run types can be created automatically + * + * @return {Promise} the run types + */ + async getAll() { + return (await getAllRunTypes((queryBuilder) => { + queryBuilder.orderBy('name', 'desc'); + queryBuilder.limit(ApiConfig.pagination.limit); + })).map(runTypeAdapter.toEntity); + } + + /** + * Return the run type matching the given identifier, or reject if there is none + * + * @param {RunTypeIdentifier} identifier the identifier of the run type to find + * @return {Promise} resolves with the run type found or rejects with a NotFoundError + */ + async getOneOrFail(identifier) { + return runTypeAdapter.toEntity(await getRunTypeOrFail(identifier)); + } +} + +exports.RunTypeService = RunTypeService; + +exports.runTypeService = new RunTypeService(); diff --git a/lib/server/services/runType/getAllRunTypes.js b/lib/server/services/runType/getAllRunTypes.js new file mode 100644 index 0000000000..355db7a9bd --- /dev/null +++ b/lib/server/services/runType/getAllRunTypes.js @@ -0,0 +1,30 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +const { utilities: { QueryBuilder } } = require('../../../database'); +const RunTypeRepository = require('../../../database/repositories/RunTypeRepository.js'); + +/** + * Return the list of all the run types + * + * @param {Function|null} qbConfiguration function called with the run types query builder as parameter to add specific configuration to the + * query + * @return {Promise} Promise resolving with the list of run types + */ +exports.getAllRunTypes = (qbConfiguration = null) => { + const queryBuilder = new QueryBuilder(); + if (qbConfiguration) { + qbConfiguration(queryBuilder); + } + return RunTypeRepository.findAll(queryBuilder); +}; diff --git a/lib/usecases/index.js b/lib/usecases/index.js index 2dfa7807e5..4c1009a9db 100644 --- a/lib/usecases/index.js +++ b/lib/usecases/index.js @@ -17,7 +17,6 @@ const flp = require('./flp'); const lhcFill = require('./lhcFill'); const log = require('./log'); const run = require('./run'); -const runType = require('./runType'); const server = require('./server'); const status = require('./status'); const tag = require('./tag'); @@ -29,7 +28,6 @@ module.exports = { lhcFill, log, run, - runType, server, status, tag, diff --git a/lib/usecases/runType/GetAllRunTypesUseCase.js b/lib/usecases/runType/GetAllRunTypesUseCase.js deleted file mode 100644 index d769a87d97..0000000000 --- a/lib/usecases/runType/GetAllRunTypesUseCase.js +++ /dev/null @@ -1,56 +0,0 @@ -/** - * @license - * Copyright 2019-2020 CERN and copyright holders of ALICE O2. - * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. - * All rights not expressly granted are reserved. - * - * This software is distributed under the terms of the GNU General Public - * License v3 (GPL Version 3), copied verbatim in the file "COPYING". - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -const { - repositories: { - RunTypeRepository, - }, - utilities: { - QueryBuilder, - TransactionHelper, - }, -} = require('../../database'); -const { ApiConfig } = require('../../config/index.js'); -const { runTypeAdapter } = require('../../database/adapters/index.js'); - -/** - * GetAllRunTypesUseCase - */ -class GetAllRunTypesUseCase { - /** - * Executes this use case. - * - * @param {Object} dto The GetAllLogs DTO which contains all request data. - * @returns {Promise} Promise object represents the result of this use case. - */ - async execute(dto = {}) { - const { query = {} } = dto; - const { page = {} } = query; - const { limit = ApiConfig.pagination.limit, offset = 0 } = page; - - const { count, rows } = await TransactionHelper.provide(async ()=> { - const queryBuilder = new QueryBuilder(); - queryBuilder.orderBy('name', 'desc'); - queryBuilder.limit(limit); - queryBuilder.offset(offset); - return RunTypeRepository.findAndCountAll(queryBuilder); - }); - return { - count, - runTypes: rows.map(runTypeAdapter.toEntity), - }; - } -} - -module.exports = GetAllRunTypesUseCase; diff --git a/lib/usecases/runType/GetRunTypeUseCase.js b/lib/usecases/runType/GetRunTypeUseCase.js deleted file mode 100644 index 01ccd84f98..0000000000 --- a/lib/usecases/runType/GetRunTypeUseCase.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -const { - repositories: { - RunTypeRepository, - }, - utilities: { - QueryBuilder, - TransactionHelper, - }, -} = require('../../database'); -const { runTypeAdapter } = require('../../database/adapters/index.js'); - -/** - * GetRunTypeUseCase - */ -class GetRunTypeUseCase { - /** - * Executes this use case. - * - * @param {Object} dto The GetRunTypeDto containing all data. - * @returns {Promise} Promise object represents the result of this use case. - */ - async execute(dto) { - const { params } = dto; - const { runTypeId, name } = params; - - /* - * Check if there is being searched on id or name - * Build query builder - */ - const queryBuilder = new QueryBuilder(); - name ? - queryBuilder.where('name').is(name) - : queryBuilder.where('id').is(runTypeId); - // Get run type and return return the entity - const runType = await TransactionHelper.provide(() => RunTypeRepository.findOne(queryBuilder)); - return runType ? runTypeAdapter.toEntity(runType) : null; - } -} - -module.exports = GetRunTypeUseCase; diff --git a/lib/usecases/runType/index.js b/lib/usecases/runType/index.js deleted file mode 100644 index 2220f5278c..0000000000 --- a/lib/usecases/runType/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright 2019-2020 CERN and copyright holders of ALICE O2. - * See http://alice-o2.web.cern.ch/copyright for details of the copyright holders. - * All rights not expressly granted are reserved. - * - * This software is distributed under the terms of the GNU General Public - * License v3 (GPL Version 3), copied verbatim in the file "COPYING". - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ -const GetRunTypeUseCase = require('./GetRunTypeUseCase'); -const GetAllRunTypesUseCase = require('./GetAllRunTypesUseCase'); - -module.exports = { - GetRunTypeUseCase, - GetAllRunTypesUseCase, -}; diff --git a/test/api/runTypes.test.js b/test/api/runTypes.test.js index 327ac69478..6ea6c12a7a 100644 --- a/test/api/runTypes.test.js +++ b/test/api/runTypes.test.js @@ -31,13 +31,14 @@ module.exports = () => { } expect(res.body.data).to.be.an('array'); + res.body.data.forEach((runType) => expect(Object.keys(runType)).to.have.members(['id', 'name'])); done(); }); }); - it('should support pagination, offset 0 and limit 1', (done) => { + it('should return all the run types without pagination information', (done) => { request(server) - .get('/api/runTypes?page[offset]=0&page[limit]=1') + .get('/api/runTypes') .expect(200) .end((err, res) => { if (err) { @@ -45,10 +46,17 @@ module.exports = () => { return; } - expect(res.body.data).to.have.lengthOf(1); + expect(res.body.data.length).to.be.greaterThan(2); + expect(res.body.meta).to.be.undefined; done(); }); }); + it('should return 400 if a pagination parameter is given', (done) => { + request(server) + .get('/api/runTypes?page[limit]=1') + .expect(400) + .end(done); + }); }); describe('GET /api/runTypes/:runTypeId', () => { it('should return 200 in all other cases', (done) => { @@ -62,6 +70,25 @@ module.exports = () => { } expect(res.body.data.id).to.equal(1); + expect(Object.keys(res.body.data)).to.have.members(['id', 'name']); + + done(); + }); + }); + + it('should return 404 if the run type does not exist', (done) => { + request(server) + .get('/api/runTypes/999999') + .expect(404) + .end((err, res) => { + if (err) { + done(err); + return; + } + + expect(res.body.errors).to.eql([ + { status: 404, title: 'Not found', detail: 'Run type with this id (999999) could not be found' }, + ]); done(); }); diff --git a/test/lib/server/services/runType/RunTypeService.test.js b/test/lib/server/services/runType/RunTypeService.test.js new file mode 100644 index 0000000000..36651d5e10 --- /dev/null +++ b/test/lib/server/services/runType/RunTypeService.test.js @@ -0,0 +1,41 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +const { runTypeService } = require('../../../../../lib/server/services/runType/RunTypeService.js'); +const { NotFoundError } = require('../../../../../lib/server/errors/NotFoundError.js'); +const { expect } = require('chai'); + +module.exports = () => { + it('should successfully return all the run types sorted by name (descending) with only their id and name', async () => { + const runTypes = await runTypeService.getAll(); + + expect(runTypes.length).to.be.greaterThan(2); + runTypes.forEach((runType) => expect(Object.keys(runType)).to.have.members(['id', 'name'])); + const names = runTypes.map(({ name }) => name); + expect(names).to.eql([...names].sort().reverse()); + }); + + it('should successfully return a run type by id', async () => { + expect(await runTypeService.getOneOrFail({ id: 1 })).to.eql({ id: 1, name: 'NONE' }); + }); + + it('should successfully return a run type by name', async () => { + expect(await runTypeService.getOneOrFail({ name: 'NONE' })).to.eql({ id: 1, name: 'NONE' }); + }); + + it('should fail with a not found error when the run type does not exist', async () => { + const error = await runTypeService.getOneOrFail({ id: 999999 }).catch((error) => error); + expect(error).to.be.instanceOf(NotFoundError); + expect(error.message).to.equal('Run type with this id (999999) could not be found'); + }); +}; diff --git a/test/lib/server/services/runType/getAllRunTypes.test.js b/test/lib/server/services/runType/getAllRunTypes.test.js new file mode 100644 index 0000000000..ac8a7f5e9c --- /dev/null +++ b/test/lib/server/services/runType/getAllRunTypes.test.js @@ -0,0 +1,31 @@ +/** + * @license + * Copyright CERN and copyright holders of ALICE O2. This software is + * distributed under the terms of the GNU General Public License v3 (GPL + * Version 3), copied verbatim in the file "COPYING". + * + * See http://alice-o2.web.cern.ch/license for full licensing information. + * + * In applying this license CERN does not waive the privileges and immunities + * granted to it by virtue of its status as an Intergovernmental Organization + * or submit itself to any jurisdiction. + */ + +const { getAllRunTypes } = require('../../../../../lib/server/services/runType/getAllRunTypes.js'); +const { expect } = require('chai'); + +module.exports = () => { + it('should successfully return all the run types', async () => { + const runTypes = await getAllRunTypes(); + expect(runTypes.length).to.be.greaterThan(2); + expect(runTypes.map(({ name }) => name)).to.include('NONE'); + }); + + it('should apply the given query builder configuration', async () => { + const ascendingIds = (await getAllRunTypes((queryBuilder) => queryBuilder.orderBy('name', 'asc'))).map(({ id }) => id); + const descendingIds = (await getAllRunTypes((queryBuilder) => queryBuilder.orderBy('name', 'desc'))).map(({ id }) => id); + expect(ascendingIds).to.eql([...descendingIds].reverse()); + + expect(await getAllRunTypes((queryBuilder) => queryBuilder.limit(1))).to.lengthOf(1); + }); +}; diff --git a/test/lib/server/services/runType/index.js b/test/lib/server/services/runType/index.js index e1a9ddd312..4bbc5c1d81 100644 --- a/test/lib/server/services/runType/index.js +++ b/test/lib/server/services/runType/index.js @@ -14,9 +14,13 @@ const getRunTypeTest = require('./getRunType.test.js'); const createRunTypeTest = require('./createRunType.test.js'); const getOrCreateRunTypeTest = require('./getOrCreateRunType.test.js'); +const getAllRunTypesTest = require('./getAllRunTypes.test.js'); +const RunTypeServiceTest = require('./RunTypeService.test.js'); module.exports = () => { describe('getRunType', getRunTypeTest); describe('createRunType', createRunTypeTest); describe('getOrCreateRunType', getOrCreateRunTypeTest); + describe('getAllRunTypes', getAllRunTypesTest); + describe('RunTypeService', RunTypeServiceTest); }; diff --git a/test/lib/usecases/index.js b/test/lib/usecases/index.js index b5fc953604..bab1e09d0a 100644 --- a/test/lib/usecases/index.js +++ b/test/lib/usecases/index.js @@ -16,7 +16,6 @@ const StatusSuite = require('./status/index.js'); const LhcFillSuite = require('./lhcFill/index.js'); const LogSuite = require('./log/index.js'); const RunSuite = require('./run/index.js'); -const RunTypeSuite = require('./runType/index.js'); const FlpSuite = require('./flp/index.js'); const ServerSuite = require('./server/index.js'); const TagSuite = require('./tag/index.js'); @@ -28,7 +27,6 @@ module.exports = () => { describe('Log use-case', LogSuite); describe('LhcFill use-case', LhcFillSuite); describe('Run use-case', RunSuite); - describe('RunType use-case', RunTypeSuite); describe('Flp use-case', FlpSuite); describe('Server use-case', ServerSuite); describe('Tag use-case', TagSuite); diff --git a/test/lib/usecases/runType/getAllRunTypesUseCase.test.js b/test/lib/usecases/runType/getAllRunTypesUseCase.test.js deleted file mode 100644 index ffa36c2818..0000000000 --- a/test/lib/usecases/runType/getAllRunTypesUseCase.test.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -const { runType: { GetAllRunTypesUseCase } } = require('../../../../lib/usecases'); -const chai = require('chai'); - -const { expect } = chai; - -module.exports = () => { - it('should return an array', async () => { - const { runTypes } = await new GetAllRunTypesUseCase().execute(); - - expect(runTypes).to.be.an('array'); - expect(runTypes.length).to.be.greaterThan(2); - }); -}; diff --git a/test/lib/usecases/runType/getRunTypeUseCase.test.js b/test/lib/usecases/runType/getRunTypeUseCase.test.js deleted file mode 100644 index 3b20efbf33..0000000000 --- a/test/lib/usecases/runType/getRunTypeUseCase.test.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ -const { runType: { GetRunTypeUseCase } } = require('../../../../lib/usecases/index.js'); -const { dtos: { GetRunTypeDto } } = require('../../../../lib/domain/index.js'); -const chai = require('chai'); - -const { expect } = chai; - -module.exports = () => { - let getRunTypeDto; - - beforeEach(async () => { - getRunTypeDto = await GetRunTypeDto.validateAsync({ - params: { - runTypeId: 1, - }, - }); - }); - - it('should return an object that has the `id` property', async () => { - const result = await new GetRunTypeUseCase() - .execute(getRunTypeDto); - - expect(result.id).to.equal(1); - expect(result.name).to.equal('NONE'); - }); -}; diff --git a/test/lib/usecases/runType/index.js b/test/lib/usecases/runType/index.js deleted file mode 100644 index f7c3a8ef52..0000000000 --- a/test/lib/usecases/runType/index.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * @license - * Copyright CERN and copyright holders of ALICE O2. This software is - * distributed under the terms of the GNU General Public License v3 (GPL - * Version 3), copied verbatim in the file "COPYING". - * - * See http://alice-o2.web.cern.ch/license for full licensing information. - * - * In applying this license CERN does not waive the privileges and immunities - * granted to it by virtue of its status as an Intergovernmental Organization - * or submit itself to any jurisdiction. - */ - -const GetRunTypeUseCase = require('./getRunTypeUseCase.test'); -const GetAllRunTypesUseCase = require('./getAllRunTypesUseCase.test'); - -module.exports = () => { - describe('GetRunTypeUseCase', GetRunTypeUseCase); - describe('GetAllRunTypesUseCase', GetAllRunTypesUseCase); -};