-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move and change messagePipeline selector that maps schemas by topic name
- Loading branch information
Showing
7 changed files
with
64 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/suite-base/src/components/MessagePipeline/selectors.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// SPDX-FileCopyrightText: Copyright (C) 2023-2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)<[email protected]> | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
|
||
import { getTopicToSchemaNameMap } from "@lichtblick/suite-base/components/MessagePipeline/selectors"; | ||
import { MessagePipelineContext } from "@lichtblick/suite-base/components/MessagePipeline/types"; | ||
import { PlayerPresence } from "@lichtblick/suite-base/players/types"; | ||
|
||
it("map schema names by topic name", () => { | ||
const state: MessagePipelineContext = { | ||
sortedTopics: [ | ||
{ name: "topic1", schemaName: "schema1" }, | ||
{ name: "topic2", schemaName: "schema2" }, | ||
], | ||
playerState: { | ||
presence: PlayerPresence.PRESENT, | ||
progress: {}, | ||
capabilities: [], | ||
profile: undefined, | ||
playerId: "", | ||
}, | ||
callService: jest.fn(), | ||
datatypes: new Map(), | ||
fetchAsset: jest.fn(), | ||
messageEventsBySubscriberId: new Map(), | ||
pauseFrame: jest.fn(), | ||
publish: jest.fn(), | ||
seekPlayback: jest.fn(), | ||
setParameter: jest.fn(), | ||
setPublishers: jest.fn(), | ||
setSubscriptions: jest.fn(), | ||
subscriptions: [], | ||
getMetadata: jest.fn(), | ||
}; | ||
const result = getTopicToSchemaNameMap(state); | ||
expect(result).toEqual({ | ||
topic1: "schema1", | ||
topic2: "schema2", | ||
}); | ||
}); |
15 changes: 15 additions & 0 deletions
15
packages/suite-base/src/components/MessagePipeline/selectors.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// SPDX-FileCopyrightText: Copyright (C) 2023-2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)<[email protected]> | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
|
||
import * as _ from "lodash-es"; | ||
|
||
import { MessagePipelineContext } from "@lichtblick/suite-base/components/MessagePipeline/types"; | ||
|
||
export const getTopicToSchemaNameMap = ( | ||
state: MessagePipelineContext, | ||
): Record<string, string | undefined> => | ||
_.mapValues(_.keyBy(state.sortedTopics, "name"), ({ schemaName }) => schemaName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters