From b3e7a37343beff12655392d38b17ae095306ddc0 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Tue, 14 Jan 2025 14:03:01 -0800 Subject: [PATCH] address pr comments, add back in lost code for product rows and for persistence update error return --- src/persistence/MCWSPersistenceProvider.js | 2 +- .../test/MCWSNamespaceModelProviderSpec.js | 2 +- .../test/MCWSNamespaceServiceSpec.js | 2 +- .../test/MCWSPersistenceProviderSpec.js | 2 +- src/product-status/DataProductRowSpec.js | 376 +++++++++--------- 5 files changed, 188 insertions(+), 196 deletions(-) diff --git a/src/persistence/MCWSPersistenceProvider.js b/src/persistence/MCWSPersistenceProvider.js index 7c3835e..c7207ad 100644 --- a/src/persistence/MCWSPersistenceProvider.js +++ b/src/persistence/MCWSPersistenceProvider.js @@ -78,7 +78,7 @@ export default class MCWSPersistenceProvider extends BaseMCWSPersistenceProvider } catch (error) { console.warn('MCWSPersistneceProvider:update', error); - return; + return false; } } diff --git a/src/persistence/test/MCWSNamespaceModelProviderSpec.js b/src/persistence/test/MCWSNamespaceModelProviderSpec.js index 761bcdd..ff29857 100644 --- a/src/persistence/test/MCWSNamespaceModelProviderSpec.js +++ b/src/persistence/test/MCWSNamespaceModelProviderSpec.js @@ -1,7 +1,7 @@ import MCWSUserContainerProvider from '../MCWSUserContainerProvider'; import MCWSPersistenceProvider from '../MCWSPersistenceProvider'; -import mcws from '../../services/mcws/mcws'; +import mcws from 'services/mcws/mcws'; describe('MCWS Providers', () => { let openmct; diff --git a/src/persistence/test/MCWSNamespaceServiceSpec.js b/src/persistence/test/MCWSNamespaceServiceSpec.js index c2dad3c..70aa872 100644 --- a/src/persistence/test/MCWSNamespaceServiceSpec.js +++ b/src/persistence/test/MCWSNamespaceServiceSpec.js @@ -1,6 +1,6 @@ import MCWSPersistenceProvider from '../MCWSPersistenceProvider'; import MCWSUserContainerProvider from '../MCWSUserContainerProvider'; -import mcws from '../../services/mcws/mcws'; +import mcws from 'services/mcws/mcws'; describe('MCWSNamespaceService', () => { let namespaceMIOs; diff --git a/src/persistence/test/MCWSPersistenceProviderSpec.js b/src/persistence/test/MCWSPersistenceProviderSpec.js index bb88e84..5a9132e 100644 --- a/src/persistence/test/MCWSPersistenceProviderSpec.js +++ b/src/persistence/test/MCWSPersistenceProviderSpec.js @@ -1,5 +1,5 @@ import MCWSPersistenceProvider from '../MCWSPersistenceProvider'; -import mcws from '../../services/mcws/mcws'; +import mcws from 'services/mcws/mcws'; describe('The MCWS Persistence Provider', () => { let mockNamespaceService; diff --git a/src/product-status/DataProductRowSpec.js b/src/product-status/DataProductRowSpec.js index 42bfbc0..97f1e11 100644 --- a/src/product-status/DataProductRowSpec.js +++ b/src/product-status/DataProductRowSpec.js @@ -1,206 +1,198 @@ -/*global define,describe,beforeEach,it,expect*/ +import DataProductRow from './DataProductRow'; -define([ - './DataProductRow' -], function ( - DataProductRow -) { - 'use strict'; +describe('The Data Product Row', () => { + let dataProductRow; + let columns; + let objectKeyString; + let limitEvaluator; + let rowId; + let startMessage; + let partReceivedMessage; + let completeMessage; - describe('The Data Product Row', function () { - let dataProductRow; - let columns; - let objectKeyString; - let limitEvaluator; - let rowId; - let startMessage; - let partReceivedMessage; - let completeMessage; - - beforeEach(function () { - columns = []; - objectKeyString = 'test-object'; - limitEvaluator = { - evaluate: function () {return {}} - }; - rowId = 'test-row-id'; - startMessage = { - "transaction_id":"McamRThumbnail\/McamRThumbnail_0457586851-19880", - "session_host":"host", - "apid":"424", - "total_parts":"0", - "session_id":"36", - "record_type":"product_started", - "part_number":"0", - "event_time":"2019-259T17:06:54.691", - "vcid":"32" - }; - partReceivedMessage = { - "creation_time":"", - "transaction_id":"McamRThumbnail\/McamRThumbnail_0457586851-19880", - "dvt_coarse":"457586851", - "ground_status":"UNKNOWN", - "session_host":"host", - "ert":"2019-259T17:06:54.590", - "dvt_fine":"19880", - "apid":"424", - "total_parts":"0", - "session_id":"36", - "scet":"2014-183T15:39:04.687010296", - "lst":"", - "version":"", - "file_size":"0", - "record_type":"product_part_received", - "command_number":"0", - "unique_name":"products\/McamRThumbnail\/McamRThumbnail_0457586851-19880", - "seq_version":"0", - "checksum":"0", - "part_number":"0", - "sclk":"0457586851.30334", - "seq_id":"0", - "event_time":"2019-259T17:06:54.691", - "vcid":"32" - }; - completeMessage = { - "creation_time":"2019-259T17:06:57.800", - "transaction_id":"McamRThumbnail\/McamRThumbnail_0457586851-19880", - "dvt_coarse":"457586851", - "ground_status":"COMPLETE_CHECKSUM_PASS", - "session_host":"host", - "ert":"2019-259T17:06:54.590", - "dvt_fine":"19880", - "apid":"424", - "total_parts":"20", - "session_id":"36", - "scet":"2014-183T15:39:04.687010296", - "lst":"", - "version":"", - "file_size":"192819", - "record_type":"complete_product", - "command_number":"2", - "unique_name":"complete_product_unique_name", - "seq_version":"0", - "checksum":"33862", - "sclk":"0457586851.30334", - "seq_id":"0", - "event_time":"2019-259T17:06:54.691", - "vcid":"32" - } - }); + beforeEach(() => { + columns = []; + objectKeyString = 'test-object'; + limitEvaluator = { + evaluate: () => ({}) + }; + rowId = 'test-row-id'; + startMessage = { + "transaction_id":"McamRThumbnail\/McamRThumbnail_0457586851-19880", + "session_host":"host", + "apid":"424", + "total_parts":"0", + "session_id":"36", + "record_type":"product_started", + "part_number":"0", + "event_time":"2019-259T17:06:54.691", + "vcid":"32" + }; + partReceivedMessage = { + "creation_time":"", + "transaction_id":"McamRThumbnail\/McamRThumbnail_0457586851-19880", + "dvt_coarse":"457586851", + "ground_status":"UNKNOWN", + "session_host":"host", + "ert":"2019-259T17:06:54.590", + "dvt_fine":"19880", + "apid":"424", + "total_parts":"0", + "session_id":"36", + "scet":"2014-183T15:39:04.687010296", + "lst":"", + "version":"", + "file_size":"0", + "record_type":"product_part_received", + "command_number":"0", + "unique_name":"products\/McamRThumbnail\/McamRThumbnail_0457586851-19880", + "seq_version":"0", + "checksum":"0", + "part_number":"0", + "sclk":"0457586851.30334", + "seq_id":"0", + "event_time":"2019-259T17:06:54.691", + "vcid":"32" + }; + completeMessage = { + "creation_time":"2019-259T17:06:57.800", + "transaction_id":"McamRThumbnail\/McamRThumbnail_0457586851-19880", + "dvt_coarse":"457586851", + "ground_status":"COMPLETE_CHECKSUM_PASS", + "session_host":"host", + "ert":"2019-259T17:06:54.590", + "dvt_fine":"19880", + "apid":"424", + "total_parts":"20", + "session_id":"36", + "scet":"2014-183T15:39:04.687010296", + "lst":"", + "version":"", + "file_size":"192819", + "record_type":"complete_product", + "command_number":"2", + "unique_name":"complete_product_unique_name", + "seq_version":"0", + "checksum":"33862", + "sclk":"0457586851.30334", + "seq_id":"0", + "event_time":"2019-259T17:06:54.691", + "vcid":"32" + } + }); - it('Sets received parts to 0 when start message received', function () { - dataProductRow = new DataProductRow(startMessage, columns, objectKeyString, limitEvaluator, rowId); - expect(dataProductRow.datum.parts_received).toBe(0); - }); + it('Sets received parts to 0 when start message received', () => { + dataProductRow = new DataProductRow(startMessage, columns, objectKeyString, limitEvaluator, rowId); + expect(dataProductRow.datum.parts_received).toBe(0); + }); - it('Increments part count when product part message received', function () { - dataProductRow = new DataProductRow(startMessage, columns, objectKeyString, limitEvaluator, rowId); - expect(dataProductRow.datum.parts_received).toBe(0); - dataProductRow.update(partReceivedMessage); - expect(dataProductRow.datum.parts_received).toBe(1); - }); + it('Increments part count when product part message received', () => { + dataProductRow = new DataProductRow(startMessage, columns, objectKeyString, limitEvaluator, rowId); + expect(dataProductRow.datum.parts_received).toBe(0); + dataProductRow.update(partReceivedMessage); + expect(dataProductRow.datum.parts_received).toBe(1); + }); - it('Replaces content of in progress rows with info from new message', function () { - const secondPartReceived = { - "creation_time":"", - "transaction_id":"McamRThumbnail\/McamRThumbnail_0457586851-19880", - "dvt_coarse":"457586851", - "ground_status":"UNKNOWN", - "session_host":"host", - "ert":"2019-259T17:06:54.590", - "dvt_fine":"19880", - "apid":"424", - "total_parts":"0", - "session_id":"36", - "scet":"2014-183T15:39:04.687010296", - "lst":"", - "version":"", - "file_size":"0", - "record_type":"product_part_received", - "command_number":"0", - "unique_name":"a_different_unique_name", - "seq_version":"0", - "checksum":"1234", - "part_number":"2", - "sclk":"0457586851.30334", - "seq_id":"0", - "event_time":"2019-259T17:06:54.691", - "vcid":"32" - }; + it('Replaces content of in progress rows with info from new message', () => { + const secondPartReceived = { + "creation_time":"", + "transaction_id":"McamRThumbnail\/McamRThumbnail_0457586851-19880", + "dvt_coarse":"457586851", + "ground_status":"UNKNOWN", + "session_host":"host", + "ert":"2019-259T17:06:54.590", + "dvt_fine":"19880", + "apid":"424", + "total_parts":"0", + "session_id":"36", + "scet":"2014-183T15:39:04.687010296", + "lst":"", + "version":"", + "file_size":"0", + "record_type":"product_part_received", + "command_number":"0", + "unique_name":"a_different_unique_name", + "seq_version":"0", + "checksum":"1234", + "part_number":"2", + "sclk":"0457586851.30334", + "seq_id":"0", + "event_time":"2019-259T17:06:54.691", + "vcid":"32" + }; - dataProductRow = new DataProductRow(startMessage, columns, objectKeyString, limitEvaluator, rowId); + dataProductRow = new DataProductRow(startMessage, columns, objectKeyString, limitEvaluator, rowId); - dataProductRow.update(partReceivedMessage); - expect(dataProductRow.datum["unique_name"]).toEqual("products\/McamRThumbnail\/McamRThumbnail_0457586851-19880"); - expect(dataProductRow.datum["checksum"]).toEqual("0"); - expect(dataProductRow.datum["part_number"]).toEqual("0"); + dataProductRow.update(partReceivedMessage); + expect(dataProductRow.datum["unique_name"]).toEqual("products\/McamRThumbnail\/McamRThumbnail_0457586851-19880"); + expect(dataProductRow.datum["checksum"]).toEqual("0"); + expect(dataProductRow.datum["part_number"]).toEqual("0"); - dataProductRow.update(secondPartReceived); - expect(dataProductRow.datum["unique_name"]).toEqual("a_different_unique_name"); - expect(dataProductRow.datum["checksum"]).toEqual("1234"); - expect(dataProductRow.datum["part_number"]).toEqual("2"); - expect(false); - }); + dataProductRow.update(secondPartReceived); + expect(dataProductRow.datum["unique_name"]).toEqual("a_different_unique_name"); + expect(dataProductRow.datum["checksum"]).toEqual("1234"); + expect(dataProductRow.datum["part_number"]).toEqual("2"); + expect(false); + }); - it('Does not replace content of complete rows with in progress rows', function () { - dataProductRow = new DataProductRow(startMessage, columns, objectKeyString, limitEvaluator, rowId); - dataProductRow.update(partReceivedMessage); - expect(dataProductRow.datum["unique_name"]).toEqual("products\/McamRThumbnail\/McamRThumbnail_0457586851-19880"); - expect(dataProductRow.datum["checksum"]).toEqual("0"); - expect(dataProductRow.datum["part_number"]).toEqual("0"); - - dataProductRow.update(completeMessage); - expect(dataProductRow.datum["unique_name"]).toEqual("complete_product_unique_name"); - expect(dataProductRow.datum["checksum"]).toEqual("33862"); - expect(dataProductRow.datum["part_number"]).toBeUndefined(); + it('Does not replace content of complete rows with in progress rows', () => { + dataProductRow = new DataProductRow(startMessage, columns, objectKeyString, limitEvaluator, rowId); + dataProductRow.update(partReceivedMessage); + expect(dataProductRow.datum["unique_name"]).toEqual("products\/McamRThumbnail\/McamRThumbnail_0457586851-19880"); + expect(dataProductRow.datum["checksum"]).toEqual("0"); + expect(dataProductRow.datum["part_number"]).toEqual("0"); + + dataProductRow.update(completeMessage); + expect(dataProductRow.datum["unique_name"]).toEqual("complete_product_unique_name"); + expect(dataProductRow.datum["checksum"]).toEqual("33862"); + expect(dataProductRow.datum["part_number"]).toBeUndefined(); - dataProductRow.update(partReceivedMessage); - expect(dataProductRow.datum["unique_name"]).toEqual("complete_product_unique_name"); - expect(dataProductRow.datum["checksum"]).toEqual("33862"); - expect(dataProductRow.datum["part_number"]).toBeUndefined(); - }); + dataProductRow.update(partReceivedMessage); + expect(dataProductRow.datum["unique_name"]).toEqual("complete_product_unique_name"); + expect(dataProductRow.datum["checksum"]).toEqual("33862"); + expect(dataProductRow.datum["part_number"]).toBeUndefined(); + }); - it('Does replace content of complete rows with complete rows', function () { - const aDifferentCompleteMessage = { - "creation_time":"2019-259T17:06:57.800", - "transaction_id":"McamRThumbnail\/McamRThumbnail_0457586851-19880", - "dvt_coarse":"457586851", - "ground_status":"COMPLETE_CHECKSUM_PASS", - "session_host":"host", - "ert":"2019-259T17:06:54.590", - "dvt_fine":"19880", - "apid":"424", - "total_parts":"20", - "session_id":"36", - "scet":"2014-183T15:39:04.687010296", - "lst":"", - "version":"", - "file_size":"192819", - "record_type":"complete_product", - "command_number":"2", - "unique_name":"a_different_complete_product_unique_name", - "seq_version":"0", - "checksum":"54321", - "sclk":"0457586851.30334", - "seq_id":"0", - "event_time":"2019-259T17:07:57.800", - "vcid":"32" - } - dataProductRow = new DataProductRow(startMessage, columns, objectKeyString, limitEvaluator, rowId); - dataProductRow.update(partReceivedMessage); - expect(dataProductRow.datum["unique_name"]).toEqual("products\/McamRThumbnail\/McamRThumbnail_0457586851-19880"); - expect(dataProductRow.datum["checksum"]).toEqual("0"); - expect(dataProductRow.datum["part_number"]).toEqual("0"); - - dataProductRow.update(completeMessage); - expect(dataProductRow.datum["unique_name"]).toEqual("complete_product_unique_name"); - expect(dataProductRow.datum["checksum"]).toEqual("33862"); - expect(dataProductRow.datum["event_time"]).toEqual("2019-259T17:06:54.691"); + it('Does replace content of complete rows with complete rows', () => { + const aDifferentCompleteMessage = { + "creation_time":"2019-259T17:06:57.800", + "transaction_id":"McamRThumbnail\/McamRThumbnail_0457586851-19880", + "dvt_coarse":"457586851", + "ground_status":"COMPLETE_CHECKSUM_PASS", + "session_host":"host", + "ert":"2019-259T17:06:54.590", + "dvt_fine":"19880", + "apid":"424", + "total_parts":"20", + "session_id":"36", + "scet":"2014-183T15:39:04.687010296", + "lst":"", + "version":"", + "file_size":"192819", + "record_type":"complete_product", + "command_number":"2", + "unique_name":"a_different_complete_product_unique_name", + "seq_version":"0", + "checksum":"54321", + "sclk":"0457586851.30334", + "seq_id":"0", + "event_time":"2019-259T17:07:57.800", + "vcid":"32" + } + dataProductRow = new DataProductRow(startMessage, columns, objectKeyString, limitEvaluator, rowId); + dataProductRow.update(partReceivedMessage); + expect(dataProductRow.datum["unique_name"]).toEqual("products\/McamRThumbnail\/McamRThumbnail_0457586851-19880"); + expect(dataProductRow.datum["checksum"]).toEqual("0"); + expect(dataProductRow.datum["part_number"]).toEqual("0"); + + dataProductRow.update(completeMessage); + expect(dataProductRow.datum["unique_name"]).toEqual("complete_product_unique_name"); + expect(dataProductRow.datum["checksum"]).toEqual("33862"); + expect(dataProductRow.datum["event_time"]).toEqual("2019-259T17:06:54.691"); - dataProductRow.update(aDifferentCompleteMessage); - expect(dataProductRow.datum["unique_name"]).toEqual("a_different_complete_product_unique_name"); - expect(dataProductRow.datum["checksum"]).toEqual("54321"); - expect(dataProductRow.datum["event_time"]).toEqual("2019-259T17:07:57.800") - }); + dataProductRow.update(aDifferentCompleteMessage); + expect(dataProductRow.datum["unique_name"]).toEqual("a_different_complete_product_unique_name"); + expect(dataProductRow.datum["checksum"]).toEqual("54321"); + expect(dataProductRow.datum["event_time"]).toEqual("2019-259T17:07:57.800") }); });