From 0eb7d135c3def7c263153dbfb79bd0815daed850 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Wed, 17 Jul 2024 12:06:36 -0400 Subject: [PATCH 01/20] EDSC-3773: - Moved out all the logic bocks in buildAccessMethods into their one files (1 for each logic block). - Created tests for each of those logic blocks and updated the buildAccessMethods to test that those methods get called the correct number of times and with the correct params. --- .../__tests__/buildAccessMethods.test.js | 1568 +++++++++-------- .../util/accessMethods/buildAccessMethods.js | 197 +-- .../__tests__/buildDownload.test.js | 45 + .../__tests__/buildEsiEcho.test.js | 114 ++ .../__tests__/buildHarmony.test.js | 747 ++++++++ .../__tests__/buildOpendap.test.js | 244 +++ .../__tests__/buildSwodlr.test.js | 123 ++ .../buildAccessMethods/buildDownload.js | 27 + .../buildAccessMethods/buildEsiEcho.js | 57 + .../buildAccessMethods/buildHarmony.js | 87 + .../buildAccessMethods/buildOpendap.js | 50 + .../buildAccessMethods/buildSwodlr.js | 29 + 12 files changed, 2330 insertions(+), 958 deletions(-) create mode 100644 static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildDownload.test.js create mode 100644 static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js create mode 100644 static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js create mode 100644 static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildOpendap.test.js create mode 100644 static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildSwodlr.test.js create mode 100644 static/src/js/util/accessMethods/buildAccessMethods/buildDownload.js create mode 100644 static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js create mode 100644 static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js create mode 100644 static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js create mode 100644 static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js diff --git a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js index c3c5dcff0a..9e2f438f5c 100644 --- a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js +++ b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js @@ -1,5 +1,11 @@ import { buildAccessMethods } from '../buildAccessMethods' +import * as buildDownload from '../buildAccessMethods/buildDownload' +import * as buildSwodlr from '../buildAccessMethods/buildSwodlr' +import * as buildHarmony from '../buildAccessMethods/buildHarmony' +import * as buildOpendap from '../buildAccessMethods/buildOpendap' +import * as buildEsiEcho from '../buildAccessMethods/buildEsiEcho' + import * as getApplicationConfig from '../../../../../../sharedUtils/config' beforeEach(() => { @@ -8,8 +14,15 @@ beforeEach(() => { })) }) +afterEach(() => { + jest.clearAllMocks() +}) + describe('buildAccessMethods', () => { - test('returns a download access method', () => { + test('calls buildDownload access method', () => { + const buildDownloadMock = jest.spyOn(buildDownload, 'buildDownload') + buildDownloadMock.mockImplementationOnce(() => jest.fn()) + const collectionMetadata = { granules: { items: [{ @@ -19,38 +32,75 @@ describe('buildAccessMethods', () => { } const isOpenSearch = false - const methods = buildAccessMethods(collectionMetadata, isOpenSearch) + buildAccessMethods(collectionMetadata, isOpenSearch) - expect(methods).toEqual({ - download: { - isValid: true, - type: 'download' - } - }) + expect(buildDownloadMock).toBeCalledTimes(1) }) - test('returns a download access method for open search', () => { - const collectionMetadata = {} - const isOpenSearch = true + describe('when ordering is disabled', () => { + test('calls buildEcho access method and no echo-order access method is returned', () => { + const buildEsiEchoMock = jest.spyOn(buildEsiEcho, 'buildEsiEcho') + buildEsiEchoMock.mockImplementationOnce(() => jest.fn()) - const methods = buildAccessMethods(collectionMetadata, isOpenSearch) + jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ + disableOrdering: 'true' + })) - expect(methods).toEqual({ - download: { - isValid: true, - type: 'download' + const collectionMetadata = { + services: { + items: [{ + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + }, + maxItemsPerOrder: 2000, + orderOptions: { + items: [{ + conceptId: 'OO10000-EDSC', + name: 'mock form', + form: 'mock form' + }] + } + }] + } } + const isOpenSearch = false + + buildAccessMethods(collectionMetadata, isOpenSearch) + + expect(buildEsiEchoMock).toBeCalledTimes(1) + + expect(buildEsiEchoMock).toHaveBeenCalledWith({ + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10000-EDSC', + form: 'mock form', + name: 'mock form' + } + ] + }, + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + } + }, 'true') }) }) - test('returns an esi access method', () => { + test('calls buildEsiEcho access method with type ECHO ORDERS', () => { + const buildEsiEchoMock = jest.spyOn(buildEsiEcho, 'buildEsiEcho') + buildEsiEchoMock.mockImplementationOnce(() => jest.fn()) + const collectionMetadata = { services: { items: [{ - type: 'ESI', + type: 'ECHO ORDERS', url: { urlValue: 'https://example.com' }, + maxItemsPerOrder: 2000, orderOptions: { items: [{ conceptId: 'OO10000-EDSC', @@ -63,27 +113,36 @@ describe('buildAccessMethods', () => { } const isOpenSearch = false - const methods = buildAccessMethods(collectionMetadata, isOpenSearch) + buildAccessMethods(collectionMetadata, isOpenSearch) - expect(methods).toEqual({ - esi0: { - form: 'mock form', - formDigest: '75f9480053e9ba083665951820d17ae5c2139d92', - optionDefinition: { - conceptId: 'OO10000-EDSC', - name: 'mock form' - }, - type: 'ESI', - url: 'https://example.com' + expect(buildEsiEchoMock).toBeCalledTimes(1) + + expect(buildEsiEchoMock).toHaveBeenCalledWith({ + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10000-EDSC', + form: 'mock form', + name: 'mock form' + } + ] + }, + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' } - }) + }, 'false') }) - test('returns an echo orders access method', () => { + test('calls buildEsiEcho access method with type ESI', () => { + const buildEsiEchoMock = jest.spyOn(buildEsiEcho, 'buildEsiEcho') + buildEsiEchoMock.mockImplementationOnce(() => jest.fn()) + const collectionMetadata = { services: { items: [{ - type: 'ECHO ORDERS', + type: 'ESI', url: { urlValue: 'https://example.com' }, @@ -100,56 +159,32 @@ describe('buildAccessMethods', () => { } const isOpenSearch = false - const methods = buildAccessMethods(collectionMetadata, isOpenSearch) - - expect(methods).toEqual({ - echoOrder0: { - form: 'mock form', - formDigest: '75f9480053e9ba083665951820d17ae5c2139d92', - optionDefinition: { - conceptId: 'OO10000-EDSC', - name: 'mock form' - }, - type: 'ECHO ORDERS', - maxItemsPerOrder: 2000, - url: 'https://example.com' - } - }) - }) + buildAccessMethods(collectionMetadata, isOpenSearch) - describe('when ordering is disabled', () => { - test('no echo-order access method is returned', () => { - jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ - disableOrdering: 'true' - })) + expect(buildEsiEchoMock).toBeCalledTimes(1) - const collectionMetadata = { - services: { - items: [{ - type: 'ECHO ORDERS', - url: { - urlValue: 'https://example.com' - }, - maxItemsPerOrder: 2000, - orderOptions: { - items: [{ - conceptId: 'OO10000-EDSC', - name: 'mock form', - form: 'mock form' - }] - } - }] - } + expect(buildEsiEchoMock).toHaveBeenCalledWith({ + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10000-EDSC', + form: 'mock form', + name: 'mock form' + } + ] + }, + type: 'ESI', + url: { + urlValue: 'https://example.com' } - const isOpenSearch = false - - const methods = buildAccessMethods(collectionMetadata, isOpenSearch) - - expect(methods).toEqual({}) - }) + }, 'false') }) - test('returns a harmony access method', () => { + test('calls buildHarmony access method', () => { + const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') + buildHarmonyMock.mockImplementationOnce(() => jest.fn()) + const collectionMetadata = { services: { items: [{ @@ -258,7 +293,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100003-EDSC', definition: 'Red channel value', - longName: 'Red Channel', + longName: 'Red channel', name: 'red_var', nativeId: 'mmt_variable_3969', scienceKeywords: null @@ -267,86 +302,15 @@ describe('buildAccessMethods', () => { } const isOpenSearch = false - const methods = buildAccessMethods(collectionMetadata, isOpenSearch) + buildAccessMethods(collectionMetadata, isOpenSearch) - expect(methods).toEqual({ - harmony0: { - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings: [ - { - id: 'V100000-EDSC' - }, - { - id: 'V100001-EDSC' - }, - { - id: 'V100002-EDSC' - }, - { - id: 'V100003-EDSC' - } - ], - id: 'S100000-EDSC', - isValid: true, - keywordMappings: [], - longName: 'Mock Service Name', - name: 'mock-name', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: [], - supportsBoundingBoxSubsetting: true, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, - supportsConcatenation: true, - defaultConcatenation: true, - enableConcatenateDownload: true, - type: 'Harmony', - url: 'https://example.com', - variables: { - 'V100000-EDSC': { - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, - 'V100001-EDSC': { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, - 'V100002-EDSC': { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, - 'V100003-EDSC': { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - } - } - } - }) + expect(buildHarmonyMock).toBeCalledTimes(1) }) - test('returns an opendap access method', () => { + test('calls buildOpendap access method', () => { + const buildOpendapMock = jest.spyOn(buildOpendap, 'buildOpendap') + buildOpendapMock.mockImplementationOnce(() => jest.fn()) + const collectionMetadata = { services: { items: [{ @@ -486,97 +450,15 @@ describe('buildAccessMethods', () => { } const isOpenSearch = false - const methods = buildAccessMethods(collectionMetadata, isOpenSearch) + buildAccessMethods(collectionMetadata, isOpenSearch) - expect(methods).toEqual({ - opendap: { - hierarchyMappings: [{ - id: 'V100000-EDSC' - }, { - id: 'V100001-EDSC' - }, { - id: 'V100002-EDSC' - }, { - id: 'V100003-EDSC' - }], - id: 'S100000-EDSC', - isValid: true, - keywordMappings: [{ - children: [{ - id: 'V100000-EDSC' - }, { - id: 'V100001-EDSC' - }, { - id: 'V100002-EDSC' - }, { - id: 'V100003-EDSC' - }], - label: 'Sea Surface Temperature' - }], - longName: 'Mock Service Name', - name: 'mock-name', - supportedOutputFormats: ['ASCII', 'BINARY', 'NETCDF-4'], - supportsVariableSubsetting: true, - type: 'OPeNDAP', - variables: { - 'V100000-EDSC': { - conceptId: 'V100000-EDSC', - definition: 'analysed_sst in units of kelvin', - longName: 'analysed_sst', - name: 'analysed_sst', - nativeId: 'e2eTestVarHiRes1', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] - }, - 'V100001-EDSC': { - conceptId: 'V100001-EDSC', - definition: 'analysis_error in units of kelvin', - longName: 'analysis_error', - name: 'analysis_error', - nativeId: 'e2eTestVarHiRes2', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] - }, - 'V100002-EDSC': { - conceptId: 'V100002-EDSC', - definition: 'mask in units of seconds since 1981-0', - longName: 'mask', - name: 'mask', - nativeId: 'e2eTestVarHiRes4', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] - }, - 'V100003-EDSC': { - conceptId: 'V100003-EDSC', - definition: 'sea_ice_fraction in units of fraction (between 0 ', - longName: 'sea_ice_fraction', - name: 'sea_ice_fraction', - nativeId: 'e2eTestVarHiRes3', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] - } - } - } - }) + expect(buildOpendapMock).toBeCalledTimes(1) }) - test('returns a swodlr access method', () => { + test('calls buildSwodlr access method', () => { + const buildSwodlrMock = jest.spyOn(buildSwodlr, 'buildSwodlr') + buildSwodlrMock.mockImplementationOnce(() => jest.fn()) + const collectionMetadata = { services: { items: [ @@ -621,27 +503,20 @@ describe('buildAccessMethods', () => { } const isOpenSearch = false - const methods = buildAccessMethods(collectionMetadata, isOpenSearch) + buildAccessMethods(collectionMetadata, isOpenSearch) - expect(methods).toEqual({ - swodlr: { - id: 'S100000-EDSC', - isValid: true, - longName: 'Mock PODAAC SWOT On-Demand Level 2 Raster Generation (SWODLR)', - name: 'Mock PODAAC_SWODLR', - supportsSwodlr: true, - type: 'SWODLR', - url: 'https://swodlr.podaac.earthdatacloud.nasa.gov' - } - }) + expect(buildSwodlrMock).toBeCalledTimes(1) }) describe('when swodlr is disabled', () => { - test('no swodlr access method is returned', () => { + test('calls buildSwodlr but no swodlr access method is returned', () => { jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ disableSwodlr: 'true' })) + const buildSwodlrMock = jest.spyOn(buildSwodlr, 'buildSwodlr') + buildSwodlrMock.mockImplementationOnce(() => jest.fn()) + const collectionMetadata = { services: { items: [ @@ -686,14 +561,54 @@ describe('buildAccessMethods', () => { } const isOpenSearch = false - const methods = buildAccessMethods(collectionMetadata, isOpenSearch) + buildAccessMethods(collectionMetadata, isOpenSearch) + + expect(buildSwodlrMock).toBeCalledTimes(1) - expect(methods).toEqual({}) + expect(buildSwodlrMock).toHaveBeenCalledWith({ + conceptId: 'S100000-EDSC', + longName: 'Mock PODAAC SWOT On-Demand Level 2 Raster Generation (SWODLR)', + name: 'Mock PODAAC_SWODLR', + orderOptions: { + items: [] + }, + serviceOptions: { + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator', + }, + { + projectionName: 'WGS84 - World Geodetic System 1984', + } + ] + }, + supportedInputProjections: null, + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator', + }, + { + projectionName: 'WGS84 - World Geodetic System 1984', + } + ], + supportedReformattings: null, + type: 'SWODLR', + url: { + description: 'Service top-level URL', + urlValue: 'https://swodlr.podaac.earthdatacloud.nasa.gov', + }, + variables: { + items: [] + } + }, 'true') }) }) describe('when the collection contains both variables associated to its services and variables directly associated to the collection', () => { - test('variables on the service are returned instead of variables directly associated to the collection', () => { + test('variables on the service are returned instead of variables directly associated to the collection and buildHarmony is called 3 times', () => { + const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') + buildHarmonyMock.mockImplementationOnce(() => jest.fn()) + const collectionMetadata = { services: { items: [{ @@ -791,7 +706,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100003-EDSC', definition: 'Red channel value', - longName: 'Red Channel', + longName: 'Red channel', name: 'red_var', nativeId: 'mmt_variable_3969', scienceKeywords: null @@ -892,7 +807,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100009-EDSC', definition: 'Red channel value', - longName: 'Red Channel', + longName: 'Red channel', name: 'red_var', nativeId: 'mmt_variable_3966', scienceKeywords: null @@ -998,224 +913,284 @@ describe('buildAccessMethods', () => { } const isOpenSearch = false - const methods = buildAccessMethods(collectionMetadata, isOpenSearch) + buildAccessMethods(collectionMetadata, isOpenSearch) - expect(methods).toEqual({ - harmony0: { - defaultConcatenation: false, - enableConcatenateDownload: false, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings: [ - { - id: 'V100000-EDSC' - }, - { - id: 'V100001-EDSC' - }, - { - id: 'V100002-EDSC' - }, - { - id: 'V100003-EDSC' - } - ], - id: 'S100000-EDSC', - isValid: true, - keywordMappings: [], + expect(buildHarmonyMock).toBeCalledTimes(3) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 1, + { + conceptId: 'S100000-EDSC', longName: 'Mock Service Name', name: 'mock-name', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: [], - supportsBoundingBoxSubsetting: true, - supportsConcatenation: false, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, + serviceOptions: { + interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }] + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }], type: 'Harmony', - url: 'https://example.com', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, variables: { - 'V100000-EDSC': { + count: 4, + items: [{ conceptId: 'V100000-EDSC', definition: 'Alpha channel value', longName: 'Alpha channel ', name: 'alpha_var', nativeId: 'mmt_variable_3972', scienceKeywords: null - }, - 'V100001-EDSC': { + }, { conceptId: 'V100001-EDSC', definition: 'Blue channel value', longName: 'Blue channel', name: 'blue_var', nativeId: 'mmt_variable_3971', scienceKeywords: null - }, - 'V100002-EDSC': { + }, { conceptId: 'V100002-EDSC', definition: 'Green channel value', longName: 'Green channel', name: 'green_var', nativeId: 'mmt_variable_3970', scienceKeywords: null - }, - 'V100003-EDSC': { + }, { conceptId: 'V100003-EDSC', definition: 'Red channel value', - longName: 'Red Channel', + longName: 'Red channel', name: 'red_var', nativeId: 'mmt_variable_3969', scienceKeywords: null - } + }] } }, - harmony1: { - defaultConcatenation: false, - enableConcatenateDownload: false, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings: [ - { - id: 'V100006-EDSC' - }, - { - id: 'V100007-EDSC' - }, - { - id: 'V100008-EDSC' - }, - { - id: 'V100009-EDSC' - } - ], - id: 'S100001-EDSC', - isValid: true, - keywordMappings: [], - longName: 'Mock Service Name 2', - name: 'mock-name 2', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: [], - supportsBoundingBoxSubsetting: true, - supportsConcatenation: false, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, - type: 'Harmony', - url: 'https://example2.com', - variables: { - 'V100006-EDSC': { - conceptId: 'V100006-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3973', - scienceKeywords: null - }, - 'V100007-EDSC': { - conceptId: 'V100007-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3974', - scienceKeywords: null - }, - 'V100008-EDSC': { - conceptId: 'V100008-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3975', - scienceKeywords: null - }, - 'V100009-EDSC': { + { + count: 4, + items: [{ + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + }] + }, + 0 + ) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 2, + { + conceptId: 'S100001-EDSC', + longName: 'Mock Service Name 2', + name: 'mock-name 2', + serviceOptions: { + interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }] + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }], + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example2.com' + }, + variables: { + count: 4, + items: [{ + conceptId: 'V100006-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3973', + scienceKeywords: null + }, { + conceptId: 'V100007-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3974', + scienceKeywords: null + }, { + conceptId: 'V100008-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3975', + scienceKeywords: null + }, { conceptId: 'V100009-EDSC', definition: 'Red channel value', - longName: 'Red Channel', + longName: 'Red channel', name: 'red_var', nativeId: 'mmt_variable_3966', scienceKeywords: null - } + }] } }, - // Harmony2 contains the default variables in the coll -> var association - harmony2: { - defaultConcatenation: false, - enableConcatenateDownload: false, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings: [ - { - id: 'V100003-EDSC' - }, - { - id: 'V100004-EDSC' - }, - { - id: 'V100005-EDSC' - } - ], - id: 'S100002-EDSC', - isValid: true, - keywordMappings: [], + { + count: 4, + items: [{ + conceptId: 'V100006-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3973', + scienceKeywords: null + }, { + conceptId: 'V100007-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3974', + scienceKeywords: null + }, { + conceptId: 'V100008-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3975', + scienceKeywords: null + }, { + conceptId: 'V100009-EDSC', + definition: 'Red channel value', + longName: 'Red channel', + name: 'red_var', + nativeId: 'mmt_variable_3966', + scienceKeywords: null + }] + }, + 1 + ) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 3, + { + conceptId: 'S100002-EDSC', longName: 'Mock Service Name 3', name: 'mock-name 3', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: [], - supportsBoundingBoxSubsetting: true, - supportsConcatenation: false, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, - type: 'Harmony', - url: 'https://example3.com', - variables: { - 'V100003-EDSC': { - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, - 'V100004-EDSC': { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null + serviceOptions: { + interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } }, - 'V100005-EDSC': { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - } + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }] + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }], + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example3.com' } - } - }) + }, + { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + }, + 2 + ) }) }) describe('when the collection contains variables directly associated to the collection and no variables associated to it services (empty)', () => { - test('variables on the collection are returned instead of variables associated to the service', () => { + test('variables on the collection are returned instead of variables associated to the service and buildHarmony is called 3 times', () => { + const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') + buildHarmonyMock.mockImplementationOnce(() => jest.fn()) + const collectionMetadata = { services: { items: [{ @@ -1464,202 +1439,214 @@ describe('buildAccessMethods', () => { } const isOpenSearch = false - const methods = buildAccessMethods(collectionMetadata, isOpenSearch) + buildAccessMethods(collectionMetadata, isOpenSearch) - expect(methods).toEqual({ - harmony0: { - defaultConcatenation: false, - enableConcatenateDownload: false, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings: [ - { - id: 'V100003-EDSC' - }, - { - id: 'V100004-EDSC' - }, - { - id: 'V100005-EDSC' - } - ], - id: 'S100000-EDSC', - isValid: true, - keywordMappings: [], + expect(buildHarmonyMock).toBeCalledTimes(3) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 1, + { + conceptId: 'S100000-EDSC', longName: 'Mock Service Name', name: 'mock-name', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: [], - supportsBoundingBoxSubsetting: true, - supportsConcatenation: false, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, + serviceOptions: { + interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }] + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }], type: 'Harmony', - url: 'https://example.com', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, variables: { - 'V100003-EDSC': { - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, - 'V100004-EDSC': { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, - 'V100005-EDSC': { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - } + count: 0, + items: [] } }, - harmony1: { - defaultConcatenation: false, - enableConcatenateDownload: false, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings: [ - { - id: 'V100003-EDSC' - }, - { - id: 'V100004-EDSC' - }, - { - id: 'V100005-EDSC' - } - ], - id: 'S100001-EDSC', - isValid: true, - keywordMappings: [], + { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + }, + 0 + ) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 2, + { + conceptId: 'S100001-EDSC', longName: 'Mock Service Name 2', name: 'mock-name 2', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: [], - supportsBoundingBoxSubsetting: true, - supportsConcatenation: false, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, + serviceOptions: { + interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }] + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }], type: 'Harmony', - url: 'https://example2.com', + url: { + description: 'Mock URL', + urlValue: 'https://example2.com' + }, variables: { - 'V100003-EDSC': { - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, - 'V100004-EDSC': { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, - 'V100005-EDSC': { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - } + count: 4, + items: [] } }, - // Harmony2 contains the default variables in the coll -> var association - harmony2: { - defaultConcatenation: false, - enableConcatenateDownload: false, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings: [ - { - id: 'V100003-EDSC' - }, - { - id: 'V100004-EDSC' - }, - { - id: 'V100005-EDSC' - } - ], - id: 'S100002-EDSC', - isValid: true, - keywordMappings: [], + { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + }, + 1 + ) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 3, + { + conceptId: 'S100002-EDSC', longName: 'Mock Service Name 3', name: 'mock-name 3', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: [], - supportsBoundingBoxSubsetting: true, - supportsConcatenation: false, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, - type: 'Harmony', - url: 'https://example3.com', - variables: { - 'V100003-EDSC': { - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, - 'V100004-EDSC': { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null + serviceOptions: { + interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } }, - 'V100005-EDSC': { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - } + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }] + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }], + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example3.com' } - } - }) + }, + { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + }, + 2 + ) }) }) describe('when the collection contains variables directly associated to the collection and some variables associated to some services', () => { - test('variables on the collection are returned for services without variables but, variables associated to the service are returned for services that have them', () => { + test('variables on the collection are returned for services without variables but, variables associated to the service are returned for services that have them and buildHarmony is called 3 times', () => { + const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') + buildHarmonyMock.mockImplementationOnce(() => jest.fn()) + const collectionMetadata = { services: { items: [{ @@ -1757,7 +1744,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100003-EDSC', definition: 'Red channel value', - longName: 'Red Channel', + longName: 'Red channel', name: 'red_var', nativeId: 'mmt_variable_3969', scienceKeywords: null @@ -1831,11 +1818,7 @@ describe('buildAccessMethods', () => { 'TIFF', 'NETCDF-4' ] - }], - variables: { - count: 4, - items: [] - } + }] }, { conceptId: 'S100002-EDSC', @@ -1936,49 +1919,47 @@ describe('buildAccessMethods', () => { } const isOpenSearch = false - const methods = buildAccessMethods(collectionMetadata, isOpenSearch) + buildAccessMethods(collectionMetadata, isOpenSearch) - expect(methods).toEqual({ - harmony0: { - defaultConcatenation: false, - enableConcatenateDownload: false, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings: [ - { - id: 'V100000-EDSC' - }, - { - id: 'V100001-EDSC' - }, - { - id: 'V100002-EDSC' - }, - { - id: 'V100003-EDSC' - } - ], - id: 'S100000-EDSC', - isValid: true, - keywordMappings: [], + expect(buildHarmonyMock).toBeCalledTimes(3) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 1, + { + conceptId: 'S100000-EDSC', longName: 'Mock Service Name', name: 'mock-name', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: [], - supportsBoundingBoxSubsetting: true, - supportsConcatenation: false, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, + serviceOptions: { + interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }] + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }], type: 'Harmony', - url: 'https://example.com', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, variables: { - 'V100000-EDSC': { + count: 4, + items: [{ conceptId: 'V100000-EDSC', definition: 'Alpha channel value', longName: 'Alpha channel ', @@ -1986,158 +1967,191 @@ describe('buildAccessMethods', () => { nativeId: 'mmt_variable_3972', scienceKeywords: null }, - 'V100001-EDSC': { + { conceptId: 'V100001-EDSC', definition: 'Blue channel value', longName: 'Blue channel', name: 'blue_var', nativeId: 'mmt_variable_3971', scienceKeywords: null - }, - 'V100002-EDSC': { + }, { conceptId: 'V100002-EDSC', definition: 'Green channel value', longName: 'Green channel', name: 'green_var', nativeId: 'mmt_variable_3970', scienceKeywords: null - }, - 'V100003-EDSC': { + }, { conceptId: 'V100003-EDSC', definition: 'Red channel value', - longName: 'Red Channel', + longName: 'Red channel', name: 'red_var', nativeId: 'mmt_variable_3969', scienceKeywords: null - } + }] } }, - harmony1: { - defaultConcatenation: false, - enableConcatenateDownload: false, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings: [ - { - id: 'V100003-EDSC' - }, - { - id: 'V100004-EDSC' - }, - { - id: 'V100005-EDSC' - } - ], - id: 'S100001-EDSC', - isValid: true, - keywordMappings: [], + { + count: 4, + items: [{ + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + }] + }, + 0 + ) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 2, + { + conceptId: 'S100001-EDSC', longName: 'Mock Service Name 2', name: 'mock-name 2', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: [], - supportsBoundingBoxSubsetting: true, - supportsConcatenation: false, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, - type: 'Harmony', - url: 'https://example2.com', - variables: { - 'V100003-EDSC': { - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, - 'V100004-EDSC': { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null + serviceOptions: { + interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } }, - 'V100005-EDSC': { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - } + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }] + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }], + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example2.com' } }, - // Harmony2 contains the default variables in the coll -> var association - harmony2: { - defaultConcatenation: false, - enableConcatenateDownload: false, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings: [ - { - id: 'V100003-EDSC' - }, - { - id: 'V100004-EDSC' - }, - { - id: 'V100005-EDSC' - } - ], - id: 'S100002-EDSC', - isValid: true, - keywordMappings: [], + { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + }, + 1 + ) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 3, + { + conceptId: 'S100002-EDSC', longName: 'Mock Service Name 3', name: 'mock-name 3', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: [], - supportsBoundingBoxSubsetting: true, - supportsConcatenation: false, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, - type: 'Harmony', - url: 'https://example3.com', - variables: { - 'V100003-EDSC': { - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, - 'V100004-EDSC': { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null + serviceOptions: { + interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } }, - 'V100005-EDSC': { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - } + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }] + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }], + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example3.com' } - } - }) + }, + { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + }, + 2 + ) }) }) }) diff --git a/static/src/js/util/accessMethods/buildAccessMethods.js b/static/src/js/util/accessMethods/buildAccessMethods.js index d4cb4cc368..fa2bebd860 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods.js +++ b/static/src/js/util/accessMethods/buildAccessMethods.js @@ -1,16 +1,10 @@ -import { camelCase, uniq } from 'lodash' - import { getApplicationConfig } from '../../../../../sharedUtils/config' -import { isDownloadable } from '../../../../../sharedUtils/isDownloadable' -import { generateFormDigest } from './generateFormDigest' -import { getVariables } from './getVariables' -import { supportsBoundingBoxSubsetting } from './supportsBoundingBoxSubsetting' -import { supportsConcatenation } from './supportsConcatenation' -import { defaultConcatenation } from './defaultConcatenation' -import { supportsShapefileSubsetting } from './supportsShapefileSubsetting' -import { supportsTemporalSubsetting } from './supportsTemporalSubsetting' -import { supportsVariableSubsetting } from './supportsVariableSubsetting' +import { buildEsiEcho } from './buildAccessMethods/buildEsiEcho' +import { buildOpendap } from './buildAccessMethods/buildOpendap' +import { buildHarmony } from './buildAccessMethods/buildHarmony' +import { buildSwodlr } from './buildAccessMethods/buildSwodlr' +import { buildDownload } from './buildAccessMethods/buildDownload' /** * Builds the different access methods available for the provided collection @@ -25,7 +19,7 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => { variables: collectionAssociatedVariables = {} } = collectionMetadata - const accessMethods = {} + let accessMethods = {} let harmonyIndex = 0 const { items: serviceItems = null } = services @@ -35,15 +29,7 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => { serviceItems.forEach((serviceItem) => { let associatedVariables = collectionAssociatedVariables const { - conceptId: serviceConceptId, - description, - orderOptions, type: serviceType, - url, - longName, - maxItemsPerOrder, - name, - supportedReformattings, variables: serviceAssociatedVariables = {} } = serviceItem @@ -56,171 +42,20 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => { const supportedServiceTypes = ['esi', 'echo orders', 'opendap', 'harmony', 'swodlr'] if (!supportedServiceTypes.includes(serviceType.toLowerCase())) return - const { urlValue } = url - - const supportsOrderOptions = ['esi', 'echo orders'] - - // Only process orderOptions if the service type uses orderOptions - // Do not include access if orders are disabled - if (supportsOrderOptions.includes(serviceType.toLowerCase()) && (disableOrdering !== 'true')) { - const { items: orderOptionsItems } = orderOptions - if (orderOptionsItems === null) return - - orderOptionsItems.forEach((orderOptionItem, orderOptionIndex) => { - const { - conceptId: orderOptionConceptId, - form, - name: orderOptionName - } = orderOptionItem - - const method = { - type: serviceType, - maxItemsPerOrder, - url: urlValue, - optionDefinition: { - conceptId: orderOptionConceptId, - name: orderOptionName - }, - form, - formDigest: generateFormDigest(form) - } - - let methodKey = camelCase(serviceType) - - // `echoOrders` needs to be singular to match existing savedAccessConfigurations - if (methodKey === 'echoOrders') { - methodKey = 'echoOrder' - } - - accessMethods[`${methodKey}${orderOptionIndex}`] = method - }) - } - - if (serviceType.toLowerCase() === 'opendap') { - const { - hierarchyMappings, - keywordMappings, - variables - } = getVariables(associatedVariables) - - const outputFormats = [] - - if (supportedReformattings) { - supportedReformattings.forEach((reformatting) => { - const { supportedOutputFormats } = reformatting - - // Collect all supported output formats from each mapping - outputFormats.push(...supportedOutputFormats) - }) - } - - accessMethods.opendap = { - hierarchyMappings, - id: serviceConceptId, - isValid: true, - keywordMappings, - longName, - name, - supportedOutputFormats: uniq(outputFormats), - supportsVariableSubsetting: supportsVariableSubsetting(serviceItem), - type: serviceType, - variables - } - } - - if (serviceType.toLowerCase() === 'harmony') { - const { - hierarchyMappings, - keywordMappings, - variables - } = getVariables(associatedVariables) - const { - supportedOutputProjections - } = serviceItem - - const outputFormats = [] - - if (supportedReformattings) { - supportedReformattings.forEach((reformatting) => { - const { supportedOutputFormats } = reformatting - - // Collect all supported output formats from each mapping - outputFormats.push(...supportedOutputFormats) - }) - } - - let outputProjections = [] - if (supportedOutputProjections) { - outputProjections = supportedOutputProjections.filter((projection) => { - const { projectionAuthority } = projection - - return projectionAuthority != null - }).map((projection) => { - const { projectionAuthority } = projection - - return projectionAuthority - }) - } - - accessMethods[`harmony${harmonyIndex}`] = { - description, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings, - id: serviceConceptId, - isValid: true, - keywordMappings, - longName, - name, - supportedOutputFormats: uniq(outputFormats), - supportedOutputProjections: outputProjections, - supportsBoundingBoxSubsetting: supportsBoundingBoxSubsetting(serviceItem), - supportsShapefileSubsetting: supportsShapefileSubsetting(serviceItem), - supportsTemporalSubsetting: supportsTemporalSubsetting(serviceItem), - supportsVariableSubsetting: supportsVariableSubsetting(serviceItem), - supportsConcatenation: supportsConcatenation(serviceItem), - defaultConcatenation: defaultConcatenation(serviceItem), - enableConcatenateDownload: defaultConcatenation(serviceItem), - type: serviceType, - url: urlValue, - variables - } - - harmonyIndex += 1 - } - - if (serviceType.toLowerCase() === 'swodlr' && (disableSwodlr !== 'true')) { - accessMethods.swodlr = { - id: serviceConceptId, - isValid: true, - longName, - name, - type: serviceType, - supportsSwodlr: true, - url: urlValue - } + accessMethods = { + ...buildEsiEcho(serviceItem, disableOrdering), + ...buildOpendap(serviceItem, associatedVariables), + // eslint-disable-next-line no-plusplus + ...buildHarmony(serviceItem, associatedVariables, harmonyIndex++), + ...buildSwodlr(serviceItem, disableSwodlr), + ...accessMethods } }) } - // Determine if the collection should have the downloadable accessMethod - let onlineAccessFlag = false - - if (granules) { - // If the collection has granules, check their online access flags to - // determine if this collection is downloadable - const { items: granuleItems } = granules - - if (granuleItems) { - onlineAccessFlag = isDownloadable(granuleItems) - } - - if (onlineAccessFlag || isOpenSearch) { - accessMethods.download = { - isValid: true, - type: 'download' - } - } + accessMethods = { + ...buildDownload(granules, isOpenSearch), + ...accessMethods } return accessMethods diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildDownload.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildDownload.test.js new file mode 100644 index 0000000000..35e27ce1dc --- /dev/null +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildDownload.test.js @@ -0,0 +1,45 @@ +import { buildDownload } from '../buildDownload' + +describe('buildDownload', () => { + test('returns a download access method', () => { + const collectionMetadata = { + granules: { + items: [{ + online_access_flag: true + }] + } + } + const isOpenSearch = false + + const { + granules + } = collectionMetadata + + const method = buildDownload(granules, isOpenSearch) + + expect(method).toEqual({ + download: { + isValid: true, + type: 'download' + } + }) + }) + + test('returns a download access method for open search', () => { + const collectionMetadata = {} + const isOpenSearch = true + + const { + granules = {} + } = collectionMetadata + + const method = buildDownload(granules, isOpenSearch) + + expect(method).toEqual({ + download: { + isValid: true, + type: 'download' + } + }) + }) +}) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js new file mode 100644 index 0000000000..aaa6dc3290 --- /dev/null +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js @@ -0,0 +1,114 @@ +import { buildEsiEcho } from '../buildEsiEcho' + +describe('buildEsiEcho', () => { + test('returns an esi access method', () => { + const collectionMetadata = { + services: { + items: [{ + type: 'ESI', + url: { + urlValue: 'https://example.com' + }, + orderOptions: { + items: [{ + conceptId: 'OO10000-EDSC', + name: 'mock form', + form: 'mock form' + }] + } + }] + } + } + const disabledOrdering = false + + const { services } = collectionMetadata + const serviceItem = services.items[0] + + const methods = buildEsiEcho(serviceItem, disabledOrdering) + + expect(methods).toEqual({ + esi0: { + form: 'mock form', + formDigest: '75f9480053e9ba083665951820d17ae5c2139d92', + optionDefinition: { + conceptId: 'OO10000-EDSC', + name: 'mock form' + }, + type: 'ESI', + url: 'https://example.com' + } + }) + }) + + test('returns an echo orders access method', () => { + const collectionMetadata = { + services: { + items: [{ + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + }, + maxItemsPerOrder: 2000, + orderOptions: { + items: [{ + conceptId: 'OO10000-EDSC', + name: 'mock form', + form: 'mock form' + }] + } + }] + } + } + + const { services } = collectionMetadata + const serviceItem = services.items[0] + + const disabledOrdering = false + + const methods = buildEsiEcho(serviceItem, disabledOrdering) + + expect(methods).toEqual({ + echoOrder0: { + form: 'mock form', + formDigest: '75f9480053e9ba083665951820d17ae5c2139d92', + optionDefinition: { + conceptId: 'OO10000-EDSC', + name: 'mock form' + }, + type: 'ECHO ORDERS', + maxItemsPerOrder: 2000, + url: 'https://example.com' + } + }) + }) + + test('returns empty when ordering disabled', () => { + const collectionMetadata = { + services: { + items: [{ + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + }, + maxItemsPerOrder: 2000, + orderOptions: { + items: [{ + conceptId: 'OO10000-EDSC', + name: 'mock form', + form: 'mock form' + }] + } + }] + } + } + + const { services } = collectionMetadata + const serviceItem = services.items[0] + + const disabledOrdering = 'true' + + const methods = buildEsiEcho(serviceItem, disabledOrdering) + + expect(methods).toEqual({}) + }) +}) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js new file mode 100644 index 0000000000..f7a8dcfc52 --- /dev/null +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js @@ -0,0 +1,747 @@ +import { buildHarmony } from '../buildHarmony' + +describe('buildHarmony', () => { + test('returns a harmony access method', () => { + const collectionMetadata = { + services: { + items: [{ + description: 'abc123', + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + }, + aggregation: { + concatenate: { + concatenateDefault: true + } + }, + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] + }, + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }], + variables: { + count: 0, + items: null + } + }] + }, + variables: { + count: 4, + items: [{ + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + }] + } + } + + const { services, variables: associatedVariables } = collectionMetadata + const serviceItem = services.items[0] + + const index = 0 + + const methods = buildHarmony(serviceItem, associatedVariables, index) + + expect(methods).toEqual({ + harmony0: { + description: 'abc123', + enableTemporalSubsetting: true, + enableSpatialSubsetting: true, + hierarchyMappings: [ + { + id: 'V100000-EDSC' + }, + { + id: 'V100001-EDSC' + }, + { + id: 'V100002-EDSC' + }, + { + id: 'V100003-EDSC' + } + ], + id: 'S100000-EDSC', + isValid: true, + keywordMappings: [], + longName: 'Mock Service Name', + name: 'mock-name', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ], + supportedOutputProjections: [], + supportsBoundingBoxSubsetting: true, + supportsShapefileSubsetting: false, + supportsTemporalSubsetting: false, + supportsVariableSubsetting: true, + supportsConcatenation: true, + defaultConcatenation: true, + enableConcatenateDownload: true, + type: 'Harmony', + url: 'https://example.com', + variables: { + 'V100000-EDSC': { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + 'V100001-EDSC': { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + 'V100002-EDSC': { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, + 'V100003-EDSC': { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } + } + } + }) + }) + + test('increments index correctly for multiple harmony items', () => { + const collectionMetadata = { + services: { + items: [{ + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + }, + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] + }, + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }], + variables: { + count: 4, + items: [{ + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + }] + } + }, { + conceptId: 'S100001-EDSC', + longName: 'Mock Service Name 2', + name: 'mock-name 2', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example2.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + }, + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] + }, + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }], + variables: { + count: 4, + items: [{ + conceptId: 'V100006-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3973', + scienceKeywords: null + }, { + conceptId: 'V100007-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3974', + scienceKeywords: null + }, { + conceptId: 'V100008-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3975', + scienceKeywords: null + }, { + conceptId: 'V100009-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3966', + scienceKeywords: null + }] + } + }, + { + conceptId: 'S100002-EDSC', + longName: 'Mock Service Name 3', + name: 'mock-name 3', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example3.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + }, + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] + }, + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] + }] + }, + variables: { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + } + } + + const { services, variables: collectionAssociatedVariables = {} } = collectionMetadata + const { items: serviceItems = null } = services + + let index = 0 + let methods = {} + + serviceItems.forEach((serviceItem) => { + let associatedVariables = collectionAssociatedVariables + + const { + variables: serviceAssociatedVariables = {} + } = serviceItem + + if (serviceAssociatedVariables.items && serviceAssociatedVariables.items.length > 0) { + associatedVariables = serviceAssociatedVariables + } + + methods = { + // eslint-disable-next-line no-plusplus + ...buildHarmony(serviceItem, associatedVariables, index++), + ...methods + } + }) + + expect(methods).toEqual({ + harmony0: { + defaultConcatenation: false, + enableConcatenateDownload: false, + enableTemporalSubsetting: true, + enableSpatialSubsetting: true, + hierarchyMappings: [ + { + id: 'V100000-EDSC' + }, + { + id: 'V100001-EDSC' + }, + { + id: 'V100002-EDSC' + }, + { + id: 'V100003-EDSC' + } + ], + id: 'S100000-EDSC', + isValid: true, + keywordMappings: [], + longName: 'Mock Service Name', + name: 'mock-name', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ], + supportedOutputProjections: [], + supportsBoundingBoxSubsetting: true, + supportsConcatenation: false, + supportsShapefileSubsetting: false, + supportsTemporalSubsetting: false, + supportsVariableSubsetting: true, + type: 'Harmony', + url: 'https://example.com', + variables: { + 'V100000-EDSC': { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + 'V100001-EDSC': { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + 'V100002-EDSC': { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, + 'V100003-EDSC': { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } + } + }, + harmony1: { + defaultConcatenation: false, + enableConcatenateDownload: false, + enableTemporalSubsetting: true, + enableSpatialSubsetting: true, + hierarchyMappings: [ + { + id: 'V100006-EDSC' + }, + { + id: 'V100007-EDSC' + }, + { + id: 'V100008-EDSC' + }, + { + id: 'V100009-EDSC' + } + ], + id: 'S100001-EDSC', + isValid: true, + keywordMappings: [], + longName: 'Mock Service Name 2', + name: 'mock-name 2', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ], + supportedOutputProjections: [], + supportsBoundingBoxSubsetting: true, + supportsConcatenation: false, + supportsShapefileSubsetting: false, + supportsTemporalSubsetting: false, + supportsVariableSubsetting: true, + type: 'Harmony', + url: 'https://example2.com', + variables: { + 'V100006-EDSC': { + conceptId: 'V100006-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3973', + scienceKeywords: null + }, + 'V100007-EDSC': { + conceptId: 'V100007-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3974', + scienceKeywords: null + }, + 'V100008-EDSC': { + conceptId: 'V100008-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3975', + scienceKeywords: null + }, + 'V100009-EDSC': { + conceptId: 'V100009-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3966', + scienceKeywords: null + } + } + }, + // Harmony2 contains the default variables in the coll -> var association + harmony2: { + defaultConcatenation: false, + enableConcatenateDownload: false, + enableTemporalSubsetting: true, + enableSpatialSubsetting: true, + hierarchyMappings: [ + { + id: 'V100003-EDSC' + }, + { + id: 'V100004-EDSC' + }, + { + id: 'V100005-EDSC' + } + ], + id: 'S100002-EDSC', + isValid: true, + keywordMappings: [], + longName: 'Mock Service Name 3', + name: 'mock-name 3', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ], + supportedOutputProjections: [], + supportsBoundingBoxSubsetting: true, + supportsConcatenation: false, + supportsShapefileSubsetting: false, + supportsTemporalSubsetting: false, + supportsVariableSubsetting: true, + type: 'Harmony', + url: 'https://example3.com', + variables: { + 'V100003-EDSC': { + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, + 'V100004-EDSC': { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, + 'V100005-EDSC': { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + } + } + } + }) + }) +}) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildOpendap.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildOpendap.test.js new file mode 100644 index 0000000000..44b2ead686 --- /dev/null +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildOpendap.test.js @@ -0,0 +1,244 @@ +import { buildOpendap } from '../buildOpendap' + +describe('buildOpendap', () => { + test('returns an opendap access method', () => { + const collectionMetadata = { + services: { + items: [{ + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + type: 'OPeNDAP', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + supportedInputProjections: [{ + projectionName: 'Geographic' + }], + supportedOutputProjections: [{ + projectionName: 'Geographic' + }], + supportedReformattings: [{ + supportedInputFormat: 'ASCII', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'BINARY', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }], + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + } + }, + supportedOutputProjections: [{ + projectionName: 'Geographic' + }], + supportedReformattings: [{ + supportedInputFormat: 'ASCII', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'BINARY', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }], + orderOptions: { + count: 0, + items: null + }, + variables: { + count: 4, + items: [{ + conceptId: 'V100000-EDSC', + definition: 'analysed_sst in units of kelvin', + longName: 'analysed_sst', + name: 'analysed_sst', + nativeId: 'e2eTestVarHiRes1', + scienceKeywords: [{ + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + }] + }, { + conceptId: 'V100001-EDSC', + definition: 'analysis_error in units of kelvin', + longName: 'analysis_error', + name: 'analysis_error', + nativeId: 'e2eTestVarHiRes2', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, { + conceptId: 'V100002-EDSC', + definition: 'mask in units of seconds since 1981-0', + longName: 'mask', + name: 'mask', + nativeId: 'e2eTestVarHiRes4', + scienceKeywords: [{ + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + }] + }, { + conceptId: 'V100003-EDSC', + definition: 'sea_ice_fraction in units of fraction (between 0 ', + longName: 'sea_ice_fraction', + name: 'sea_ice_fraction', + nativeId: 'e2eTestVarHiRes3', + scienceKeywords: [{ + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + }] + }] + } + }] + } + } + + const { services, variables: collectionAssociatedVariables = {} } = collectionMetadata + const serviceItem = services.items[0] + + let associatedVariables = collectionAssociatedVariables + + const { + variables: serviceAssociatedVariables = {} + } = serviceItem + + if (serviceAssociatedVariables.items && serviceAssociatedVariables.items.length > 0) { + associatedVariables = serviceAssociatedVariables + } + + const methods = buildOpendap(serviceItem, associatedVariables) + expect(methods).toEqual({ + opendap: { + hierarchyMappings: [{ + id: 'V100000-EDSC' + }, { + id: 'V100001-EDSC' + }, { + id: 'V100002-EDSC' + }, { + id: 'V100003-EDSC' + }], + id: 'S100000-EDSC', + isValid: true, + keywordMappings: [{ + children: [{ + id: 'V100000-EDSC' + }, { + id: 'V100001-EDSC' + }, { + id: 'V100002-EDSC' + }, { + id: 'V100003-EDSC' + }], + label: 'Sea Surface Temperature' + }], + longName: 'Mock Service Name', + name: 'mock-name', + supportedOutputFormats: ['ASCII', 'BINARY', 'NETCDF-4'], + supportsVariableSubsetting: true, + type: 'OPeNDAP', + variables: { + 'V100000-EDSC': { + conceptId: 'V100000-EDSC', + definition: 'analysed_sst in units of kelvin', + longName: 'analysed_sst', + name: 'analysed_sst', + nativeId: 'e2eTestVarHiRes1', + scienceKeywords: [{ + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + }] + }, + 'V100001-EDSC': { + conceptId: 'V100001-EDSC', + definition: 'analysis_error in units of kelvin', + longName: 'analysis_error', + name: 'analysis_error', + nativeId: 'e2eTestVarHiRes2', + scienceKeywords: [{ + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + }] + }, + 'V100002-EDSC': { + conceptId: 'V100002-EDSC', + definition: 'mask in units of seconds since 1981-0', + longName: 'mask', + name: 'mask', + nativeId: 'e2eTestVarHiRes4', + scienceKeywords: [{ + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + }] + }, + 'V100003-EDSC': { + conceptId: 'V100003-EDSC', + definition: 'sea_ice_fraction in units of fraction (between 0 ', + longName: 'sea_ice_fraction', + name: 'sea_ice_fraction', + nativeId: 'e2eTestVarHiRes3', + scienceKeywords: [{ + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + }] + } + } + } + }) + }) +}) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildSwodlr.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildSwodlr.test.js new file mode 100644 index 0000000000..1a0ef92036 --- /dev/null +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildSwodlr.test.js @@ -0,0 +1,123 @@ +import { buildSwodlr } from '../buildSwodlr' + +describe('buildSwodlr', () => { + test('returns an swodlr access method', () => { + const collectionMetadata = { + services: { + items: [ + { + conceptId: 'S100000-EDSC', + longName: 'Mock PODAAC SWOT On-Demand Level 2 Raster Generation (SWODLR)', + name: 'Mock PODAAC_SWODLR', + type: 'SWODLR', + url: { + description: 'Service top-level URL', + urlValue: 'https://swodlr.podaac.earthdatacloud.nasa.gov' + }, + serviceOptions: { + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator' + }, + { + projectionName: 'WGS84 - World Geodetic System 1984' + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator' + }, + { + projectionName: 'WGS84 - World Geodetic System 1984' + } + ], + supportedReformattings: null, + supportedInputProjections: null, + orderOptions: { + items: [] + }, + variables: { + items: [] + } + } + ] + } + } + + const { services } = collectionMetadata + const serviceItem = services.items[0] + + const disableSwodlr = false + + const methods = buildSwodlr(serviceItem, disableSwodlr) + + expect(methods).toEqual({ + swodlr: { + id: 'S100000-EDSC', + isValid: true, + longName: 'Mock PODAAC SWOT On-Demand Level 2 Raster Generation (SWODLR)', + name: 'Mock PODAAC_SWODLR', + supportsSwodlr: true, + type: 'SWODLR', + url: 'https://swodlr.podaac.earthdatacloud.nasa.gov' + } + }) + }) + + describe('when swodlr is disabled', () => { + test('no swodlr access method is returned', () => { + const collectionMetadata = { + services: { + items: [ + { + conceptId: 'S100000-EDSC', + longName: 'Mock PODAAC SWOT On-Demand Level 2 Raster Generation (SWODLR)', + name: 'Mock PODAAC_SWODLR', + type: 'SWODLR', + url: { + description: 'Service top-level URL', + urlValue: 'https://swodlr.podaac.earthdatacloud.nasa.gov' + }, + serviceOptions: { + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator' + }, + { + projectionName: 'WGS84 - World Geodetic System 1984' + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator' + }, + { + projectionName: 'WGS84 - World Geodetic System 1984' + } + ], + supportedReformattings: null, + supportedInputProjections: null, + orderOptions: { + items: [] + }, + variables: { + items: [] + } + } + ] + } + } + + const { services } = collectionMetadata + const serviceItem = services.items[0] + + const disableSwodlr = 'true' + + const methods = buildSwodlr(serviceItem, disableSwodlr) + + expect(methods).toEqual({}) + }) + }) +}) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildDownload.js b/static/src/js/util/accessMethods/buildAccessMethods/buildDownload.js new file mode 100644 index 0000000000..77506aaaa8 --- /dev/null +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildDownload.js @@ -0,0 +1,27 @@ +import { isDownloadable } from '../../../../../../sharedUtils/isDownloadable' + +export const buildDownload = (granules, isOpenSearch) => { + const accessMethods = {} + + // Determine if the collection should have the downloadable accessMethod + let onlineAccessFlag = false + + if (granules) { + // If the collection has granules, check their online access flags to + // determine if this collection is downloadable + const { items: granuleItems } = granules + + if (granuleItems) { + onlineAccessFlag = isDownloadable(granuleItems) + } + + if (onlineAccessFlag || isOpenSearch) { + accessMethods.download = { + isValid: true, + type: 'download' + } + } + } + + return accessMethods +} diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js new file mode 100644 index 0000000000..8d066d0a19 --- /dev/null +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js @@ -0,0 +1,57 @@ +import { camelCase } from 'lodash' +import { generateFormDigest } from '../generateFormDigest' + +export const buildEsiEcho = (serviceItem, disableOrdering) => { + const supportsOrderOptions = ['esi', 'echo orders'] + + const accessMethods = {} + // Only process orderOptions if the service type uses orderOptions + // Do not include access if orders are disabled + + const { + orderOptions, + type: serviceType, + url, + maxItemsPerOrder + } = serviceItem + + if (supportsOrderOptions.includes(serviceType.toLowerCase()) && (disableOrdering !== 'true')) { + const { urlValue } = url + + const { items: orderOptionsItems } = orderOptions + if (orderOptionsItems === null) return {} + + orderOptionsItems.forEach((orderOptionItem, orderOptionIndex) => { + const { + conceptId: orderOptionConceptId, + form, + name: orderOptionName + } = orderOptionItem + + const method = { + type: serviceType, + maxItemsPerOrder, + url: urlValue, + optionDefinition: { + conceptId: orderOptionConceptId, + name: orderOptionName + }, + form, + formDigest: generateFormDigest(form) + } + + let methodKey = camelCase(serviceType) + + // `echoOrders` needs to be singular to match existing savedAccessConfigurations + if (methodKey === 'echoOrders') { + methodKey = 'echoOrder' + } + + accessMethods[`${methodKey}${orderOptionIndex}`] = method + }) + + return accessMethods + } + + return {} +} diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js b/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js new file mode 100644 index 0000000000..f9ae81ac9f --- /dev/null +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js @@ -0,0 +1,87 @@ +import { uniq } from 'lodash' + +import { getVariables } from '../getVariables' + +import { supportsBoundingBoxSubsetting } from '../supportsBoundingBoxSubsetting' +import { supportsConcatenation } from '../supportsConcatenation' +import { defaultConcatenation } from '../defaultConcatenation' +import { supportsShapefileSubsetting } from '../supportsShapefileSubsetting' +import { supportsTemporalSubsetting } from '../supportsTemporalSubsetting' +import { supportsVariableSubsetting } from '../supportsVariableSubsetting' + +export const buildHarmony = (serviceItem, associatedVariables, index) => { + const accessMethods = {} + + const { + description, + conceptId: serviceConceptId, + type: serviceType, + longName, + name, + url, + supportedReformattings + } = serviceItem + + const { urlValue } = url + + if (serviceType.toLowerCase() === 'harmony') { + const { + hierarchyMappings, + keywordMappings, + variables + } = getVariables(associatedVariables) + const { + supportedOutputProjections + } = serviceItem + + const outputFormats = [] + + if (supportedReformattings) { + supportedReformattings.forEach((reformatting) => { + const { supportedOutputFormats } = reformatting + + // Collect all supported output formats from each mapping + outputFormats.push(...supportedOutputFormats) + }) + } + + let outputProjections = [] + if (supportedOutputProjections) { + outputProjections = supportedOutputProjections.filter((projection) => { + const { projectionAuthority } = projection + + return projectionAuthority != null + }).map((projection) => { + const { projectionAuthority } = projection + + return projectionAuthority + }) + } + + accessMethods[`harmony${index}`] = { + description, + enableTemporalSubsetting: true, + enableSpatialSubsetting: true, + hierarchyMappings, + id: serviceConceptId, + isValid: true, + keywordMappings, + longName, + name, + supportedOutputFormats: uniq(outputFormats), + supportedOutputProjections: outputProjections, + supportsBoundingBoxSubsetting: supportsBoundingBoxSubsetting(serviceItem), + supportsShapefileSubsetting: supportsShapefileSubsetting(serviceItem), + supportsTemporalSubsetting: supportsTemporalSubsetting(serviceItem), + supportsVariableSubsetting: supportsVariableSubsetting(serviceItem), + supportsConcatenation: supportsConcatenation(serviceItem), + defaultConcatenation: defaultConcatenation(serviceItem), + enableConcatenateDownload: defaultConcatenation(serviceItem), + type: serviceType, + url: urlValue, + variables + } + } + + return accessMethods +} diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js b/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js new file mode 100644 index 0000000000..683f03c558 --- /dev/null +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js @@ -0,0 +1,50 @@ +import { uniq } from 'lodash' + +import { getVariables } from '../getVariables' +import { supportsVariableSubsetting } from '../supportsVariableSubsetting' + +export const buildOpendap = (serviceItem, associatedVariables) => { + const accessMethods = {} + + const { + conceptId: serviceConceptId, + type: serviceType, + longName, + name, + supportedReformattings + } = serviceItem + + if (serviceType.toLowerCase() === 'opendap') { + const { + hierarchyMappings, + keywordMappings, + variables + } = getVariables(associatedVariables) + + const outputFormats = [] + + if (supportedReformattings) { + supportedReformattings.forEach((reformatting) => { + const { supportedOutputFormats } = reformatting + + // Collect all supported output formats from each mapping + outputFormats.push(...supportedOutputFormats) + }) + } + + accessMethods.opendap = { + hierarchyMappings, + id: serviceConceptId, + isValid: true, + keywordMappings, + longName, + name, + supportedOutputFormats: uniq(outputFormats), + supportsVariableSubsetting: supportsVariableSubsetting(serviceItem), + type: serviceType, + variables + } + } + + return accessMethods +} diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js new file mode 100644 index 0000000000..0fe78a11e9 --- /dev/null +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js @@ -0,0 +1,29 @@ +export const buildSwodlr = (serviceItem, disableSwodlr) => { + const accessMethods = {} + + const { + conceptId: serviceConceptId, + longName, + name, + type: serviceType, + url + } = serviceItem + + const { urlValue } = url + + if (serviceType.toLowerCase() === 'swodlr' && (disableSwodlr !== 'true')) { + accessMethods.swodlr = { + id: serviceConceptId, + isValid: true, + longName, + name, + type: serviceType, + supportsSwodlr: true, + url: urlValue + } + + return accessMethods + } + + return {} +} From bcf7eadf53ff8066287ece4537e2cfdd634f3c16 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Wed, 17 Jul 2024 13:07:17 -0400 Subject: [PATCH 02/20] removed dangling cammas --- .../accessMethods/__tests__/buildAccessMethods.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js index 9e2f438f5c..dfa9b3ba71 100644 --- a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js +++ b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js @@ -575,27 +575,27 @@ describe('buildAccessMethods', () => { serviceOptions: { supportedOutputProjections: [ { - projectionName: 'Universal Transverse Mercator', + projectionName: 'Universal Transverse Mercator' }, { - projectionName: 'WGS84 - World Geodetic System 1984', + projectionName: 'WGS84 - World Geodetic System 1984' } ] }, supportedInputProjections: null, supportedOutputProjections: [ { - projectionName: 'Universal Transverse Mercator', + projectionName: 'Universal Transverse Mercator' }, { - projectionName: 'WGS84 - World Geodetic System 1984', + projectionName: 'WGS84 - World Geodetic System 1984' } ], supportedReformattings: null, type: 'SWODLR', url: { description: 'Service top-level URL', - urlValue: 'https://swodlr.podaac.earthdatacloud.nasa.gov', + urlValue: 'https://swodlr.podaac.earthdatacloud.nasa.gov' }, variables: { items: [] From cd93a33ffe2216a0b2a3116b49d03c01eeb7d6c9 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Wed, 17 Jul 2024 17:19:13 -0400 Subject: [PATCH 03/20] EDSC-3773: a bit of cleanup --- .../js/util/accessMethods/buildAccessMethods/buildEsiEcho.js | 4 +--- .../js/util/accessMethods/buildAccessMethods/buildSwodlr.js | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js index 8d066d0a19..58ca58fb69 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js @@ -49,9 +49,7 @@ export const buildEsiEcho = (serviceItem, disableOrdering) => { accessMethods[`${methodKey}${orderOptionIndex}`] = method }) - - return accessMethods } - return {} + return accessMethods } diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js index 0fe78a11e9..36980cb334 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js @@ -21,9 +21,7 @@ export const buildSwodlr = (serviceItem, disableSwodlr) => { supportsSwodlr: true, url: urlValue } - - return accessMethods } - return {} + return accessMethods } From c543c69e61a0fb619acd0af91dd910cfedb5a8e9 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Wed, 17 Jul 2024 17:48:05 -0400 Subject: [PATCH 04/20] EDSC-3773: added some code coverage --- .../buildAccessMethods/__tests__/buildHarmony.test.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js index f7a8dcfc52..c16f088d1d 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js @@ -255,9 +255,11 @@ describe('buildHarmony', () => { }] }, supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' + projectionName: 'Polar Stereographic', + projectionAuthority: 'Polar Stereographic' }, { - projectionName: 'Geographic' + projectionName: 'Geographic', + projectionAuthority: 'Geographic' }], supportedReformattings: [{ supportedInputFormat: 'NETCDF-4', @@ -563,7 +565,7 @@ describe('buildHarmony', () => { 'TIFF', 'NETCDF-4' ], - supportedOutputProjections: [], + supportedOutputProjections: ['Polar Stereographic', 'Geographic'], supportsBoundingBoxSubsetting: true, supportsConcatenation: false, supportsShapefileSubsetting: false, From 483ed3f52b5fb1573455d1fe8de33035768414b9 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Fri, 19 Jul 2024 12:59:10 -0400 Subject: [PATCH 05/20] EDSC-3773: updated documentation and how we run buildAccessMethods. --- .../__tests__/buildAccessMethods.test.js | 368 +++++++++++++++++- .../util/accessMethods/buildAccessMethods.js | 78 ++-- .../buildAccessMethods/buildDownload.js | 6 + .../buildAccessMethods/buildEsiEcho.js | 22 +- .../buildAccessMethods/buildHarmony.js | 105 ++--- .../buildAccessMethods/buildOpendap.js | 64 +-- .../buildAccessMethods/buildSwodlr.js | 8 +- 7 files changed, 524 insertions(+), 127 deletions(-) diff --git a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js index dfa9b3ba71..296286c19d 100644 --- a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js +++ b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js @@ -35,6 +35,8 @@ describe('buildAccessMethods', () => { buildAccessMethods(collectionMetadata, isOpenSearch) expect(buildDownloadMock).toBeCalledTimes(1) + + expect(buildDownloadMock).toBeCalledWith({ items: [{ online_access_flag: true }] }, false) }) describe('when ordering is disabled', () => { @@ -293,7 +295,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100003-EDSC', definition: 'Red channel value', - longName: 'Red channel', + longName: 'Red Channel', name: 'red_var', nativeId: 'mmt_variable_3969', scienceKeywords: null @@ -305,6 +307,85 @@ describe('buildAccessMethods', () => { buildAccessMethods(collectionMetadata, isOpenSearch) expect(buildHarmonyMock).toBeCalledTimes(1) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 1, + { + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + serviceOptions: { + aggregation: { + concatenate: { + concatenateDefault: true + } + }, + interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }] + }, + supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }], + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + variables: { + count: 0, + items: null + } + }, + { + count: 4, + items: [{ + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + }] + }, + 0 + ) }) test('calls buildOpendap access method', () => { @@ -453,9 +534,239 @@ describe('buildAccessMethods', () => { buildAccessMethods(collectionMetadata, isOpenSearch) expect(buildOpendapMock).toBeCalledTimes(1) + + expect(buildOpendapMock).toBeCalledWith( + { + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + orderOptions: { + count: 0, + items: null + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + }, + supportedInputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedOutputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'ASCII', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'BINARY', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'ASCII', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'BINARY', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + } + ], + type: 'OPeNDAP', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + variables: { + count: 4, + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'analysed_sst in units of kelvin', + longName: 'analysed_sst', + name: 'analysed_sst', + nativeId: 'e2eTestVarHiRes1', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100001-EDSC', + definition: 'analysis_error in units of kelvin', + longName: 'analysis_error', + name: 'analysis_error', + nativeId: 'e2eTestVarHiRes2', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100002-EDSC', + definition: 'mask in units of seconds since 1981-0', + longName: 'mask', + name: 'mask', + nativeId: 'e2eTestVarHiRes4', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100003-EDSC', + definition: 'sea_ice_fraction in units of fraction (between 0 ', + longName: 'sea_ice_fraction', + name: 'sea_ice_fraction', + nativeId: 'e2eTestVarHiRes3', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + } + ] + } + }, + { + count: 4, + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'analysed_sst in units of kelvin', + longName: 'analysed_sst', + name: 'analysed_sst', + nativeId: 'e2eTestVarHiRes1', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100001-EDSC', + definition: 'analysis_error in units of kelvin', + longName: 'analysis_error', + name: 'analysis_error', + nativeId: 'e2eTestVarHiRes2', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100002-EDSC', + definition: 'mask in units of seconds since 1981-0', + longName: 'mask', + name: 'mask', + nativeId: 'e2eTestVarHiRes4', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100003-EDSC', + definition: 'sea_ice_fraction in units of fraction (between 0 ', + longName: 'sea_ice_fraction', + name: 'sea_ice_fraction', + nativeId: 'e2eTestVarHiRes3', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + } + ] + } + ) }) test('calls buildSwodlr access method', () => { + jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ + disableSwodlr: 'false' + })) + const buildSwodlrMock = jest.spyOn(buildSwodlr, 'buildSwodlr') buildSwodlrMock.mockImplementationOnce(() => jest.fn()) @@ -506,6 +817,43 @@ describe('buildAccessMethods', () => { buildAccessMethods(collectionMetadata, isOpenSearch) expect(buildSwodlrMock).toBeCalledTimes(1) + + expect(buildSwodlrMock).toHaveBeenCalledWith({ + conceptId: 'S100000-EDSC', + longName: 'Mock PODAAC SWOT On-Demand Level 2 Raster Generation (SWODLR)', + name: 'Mock PODAAC_SWODLR', + orderOptions: { + items: [] + }, + serviceOptions: { + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator' + }, + { + projectionName: 'WGS84 - World Geodetic System 1984' + } + ] + }, + supportedInputProjections: null, + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator' + }, + { + projectionName: 'WGS84 - World Geodetic System 1984' + } + ], + supportedReformattings: null, + type: 'SWODLR', + url: { + description: 'Service top-level URL', + urlValue: 'https://swodlr.podaac.earthdatacloud.nasa.gov' + }, + variables: { + items: [] + } + }, 'false') }) describe('when swodlr is disabled', () => { @@ -706,7 +1054,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100003-EDSC', definition: 'Red channel value', - longName: 'Red channel', + longName: 'Red Channel', name: 'red_var', nativeId: 'mmt_variable_3969', scienceKeywords: null @@ -807,7 +1155,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100009-EDSC', definition: 'Red channel value', - longName: 'Red channel', + longName: 'Red Channel', name: 'red_var', nativeId: 'mmt_variable_3966', scienceKeywords: null @@ -977,7 +1325,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100003-EDSC', definition: 'Red channel value', - longName: 'Red channel', + longName: 'Red Channel', name: 'red_var', nativeId: 'mmt_variable_3969', scienceKeywords: null @@ -1010,7 +1358,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100003-EDSC', definition: 'Red channel value', - longName: 'Red channel', + longName: 'Red Channel', name: 'red_var', nativeId: 'mmt_variable_3969', scienceKeywords: null @@ -1079,7 +1427,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100009-EDSC', definition: 'Red channel value', - longName: 'Red channel', + longName: 'Red Channel', name: 'red_var', nativeId: 'mmt_variable_3966', scienceKeywords: null @@ -1112,7 +1460,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100009-EDSC', definition: 'Red channel value', - longName: 'Red channel', + longName: 'Red Channel', name: 'red_var', nativeId: 'mmt_variable_3966', scienceKeywords: null @@ -1744,7 +2092,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100003-EDSC', definition: 'Red channel value', - longName: 'Red channel', + longName: 'Red Channel', name: 'red_var', nativeId: 'mmt_variable_3969', scienceKeywords: null @@ -1984,7 +2332,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100003-EDSC', definition: 'Red channel value', - longName: 'Red channel', + longName: 'Red Channel', name: 'red_var', nativeId: 'mmt_variable_3969', scienceKeywords: null @@ -2018,7 +2366,7 @@ describe('buildAccessMethods', () => { }, { conceptId: 'V100003-EDSC', definition: 'Red channel value', - longName: 'Red channel', + longName: 'Red Channel', name: 'red_var', nativeId: 'mmt_variable_3969', scienceKeywords: null diff --git a/static/src/js/util/accessMethods/buildAccessMethods.js b/static/src/js/util/accessMethods/buildAccessMethods.js index fa2bebd860..5c157bfd81 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods.js +++ b/static/src/js/util/accessMethods/buildAccessMethods.js @@ -19,43 +19,61 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => { variables: collectionAssociatedVariables = {} } = collectionMetadata - let accessMethods = {} let harmonyIndex = 0 const { items: serviceItems = null } = services const { disableOrdering, disableSwodlr } = getApplicationConfig() - if (serviceItems !== null) { - serviceItems.forEach((serviceItem) => { - let associatedVariables = collectionAssociatedVariables - const { - type: serviceType, - variables: serviceAssociatedVariables = {} - } = serviceItem - - // Overwrite variables if there are variables associated to the service record - if (serviceAssociatedVariables.items && serviceAssociatedVariables.items.length > 0) { - associatedVariables = serviceAssociatedVariables - } - - // Only process service types that EDSC supports - const supportedServiceTypes = ['esi', 'echo orders', 'opendap', 'harmony', 'swodlr'] - if (!supportedServiceTypes.includes(serviceType.toLowerCase())) return - - accessMethods = { - ...buildEsiEcho(serviceItem, disableOrdering), - ...buildOpendap(serviceItem, associatedVariables), - // eslint-disable-next-line no-plusplus - ...buildHarmony(serviceItem, associatedVariables, harmonyIndex++), - ...buildSwodlr(serviceItem, disableSwodlr), - ...accessMethods - } - }) + const buildMethods = { + esi: (serviceItem, params) => buildEsiEcho(serviceItem, params.disableOrdering), + 'echo orders': (serviceItem, params) => buildEsiEcho(serviceItem, params.disableOrdering), + opendap: (serviceItem, params) => buildOpendap(serviceItem, params.associatedVariables), + // eslint-disable-next-line max-len + harmony: (serviceItem, params) => buildHarmony(serviceItem, params.associatedVariables, params.harmonyIndex), + swodlr: (serviceItem, params) => buildSwodlr(serviceItem, params.disableSwodlr), + downloads: () => buildDownload(granules, isOpenSearch) } - accessMethods = { - ...buildDownload(granules, isOpenSearch), - ...accessMethods + const nonDownloadMethods = serviceItems !== null ? serviceItems.reduce((methods, serviceItem) => { + let associatedVariables = collectionAssociatedVariables + const { + type: serviceType, + variables: serviceAssociatedVariables = {} + } = serviceItem + + // Overwrite variables if there are variables associated to the service record + if (serviceAssociatedVariables.items && serviceAssociatedVariables.items.length > 0) { + associatedVariables = serviceAssociatedVariables + } + + const lowerServiceType = serviceType.toLowerCase() + + // Only process service types that EDSC supports + const supportedServiceTypes = ['esi', 'echo orders', 'opendap', 'harmony', 'swodlr'] + if (!supportedServiceTypes.includes(lowerServiceType)) return {} + + const params = { + disableOrdering, + harmonyIndex, + associatedVariables, + disableSwodlr + } + + const updatedMethods = { + ...methods, + ...buildMethods[lowerServiceType](serviceItem, params) + } + + if (lowerServiceType === 'harmony') { + harmonyIndex += 1 + } + + return updatedMethods + }, {}) : {} + + const accessMethods = { + ...nonDownloadMethods, + ...buildMethods.downloads() } return accessMethods diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildDownload.js b/static/src/js/util/accessMethods/buildAccessMethods/buildDownload.js index 77506aaaa8..d8f9ef918a 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildDownload.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildDownload.js @@ -1,5 +1,11 @@ import { isDownloadable } from '../../../../../../sharedUtils/isDownloadable' +/** + * Builds the Downloads access method + * @param {object} granules granules object pulled from the collectionMetdata + * @param {boolean} isOpenSearch Is the collection an open search collection + * @returns {object} Access method for Downloads + */ export const buildDownload = (granules, isOpenSearch) => { const accessMethods = {} diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js index 58ca58fb69..c6bb882afe 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js @@ -1,9 +1,13 @@ import { camelCase } from 'lodash' import { generateFormDigest } from '../generateFormDigest' +/** + * Builds the ESI or Echo Ordering access method + * @param {object} serviceItem serviceItem in the Collection Metadata + * @param {boolean} disabledOrdering true if ordering is disabled + * @returns {object} Access method for ESI or Echo Orders + */ export const buildEsiEcho = (serviceItem, disableOrdering) => { - const supportsOrderOptions = ['esi', 'echo orders'] - const accessMethods = {} // Only process orderOptions if the service type uses orderOptions // Do not include access if orders are disabled @@ -15,13 +19,16 @@ export const buildEsiEcho = (serviceItem, disableOrdering) => { maxItemsPerOrder } = serviceItem - if (supportsOrderOptions.includes(serviceType.toLowerCase()) && (disableOrdering !== 'true')) { + if (disableOrdering !== 'true') { const { urlValue } = url const { items: orderOptionsItems } = orderOptions if (orderOptionsItems === null) return {} - orderOptionsItems.forEach((orderOptionItem, orderOptionIndex) => { + let esiIndex = 0 + let echoIndex = 0 + + orderOptionsItems.forEach((orderOptionItem) => { const { conceptId: orderOptionConceptId, form, @@ -45,9 +52,12 @@ export const buildEsiEcho = (serviceItem, disableOrdering) => { // `echoOrders` needs to be singular to match existing savedAccessConfigurations if (methodKey === 'echoOrders') { methodKey = 'echoOrder' + accessMethods[`${methodKey}${echoIndex}`] = method + echoIndex += 1 + } else { + accessMethods[`${methodKey}${esiIndex}`] = method + esiIndex += 1 } - - accessMethods[`${methodKey}${orderOptionIndex}`] = method }) } diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js b/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js index f9ae81ac9f..3cf1e2bf5e 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js @@ -9,6 +9,13 @@ import { supportsShapefileSubsetting } from '../supportsShapefileSubsetting' import { supportsTemporalSubsetting } from '../supportsTemporalSubsetting' import { supportsVariableSubsetting } from '../supportsVariableSubsetting' +/** + * Builds the Harmony access method + * @param {object} serviceItem serviceItem in the Collection Metadata + * @param {object} associatedVariables variables that are either in the serviceItem or collectionMetadata (prioritizes the serviceItem variables) + * @param {integer} index the harmony index for this harmony service item + * @returns {object} Access method for Harmony + */ export const buildHarmony = (serviceItem, associatedVariables, index) => { const accessMethods = {} @@ -24,63 +31,61 @@ export const buildHarmony = (serviceItem, associatedVariables, index) => { const { urlValue } = url - if (serviceType.toLowerCase() === 'harmony') { - const { - hierarchyMappings, - keywordMappings, - variables - } = getVariables(associatedVariables) - const { - supportedOutputProjections - } = serviceItem + const { + hierarchyMappings, + keywordMappings, + variables + } = getVariables(associatedVariables) + const { + supportedOutputProjections + } = serviceItem - const outputFormats = [] + const outputFormats = [] - if (supportedReformattings) { - supportedReformattings.forEach((reformatting) => { - const { supportedOutputFormats } = reformatting + if (supportedReformattings) { + supportedReformattings.forEach((reformatting) => { + const { supportedOutputFormats } = reformatting - // Collect all supported output formats from each mapping - outputFormats.push(...supportedOutputFormats) - }) - } + // Collect all supported output formats from each mapping + outputFormats.push(...supportedOutputFormats) + }) + } - let outputProjections = [] - if (supportedOutputProjections) { - outputProjections = supportedOutputProjections.filter((projection) => { - const { projectionAuthority } = projection + let outputProjections = [] + if (supportedOutputProjections) { + outputProjections = supportedOutputProjections.filter((projection) => { + const { projectionAuthority } = projection - return projectionAuthority != null - }).map((projection) => { - const { projectionAuthority } = projection + return projectionAuthority != null + }).map((projection) => { + const { projectionAuthority } = projection - return projectionAuthority - }) - } + return projectionAuthority + }) + } - accessMethods[`harmony${index}`] = { - description, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings, - id: serviceConceptId, - isValid: true, - keywordMappings, - longName, - name, - supportedOutputFormats: uniq(outputFormats), - supportedOutputProjections: outputProjections, - supportsBoundingBoxSubsetting: supportsBoundingBoxSubsetting(serviceItem), - supportsShapefileSubsetting: supportsShapefileSubsetting(serviceItem), - supportsTemporalSubsetting: supportsTemporalSubsetting(serviceItem), - supportsVariableSubsetting: supportsVariableSubsetting(serviceItem), - supportsConcatenation: supportsConcatenation(serviceItem), - defaultConcatenation: defaultConcatenation(serviceItem), - enableConcatenateDownload: defaultConcatenation(serviceItem), - type: serviceType, - url: urlValue, - variables - } + accessMethods[`harmony${index}`] = { + description, + enableTemporalSubsetting: true, + enableSpatialSubsetting: true, + hierarchyMappings, + id: serviceConceptId, + isValid: true, + keywordMappings, + longName, + name, + supportedOutputFormats: uniq(outputFormats), + supportedOutputProjections: outputProjections, + supportsBoundingBoxSubsetting: supportsBoundingBoxSubsetting(serviceItem), + supportsShapefileSubsetting: supportsShapefileSubsetting(serviceItem), + supportsTemporalSubsetting: supportsTemporalSubsetting(serviceItem), + supportsVariableSubsetting: supportsVariableSubsetting(serviceItem), + supportsConcatenation: supportsConcatenation(serviceItem), + defaultConcatenation: defaultConcatenation(serviceItem), + enableConcatenateDownload: defaultConcatenation(serviceItem), + type: serviceType, + url: urlValue, + variables } return accessMethods diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js b/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js index 683f03c558..b116f5cbf0 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js @@ -3,6 +3,12 @@ import { uniq } from 'lodash' import { getVariables } from '../getVariables' import { supportsVariableSubsetting } from '../supportsVariableSubsetting' +/** + * Builds the oPeNDAP access method + * @param {object} serviceItem serviceItem in the Collection Metadata + * @param {object} associatedVariables variables that are either in the serviceItem or collectionMetadata (prioritizes the serviceItem variables) + * @returns {object} Access method for oPeNDAP + */ export const buildOpendap = (serviceItem, associatedVariables) => { const accessMethods = {} @@ -14,36 +20,34 @@ export const buildOpendap = (serviceItem, associatedVariables) => { supportedReformattings } = serviceItem - if (serviceType.toLowerCase() === 'opendap') { - const { - hierarchyMappings, - keywordMappings, - variables - } = getVariables(associatedVariables) - - const outputFormats = [] - - if (supportedReformattings) { - supportedReformattings.forEach((reformatting) => { - const { supportedOutputFormats } = reformatting - - // Collect all supported output formats from each mapping - outputFormats.push(...supportedOutputFormats) - }) - } - - accessMethods.opendap = { - hierarchyMappings, - id: serviceConceptId, - isValid: true, - keywordMappings, - longName, - name, - supportedOutputFormats: uniq(outputFormats), - supportsVariableSubsetting: supportsVariableSubsetting(serviceItem), - type: serviceType, - variables - } + const { + hierarchyMappings, + keywordMappings, + variables + } = getVariables(associatedVariables) + + const outputFormats = [] + + if (supportedReformattings) { + supportedReformattings.forEach((reformatting) => { + const { supportedOutputFormats } = reformatting + + // Collect all supported output formats from each mapping + outputFormats.push(...supportedOutputFormats) + }) + } + + accessMethods.opendap = { + hierarchyMappings, + id: serviceConceptId, + isValid: true, + keywordMappings, + longName, + name, + supportedOutputFormats: uniq(outputFormats), + supportsVariableSubsetting: supportsVariableSubsetting(serviceItem), + type: serviceType, + variables } return accessMethods diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js index 36980cb334..81e7a2b68b 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js @@ -1,3 +1,9 @@ +/** + * Builds the swodlr access method + * @param {object} serviceItem serviceItem in the Collection Metadata + * @param {boolean} disabledSwodlr true if the swodlr acceessMethod disabled + * @returns {object} Access method for SWODLR + */ export const buildSwodlr = (serviceItem, disableSwodlr) => { const accessMethods = {} @@ -11,7 +17,7 @@ export const buildSwodlr = (serviceItem, disableSwodlr) => { const { urlValue } = url - if (serviceType.toLowerCase() === 'swodlr' && (disableSwodlr !== 'true')) { + if (disableSwodlr !== 'true') { accessMethods.swodlr = { id: serviceConceptId, isValid: true, From d7993e25ac3e42c4803825d10d977238e12b3e71 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Fri, 19 Jul 2024 13:12:42 -0400 Subject: [PATCH 06/20] EDSC-3773: changed lodash to lodash-es --- .../js/util/accessMethods/buildAccessMethods/buildEsiEcho.js | 2 +- .../js/util/accessMethods/buildAccessMethods/buildHarmony.js | 2 +- .../js/util/accessMethods/buildAccessMethods/buildOpendap.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js index c6bb882afe..b49c7665d4 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js @@ -1,4 +1,4 @@ -import { camelCase } from 'lodash' +import { camelCase } from 'lodash-es' import { generateFormDigest } from '../generateFormDigest' /** diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js b/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js index 3cf1e2bf5e..852f709a19 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js @@ -1,4 +1,4 @@ -import { uniq } from 'lodash' +import { uniq } from 'lodash-es' import { getVariables } from '../getVariables' diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js b/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js index b116f5cbf0..380578f5a9 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js @@ -1,4 +1,4 @@ -import { uniq } from 'lodash' +import { uniq } from 'lodash-es' import { getVariables } from '../getVariables' import { supportsVariableSubsetting } from '../supportsVariableSubsetting' From e9df97433912411e45ce94ccb185d0fe204ddd29 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Mon, 22 Jul 2024 17:37:57 -0400 Subject: [PATCH 07/20] EDSC-3773: fixed the indexing issue and cleaned up some stuff --- .../__tests__/buildAccessMethods.test.js | 752 ++++++++++-------- .../util/accessMethods/buildAccessMethods.js | 103 +-- .../__tests__/buildEsiEcho.test.js | 161 +++- .../__tests__/buildSwodlr.test.js | 22 +- .../buildAccessMethods/buildEsiEcho.js | 24 +- .../buildAccessMethods/buildHarmony.js | 4 +- .../buildAccessMethods/buildSwodlr.js | 6 +- 7 files changed, 638 insertions(+), 434 deletions(-) diff --git a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js index 296286c19d..70b21ceba9 100644 --- a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js +++ b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js @@ -87,7 +87,12 @@ describe('buildAccessMethods', () => { url: { urlValue: 'https://example.com' } - }, 'true') + }, { + associatedVariables: {}, + echoIndex: 0, + esiIndex: 0, + harmonyIndex: 0 + }) }) }) @@ -134,7 +139,12 @@ describe('buildAccessMethods', () => { url: { urlValue: 'https://example.com' } - }, 'false') + }, { + associatedVariables: {}, + echoIndex: 0, + esiIndex: 0, + harmonyIndex: 0 + }) }) test('calls buildEsiEcho access method with type ESI', () => { @@ -180,7 +190,12 @@ describe('buildAccessMethods', () => { url: { urlValue: 'https://example.com' } - }, 'false') + }, { + associatedVariables: {}, + echoIndex: 0, + esiIndex: 0, + harmonyIndex: 0 + }) }) test('calls buildHarmony access method', () => { @@ -353,38 +368,42 @@ describe('buildAccessMethods', () => { } }, { - count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] - }, - 0 + associatedVariables: { + count: 4, + items: [{ + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + }] + }, + echoIndex: 0, + esiIndex: 0, + harmonyIndex: 0 + } ) }) @@ -695,69 +714,74 @@ describe('buildAccessMethods', () => { } }, { - count: 4, - items: [ - { - conceptId: 'V100000-EDSC', - definition: 'analysed_sst in units of kelvin', - longName: 'analysed_sst', - name: 'analysed_sst', - nativeId: 'e2eTestVarHiRes1', - scienceKeywords: [ - { - category: 'Earth Science', - term: 'Ocean Temperature', - topic: 'Oceans', - variableLevel1: 'Sea Surface Temperature' - } - ] - }, - { - conceptId: 'V100001-EDSC', - definition: 'analysis_error in units of kelvin', - longName: 'analysis_error', - name: 'analysis_error', - nativeId: 'e2eTestVarHiRes2', - scienceKeywords: [ - { - category: 'Earth Science', - term: 'Ocean Temperature', - topic: 'Oceans', - variableLevel1: 'Sea Surface Temperature' - } - ] - }, - { - conceptId: 'V100002-EDSC', - definition: 'mask in units of seconds since 1981-0', - longName: 'mask', - name: 'mask', - nativeId: 'e2eTestVarHiRes4', - scienceKeywords: [ - { - category: 'Earth Science', - term: 'Ocean Temperature', - topic: 'Oceans', - variableLevel1: 'Sea Surface Temperature' - } - ] - }, - { - conceptId: 'V100003-EDSC', - definition: 'sea_ice_fraction in units of fraction (between 0 ', - longName: 'sea_ice_fraction', - name: 'sea_ice_fraction', - nativeId: 'e2eTestVarHiRes3', - scienceKeywords: [ - { - category: 'Earth Science', - term: 'Ocean Temperature', - topic: 'Oceans', - variableLevel1: 'Sea Surface Temperature' - } - ] - } - ] + associatedVariables: { + count: 4, + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'analysed_sst in units of kelvin', + longName: 'analysed_sst', + name: 'analysed_sst', + nativeId: 'e2eTestVarHiRes1', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100001-EDSC', + definition: 'analysis_error in units of kelvin', + longName: 'analysis_error', + name: 'analysis_error', + nativeId: 'e2eTestVarHiRes2', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100002-EDSC', + definition: 'mask in units of seconds since 1981-0', + longName: 'mask', + name: 'mask', + nativeId: 'e2eTestVarHiRes4', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100003-EDSC', + definition: 'sea_ice_fraction in units of fraction (between 0 ', + longName: 'sea_ice_fraction', + name: 'sea_ice_fraction', + nativeId: 'e2eTestVarHiRes3', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + } + ] + }, + echoIndex: 0, + esiIndex: 0, + harmonyIndex: 0 } ) }) @@ -853,7 +877,7 @@ describe('buildAccessMethods', () => { variables: { items: [] } - }, 'false') + }) }) describe('when swodlr is disabled', () => { @@ -948,7 +972,7 @@ describe('buildAccessMethods', () => { variables: { items: [] } - }, 'true') + }) }) }) @@ -1333,38 +1357,42 @@ describe('buildAccessMethods', () => { } }, { - count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] - }, - 0 + associatedVariables: { + count: 4, + items: [{ + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + }] + }, + echoIndex: 0, + esiIndex: 0, + harmonyIndex: 0 + } ) expect(buildHarmonyMock).toHaveBeenNthCalledWith( @@ -1435,38 +1463,42 @@ describe('buildAccessMethods', () => { } }, { - count: 4, - items: [{ - conceptId: 'V100006-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3973', - scienceKeywords: null - }, { - conceptId: 'V100007-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3974', - scienceKeywords: null - }, { - conceptId: 'V100008-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3975', - scienceKeywords: null - }, { - conceptId: 'V100009-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3966', - scienceKeywords: null - }] - }, - 1 + associatedVariables: { + count: 4, + items: [{ + conceptId: 'V100006-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3973', + scienceKeywords: null + }, { + conceptId: 'V100007-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3974', + scienceKeywords: null + }, { + conceptId: 'V100008-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3975', + scienceKeywords: null + }, { + conceptId: 'V100009-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3966', + scienceKeywords: null + }] + }, + echoIndex: undefined, + esiIndex: undefined, + harmonyIndex: 1 + } ) expect(buildHarmonyMock).toHaveBeenNthCalledWith( @@ -1505,31 +1537,35 @@ describe('buildAccessMethods', () => { } }, { - count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] - }, - 2 + associatedVariables: { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + }, + echoIndex: undefined, + esiIndex: undefined, + harmonyIndex: 2 + } ) }) }) @@ -1831,31 +1867,35 @@ describe('buildAccessMethods', () => { } }, { - count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] - }, - 0 + associatedVariables: { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + }, + echoIndex: 0, + esiIndex: 0, + harmonyIndex: 0 + } ) expect(buildHarmonyMock).toHaveBeenNthCalledWith( @@ -1898,31 +1938,35 @@ describe('buildAccessMethods', () => { } }, { - count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] - }, - 1 + associatedVariables: { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + }, + echoIndex: undefined, + esiIndex: undefined, + harmonyIndex: 1 + } ) expect(buildHarmonyMock).toHaveBeenNthCalledWith( @@ -1961,31 +2005,35 @@ describe('buildAccessMethods', () => { } }, { - count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] - }, - 2 + associatedVariables: { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + }, + echoIndex: undefined, + esiIndex: undefined, + harmonyIndex: 2 + } ) }) }) @@ -2340,39 +2388,43 @@ describe('buildAccessMethods', () => { } }, { - count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null + associatedVariables: { + count: 4, + items: [{ + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + }] }, - { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] - }, - 0 + echoIndex: 0, + esiIndex: 0, + harmonyIndex: 0 + } ) expect(buildHarmonyMock).toHaveBeenNthCalledWith( @@ -2411,31 +2463,35 @@ describe('buildAccessMethods', () => { } }, { - count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] - }, - 1 + associatedVariables: { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + }, + echoIndex: undefined, + esiIndex: undefined, + harmonyIndex: 1 + } ) expect(buildHarmonyMock).toHaveBeenNthCalledWith( @@ -2474,31 +2530,35 @@ describe('buildAccessMethods', () => { } }, { - count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] - }, - 2 + associatedVariables: { + count: 3, + items: [{ + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + }] + }, + echoIndex: undefined, + esiIndex: undefined, + harmonyIndex: 2 + } ) }) }) diff --git a/static/src/js/util/accessMethods/buildAccessMethods.js b/static/src/js/util/accessMethods/buildAccessMethods.js index 5c157bfd81..ca4bfdf977 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods.js +++ b/static/src/js/util/accessMethods/buildAccessMethods.js @@ -1,5 +1,3 @@ -import { getApplicationConfig } from '../../../../../sharedUtils/config' - import { buildEsiEcho } from './buildAccessMethods/buildEsiEcho' import { buildOpendap } from './buildAccessMethods/buildOpendap' import { buildHarmony } from './buildAccessMethods/buildHarmony' @@ -20,56 +18,69 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => { } = collectionMetadata let harmonyIndex = 0 - const { items: serviceItems = null } = services + let echoIndex = 0 + let esiIndex = 0 - const { disableOrdering, disableSwodlr } = getApplicationConfig() + const { items: serviceItems = null } = services const buildMethods = { - esi: (serviceItem, params) => buildEsiEcho(serviceItem, params.disableOrdering), - 'echo orders': (serviceItem, params) => buildEsiEcho(serviceItem, params.disableOrdering), - opendap: (serviceItem, params) => buildOpendap(serviceItem, params.associatedVariables), - // eslint-disable-next-line max-len - harmony: (serviceItem, params) => buildHarmony(serviceItem, params.associatedVariables, params.harmonyIndex), - swodlr: (serviceItem, params) => buildSwodlr(serviceItem, params.disableSwodlr), + esi: (serviceItem, params) => buildEsiEcho(serviceItem, params), + 'echo orders': (serviceItem, params) => buildEsiEcho(serviceItem, params), + opendap: (serviceItem, params) => buildOpendap(serviceItem, params), + harmony: (serviceItem, params) => buildHarmony(serviceItem, params), + swodlr: (serviceItem) => buildSwodlr(serviceItem), downloads: () => buildDownload(granules, isOpenSearch) } - const nonDownloadMethods = serviceItems !== null ? serviceItems.reduce((methods, serviceItem) => { - let associatedVariables = collectionAssociatedVariables - const { - type: serviceType, - variables: serviceAssociatedVariables = {} - } = serviceItem - - // Overwrite variables if there are variables associated to the service record - if (serviceAssociatedVariables.items && serviceAssociatedVariables.items.length > 0) { - associatedVariables = serviceAssociatedVariables - } - - const lowerServiceType = serviceType.toLowerCase() - - // Only process service types that EDSC supports - const supportedServiceTypes = ['esi', 'echo orders', 'opendap', 'harmony', 'swodlr'] - if (!supportedServiceTypes.includes(lowerServiceType)) return {} - - const params = { - disableOrdering, - harmonyIndex, - associatedVariables, - disableSwodlr - } - - const updatedMethods = { - ...methods, - ...buildMethods[lowerServiceType](serviceItem, params) - } - - if (lowerServiceType === 'harmony') { - harmonyIndex += 1 - } - - return updatedMethods - }, {}) : {} + const nonDownloadMethods = serviceItems === null + ? {} + : serviceItems.reduce((methods, serviceItem) => { + let associatedVariables = collectionAssociatedVariables + const { + type: serviceType, + variables: serviceAssociatedVariables = {} + } = serviceItem + + // Overwrite variables if there are variables associated to the service record + if (serviceAssociatedVariables.items && serviceAssociatedVariables.items.length > 0) { + associatedVariables = serviceAssociatedVariables + } + + const lowerServiceType = serviceType.toLowerCase() + + // Only process service types that EDSC supports + const supportedServiceTypes = ['esi', 'echo orders', 'opendap', 'harmony', 'swodlr'] + if (!supportedServiceTypes.includes(lowerServiceType)) return {} + + const params = { + harmonyIndex, + echoIndex, + esiIndex, + associatedVariables + } + + const builtMethod = buildMethods[lowerServiceType](serviceItem, params) + + const { + accessMethods: newAccessMethods, + esiIndex: newEsiIndex, + echoIndex: newEchoIndex + } = builtMethod + + esiIndex = newEsiIndex + echoIndex = newEchoIndex + + const updatedMethods = { + ...methods, + ...newAccessMethods + } + + if (lowerServiceType === 'harmony') { + harmonyIndex += 1 + } + + return updatedMethods + }, {}) const accessMethods = { ...nonDownloadMethods, diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js index aaa6dc3290..3560e8fe09 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js @@ -1,5 +1,17 @@ import { buildEsiEcho } from '../buildEsiEcho' +import * as getApplicationConfig from '../../../../../../../sharedUtils/config' + +beforeEach(() => { + jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ + disableOrdering: 'false' + })) +}) + +afterEach(() => { + jest.clearAllMocks() +}) + describe('buildEsiEcho', () => { test('returns an esi access method', () => { const collectionMetadata = { @@ -19,12 +31,23 @@ describe('buildEsiEcho', () => { }] } } - const disabledOrdering = false const { services } = collectionMetadata const serviceItem = services.items[0] - const methods = buildEsiEcho(serviceItem, disabledOrdering) + const params = { + esiIndex: 0, + echoIndex: 0 + } + + const { + accessMethods: methods, + esiIndex: newEsiIndex, + echoIndex: newEchoIndex + } = buildEsiEcho(serviceItem, params) + + expect(newEsiIndex).toEqual(1) + expect(newEchoIndex).toEqual(0) expect(methods).toEqual({ esi0: { @@ -54,6 +77,25 @@ describe('buildEsiEcho', () => { conceptId: 'OO10000-EDSC', name: 'mock form', form: 'mock form' + }, + { + conceptId: 'OO30000-EDSC', + name: 'mock form', + form: 'mock form' + }] + } + }, + { + type: 'ESI', + url: { + urlValue: 'https://example.com' + }, + maxItemsPerOrder: 2000, + orderOptions: { + items: [{ + conceptId: 'OO20000-EDSC', + name: 'mock form', + form: 'mock form' }] } }] @@ -61,13 +103,33 @@ describe('buildEsiEcho', () => { } const { services } = collectionMetadata - const serviceItem = services.items[0] + const serviceItem0 = services.items[0] + const serviceItem1 = services.items[1] - const disabledOrdering = false + const params = { + esiIndex: 0, + echoIndex: 0 + } - const methods = buildEsiEcho(serviceItem, disabledOrdering) + const { + accessMethods: echoMethods, + esiIndex: newEsiIndex, + echoIndex: newEchoIndex + } = buildEsiEcho(serviceItem0, params) - expect(methods).toEqual({ + params.esiIndex = newEsiIndex + params.echoIndex = newEchoIndex + + const { + accessMethods: esiMethods, + esiIndex: finalEsiIndex, + echoIndex: finalEchoIndex + } = buildEsiEcho(serviceItem1, params) + + expect(finalEchoIndex).toEqual(2) + expect(finalEsiIndex).toEqual(1) + + expect(echoMethods).toEqual({ echoOrder0: { form: 'mock form', formDigest: '75f9480053e9ba083665951820d17ae5c2139d92', @@ -78,37 +140,78 @@ describe('buildEsiEcho', () => { type: 'ECHO ORDERS', maxItemsPerOrder: 2000, url: 'https://example.com' + }, + echoOrder1: { + form: 'mock form', + formDigest: '75f9480053e9ba083665951820d17ae5c2139d92', + optionDefinition: { + conceptId: 'OO30000-EDSC', + name: 'mock form' + }, + type: 'ECHO ORDERS', + maxItemsPerOrder: 2000, + url: 'https://example.com' + } + }) + + expect(esiMethods).toEqual({ + esi0: { + form: 'mock form', + formDigest: '75f9480053e9ba083665951820d17ae5c2139d92', + optionDefinition: { + conceptId: 'OO20000-EDSC', + name: 'mock form' + }, + type: 'ESI', + maxItemsPerOrder: 2000, + url: 'https://example.com' } }) }) - test('returns empty when ordering disabled', () => { - const collectionMetadata = { - services: { - items: [{ - type: 'ECHO ORDERS', - url: { - urlValue: 'https://example.com' - }, - maxItemsPerOrder: 2000, - orderOptions: { - items: [{ - conceptId: 'OO10000-EDSC', - name: 'mock form', - form: 'mock form' - }] - } - }] + describe('diabledOrders', () => { + test('returns empty when ordering disabled', () => { + jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ + disableOrdering: 'true' + })) + + const collectionMetadata = { + services: { + items: [{ + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + }, + maxItemsPerOrder: 2000, + orderOptions: { + items: [{ + conceptId: 'OO10000-EDSC', + name: 'mock form', + form: 'mock form' + }] + } + }] + } } - } - const { services } = collectionMetadata - const serviceItem = services.items[0] + const { services } = collectionMetadata + const serviceItem = services.items[0] + + const params = { + esiIndex: 0, + echoIndex: 0 + } - const disabledOrdering = 'true' + const { + accessMethods: methods, + esiIndex: newEsiIndex, + echoIndex: newEchoIndex + } = buildEsiEcho(serviceItem, params) - const methods = buildEsiEcho(serviceItem, disabledOrdering) + expect(newEsiIndex).toEqual(0) + expect(newEchoIndex).toEqual(0) - expect(methods).toEqual({}) + expect(methods).toEqual({}) + }) }) }) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildSwodlr.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildSwodlr.test.js index 1a0ef92036..d73ab21958 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildSwodlr.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildSwodlr.test.js @@ -1,5 +1,13 @@ import { buildSwodlr } from '../buildSwodlr' +import * as getApplicationConfig from '../../../../../../../sharedUtils/config' + +beforeEach(() => { + jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ + disableSwodlr: 'false' + })) +}) + describe('buildSwodlr', () => { test('returns an swodlr access method', () => { const collectionMetadata = { @@ -48,9 +56,7 @@ describe('buildSwodlr', () => { const { services } = collectionMetadata const serviceItem = services.items[0] - const disableSwodlr = false - - const methods = buildSwodlr(serviceItem, disableSwodlr) + const methods = buildSwodlr(serviceItem) expect(methods).toEqual({ swodlr: { @@ -66,6 +72,12 @@ describe('buildSwodlr', () => { }) describe('when swodlr is disabled', () => { + beforeEach(() => { + jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ + disableSwodlr: 'true' + })) + }) + test('no swodlr access method is returned', () => { const collectionMetadata = { services: { @@ -113,9 +125,7 @@ describe('buildSwodlr', () => { const { services } = collectionMetadata const serviceItem = services.items[0] - const disableSwodlr = 'true' - - const methods = buildSwodlr(serviceItem, disableSwodlr) + const methods = buildSwodlr(serviceItem) expect(methods).toEqual({}) }) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js index b49c7665d4..f2230efb3f 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js @@ -1,4 +1,7 @@ import { camelCase } from 'lodash-es' + +import { getApplicationConfig } from '../../../../../../sharedUtils/config' + import { generateFormDigest } from '../generateFormDigest' /** @@ -7,10 +10,20 @@ import { generateFormDigest } from '../generateFormDigest' * @param {boolean} disabledOrdering true if ordering is disabled * @returns {object} Access method for ESI or Echo Orders */ -export const buildEsiEcho = (serviceItem, disableOrdering) => { +export const buildEsiEcho = (serviceItem, params) => { const accessMethods = {} // Only process orderOptions if the service type uses orderOptions // Do not include access if orders are disabled + const { disableOrdering } = getApplicationConfig() + + // Pull out the esi and echo indeces and increment them to have an accurate count + const { + esiIndex: initEsiIndex, + echoIndex: initEchoIndex + } = params + + let esiIndex = initEsiIndex + let echoIndex = initEchoIndex const { orderOptions, @@ -25,9 +38,6 @@ export const buildEsiEcho = (serviceItem, disableOrdering) => { const { items: orderOptionsItems } = orderOptions if (orderOptionsItems === null) return {} - let esiIndex = 0 - let echoIndex = 0 - orderOptionsItems.forEach((orderOptionItem) => { const { conceptId: orderOptionConceptId, @@ -61,5 +71,9 @@ export const buildEsiEcho = (serviceItem, disableOrdering) => { }) } - return accessMethods + return { + accessMethods, + echoIndex, + esiIndex + } } diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js b/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js index 852f709a19..ded5fb930b 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js @@ -16,9 +16,11 @@ import { supportsVariableSubsetting } from '../supportsVariableSubsetting' * @param {integer} index the harmony index for this harmony service item * @returns {object} Access method for Harmony */ -export const buildHarmony = (serviceItem, associatedVariables, index) => { +export const buildHarmony = (serviceItem, params) => { const accessMethods = {} + const { associatedVariables, index } = params + const { description, conceptId: serviceConceptId, diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js index 81e7a2b68b..923dff1d19 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js @@ -1,12 +1,16 @@ +import { getApplicationConfig } from '../../../../../../sharedUtils/config' + /** * Builds the swodlr access method * @param {object} serviceItem serviceItem in the Collection Metadata * @param {boolean} disabledSwodlr true if the swodlr acceessMethod disabled * @returns {object} Access method for SWODLR */ -export const buildSwodlr = (serviceItem, disableSwodlr) => { +export const buildSwodlr = (serviceItem) => { const accessMethods = {} + const { disableSwodlr } = getApplicationConfig() + const { conceptId: serviceConceptId, longName, From 5c49a419a4014fc7c4be3dd9613e4f9760c2080c Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Tue, 23 Jul 2024 10:28:21 -0400 Subject: [PATCH 08/20] EDSC-3773: fixed harmony tests --- .../__tests__/buildHarmony.test.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js index c16f088d1d..c47511f0f1 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js @@ -124,7 +124,12 @@ describe('buildHarmony', () => { const index = 0 - const methods = buildHarmony(serviceItem, associatedVariables, index) + const params = { + associatedVariables, + index + } + + const methods = buildHarmony(serviceItem, params) expect(methods).toEqual({ harmony0: { @@ -527,11 +532,18 @@ describe('buildHarmony', () => { associatedVariables = serviceAssociatedVariables } + const params = { + associatedVariables, + index + } + methods = { // eslint-disable-next-line no-plusplus - ...buildHarmony(serviceItem, associatedVariables, index++), + ...buildHarmony(serviceItem, params), ...methods } + + index += 1 }) expect(methods).toEqual({ From b111fab71171d4d0eb246f5aa31cdfc72b18b31a Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Wed, 24 Jul 2024 14:05:31 -0400 Subject: [PATCH 09/20] EDSC-3773: addressed matthew's comments --- .../__tests__/buildAccessMethods.test.js | 168 +----------------- .../__tests__/buildEsiEcho.test.js | 4 +- .../buildAccessMethods/buildEsiEcho.js | 28 +-- .../buildAccessMethods/buildSwodlr.js | 19 +- 4 files changed, 32 insertions(+), 187 deletions(-) diff --git a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js index 70b21ceba9..39320b5f5c 100644 --- a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js +++ b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js @@ -10,7 +10,8 @@ import * as getApplicationConfig from '../../../../../../sharedUtils/config' beforeEach(() => { jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ - disableOrdering: 'false' + disableOrdering: 'false', + disableSwodlr: 'false' })) }) @@ -18,7 +19,7 @@ afterEach(() => { jest.clearAllMocks() }) -describe('buildAccessMethods', () => { +describe('when buildAccessMethods is called', () => { test('calls buildDownload access method', () => { const buildDownloadMock = jest.spyOn(buildDownload, 'buildDownload') buildDownloadMock.mockImplementationOnce(() => jest.fn()) @@ -39,63 +40,6 @@ describe('buildAccessMethods', () => { expect(buildDownloadMock).toBeCalledWith({ items: [{ online_access_flag: true }] }, false) }) - describe('when ordering is disabled', () => { - test('calls buildEcho access method and no echo-order access method is returned', () => { - const buildEsiEchoMock = jest.spyOn(buildEsiEcho, 'buildEsiEcho') - buildEsiEchoMock.mockImplementationOnce(() => jest.fn()) - - jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ - disableOrdering: 'true' - })) - - const collectionMetadata = { - services: { - items: [{ - type: 'ECHO ORDERS', - url: { - urlValue: 'https://example.com' - }, - maxItemsPerOrder: 2000, - orderOptions: { - items: [{ - conceptId: 'OO10000-EDSC', - name: 'mock form', - form: 'mock form' - }] - } - }] - } - } - const isOpenSearch = false - - buildAccessMethods(collectionMetadata, isOpenSearch) - - expect(buildEsiEchoMock).toBeCalledTimes(1) - - expect(buildEsiEchoMock).toHaveBeenCalledWith({ - maxItemsPerOrder: 2000, - orderOptions: { - items: [ - { - conceptId: 'OO10000-EDSC', - form: 'mock form', - name: 'mock form' - } - ] - }, - type: 'ECHO ORDERS', - url: { - urlValue: 'https://example.com' - } - }, { - associatedVariables: {}, - echoIndex: 0, - esiIndex: 0, - harmonyIndex: 0 - }) - }) - }) - test('calls buildEsiEcho access method with type ECHO ORDERS', () => { const buildEsiEchoMock = jest.spyOn(buildEsiEcho, 'buildEsiEcho') buildEsiEchoMock.mockImplementationOnce(() => jest.fn()) @@ -787,10 +731,6 @@ describe('buildAccessMethods', () => { }) test('calls buildSwodlr access method', () => { - jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ - disableSwodlr: 'false' - })) - const buildSwodlrMock = jest.spyOn(buildSwodlr, 'buildSwodlr') buildSwodlrMock.mockImplementationOnce(() => jest.fn()) @@ -880,103 +820,7 @@ describe('buildAccessMethods', () => { }) }) - describe('when swodlr is disabled', () => { - test('calls buildSwodlr but no swodlr access method is returned', () => { - jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ - disableSwodlr: 'true' - })) - - const buildSwodlrMock = jest.spyOn(buildSwodlr, 'buildSwodlr') - buildSwodlrMock.mockImplementationOnce(() => jest.fn()) - - const collectionMetadata = { - services: { - items: [ - { - conceptId: 'S100000-EDSC', - longName: 'Mock PODAAC SWOT On-Demand Level 2 Raster Generation (SWODLR)', - name: 'Mock PODAAC_SWODLR', - type: 'SWODLR', - url: { - description: 'Service top-level URL', - urlValue: 'https://swodlr.podaac.earthdatacloud.nasa.gov' - }, - serviceOptions: { - supportedOutputProjections: [ - { - projectionName: 'Universal Transverse Mercator' - }, - { - projectionName: 'WGS84 - World Geodetic System 1984' - } - ] - }, - supportedOutputProjections: [ - { - projectionName: 'Universal Transverse Mercator' - }, - { - projectionName: 'WGS84 - World Geodetic System 1984' - } - ], - supportedReformattings: null, - supportedInputProjections: null, - orderOptions: { - items: [] - }, - variables: { - items: [] - } - } - ] - } - } - const isOpenSearch = false - - buildAccessMethods(collectionMetadata, isOpenSearch) - - expect(buildSwodlrMock).toBeCalledTimes(1) - - expect(buildSwodlrMock).toHaveBeenCalledWith({ - conceptId: 'S100000-EDSC', - longName: 'Mock PODAAC SWOT On-Demand Level 2 Raster Generation (SWODLR)', - name: 'Mock PODAAC_SWODLR', - orderOptions: { - items: [] - }, - serviceOptions: { - supportedOutputProjections: [ - { - projectionName: 'Universal Transverse Mercator' - }, - { - projectionName: 'WGS84 - World Geodetic System 1984' - } - ] - }, - supportedInputProjections: null, - supportedOutputProjections: [ - { - projectionName: 'Universal Transverse Mercator' - }, - { - projectionName: 'WGS84 - World Geodetic System 1984' - } - ], - supportedReformattings: null, - type: 'SWODLR', - url: { - description: 'Service top-level URL', - urlValue: 'https://swodlr.podaac.earthdatacloud.nasa.gov' - }, - variables: { - items: [] - } - }) - }) - }) - - describe('when the collection contains both variables associated to its services and variables directly associated to the collection', () => { + describe('when the collection contains both variables associated to its services and variables directly associated to the collection and 3 service records', () => { test('variables on the service are returned instead of variables directly associated to the collection and buildHarmony is called 3 times', () => { const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') buildHarmonyMock.mockImplementationOnce(() => jest.fn()) @@ -1570,7 +1414,7 @@ describe('buildAccessMethods', () => { }) }) - describe('when the collection contains variables directly associated to the collection and no variables associated to it services (empty)', () => { + describe('when the collection contains variables directly associated to the collection and no variables associated to it services (empty) and 3 service records', () => { test('variables on the collection are returned instead of variables associated to the service and buildHarmony is called 3 times', () => { const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') buildHarmonyMock.mockImplementationOnce(() => jest.fn()) @@ -2038,7 +1882,7 @@ describe('buildAccessMethods', () => { }) }) - describe('when the collection contains variables directly associated to the collection and some variables associated to some services', () => { + describe('when the collection contains variables directly associated to the collection and some variables associated to some services and 3 service records', () => { test('variables on the collection are returned for services without variables but, variables associated to the service are returned for services that have them and buildHarmony is called 3 times', () => { const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') buildHarmonyMock.mockImplementationOnce(() => jest.fn()) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js index 3560e8fe09..db85ca6672 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js @@ -169,8 +169,8 @@ describe('buildEsiEcho', () => { }) }) - describe('diabledOrders', () => { - test('returns empty when ordering disabled', () => { + describe('when ordering is disabled', () => { + test('returns an empty object', () => { jest.spyOn(getApplicationConfig, 'getApplicationConfig').mockImplementation(() => ({ disableOrdering: 'true' })) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js index f2230efb3f..480b5146c0 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js @@ -16,23 +16,23 @@ export const buildEsiEcho = (serviceItem, params) => { // Do not include access if orders are disabled const { disableOrdering } = getApplicationConfig() - // Pull out the esi and echo indeces and increment them to have an accurate count - const { - esiIndex: initEsiIndex, - echoIndex: initEchoIndex - } = params + if (disableOrdering !== 'true') { + // Pull out the esi and echo indeces and increment them to have an accurate count + const { + esiIndex: initEsiIndex, + echoIndex: initEchoIndex + } = params - let esiIndex = initEsiIndex - let echoIndex = initEchoIndex + let esiIndex = initEsiIndex + let echoIndex = initEchoIndex - const { - orderOptions, - type: serviceType, - url, - maxItemsPerOrder - } = serviceItem + const { + orderOptions, + type: serviceType, + url, + maxItemsPerOrder + } = serviceItem - if (disableOrdering !== 'true') { const { urlValue } = url const { items: orderOptionsItems } = orderOptions diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js index 923dff1d19..6d886c4d5f 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js @@ -11,17 +11,18 @@ export const buildSwodlr = (serviceItem) => { const { disableSwodlr } = getApplicationConfig() - const { - conceptId: serviceConceptId, - longName, - name, - type: serviceType, - url - } = serviceItem + if (disableSwodlr !== 'true') { + const { + conceptId: serviceConceptId, + longName, + name, + type: serviceType, + url + } = serviceItem + + const { urlValue } = url - const { urlValue } = url - if (disableSwodlr !== 'true') { accessMethods.swodlr = { id: serviceConceptId, isValid: true, From 84d7d88895bdd0207f81eacfce155f9bef9c598a Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Thu, 25 Jul 2024 10:21:17 -0400 Subject: [PATCH 10/20] EDSC-3773: added some comments and pushed a small lint fix --- .../js/util/accessMethods/__tests__/buildAccessMethods.test.js | 2 ++ .../src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js index 39320b5f5c..b0fae975d6 100644 --- a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js +++ b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js @@ -1239,6 +1239,7 @@ describe('when buildAccessMethods is called', () => { } ) + // Checks also that harmony increments it's index correctly expect(buildHarmonyMock).toHaveBeenNthCalledWith( 2, { @@ -1345,6 +1346,7 @@ describe('when buildAccessMethods is called', () => { } ) + // Checks also that harmony increments it's index correctly expect(buildHarmonyMock).toHaveBeenNthCalledWith( 3, { diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js index 6d886c4d5f..8704ccc5b1 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js @@ -22,7 +22,6 @@ export const buildSwodlr = (serviceItem) => { const { urlValue } = url - accessMethods.swodlr = { id: serviceConceptId, isValid: true, From 62d8a4849609dfbf8404cf32661d629f3a4b40e9 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Thu, 25 Jul 2024 11:49:00 -0400 Subject: [PATCH 11/20] EDSC-3773: fixed some eslint issues --- .../buildAccessMethods/buildEsiEcho.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js index 480b5146c0..8de435c43c 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js @@ -16,16 +16,16 @@ export const buildEsiEcho = (serviceItem, params) => { // Do not include access if orders are disabled const { disableOrdering } = getApplicationConfig() - if (disableOrdering !== 'true') { - // Pull out the esi and echo indeces and increment them to have an accurate count - const { - esiIndex: initEsiIndex, - echoIndex: initEchoIndex - } = params + const { + esiIndex: initEsiIndex, + echoIndex: initEchoIndex + } = params - let esiIndex = initEsiIndex - let echoIndex = initEchoIndex + let esiIndex = initEsiIndex + let echoIndex = initEchoIndex + if (disableOrdering !== 'true') { + // Pull out the esi and echo indeces and increment them to have an accurate count const { orderOptions, type: serviceType, From 898652cdc84c10d4306e445950e1b4f3ec14f0fc Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Thu, 25 Jul 2024 16:59:58 -0400 Subject: [PATCH 12/20] fixed some wording --- .../buildAccessMethods/__tests__/buildHarmony.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js index c47511f0f1..a250413ea2 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js @@ -209,7 +209,7 @@ describe('buildHarmony', () => { }) }) - test('increments index correctly for multiple harmony items', () => { + test('correctly builds multiple harmony items', () => { const collectionMetadata = { services: { items: [{ From 1ab50258694109da0992562c6cbfd98d53451544 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Mon, 29 Jul 2024 13:11:27 -0400 Subject: [PATCH 13/20] EDSC-3773: added a test that needs to be finished in buildAccessMethods --- .../util/accessMethods/__tests__/buildAccessMethods.test.js | 4 ++++ .../buildAccessMethods/__tests__/buildEsiEcho.test.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js index b0fae975d6..f990762d29 100644 --- a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js +++ b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js @@ -820,6 +820,10 @@ describe('when buildAccessMethods is called', () => { }) }) + describe('calls complex compilation of mutliple different access methods', () => { + + }) + describe('when the collection contains both variables associated to its services and variables directly associated to the collection and 3 service records', () => { test('variables on the service are returned instead of variables directly associated to the collection and buildHarmony is called 3 times', () => { const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js index db85ca6672..a0675648ea 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js @@ -63,7 +63,7 @@ describe('buildEsiEcho', () => { }) }) - test('returns an echo orders access method', () => { + test('returns an echo orders access method and indexes are incremented correctly', () => { const collectionMetadata = { services: { items: [{ From 737fe813b1a7be47e764a7d1456e3ca2a1f81099 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Mon, 19 Aug 2024 10:58:17 -0400 Subject: [PATCH 14/20] EDSC-3773: fixed up the format and tests of Harmony, Opendap, and Swodlr results to match Esi and Echo Orders --- .../util/accessMethods/buildAccessMethods.js | 7 + .../__tests__/buildHarmony.test.js | 428 +++++++++--------- .../__tests__/buildOpendap.test.js | 5 +- .../__tests__/buildSwodlr.test.js | 8 +- .../buildAccessMethods/buildHarmony.js | 6 +- .../buildAccessMethods/buildOpendap.js | 4 +- .../buildAccessMethods/buildSwodlr.js | 4 +- 7 files changed, 242 insertions(+), 220 deletions(-) diff --git a/static/src/js/util/accessMethods/buildAccessMethods.js b/static/src/js/util/accessMethods/buildAccessMethods.js index ca4bfdf977..d5de9b4789 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods.js +++ b/static/src/js/util/accessMethods/buildAccessMethods.js @@ -21,6 +21,9 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => { let echoIndex = 0 let esiIndex = 0 + console.log(collectionMetadata) + console.log(services) + const { items: serviceItems = null } = services const buildMethods = { @@ -32,9 +35,13 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => { downloads: () => buildDownload(granules, isOpenSearch) } + console.log(serviceItems) + const nonDownloadMethods = serviceItems === null ? {} : serviceItems.reduce((methods, serviceItem) => { + console.log(methods) + console.log(serviceItem) let associatedVariables = collectionAssociatedVariables const { type: serviceType, diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js index a250413ea2..d268504034 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js @@ -122,16 +122,16 @@ describe('buildHarmony', () => { const { services, variables: associatedVariables } = collectionMetadata const serviceItem = services.items[0] - const index = 0 + const harmonyIndex = 0 const params = { associatedVariables, - index + harmonyIndex } - const methods = buildHarmony(serviceItem, params) + const { accessMethods } = buildHarmony(serviceItem, params) - expect(methods).toEqual({ + expect(accessMethods).toEqual({ harmony0: { description: 'abc123', enableTemporalSubsetting: true, @@ -212,35 +212,62 @@ describe('buildHarmony', () => { test('correctly builds multiple harmony items', () => { const collectionMetadata = { services: { - items: [{ - conceptId: 'S100000-EDSC', - longName: 'Mock Service Name', - name: 'mock-name', - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example.com' - }, - serviceOptions: { - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false + items: [ + { + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + description: 'Mock Name', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true } }, - variableSubset: { - allowMultipleValues: true - } + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] }, supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' + projectionName: 'Polar Stereographic', + projectionAuthority: 'Polar Stereographic' }, { - projectionName: 'Geographic' + projectionName: 'Geographic', + projectionAuthority: 'Geographic' }], - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], supportedReformattings: [{ supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ @@ -257,93 +284,91 @@ describe('buildHarmony', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic', - projectionAuthority: 'Polar Stereographic' - }, { - projectionName: 'Geographic', - projectionAuthority: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] + }], + variables: { + count: 4, + items: [{ + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + }] + } }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }], - variables: { - count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] - } - }, { - conceptId: 'S100001-EDSC', - longName: 'Mock Service Name 2', - name: 'mock-name 2', - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example2.com' - }, - serviceOptions: { - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false + conceptId: 'S100001-EDSC', + longName: 'Mock Service Name 2', + name: 'mock-name 2', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example2.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true } }, - variableSubset: { - allowMultipleValues: true - } + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] }, supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], supportedReformattings: [{ supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ @@ -360,92 +385,92 @@ describe('buildHarmony', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }], - variables: { - count: 4, - items: [{ - conceptId: 'V100006-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3973', - scienceKeywords: null - }, { - conceptId: 'V100007-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3974', - scienceKeywords: null - }, { - conceptId: 'V100008-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3975', - scienceKeywords: null - }, { - conceptId: 'V100009-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3966', - scienceKeywords: null - }] - } - }, - { - conceptId: 'S100002-EDSC', - longName: 'Mock Service Name 3', - name: 'mock-name 3', - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example3.com' + }], + variables: { + count: 4, + items: [{ + conceptId: 'V100006-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3973', + scienceKeywords: null + }, { + conceptId: 'V100007-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3974', + scienceKeywords: null + }, { + conceptId: 'V100008-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3975', + scienceKeywords: null + }, { + conceptId: 'V100009-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3966', + scienceKeywords: null + }] + } }, - serviceOptions: { - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false + { + conceptId: 'S100002-EDSC', + longName: 'Mock Service Name 3', + name: 'mock-name 3', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example3.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true } }, - variableSubset: { - allowMultipleValues: true - } + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] }, supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], supportedReformattings: [{ supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ @@ -463,30 +488,7 @@ describe('buildHarmony', () => { 'NETCDF-4' ] }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] }] - }] }, variables: { count: 3, @@ -518,7 +520,7 @@ describe('buildHarmony', () => { const { services, variables: collectionAssociatedVariables = {} } = collectionMetadata const { items: serviceItems = null } = services - let index = 0 + let harmonyIndex = 0 let methods = {} serviceItems.forEach((serviceItem) => { @@ -534,16 +536,21 @@ describe('buildHarmony', () => { const params = { associatedVariables, - index + harmonyIndex } + const harmonyResult = buildHarmony(serviceItem, params) + + const { + accessMethods + } = harmonyResult + methods = { - // eslint-disable-next-line no-plusplus - ...buildHarmony(serviceItem, params), + ...accessMethods, ...methods } - index += 1 + harmonyIndex += 1 }) expect(methods).toEqual({ @@ -552,6 +559,7 @@ describe('buildHarmony', () => { enableConcatenateDownload: false, enableTemporalSubsetting: true, enableSpatialSubsetting: true, + description: 'Mock Name', hierarchyMappings: [ { id: 'V100000-EDSC' diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildOpendap.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildOpendap.test.js index 44b2ead686..96a53b4fd2 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildOpendap.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildOpendap.test.js @@ -153,8 +153,9 @@ describe('buildOpendap', () => { associatedVariables = serviceAssociatedVariables } - const methods = buildOpendap(serviceItem, associatedVariables) - expect(methods).toEqual({ + const { accessMethods } = buildOpendap(serviceItem, associatedVariables) + + expect(accessMethods).toEqual({ opendap: { hierarchyMappings: [{ id: 'V100000-EDSC' diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildSwodlr.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildSwodlr.test.js index d73ab21958..3f08f96229 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildSwodlr.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildSwodlr.test.js @@ -56,9 +56,9 @@ describe('buildSwodlr', () => { const { services } = collectionMetadata const serviceItem = services.items[0] - const methods = buildSwodlr(serviceItem) + const { accessMethods } = buildSwodlr(serviceItem) - expect(methods).toEqual({ + expect(accessMethods).toEqual({ swodlr: { id: 'S100000-EDSC', isValid: true, @@ -125,9 +125,9 @@ describe('buildSwodlr', () => { const { services } = collectionMetadata const serviceItem = services.items[0] - const methods = buildSwodlr(serviceItem) + const { accessMethods } = buildSwodlr(serviceItem) - expect(methods).toEqual({}) + expect(accessMethods).toEqual({}) }) }) }) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js b/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js index ded5fb930b..292e2a6db8 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js @@ -19,7 +19,7 @@ import { supportsVariableSubsetting } from '../supportsVariableSubsetting' export const buildHarmony = (serviceItem, params) => { const accessMethods = {} - const { associatedVariables, index } = params + const { associatedVariables, harmonyIndex: index } = params const { description, @@ -90,5 +90,7 @@ export const buildHarmony = (serviceItem, params) => { variables } - return accessMethods + return { + accessMethods + } } diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js b/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js index 380578f5a9..9a3b67f95e 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildOpendap.js @@ -50,5 +50,7 @@ export const buildOpendap = (serviceItem, associatedVariables) => { variables } - return accessMethods + return { + accessMethods + } } diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js index 8704ccc5b1..8c901171aa 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildSwodlr.js @@ -33,5 +33,7 @@ export const buildSwodlr = (serviceItem) => { } } - return accessMethods + return { + accessMethods + } } From 3d22271a4c1ce874052c8a503ba50a318819bcf7 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Mon, 19 Aug 2024 11:06:39 -0400 Subject: [PATCH 15/20] EDSC-3773: removed console.logs --- .eslintrc | 15 ++++++++++----- .../js/util/accessMethods/buildAccessMethods.js | 7 ------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.eslintrc b/.eslintrc index 9865829bf5..93b2bd4139 100644 --- a/.eslintrc +++ b/.eslintrc @@ -7,9 +7,16 @@ }, "rules": { // Allowing cyclic dependancies - "import/no-cycle": "off" + "import/no-cycle": "off", + "import/no-unresolved": [ + "error", + { + "ignore": [ + "^@edsc/earthdata-react-icons/.+" + ] + } + ] }, - "overrides": [ { "files": [ @@ -28,12 +35,10 @@ } } ], - // Use AirBnb settings as a base "extends": [ "@edsc" ], - // Define version settings "settings": { "react": { @@ -41,4 +46,4 @@ "version": "16.12.0" } } -} +} \ No newline at end of file diff --git a/static/src/js/util/accessMethods/buildAccessMethods.js b/static/src/js/util/accessMethods/buildAccessMethods.js index d5de9b4789..ca4bfdf977 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods.js +++ b/static/src/js/util/accessMethods/buildAccessMethods.js @@ -21,9 +21,6 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => { let echoIndex = 0 let esiIndex = 0 - console.log(collectionMetadata) - console.log(services) - const { items: serviceItems = null } = services const buildMethods = { @@ -35,13 +32,9 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => { downloads: () => buildDownload(granules, isOpenSearch) } - console.log(serviceItems) - const nonDownloadMethods = serviceItems === null ? {} : serviceItems.reduce((methods, serviceItem) => { - console.log(methods) - console.log(serviceItem) let associatedVariables = collectionAssociatedVariables const { type: serviceType, From afe3ca8b7584ea1b5ca92ac19ee9f0503c89b09a Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Tue, 27 Aug 2024 17:16:32 -0400 Subject: [PATCH 16/20] EDSC-3773: fixed up syntax/linting so it matches our standards --- .eslintrc | 2 +- .../__tests__/buildAccessMethods.test.js | 3055 ++++++++++------- .../__tests__/buildDownload.test.js | 24 +- .../__tests__/buildEsiEcho.test.js | 78 +- .../__tests__/buildHarmony.test.js | 959 +++--- .../__tests__/buildOpendap.test.js | 391 ++- 6 files changed, 2584 insertions(+), 1925 deletions(-) diff --git a/.eslintrc b/.eslintrc index 93b2bd4139..7e5d866fb0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -46,4 +46,4 @@ "version": "16.12.0" } } -} \ No newline at end of file +} diff --git a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js index f990762d29..dad962272a 100644 --- a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js +++ b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js @@ -46,20 +46,24 @@ describe('when buildAccessMethods is called', () => { const collectionMetadata = { services: { - items: [{ - type: 'ECHO ORDERS', - url: { - urlValue: 'https://example.com' - }, - maxItemsPerOrder: 2000, - orderOptions: { - items: [{ - conceptId: 'OO10000-EDSC', - name: 'mock form', - form: 'mock form' - }] + items: [ + { + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + }, + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10000-EDSC', + name: 'mock form', + form: 'mock form' + } + ] + } } - }] + ] } } const isOpenSearch = false @@ -68,27 +72,30 @@ describe('when buildAccessMethods is called', () => { expect(buildEsiEchoMock).toBeCalledTimes(1) - expect(buildEsiEchoMock).toHaveBeenCalledWith({ - maxItemsPerOrder: 2000, - orderOptions: { - items: [ - { - conceptId: 'OO10000-EDSC', - form: 'mock form', - name: 'mock form' - } - ] + expect(buildEsiEchoMock).toHaveBeenCalledWith( + { + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10000-EDSC', + form: 'mock form', + name: 'mock form' + } + ] + }, + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + } }, - type: 'ECHO ORDERS', - url: { - urlValue: 'https://example.com' + { + associatedVariables: {}, + echoIndex: 0, + esiIndex: 0, + harmonyIndex: 0 } - }, { - associatedVariables: {}, - echoIndex: 0, - esiIndex: 0, - harmonyIndex: 0 - }) + ) }) test('calls buildEsiEcho access method with type ESI', () => { @@ -97,20 +104,24 @@ describe('when buildAccessMethods is called', () => { const collectionMetadata = { services: { - items: [{ - type: 'ESI', - url: { - urlValue: 'https://example.com' - }, - maxItemsPerOrder: 2000, - orderOptions: { - items: [{ - conceptId: 'OO10000-EDSC', - name: 'mock form', - form: 'mock form' - }] + items: [ + { + type: 'ESI', + url: { + urlValue: 'https://example.com' + }, + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10000-EDSC', + name: 'mock form', + form: 'mock form' + } + ] + } } - }] + ] } } const isOpenSearch = false @@ -119,27 +130,30 @@ describe('when buildAccessMethods is called', () => { expect(buildEsiEchoMock).toBeCalledTimes(1) - expect(buildEsiEchoMock).toHaveBeenCalledWith({ - maxItemsPerOrder: 2000, - orderOptions: { - items: [ - { - conceptId: 'OO10000-EDSC', - form: 'mock form', - name: 'mock form' - } - ] + expect(buildEsiEchoMock).toHaveBeenCalledWith( + { + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10000-EDSC', + form: 'mock form', + name: 'mock form' + } + ] + }, + type: 'ESI', + url: { + urlValue: 'https://example.com' + } }, - type: 'ESI', - url: { - urlValue: 'https://example.com' + { + associatedVariables: {}, + echoIndex: 0, + esiIndex: 0, + harmonyIndex: 0 } - }, { - associatedVariables: {}, - echoIndex: 0, - esiIndex: 0, - harmonyIndex: 0 - }) + ) }) test('calls buildHarmony access method', () => { @@ -148,117 +162,134 @@ describe('when buildAccessMethods is called', () => { const collectionMetadata = { services: { - items: [{ - conceptId: 'S100000-EDSC', - longName: 'Mock Service Name', - name: 'mock-name', - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example.com' - }, - serviceOptions: { - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false + items: [ + { + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true } }, - variableSubset: { - allowMultipleValues: true - } + aggregation: { + concatenate: { + concatenateDefault: true + } + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] }, - aggregation: { - concatenate: { - concatenateDefault: true + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' } - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' ], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }], - variables: { - count: 0, - items: null + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }], + variables: { + count: 0, + items: null + } } - }] + ] }, variables: { count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, + { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } + ] } } const isOpenSearch = false @@ -284,24 +315,44 @@ describe('when buildAccessMethods is called', () => { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }] - }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }], - type: 'Harmony', + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + } + ], + type: 'Harmony', url: { description: 'Mock URL', urlValue: 'https://example.com' @@ -314,35 +365,40 @@ describe('when buildAccessMethods is called', () => { { associatedVariables: { count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, + { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } + ] }, echoIndex: 0, esiIndex: 0, @@ -367,127 +423,152 @@ describe('when buildAccessMethods is called', () => { urlValue: 'https://example.com' }, serviceOptions: { - supportedInputProjections: [{ - projectionName: 'Geographic' - }], - supportedOutputProjections: [{ + supportedInputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedOutputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'ASCII', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'BINARY', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + } + ], + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + } + }, + supportedOutputProjections: [ + { projectionName: 'Geographic' - }], - supportedReformattings: [{ + } + ], + supportedReformattings: [ + { supportedInputFormat: 'ASCII', supportedOutputFormats: [ 'ASCII', 'BINARY', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'BINARY', supportedOutputFormats: [ 'ASCII', 'BINARY', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ 'ASCII', 'BINARY', 'NETCDF-4' ] - }], - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false - } - }, - variableSubset: { - allowMultipleValues: true - } } - }, - supportedOutputProjections: [{ - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'ASCII', - supportedOutputFormats: [ - 'ASCII', - 'BINARY', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'BINARY', - supportedOutputFormats: [ - 'ASCII', - 'BINARY', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'ASCII', - 'BINARY', - 'NETCDF-4' - ] - }], + ], orderOptions: { count: 0, items: null }, variables: { count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'analysed_sst in units of kelvin', - longName: 'analysed_sst', - name: 'analysed_sst', - nativeId: 'e2eTestVarHiRes1', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] - }, { - conceptId: 'V100001-EDSC', - definition: 'analysis_error in units of kelvin', - longName: 'analysis_error', - name: 'analysis_error', - nativeId: 'e2eTestVarHiRes2', - scienceKeywords: [ - { - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - } - ] - }, { - conceptId: 'V100002-EDSC', - definition: 'mask in units of seconds since 1981-0', - longName: 'mask', - name: 'mask', - nativeId: 'e2eTestVarHiRes4', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] - }, { - conceptId: 'V100003-EDSC', - definition: 'sea_ice_fraction in units of fraction (between 0 ', - longName: 'sea_ice_fraction', - name: 'sea_ice_fraction', - nativeId: 'e2eTestVarHiRes3', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] - }] + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'analysed_sst in units of kelvin', + longName: 'analysed_sst', + name: 'analysed_sst', + nativeId: 'e2eTestVarHiRes1', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100001-EDSC', + definition: 'analysis_error in units of kelvin', + longName: 'analysis_error', + name: 'analysis_error', + nativeId: 'e2eTestVarHiRes2', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100002-EDSC', + definition: 'mask in units of seconds since 1981-0', + longName: 'mask', + name: 'mask', + nativeId: 'e2eTestVarHiRes4', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100003-EDSC', + definition: 'sea_ice_fraction in units of fraction (between 0 ', + longName: 'sea_ice_fraction', + name: 'sea_ice_fraction', + nativeId: 'e2eTestVarHiRes3', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + } + ] } }] } @@ -851,16 +932,48 @@ describe('when buildAccessMethods is called', () => { allowMultipleValues: true } }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], - supportedReformattings: [{ + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ 'GEOTIFF', @@ -868,7 +981,8 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -876,61 +990,43 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }], + }], variables: { count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, + { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } + ] } }, { conceptId: 'S100001-EDSC', @@ -952,16 +1048,49 @@ describe('when buildAccessMethods is called', () => { allowMultipleValues: true } }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], interpolationTypes: [ 'Bilinear Interpolation', 'Nearest Neighbor' ], - supportedReformattings: [{ + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ 'GEOTIFF', @@ -969,7 +1098,8 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -977,61 +1107,43 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }], + }], variables: { count: 4, - items: [{ - conceptId: 'V100006-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3973', - scienceKeywords: null - }, { - conceptId: 'V100007-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3974', - scienceKeywords: null - }, { - conceptId: 'V100008-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3975', - scienceKeywords: null - }, { - conceptId: 'V100009-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3966', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100006-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3973', + scienceKeywords: null + }, + { + conceptId: 'V100007-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3974', + scienceKeywords: null + }, + { + conceptId: 'V100008-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3975', + scienceKeywords: null + }, + { + conceptId: 'V100009-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3966', + scienceKeywords: null + } + ] } }, { @@ -1054,16 +1166,49 @@ describe('when buildAccessMethods is called', () => { allowMultipleValues: true } }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], interpolationTypes: [ 'Bilinear Interpolation', 'Nearest Neighbor' ], - supportedReformattings: [{ + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ 'GEOTIFF', @@ -1071,7 +1216,8 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -1079,56 +1225,38 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }] + } + ] }] }, variables: { count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, + { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, + { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + } + ] } } const isOpenSearch = false @@ -1149,23 +1277,63 @@ describe('when buildAccessMethods is called', () => { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }] - }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }], + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], type: 'Harmony', url: { description: 'Mock URL', @@ -1173,69 +1341,79 @@ describe('when buildAccessMethods is called', () => { }, variables: { count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, + { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } + ] } }, { associatedVariables: { count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, + { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } + ] }, echoIndex: 0, esiIndex: 0, @@ -1256,23 +1434,63 @@ describe('when buildAccessMethods is called', () => { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }] + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }], + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], type: 'Harmony', url: { description: 'Mock URL', @@ -1280,69 +1498,79 @@ describe('when buildAccessMethods is called', () => { }, variables: { count: 4, - items: [{ - conceptId: 'V100006-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3973', - scienceKeywords: null - }, { - conceptId: 'V100007-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3974', - scienceKeywords: null - }, { - conceptId: 'V100008-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3975', - scienceKeywords: null - }, { - conceptId: 'V100009-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3966', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100006-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3973', + scienceKeywords: null + }, + { + conceptId: 'V100007-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3974', + scienceKeywords: null + }, + { + conceptId: 'V100008-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3975', + scienceKeywords: null + }, + { + conceptId: 'V100009-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3966', + scienceKeywords: null + } + ] } }, { associatedVariables: { count: 4, - items: [{ - conceptId: 'V100006-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3973', - scienceKeywords: null - }, { - conceptId: 'V100007-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3974', - scienceKeywords: null - }, { - conceptId: 'V100008-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3975', - scienceKeywords: null - }, { - conceptId: 'V100009-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3966', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100006-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3973', + scienceKeywords: null + }, + { + conceptId: 'V100007-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3974', + scienceKeywords: null + }, + { + conceptId: 'V100008-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3975', + scienceKeywords: null + }, + { + conceptId: 'V100009-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3966', + scienceKeywords: null + } + ] }, echoIndex: undefined, esiIndex: undefined, @@ -1363,23 +1591,62 @@ describe('when buildAccessMethods is called', () => { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }] - }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }], + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }], type: 'Harmony', url: { description: 'Mock URL', @@ -1389,28 +1656,32 @@ describe('when buildAccessMethods is called', () => { { associatedVariables: { count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, + { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, + { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + } + ] }, echoIndex: undefined, esiIndex: undefined, @@ -1427,108 +1698,144 @@ describe('when buildAccessMethods is called', () => { const collectionMetadata = { services: { - items: [{ - conceptId: 'S100000-EDSC', - longName: 'Mock Service Name', - name: 'mock-name', - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example.com' - }, - serviceOptions: { - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false + items: [ + { + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true } }, - variableSubset: { - allowMultipleValues: true - } + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } ], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], + variables: { + count: 0, + items: [] + } }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }], - variables: { - count: 0, - items: [] - } - }, { - conceptId: 'S100001-EDSC', - longName: 'Mock Service Name 2', - name: 'mock-name 2', - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example2.com' - }, - serviceOptions: { - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false + conceptId: 'S100001-EDSC', + longName: 'Mock Service Name 2', + name: 'mock-name 2', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example2.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true } }, - variableSubset: { - allowMultipleValues: true - } + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] }, supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], supportedReformattings: [{ supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ @@ -1545,64 +1852,64 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }], - variables: { - count: 4, - items: [] - } - }, - { - conceptId: 'S100002-EDSC', - longName: 'Mock Service Name 3', - name: 'mock-name 3', - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example3.com' + }], + variables: { + count: 4, + items: [] + } }, - serviceOptions: { - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false + { + conceptId: 'S100002-EDSC', + longName: 'Mock Service Name 3', + name: 'mock-name 3', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example3.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true } }, - variableSubset: { - allowMultipleValues: true - } + supportedOutputProjections: [{ + projectionName: 'Polar Stereographic' + }, { + projectionName: 'Geographic' + }], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [{ + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] }, supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], supportedReformattings: [{ supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ @@ -1620,30 +1927,7 @@ describe('when buildAccessMethods is called', () => { 'NETCDF-4' ] }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] }] - }] }, variables: { count: 3, @@ -1684,7 +1968,10 @@ describe('when buildAccessMethods is called', () => { longName: 'Mock Service Name', name: 'mock-name', serviceOptions: { - interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], subset: { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } @@ -1755,7 +2042,10 @@ describe('when buildAccessMethods is called', () => { longName: 'Mock Service Name 2', name: 'mock-name 2', serviceOptions: { - interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], subset: { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } @@ -1826,28 +2116,71 @@ describe('when buildAccessMethods is called', () => { longName: 'Mock Service Name 3', name: 'mock-name 3', serviceOptions: { - interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], subset: { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }] - }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }], + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], type: 'Harmony', url: { description: 'Mock URL', @@ -1857,28 +2190,32 @@ describe('when buildAccessMethods is called', () => { { associatedVariables: { count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, + { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, + { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + } + ] }, echoIndex: undefined, esiIndex: undefined, @@ -1895,36 +2232,351 @@ describe('when buildAccessMethods is called', () => { const collectionMetadata = { services: { - items: [{ - conceptId: 'S100000-EDSC', - longName: 'Mock Service Name', - name: 'mock-name', - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example.com' - }, - serviceOptions: { - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false + items: [ + { + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true } }, - variableSubset: { - allowMultipleValues: true + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], + variables: { + count: 4, + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, + { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } + ] + } + }, { + conceptId: 'S100001-EDSC', + longName: 'Mock Service Name 2', + name: 'mock-name 2', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example2.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + { + conceptId: 'S100002-EDSC', + longName: 'Mock Service Name 3', + name: 'mock-name 3', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example3.com' }, - supportedOutputProjections: [{ + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + } + ] + }, + variables: { + count: 3, + items: [ + { + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, + { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, + { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + } + ] + } + } + const isOpenSearch = false + + buildAccessMethods(collectionMetadata, isOpenSearch) + + expect(buildHarmonyMock).toBeCalledTimes(3) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 1, + { + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + serviceOptions: { + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } + }, + supportedOutputProjections: [ + { projectionName: 'Polar Stereographic' - }, { + }, + { projectionName: 'Geographic' - }], - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], - supportedReformattings: [{ + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ 'GEOTIFF', @@ -1932,7 +2584,8 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -1940,14 +2593,15 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ + } + ] + }, + supportedOutputProjections: [ + { projectionName: 'Polar Stereographic' }, + { projectionName: 'Geographic' } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ 'GEOTIFF', @@ -1955,7 +2609,8 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -1963,313 +2618,88 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }], - variables: { - count: 4, - items: [{ + } + ], + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + variables: { + count: 4, + items: [ + { conceptId: 'V100000-EDSC', definition: 'Alpha channel value', longName: 'Alpha channel ', name: 'alpha_var', nativeId: 'mmt_variable_3972', scienceKeywords: null - }, { + }, + { conceptId: 'V100001-EDSC', definition: 'Blue channel value', longName: 'Blue channel', name: 'blue_var', nativeId: 'mmt_variable_3971', scienceKeywords: null - }, { + }, + { conceptId: 'V100002-EDSC', definition: 'Green channel value', longName: 'Green channel', name: 'green_var', nativeId: 'mmt_variable_3970', scienceKeywords: null - }, { + }, + { conceptId: 'V100003-EDSC', definition: 'Red channel value', longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] - } - }, { - conceptId: 'S100001-EDSC', - longName: 'Mock Service Name 2', - name: 'mock-name 2', - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example2.com' - }, - serviceOptions: { - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false - } - }, - variableSubset: { - allowMultipleValues: true - } - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }] - }, - { - conceptId: 'S100002-EDSC', - longName: 'Mock Service Name 3', - name: 'mock-name 3', - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example3.com' - }, - serviceOptions: { - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false - } - }, - variableSubset: { - allowMultipleValues: true - } - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }] - }] - }, - variables: { - count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] - } - } - const isOpenSearch = false - - buildAccessMethods(collectionMetadata, isOpenSearch) - - expect(buildHarmonyMock).toBeCalledTimes(3) - - expect(buildHarmonyMock).toHaveBeenNthCalledWith( - 1, - { - conceptId: 'S100000-EDSC', - longName: 'Mock Service Name', - name: 'mock-name', - serviceOptions: { - interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], - subset: { - spatialSubset: { boundingBox: { allowMultipleValues: false } }, - variableSubset: { allowMultipleValues: true } - }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }] - }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }], - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example.com' - }, - variables: { - count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, - { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] - } - }, - { - associatedVariables: { - count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, - { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } + ] + } + }, + { + associatedVariables: { + count: 4, + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, + { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } + ] }, echoIndex: 0, esiIndex: 0, @@ -2284,28 +2714,70 @@ describe('when buildAccessMethods is called', () => { longName: 'Mock Service Name 2', name: 'mock-name 2', serviceOptions: { - interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], subset: { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }] - }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }], + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], type: 'Harmony', url: { description: 'Mock URL', @@ -2315,28 +2787,32 @@ describe('when buildAccessMethods is called', () => { { associatedVariables: { count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, + { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, + { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + } + ] }, echoIndex: undefined, esiIndex: undefined, @@ -2351,28 +2827,71 @@ describe('when buildAccessMethods is called', () => { longName: 'Mock Service Name 3', name: 'mock-name 3', serviceOptions: { - interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], subset: { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }] - }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }], + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], type: 'Harmony', url: { description: 'Mock URL', @@ -2382,28 +2901,32 @@ describe('when buildAccessMethods is called', () => { { associatedVariables: { count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, + { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, + { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + } + ] }, echoIndex: undefined, esiIndex: undefined, diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildDownload.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildDownload.test.js index 35e27ce1dc..936dda0011 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildDownload.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildDownload.test.js @@ -17,12 +17,14 @@ describe('buildDownload', () => { const method = buildDownload(granules, isOpenSearch) - expect(method).toEqual({ - download: { - isValid: true, - type: 'download' + expect(method).toEqual( + { + download: { + isValid: true, + type: 'download' + } } - }) + ) }) test('returns a download access method for open search', () => { @@ -35,11 +37,13 @@ describe('buildDownload', () => { const method = buildDownload(granules, isOpenSearch) - expect(method).toEqual({ - download: { - isValid: true, - type: 'download' + expect(method).toEqual( + { + download: { + isValid: true, + type: 'download' + } } - }) + ) }) }) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js index a0675648ea..d4d282f79f 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildEsiEcho.test.js @@ -66,39 +66,45 @@ describe('buildEsiEcho', () => { test('returns an echo orders access method and indexes are incremented correctly', () => { const collectionMetadata = { services: { - items: [{ - type: 'ECHO ORDERS', - url: { - urlValue: 'https://example.com' - }, - maxItemsPerOrder: 2000, - orderOptions: { - items: [{ - conceptId: 'OO10000-EDSC', - name: 'mock form', - form: 'mock form' + items: [ + { + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' }, - { - conceptId: 'OO30000-EDSC', - name: 'mock form', - form: 'mock form' - }] - } - }, - { - type: 'ESI', - url: { - urlValue: 'https://example.com' + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10000-EDSC', + name: 'mock form', + form: 'mock form' + }, + { + conceptId: 'OO30000-EDSC', + name: 'mock form', + form: 'mock form' + } + ] + } }, - maxItemsPerOrder: 2000, - orderOptions: { - items: [{ - conceptId: 'OO20000-EDSC', - name: 'mock form', - form: 'mock form' - }] + { + type: 'ESI', + url: { + urlValue: 'https://example.com' + }, + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO20000-EDSC', + name: 'mock form', + form: 'mock form' + } + ] + } } - }] + ] } } @@ -184,11 +190,13 @@ describe('buildEsiEcho', () => { }, maxItemsPerOrder: 2000, orderOptions: { - items: [{ - conceptId: 'OO10000-EDSC', - name: 'mock form', - form: 'mock form' - }] + items: [ + { + conceptId: 'OO10000-EDSC', + name: 'mock form', + form: 'mock form' + } + ] } }] } diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js index d268504034..b57a8f2b33 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js @@ -30,16 +30,49 @@ describe('buildHarmony', () => { concatenateDefault: true } }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], interpolationTypes: [ 'Bilinear Interpolation', 'Nearest Neighbor' ], - supportedReformattings: [{ + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ 'GEOTIFF', @@ -47,7 +80,8 @@ describe('buildHarmony', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -55,30 +89,8 @@ describe('buildHarmony', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }], + } + ], variables: { count: 0, items: null @@ -87,35 +99,40 @@ describe('buildHarmony', () => { }, variables: { count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, + { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } + ] } } @@ -234,16 +251,51 @@ describe('buildHarmony', () => { allowMultipleValues: true } }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], interpolationTypes: [ 'Bilinear Interpolation', 'Nearest Neighbor' ], - supportedReformattings: [{ + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic', + projectionAuthority: 'Polar Stereographic' + }, + { + projectionName: 'Geographic', + projectionAuthority: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ 'GEOTIFF', @@ -251,7 +303,8 @@ describe('buildHarmony', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -259,65 +312,47 @@ describe('buildHarmony', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic', - projectionAuthority: 'Polar Stereographic' - }, { - projectionName: 'Geographic', - projectionAuthority: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }], + } + ], variables: { count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, + { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } + ] } - }, { + }, + { conceptId: 'S100001-EDSC', longName: 'Mock Service Name 2', name: 'mock-name 2', @@ -337,16 +372,49 @@ describe('buildHarmony', () => { allowMultipleValues: true } }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], interpolationTypes: [ 'Bilinear Interpolation', 'Nearest Neighbor' ], - supportedReformattings: [{ + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ 'GEOTIFF', @@ -354,7 +422,8 @@ describe('buildHarmony', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -362,61 +431,44 @@ describe('buildHarmony', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }], + } + ], variables: { count: 4, - items: [{ - conceptId: 'V100006-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3973', - scienceKeywords: null - }, { - conceptId: 'V100007-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3974', - scienceKeywords: null - }, { - conceptId: 'V100008-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3975', - scienceKeywords: null - }, { - conceptId: 'V100009-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3966', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100006-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3973', + scienceKeywords: null + }, + { + conceptId: 'V100007-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3974', + scienceKeywords: null + }, + { + conceptId: 'V100008-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3975', + scienceKeywords: null + }, + { + conceptId: 'V100009-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3966', + scienceKeywords: null + } + ] } }, { @@ -439,16 +491,49 @@ describe('buildHarmony', () => { allowMultipleValues: true } }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], interpolationTypes: [ 'Bilinear Interpolation', 'Nearest Neighbor' ], - supportedReformattings: [{ + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ 'GEOTIFF', @@ -456,7 +541,8 @@ describe('buildHarmony', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -464,56 +550,38 @@ describe('buildHarmony', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }] + } + ] }] }, variables: { count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] + items: [ + { + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, + { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, + { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + } + ] } } @@ -553,217 +621,222 @@ describe('buildHarmony', () => { harmonyIndex += 1 }) - expect(methods).toEqual({ - harmony0: { - defaultConcatenation: false, - enableConcatenateDownload: false, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - description: 'Mock Name', - hierarchyMappings: [ - { - id: 'V100000-EDSC' - }, - { - id: 'V100001-EDSC' - }, - { - id: 'V100002-EDSC' - }, - { - id: 'V100003-EDSC' - } - ], - id: 'S100000-EDSC', - isValid: true, - keywordMappings: [], - longName: 'Mock Service Name', - name: 'mock-name', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: ['Polar Stereographic', 'Geographic'], - supportsBoundingBoxSubsetting: true, - supportsConcatenation: false, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, - type: 'Harmony', - url: 'https://example.com', - variables: { - 'V100000-EDSC': { - conceptId: 'V100000-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3972', - scienceKeywords: null - }, - 'V100001-EDSC': { - conceptId: 'V100001-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3971', - scienceKeywords: null - }, - 'V100002-EDSC': { - conceptId: 'V100002-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3970', - scienceKeywords: null - }, - 'V100003-EDSC': { - conceptId: 'V100003-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3969', - scienceKeywords: null - } - } - }, - harmony1: { - defaultConcatenation: false, - enableConcatenateDownload: false, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings: [ - { - id: 'V100006-EDSC' - }, - { - id: 'V100007-EDSC' - }, - { - id: 'V100008-EDSC' - }, - { - id: 'V100009-EDSC' - } - ], - id: 'S100001-EDSC', - isValid: true, - keywordMappings: [], - longName: 'Mock Service Name 2', - name: 'mock-name 2', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: [], - supportsBoundingBoxSubsetting: true, - supportsConcatenation: false, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, - type: 'Harmony', - url: 'https://example2.com', - variables: { - 'V100006-EDSC': { - conceptId: 'V100006-EDSC', - definition: 'Alpha channel value', - longName: 'Alpha channel ', - name: 'alpha_var', - nativeId: 'mmt_variable_3973', - scienceKeywords: null - }, - 'V100007-EDSC': { - conceptId: 'V100007-EDSC', - definition: 'Blue channel value', - longName: 'Blue channel', - name: 'blue_var', - nativeId: 'mmt_variable_3974', - scienceKeywords: null - }, - 'V100008-EDSC': { - conceptId: 'V100008-EDSC', - definition: 'Green channel value', - longName: 'Green channel', - name: 'green_var', - nativeId: 'mmt_variable_3975', - scienceKeywords: null - }, - 'V100009-EDSC': { - conceptId: 'V100009-EDSC', - definition: 'Red channel value', - longName: 'Red Channel', - name: 'red_var', - nativeId: 'mmt_variable_3966', - scienceKeywords: null + expect(methods).toEqual( + { + harmony0: { + defaultConcatenation: false, + enableConcatenateDownload: false, + enableTemporalSubsetting: true, + enableSpatialSubsetting: true, + description: 'Mock Name', + hierarchyMappings: [ + { + id: 'V100000-EDSC' + }, + { + id: 'V100001-EDSC' + }, + { + id: 'V100002-EDSC' + }, + { + id: 'V100003-EDSC' + } + ], + id: 'S100000-EDSC', + isValid: true, + keywordMappings: [], + longName: 'Mock Service Name', + name: 'mock-name', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ], + supportedOutputProjections: [ + 'Polar Stereographic', + 'Geographic' + ], + supportsBoundingBoxSubsetting: true, + supportsConcatenation: false, + supportsShapefileSubsetting: false, + supportsTemporalSubsetting: false, + supportsVariableSubsetting: true, + type: 'Harmony', + url: 'https://example.com', + variables: { + 'V100000-EDSC': { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + 'V100001-EDSC': { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + 'V100002-EDSC': { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + }, + 'V100003-EDSC': { + conceptId: 'V100003-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3969', + scienceKeywords: null + } } - } - }, - // Harmony2 contains the default variables in the coll -> var association - harmony2: { - defaultConcatenation: false, - enableConcatenateDownload: false, - enableTemporalSubsetting: true, - enableSpatialSubsetting: true, - hierarchyMappings: [ - { - id: 'V100003-EDSC' - }, - { - id: 'V100004-EDSC' - }, - { - id: 'V100005-EDSC' + }, + harmony1: { + defaultConcatenation: false, + enableConcatenateDownload: false, + enableTemporalSubsetting: true, + enableSpatialSubsetting: true, + hierarchyMappings: [ + { + id: 'V100006-EDSC' + }, + { + id: 'V100007-EDSC' + }, + { + id: 'V100008-EDSC' + }, + { + id: 'V100009-EDSC' + } + ], + id: 'S100001-EDSC', + isValid: true, + keywordMappings: [], + longName: 'Mock Service Name 2', + name: 'mock-name 2', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ], + supportedOutputProjections: [], + supportsBoundingBoxSubsetting: true, + supportsConcatenation: false, + supportsShapefileSubsetting: false, + supportsTemporalSubsetting: false, + supportsVariableSubsetting: true, + type: 'Harmony', + url: 'https://example2.com', + variables: { + 'V100006-EDSC': { + conceptId: 'V100006-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3973', + scienceKeywords: null + }, + 'V100007-EDSC': { + conceptId: 'V100007-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3974', + scienceKeywords: null + }, + 'V100008-EDSC': { + conceptId: 'V100008-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3975', + scienceKeywords: null + }, + 'V100009-EDSC': { + conceptId: 'V100009-EDSC', + definition: 'Red channel value', + longName: 'Red Channel', + name: 'red_var', + nativeId: 'mmt_variable_3966', + scienceKeywords: null + } } - ], - id: 'S100002-EDSC', - isValid: true, - keywordMappings: [], - longName: 'Mock Service Name 3', - name: 'mock-name 3', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ], - supportedOutputProjections: [], - supportsBoundingBoxSubsetting: true, - supportsConcatenation: false, - supportsShapefileSubsetting: false, - supportsTemporalSubsetting: false, - supportsVariableSubsetting: true, - type: 'Harmony', - url: 'https://example3.com', - variables: { - 'V100003-EDSC': { - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, - 'V100004-EDSC': { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, - 'V100005-EDSC': { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null + }, + // Harmony2 contains the default variables in the coll -> var association + harmony2: { + defaultConcatenation: false, + enableConcatenateDownload: false, + enableTemporalSubsetting: true, + enableSpatialSubsetting: true, + hierarchyMappings: [ + { + id: 'V100003-EDSC' + }, + { + id: 'V100004-EDSC' + }, + { + id: 'V100005-EDSC' + } + ], + id: 'S100002-EDSC', + isValid: true, + keywordMappings: [], + longName: 'Mock Service Name 3', + name: 'mock-name 3', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ], + supportedOutputProjections: [], + supportsBoundingBoxSubsetting: true, + supportsConcatenation: false, + supportsShapefileSubsetting: false, + supportsTemporalSubsetting: false, + supportsVariableSubsetting: true, + type: 'Harmony', + url: 'https://example3.com', + variables: { + 'V100003-EDSC': { + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, + 'V100004-EDSC': { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, + 'V100005-EDSC': { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + } } } } - }) + ) }) }) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildOpendap.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildOpendap.test.js index 96a53b4fd2..7a057939cb 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildOpendap.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildOpendap.test.js @@ -4,139 +4,166 @@ describe('buildOpendap', () => { test('returns an opendap access method', () => { const collectionMetadata = { services: { - items: [{ - conceptId: 'S100000-EDSC', - longName: 'Mock Service Name', - name: 'mock-name', - type: 'OPeNDAP', - url: { - description: 'Mock URL', - urlValue: 'https://example.com' - }, - serviceOptions: { - supportedInputProjections: [{ - projectionName: 'Geographic' - }], - supportedOutputProjections: [{ - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'ASCII', - supportedOutputFormats: [ - 'ASCII', - 'BINARY', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'BINARY', - supportedOutputFormats: [ - 'ASCII', - 'BINARY', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'ASCII', - 'BINARY', - 'NETCDF-4' - ] - }], - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false + items: [ + { + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + type: 'OPeNDAP', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + supportedInputProjections: [ + { + projectionName: 'Geographic' } + ], + supportedOutputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'ASCII', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'BINARY', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + } + ], + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + } + }, + supportedOutputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'ASCII', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'BINARY', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] }, - variableSubset: { - allowMultipleValues: true + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] } - } - }, - supportedOutputProjections: [{ - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'ASCII', - supportedOutputFormats: [ - 'ASCII', - 'BINARY', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'BINARY', - supportedOutputFormats: [ - 'ASCII', - 'BINARY', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'ASCII', - 'BINARY', - 'NETCDF-4' - ] - }], - orderOptions: { - count: 0, - items: null - }, - variables: { - count: 4, - items: [{ - conceptId: 'V100000-EDSC', - definition: 'analysed_sst in units of kelvin', - longName: 'analysed_sst', - name: 'analysed_sst', - nativeId: 'e2eTestVarHiRes1', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] - }, { - conceptId: 'V100001-EDSC', - definition: 'analysis_error in units of kelvin', - longName: 'analysis_error', - name: 'analysis_error', - nativeId: 'e2eTestVarHiRes2', - scienceKeywords: [ + ], + orderOptions: { + count: 0, + items: null + }, + variables: { + count: 4, + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'analysed_sst in units of kelvin', + longName: 'analysed_sst', + name: 'analysed_sst', + nativeId: 'e2eTestVarHiRes1', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100001-EDSC', + definition: 'analysis_error in units of kelvin', + longName: 'analysis_error', + name: 'analysis_error', + nativeId: 'e2eTestVarHiRes2', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100002-EDSC', + definition: 'mask in units of seconds since 1981-0', + longName: 'mask', + name: 'mask', + nativeId: 'e2eTestVarHiRes4', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, { - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' + conceptId: 'V100003-EDSC', + definition: 'sea_ice_fraction in units of fraction (between 0 ', + longName: 'sea_ice_fraction', + name: 'sea_ice_fraction', + nativeId: 'e2eTestVarHiRes3', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] } ] - }, { - conceptId: 'V100002-EDSC', - definition: 'mask in units of seconds since 1981-0', - longName: 'mask', - name: 'mask', - nativeId: 'e2eTestVarHiRes4', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] - }, { - conceptId: 'V100003-EDSC', - definition: 'sea_ice_fraction in units of fraction (between 0 ', - longName: 'sea_ice_fraction', - name: 'sea_ice_fraction', - nativeId: 'e2eTestVarHiRes3', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] - }] + } } - }] + ] } } @@ -157,32 +184,48 @@ describe('buildOpendap', () => { expect(accessMethods).toEqual({ opendap: { - hierarchyMappings: [{ - id: 'V100000-EDSC' - }, { - id: 'V100001-EDSC' - }, { - id: 'V100002-EDSC' - }, { - id: 'V100003-EDSC' - }], - id: 'S100000-EDSC', - isValid: true, - keywordMappings: [{ - children: [{ + hierarchyMappings: [ + { id: 'V100000-EDSC' - }, { + }, + { id: 'V100001-EDSC' - }, { + }, + { id: 'V100002-EDSC' - }, { + }, + { id: 'V100003-EDSC' - }], - label: 'Sea Surface Temperature' - }], + } + ], + id: 'S100000-EDSC', + isValid: true, + keywordMappings: [ + { + children: [ + { + id: 'V100000-EDSC' + }, + { + id: 'V100001-EDSC' + }, + { + id: 'V100002-EDSC' + }, + { + id: 'V100003-EDSC' + } + ], + label: 'Sea Surface Temperature' + } + ], longName: 'Mock Service Name', name: 'mock-name', - supportedOutputFormats: ['ASCII', 'BINARY', 'NETCDF-4'], + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ], supportsVariableSubsetting: true, type: 'OPeNDAP', variables: { @@ -192,12 +235,14 @@ describe('buildOpendap', () => { longName: 'analysed_sst', name: 'analysed_sst', nativeId: 'e2eTestVarHiRes1', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] }, 'V100001-EDSC': { conceptId: 'V100001-EDSC', @@ -205,12 +250,14 @@ describe('buildOpendap', () => { longName: 'analysis_error', name: 'analysis_error', nativeId: 'e2eTestVarHiRes2', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] }, 'V100002-EDSC': { conceptId: 'V100002-EDSC', @@ -218,12 +265,14 @@ describe('buildOpendap', () => { longName: 'mask', name: 'mask', nativeId: 'e2eTestVarHiRes4', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] }, 'V100003-EDSC': { conceptId: 'V100003-EDSC', @@ -231,12 +280,14 @@ describe('buildOpendap', () => { longName: 'sea_ice_fraction', name: 'sea_ice_fraction', nativeId: 'e2eTestVarHiRes3', - scienceKeywords: [{ - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - }] + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] } } } From 9ee253d7db5c47d095ea88a59c1082b8caf7bb78 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Tue, 27 Aug 2024 17:23:14 -0400 Subject: [PATCH 17/20] EDSC-3773: forgot a couple of the lint changes --- .../__tests__/buildAccessMethods.test.js | 6 + .../__tests__/buildHarmony.test.js | 122 +++++++++--------- 2 files changed, 68 insertions(+), 60 deletions(-) diff --git a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js index dad962272a..904aacf04c 100644 --- a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js +++ b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js @@ -22,6 +22,7 @@ afterEach(() => { describe('when buildAccessMethods is called', () => { test('calls buildDownload access method', () => { const buildDownloadMock = jest.spyOn(buildDownload, 'buildDownload') + buildDownloadMock.mockImplementationOnce(() => jest.fn()) const collectionMetadata = { @@ -42,6 +43,7 @@ describe('when buildAccessMethods is called', () => { test('calls buildEsiEcho access method with type ECHO ORDERS', () => { const buildEsiEchoMock = jest.spyOn(buildEsiEcho, 'buildEsiEcho') + buildEsiEchoMock.mockImplementationOnce(() => jest.fn()) const collectionMetadata = { @@ -100,6 +102,7 @@ describe('when buildAccessMethods is called', () => { test('calls buildEsiEcho access method with type ESI', () => { const buildEsiEchoMock = jest.spyOn(buildEsiEcho, 'buildEsiEcho') + buildEsiEchoMock.mockImplementationOnce(() => jest.fn()) const collectionMetadata = { @@ -158,6 +161,7 @@ describe('when buildAccessMethods is called', () => { test('calls buildHarmony access method', () => { const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') + buildHarmonyMock.mockImplementationOnce(() => jest.fn()) const collectionMetadata = { @@ -409,6 +413,7 @@ describe('when buildAccessMethods is called', () => { test('calls buildOpendap access method', () => { const buildOpendapMock = jest.spyOn(buildOpendap, 'buildOpendap') + buildOpendapMock.mockImplementationOnce(() => jest.fn()) const collectionMetadata = { @@ -813,6 +818,7 @@ describe('when buildAccessMethods is called', () => { test('calls buildSwodlr access method', () => { const buildSwodlrMock = jest.spyOn(buildSwodlr, 'buildSwodlr') + buildSwodlrMock.mockImplementationOnce(() => jest.fn()) const collectionMetadata = { diff --git a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js index b57a8f2b33..0cd9ab541c 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/__tests__/buildHarmony.test.js @@ -4,31 +4,65 @@ describe('buildHarmony', () => { test('returns a harmony access method', () => { const collectionMetadata = { services: { - items: [{ - description: 'abc123', - conceptId: 'S100000-EDSC', - longName: 'Mock Service Name', - name: 'mock-name', - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example.com' - }, - serviceOptions: { - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false + items: [ + { + description: 'abc123', + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true } }, - variableSubset: { - allowMultipleValues: true - } - }, - aggregation: { - concatenate: { - concatenateDefault: true - } + aggregation: { + concatenate: { + concatenateDefault: true + } + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] }, supportedOutputProjections: [ { @@ -38,10 +72,6 @@ describe('buildHarmony', () => { projectionName: 'Geographic' } ], - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], supportedReformattings: [ { supportedInputFormat: 'NETCDF-4', @@ -61,41 +91,13 @@ describe('buildHarmony', () => { 'NETCDF-4' ] } - ] - }, - supportedOutputProjections: [ - { - projectionName: 'Polar Stereographic' - }, - { - projectionName: 'Geographic' - } - ], - supportedReformattings: [ - { - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, - { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] + ], + variables: { + count: 0, + items: null } - ], - variables: { - count: 0, - items: null } - }] + ] }, variables: { count: 4, From 11975a8ebbde8bf58fb87a816d3c6c0ebd310632 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Thu, 29 Aug 2024 12:37:15 -0400 Subject: [PATCH 18/20] adding test and seeing weirdness --- .../__tests__/buildAccessMethods.test.js | 1584 +++++++++++++---- .../util/accessMethods/buildAccessMethods.js | 9 +- .../buildAccessMethods/buildEsiEcho.js | 9 +- .../buildAccessMethods/buildHarmony.js | 1 + 4 files changed, 1206 insertions(+), 397 deletions(-) diff --git a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js index 904aacf04c..e115d3ec88 100644 --- a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js +++ b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js @@ -314,7 +314,10 @@ describe('when buildAccessMethods is called', () => { concatenateDefault: true } }, - interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], subset: { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } @@ -330,11 +333,21 @@ describe('when buildAccessMethods is called', () => { supportedReformattings: [ { supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] }, { supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] } ] }, @@ -349,11 +362,21 @@ describe('when buildAccessMethods is called', () => { supportedReformattings: [ { supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] }, { supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] } ], type: 'Harmony', @@ -418,21 +441,64 @@ describe('when buildAccessMethods is called', () => { const collectionMetadata = { services: { - items: [{ - conceptId: 'S100000-EDSC', - longName: 'Mock Service Name', - name: 'mock-name', - type: 'OPeNDAP', - url: { - description: 'Mock URL', - urlValue: 'https://example.com' - }, - serviceOptions: { - supportedInputProjections: [ - { - projectionName: 'Geographic' + items: [ + { + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + type: 'OPeNDAP', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + supportedInputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedOutputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'ASCII', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'BINARY', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + } + ], + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } } - ], + }, supportedOutputProjections: [ { projectionName: 'Geographic' @@ -464,118 +530,77 @@ describe('when buildAccessMethods is called', () => { ] } ], - subset: { - spatialSubset: { - boundingBox: { - allowMultipleValues: false - } - }, - variableSubset: { - allowMultipleValues: true - } - } - }, - supportedOutputProjections: [ - { - projectionName: 'Geographic' - } - ], - supportedReformattings: [ - { - supportedInputFormat: 'ASCII', - supportedOutputFormats: [ - 'ASCII', - 'BINARY', - 'NETCDF-4' - ] - }, - { - supportedInputFormat: 'BINARY', - supportedOutputFormats: [ - 'ASCII', - 'BINARY', - 'NETCDF-4' - ] + orderOptions: { + count: 0, + items: null }, - { - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'ASCII', - 'BINARY', - 'NETCDF-4' + variables: { + count: 4, + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'analysed_sst in units of kelvin', + longName: 'analysed_sst', + name: 'analysed_sst', + nativeId: 'e2eTestVarHiRes1', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100001-EDSC', + definition: 'analysis_error in units of kelvin', + longName: 'analysis_error', + name: 'analysis_error', + nativeId: 'e2eTestVarHiRes2', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100002-EDSC', + definition: 'mask in units of seconds since 1981-0', + longName: 'mask', + name: 'mask', + nativeId: 'e2eTestVarHiRes4', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100003-EDSC', + definition: 'sea_ice_fraction in units of fraction (between 0 ', + longName: 'sea_ice_fraction', + name: 'sea_ice_fraction', + nativeId: 'e2eTestVarHiRes3', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + } ] } - ], - orderOptions: { - count: 0, - items: null - }, - variables: { - count: 4, - items: [ - { - conceptId: 'V100000-EDSC', - definition: 'analysed_sst in units of kelvin', - longName: 'analysed_sst', - name: 'analysed_sst', - nativeId: 'e2eTestVarHiRes1', - scienceKeywords: [ - { - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - } - ] - }, - { - conceptId: 'V100001-EDSC', - definition: 'analysis_error in units of kelvin', - longName: 'analysis_error', - name: 'analysis_error', - nativeId: 'e2eTestVarHiRes2', - scienceKeywords: [ - { - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - } - ] - }, - { - conceptId: 'V100002-EDSC', - definition: 'mask in units of seconds since 1981-0', - longName: 'mask', - name: 'mask', - nativeId: 'e2eTestVarHiRes4', - scienceKeywords: [ - { - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - } - ] - }, - { - conceptId: 'V100003-EDSC', - definition: 'sea_ice_fraction in units of fraction (between 0 ', - longName: 'sea_ice_fraction', - name: 'sea_ice_fraction', - nativeId: 'e2eTestVarHiRes3', - scienceKeywords: [ - { - category: 'Earth Science', - topic: 'Oceans', - term: 'Ocean Temperature', - variableLevel1: 'Sea Surface Temperature' - } - ] - } - ] } - }] + ] } } const isOpenSearch = false @@ -907,10 +932,6 @@ describe('when buildAccessMethods is called', () => { }) }) - describe('calls complex compilation of mutliple different access methods', () => { - - }) - describe('when the collection contains both variables associated to its services and variables directly associated to the collection and 3 service records', () => { test('variables on the service are returned instead of variables directly associated to the collection and buildHarmony is called 3 times', () => { const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') @@ -959,7 +980,8 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -1034,7 +1056,8 @@ describe('when buildAccessMethods is called', () => { } ] } - }, { + }, + { conceptId: 'S100001-EDSC', longName: 'Mock Service Name 2', name: 'mock-name 2', @@ -1278,7 +1301,10 @@ describe('when buildAccessMethods is called', () => { longName: 'Mock Service Name', name: 'mock-name', serviceOptions: { - interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], subset: { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } @@ -1435,7 +1461,10 @@ describe('when buildAccessMethods is called', () => { longName: 'Mock Service Name 2', name: 'mock-name 2', serviceOptions: { - interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], subset: { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } @@ -1592,7 +1621,10 @@ describe('when buildAccessMethods is called', () => { longName: 'Mock Service Name 3', name: 'mock-name 3', serviceOptions: { - interpolationTypes: ['Bilinear Interpolation', 'Nearest Neighbor'], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], subset: { spatialSubset: { boundingBox: { allowMultipleValues: false } }, variableSubset: { allowMultipleValues: true } @@ -1790,7 +1822,8 @@ describe('when buildAccessMethods is called', () => { count: 0, items: [] } - }, { + }, + { conceptId: 'S100001-EDSC', longName: 'Mock Service Name 2', name: 'mock-name 2', @@ -1810,16 +1843,52 @@ describe('when buildAccessMethods is called', () => { allowMultipleValues: true } }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], + supportedOutputProjections: [ + { + projectionName: + 'Polar Stereographic' + }, + { + projectionName: + 'Geographic' + } + ], interpolationTypes: [ 'Bilinear Interpolation', 'Nearest Neighbor' ], - supportedReformattings: [{ + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] + }, + supportedOutputProjections: [ + { + projectionName: + 'Polar Stereographic' + }, + { + projectionName: + 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ 'GEOTIFF', @@ -1827,7 +1896,8 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -1835,30 +1905,8 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }], + } + ], variables: { count: 4, items: [] @@ -1884,16 +1932,51 @@ describe('when buildAccessMethods is called', () => { allowMultipleValues: true } }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - interpolationTypes: [ - 'Bilinear Interpolation', + supportedOutputProjections: [ + { + projectionName: + 'Polar Stereographic' + }, + { + projectionName: + 'Geographic' + } + ], + interpolationTypes: [ + 'Bilinear Interpolation', 'Nearest Neighbor' ], - supportedReformattings: [{ + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { supportedInputFormat: 'NETCDF-4', supportedOutputFormats: [ 'GEOTIFF', @@ -1901,7 +1984,8 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -1909,218 +1993,53 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }] - }, - supportedOutputProjections: [{ - projectionName: 'Polar Stereographic' - }, { - projectionName: 'Geographic' - }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }] - }] + } + ] + } + ] }, variables: { count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] - } - } - const isOpenSearch = false - - buildAccessMethods(collectionMetadata, isOpenSearch) - - expect(buildHarmonyMock).toBeCalledTimes(3) - - expect(buildHarmonyMock).toHaveBeenNthCalledWith( - 1, - { - conceptId: 'S100000-EDSC', - longName: 'Mock Service Name', - name: 'mock-name', - serviceOptions: { - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], - subset: { - spatialSubset: { boundingBox: { allowMultipleValues: false } }, - variableSubset: { allowMultipleValues: true } - }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }] - }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }], - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example.com' - }, - variables: { - count: 0, - items: [] - } - }, - { - associatedVariables: { - count: 3, - items: [{ + items: [ + { conceptId: 'V100003-EDSC', definition: 'Beta channel value', longName: 'Beta channel ', name: 'beta_var', nativeId: 'mmt_variable_4972', scienceKeywords: null - }, { - conceptId: 'V100004-EDSC', - definition: 'Orange channel value', - longName: 'Orange channel', - name: 'orange_var', - nativeId: 'mmt_variable_4971', - scienceKeywords: null - }, { - conceptId: 'V100005-EDSC', - definition: 'Purple channel value', - longName: 'Purple channel', - name: 'purple_var', - nativeId: 'mmt_variable_4970', - scienceKeywords: null - }] - }, - echoIndex: 0, - esiIndex: 0, - harmonyIndex: 0 - } - ) - - expect(buildHarmonyMock).toHaveBeenNthCalledWith( - 2, - { - conceptId: 'S100001-EDSC', - longName: 'Mock Service Name 2', - name: 'mock-name 2', - serviceOptions: { - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], - subset: { - spatialSubset: { boundingBox: { allowMultipleValues: false } }, - variableSubset: { allowMultipleValues: true } }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }] - }, - supportedOutputProjections: [{ projectionName: 'Polar Stereographic' }, { projectionName: 'Geographic' }], - supportedReformattings: [{ - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }, { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: ['GEOTIFF', 'PNG', 'TIFF', 'NETCDF-4'] - }], - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example2.com' - }, - variables: { - count: 4, - items: [] - } - }, - { - associatedVariables: { - count: 3, - items: [{ - conceptId: 'V100003-EDSC', - definition: 'Beta channel value', - longName: 'Beta channel ', - name: 'beta_var', - nativeId: 'mmt_variable_4972', - scienceKeywords: null - }, { + { conceptId: 'V100004-EDSC', definition: 'Orange channel value', longName: 'Orange channel', name: 'orange_var', nativeId: 'mmt_variable_4971', scienceKeywords: null - }, { + }, + { conceptId: 'V100005-EDSC', definition: 'Purple channel value', longName: 'Purple channel', name: 'purple_var', nativeId: 'mmt_variable_4970', scienceKeywords: null - }] - }, - echoIndex: undefined, - esiIndex: undefined, - harmonyIndex: 1 + } + ] } - ) + } + const isOpenSearch = false + + buildAccessMethods(collectionMetadata, isOpenSearch) + + expect(buildHarmonyMock).toBeCalledTimes(3) expect(buildHarmonyMock).toHaveBeenNthCalledWith( - 3, + 1, { - conceptId: 'S100002-EDSC', - longName: 'Mock Service Name 3', - name: 'mock-name 3', + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', serviceOptions: { interpolationTypes: [ 'Bilinear Interpolation', @@ -2132,10 +2051,12 @@ describe('when buildAccessMethods is called', () => { }, supportedOutputProjections: [ { - projectionName: 'Polar Stereographic' + projectionName: + 'Polar Stereographic' }, { - projectionName: 'Geographic' + projectionName: + 'Geographic' } ], supportedReformattings: [ @@ -2161,10 +2082,12 @@ describe('when buildAccessMethods is called', () => { }, supportedOutputProjections: [ { - projectionName: 'Polar Stereographic' + projectionName: + 'Polar Stereographic' }, { - projectionName: 'Geographic' + projectionName: + 'Geographic' } ], supportedReformattings: [ @@ -2190,7 +2113,11 @@ describe('when buildAccessMethods is called', () => { type: 'Harmony', url: { description: 'Mock URL', - urlValue: 'https://example3.com' + urlValue: 'https://example.com' + }, + variables: { + count: 0, + items: [] } }, { @@ -2223,34 +2150,270 @@ describe('when buildAccessMethods is called', () => { } ] }, - echoIndex: undefined, - esiIndex: undefined, - harmonyIndex: 2 + echoIndex: 0, + esiIndex: 0, + harmonyIndex: 0 } ) - }) - }) - - describe('when the collection contains variables directly associated to the collection and some variables associated to some services and 3 service records', () => { - test('variables on the collection are returned for services without variables but, variables associated to the service are returned for services that have them and buildHarmony is called 3 times', () => { - const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') - buildHarmonyMock.mockImplementationOnce(() => jest.fn()) - const collectionMetadata = { - services: { - items: [ - { - conceptId: 'S100000-EDSC', - longName: 'Mock Service Name', - name: 'mock-name', - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example.com' + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 2, + { + conceptId: 'S100001-EDSC', + longName: 'Mock Service Name 2', + name: 'mock-name 2', + serviceOptions: { + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } + }, + supportedOutputProjections: [ + { + projectionName: + 'Polar Stereographic' }, - serviceOptions: { - subset: { - spatialSubset: { + { + projectionName: + 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: + 'Polar Stereographic' + }, + { + projectionName: + 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example2.com' + }, + variables: { + count: 4, + items: [] + } + }, + { + associatedVariables: { + count: 3, + items: [ + { + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, + { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, + { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + } + ] + }, + echoIndex: undefined, + esiIndex: undefined, + harmonyIndex: 1 + } + ) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 3, + { + conceptId: 'S100002-EDSC', + longName: 'Mock Service Name 3', + name: 'mock-name 3', + serviceOptions: { + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example3.com' + } + }, + { + associatedVariables: { + count: 3, + items: [ + { + conceptId: 'V100003-EDSC', + definition: 'Beta channel value', + longName: 'Beta channel ', + name: 'beta_var', + nativeId: 'mmt_variable_4972', + scienceKeywords: null + }, + { + conceptId: 'V100004-EDSC', + definition: 'Orange channel value', + longName: 'Orange channel', + name: 'orange_var', + nativeId: 'mmt_variable_4971', + scienceKeywords: null + }, + { + conceptId: 'V100005-EDSC', + definition: 'Purple channel value', + longName: 'Purple channel', + name: 'purple_var', + nativeId: 'mmt_variable_4970', + scienceKeywords: null + } + ] + }, + echoIndex: undefined, + esiIndex: undefined, + harmonyIndex: 2 + } + ) + }) + }) + + describe('when the collection contains variables directly associated to the collection and some variables associated to some services and 3 service records', () => { + test('variables on the collection are returned for services without variables but, variables associated to the service are returned for services that have them and buildHarmony is called 3 times', () => { + const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') + buildHarmonyMock.mockImplementationOnce(() => jest.fn()) + + const collectionMetadata = { + services: { + items: [ + { + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } @@ -2356,7 +2519,8 @@ describe('when buildAccessMethods is called', () => { } ] } - }, { + }, + { conceptId: 'S100001-EDSC', longName: 'Mock Service Name 2', name: 'mock-name 2', @@ -2552,6 +2716,7 @@ describe('when buildAccessMethods is called', () => { ] } } + const isOpenSearch = false buildAccessMethods(collectionMetadata, isOpenSearch) @@ -2745,7 +2910,8 @@ describe('when buildAccessMethods is called', () => { 'TIFF', 'NETCDF-4' ] - }, { + }, + { supportedInputFormat: 'GEOTIFF', supportedOutputFormats: [ 'GEOTIFF', @@ -2941,4 +3107,634 @@ describe('when buildAccessMethods is called', () => { ) }) }) + + describe('calls complex compilation of mutliple different access methods', () => { + test.only('calls all access methods correctly', () => { + const buildEsiEchoMock = jest.spyOn(buildEsiEcho, 'buildEsiEcho') + const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') + const buildOpendapMock = jest.spyOn(buildOpendap, 'buildOpendap') + const buildSwodlrMock = jest.spyOn(buildSwodlr, 'buildSwodlr') + + buildEsiEchoMock.mockImplementationOnce(() => jest.fn()) + buildHarmonyMock.mockImplementationOnce(() => jest.fn()) + buildOpendapMock.mockImplementationOnce(() => jest.fn()) + buildSwodlrMock.mockImplementationOnce(() => jest.fn()) + + const echoOrderItem1 = { + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + }, + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10000-EDSC', + name: 'mock form', + form: 'mock form' + } + ] + } + } + + const esiItem = { + type: 'ESI', + url: { + urlValue: 'https://example.com' + }, + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10001-EDSC', + name: 'mock form', + form: 'mock form' + } + ] + } + } + + const harmonyItem1 = { + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + }, + aggregation: { + concatenate: { + concatenateDefault: true + } + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }], + variables: { + count: 0, + items: null + } + } + + const echoOrderItem2 = { + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + }, + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10002-EDSC', + name: 'mock form', + form: 'mock form' + } + ] + } + } + + const opendapItem = { + conceptId: 'S100003-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + type: 'OPeNDAP', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + serviceOptions: { + supportedInputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedOutputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'ASCII', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'BINARY', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + } + ], + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + } + }, + supportedOutputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'ASCII', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'BINARY', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + } + ], + orderOptions: { + count: 0, + items: null + }, + variables: { + count: 4, + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'analysed_sst in units of kelvin', + longName: 'analysed_sst', + name: 'analysed_sst', + nativeId: 'e2eTestVarHiRes1', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100001-EDSC', + definition: 'analysis_error in units of kelvin', + longName: 'analysis_error', + name: 'analysis_error', + nativeId: 'e2eTestVarHiRes2', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100002-EDSC', + definition: 'mask in units of seconds since 1981-0', + longName: 'mask', + name: 'mask', + nativeId: 'e2eTestVarHiRes4', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100003-EDSC', + definition: 'sea_ice_fraction in units of fraction (between 0 ', + longName: 'sea_ice_fraction', + name: 'sea_ice_fraction', + nativeId: 'e2eTestVarHiRes3', + scienceKeywords: [ + { + category: 'Earth Science', + topic: 'Oceans', + term: 'Ocean Temperature', + variableLevel1: 'Sea Surface Temperature' + } + ] + } + ] + } + } + + const swodlrItem = { + conceptId: 'S100004-EDSC', + longName: 'Mock PODAAC SWOT On-Demand Level 2 Raster Generation (SWODLR)', + name: 'Mock PODAAC_SWODLR', + type: 'SWODLR', + url: { + description: 'Service top-level URL', + urlValue: 'https://swodlr.podaac.earthdatacloud.nasa.gov' + }, + serviceOptions: { + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator' + }, + { + projectionName: 'WGS84 - World Geodetic System 1984' + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator' + }, + { + projectionName: 'WGS84 - World Geodetic System 1984' + } + ], + supportedReformattings: null, + supportedInputProjections: null, + orderOptions: { + items: [] + }, + variables: { + items: [] + } + } + + const harmonyItem2 = { + conceptId: 'S100001-EDSC', + longName: 'Mock Service Name 2', + name: 'mock-name 2', + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example2.com' + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + }, + supportedOutputProjections: [ + { + projectionName: + 'Polar Stereographic' + }, + { + projectionName: + 'Geographic' + } + ], + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }] + }, + supportedOutputProjections: [ + { + projectionName: + 'Polar Stereographic' + }, + { + projectionName: + 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], + variables: { + count: 4, + items: [] + } + } + + const collectionMetadata = { + services: { + items: [ + opendapItem, + echoOrderItem1, + esiItem, + echoOrderItem2, + harmonyItem1, + swodlrItem, + harmonyItem2 + ] + }, + variables: { + count: 3, + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + } + ] + } + } + + const isOpenSearch = false + + buildAccessMethods(collectionMetadata, isOpenSearch) + + expect(buildEsiEchoMock).toHaveBeenCalledTimes(3) // Apparently the buildEsiEchoMock gets called 3 times but the first call isn't actually going through the code + expect(buildHarmonyMock).toHaveBeenCalledTimes(2) + expect(buildOpendapMock).toHaveBeenCalledTimes(1) + expect(buildSwodlrMock).toHaveBeenCalledTimes(1) + + // Index counters for echo/esi orders & harmony + let echoIndex = 0 + let esiIndex = 0 + let harmonyIndex = 0 // Will be indexed later + + const defaultAssociatedVariables = { + count: 3, + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'Alpha channel value', + longName: 'Alpha channel ', + name: 'alpha_var', + nativeId: 'mmt_variable_3972', + scienceKeywords: null + }, + { + conceptId: 'V100001-EDSC', + definition: 'Blue channel value', + longName: 'Blue channel', + name: 'blue_var', + nativeId: 'mmt_variable_3971', + scienceKeywords: null + }, + { + conceptId: 'V100002-EDSC', + definition: 'Green channel value', + longName: 'Green channel', + name: 'green_var', + nativeId: 'mmt_variable_3970', + scienceKeywords: null + } + ] + } + + // ESI & Echo Order expected Calls + const echoCall1 = { + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10000-EDSC', + form: 'mock form', + name: 'mock form' + } + ] + }, + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + } + } + + const esiCall = { + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10001-EDSC', + form: 'mock form', + name: 'mock form' + } + ] + }, + type: 'ESI', + url: { + urlValue: 'https://example.com' + } + } + + const echoCall2 = { + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10002-EDSC', + form: 'mock form', + name: 'mock form' + } + ] + }, + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + } + } + + expect(buildEsiEchoMock).toHaveBeenNthCalledWith( + 1, + echoCall1, + { + associatedVariables: defaultAssociatedVariables, + echoIndex, + esiIndex, + harmonyIndex + } + ) + + // Increment echoIndex after expecting the esiEchoMethod to have been called for echo orders + echoIndex += 1 + + expect(buildEsiEchoMock).toHaveBeenNthCalledWith( + 2, + esiCall, + { + associatedVariables: defaultAssociatedVariables, + echoIndex, + esiIndex, + harmonyIndex + } + ) + + // Increment esiIndex after expecting the esiEchoMethod to have been called for an ESI Order + esiIndex += 1 + + expect(buildEsiEchoMock).toHaveBeenNthCalledWith( + 3, + echoCall2, + { + associatedVariables: defaultAssociatedVariables, + echoIndex, + esiIndex, + harmonyIndex + } + ) + + // Increment echoIndex after expecting the esiEchoMethod to have been called for echo orders + echoIndex += 1 + + // NOT READY FOR THIS YET + // expect(buildHarmonyMock).toHaveBeenNthCalledWith(1, {}) + // expect(buildHarmonyMock).toHaveBeenNthCalledWith(2, {}) + + // expect(buildOpendapMock).toHaveBeenNthCalledWith(1, {}) + + // expect(buildSwodlrMock).toHaveBeenNthCalledWith(1, {}) + }) + }) }) diff --git a/static/src/js/util/accessMethods/buildAccessMethods.js b/static/src/js/util/accessMethods/buildAccessMethods.js index ca4bfdf977..0c0f55a017 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods.js +++ b/static/src/js/util/accessMethods/buildAccessMethods.js @@ -67,8 +67,13 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => { echoIndex: newEchoIndex } = builtMethod - esiIndex = newEsiIndex - echoIndex = newEchoIndex + esiIndex = newEsiIndex || esiIndex + echoIndex = newEchoIndex || echoIndex + + console.log(lowerServiceType) + + console.log(`esiIndex: ${esiIndex}\t newEsiIndex: ${newEsiIndex}`) + console.log(`echoIndex: ${echoIndex}\t newEchoIndex: ${newEchoIndex}`) const updatedMethods = { ...methods, diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js index 8de435c43c..17afeb309a 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js @@ -11,6 +11,7 @@ import { generateFormDigest } from '../generateFormDigest' * @returns {object} Access method for ESI or Echo Orders */ export const buildEsiEcho = (serviceItem, params) => { + console.log('calling buildEsiEcho') const accessMethods = {} // Only process orderOptions if the service type uses orderOptions // Do not include access if orders are disabled @@ -25,7 +26,7 @@ export const buildEsiEcho = (serviceItem, params) => { let echoIndex = initEchoIndex if (disableOrdering !== 'true') { - // Pull out the esi and echo indeces and increment them to have an accurate count + // Pull out the esi and echo indices and increment them to have an accurate count const { orderOptions, type: serviceType, @@ -37,6 +38,7 @@ export const buildEsiEcho = (serviceItem, params) => { const { items: orderOptionsItems } = orderOptions if (orderOptionsItems === null) return {} + console.log('about to go through orderOptions') orderOptionsItems.forEach((orderOptionItem) => { const { @@ -59,12 +61,17 @@ export const buildEsiEcho = (serviceItem, params) => { let methodKey = camelCase(serviceType) + console.log(`methodKey: ${methodKey}`) + // `echoOrders` needs to be singular to match existing savedAccessConfigurations if (methodKey === 'echoOrders') { + console.log('in EchoOrders') methodKey = 'echoOrder' accessMethods[`${methodKey}${echoIndex}`] = method echoIndex += 1 + console.log(`new echoIndex: ${echoIndex}`) } else { + console.log('in esi') accessMethods[`${methodKey}${esiIndex}`] = method esiIndex += 1 } diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js b/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js index 292e2a6db8..1a56fdb187 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildHarmony.js @@ -38,6 +38,7 @@ export const buildHarmony = (serviceItem, params) => { keywordMappings, variables } = getVariables(associatedVariables) + const { supportedOutputProjections } = serviceItem From 5f8a29ec72450ba17bd525dba8cf3d1a394b0701 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Thu, 29 Aug 2024 15:40:34 -0400 Subject: [PATCH 19/20] fixed up the test --- .../__tests__/buildAccessMethods.test.js | 633 +++++++++++++++--- .../util/accessMethods/buildAccessMethods.js | 5 - 2 files changed, 552 insertions(+), 86 deletions(-) diff --git a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js index e115d3ec88..1109f60e04 100644 --- a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js +++ b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js @@ -44,8 +44,6 @@ describe('when buildAccessMethods is called', () => { test('calls buildEsiEcho access method with type ECHO ORDERS', () => { const buildEsiEchoMock = jest.spyOn(buildEsiEcho, 'buildEsiEcho') - buildEsiEchoMock.mockImplementationOnce(() => jest.fn()) - const collectionMetadata = { services: { items: [ @@ -64,6 +62,22 @@ describe('when buildAccessMethods is called', () => { } ] } + }, + { + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + }, + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10001-EDSC', + name: 'mock form', + form: 'mock form' + } + ] + } } ] } @@ -72,9 +86,10 @@ describe('when buildAccessMethods is called', () => { buildAccessMethods(collectionMetadata, isOpenSearch) - expect(buildEsiEchoMock).toBeCalledTimes(1) + expect(buildEsiEchoMock).toBeCalledTimes(2) - expect(buildEsiEchoMock).toHaveBeenCalledWith( + expect(buildEsiEchoMock).toHaveBeenNthCalledWith( + 1, { maxItemsPerOrder: 2000, orderOptions: { @@ -98,6 +113,32 @@ describe('when buildAccessMethods is called', () => { harmonyIndex: 0 } ) + + expect(buildEsiEchoMock).toHaveBeenNthCalledWith( + 2, + { + maxItemsPerOrder: 2000, + orderOptions: { + items: [ + { + conceptId: 'OO10001-EDSC', + form: 'mock form', + name: 'mock form' + } + ] + }, + type: 'ECHO ORDERS', + url: { + urlValue: 'https://example.com' + } + }, + { + associatedVariables: {}, + echoIndex: 1, + esiIndex: 0, + harmonyIndex: 0 + } + ) }) test('calls buildEsiEcho access method with type ESI', () => { @@ -894,14 +935,25 @@ describe('when buildAccessMethods is called', () => { expect(buildSwodlrMock).toBeCalledTimes(1) - expect(buildSwodlrMock).toHaveBeenCalledWith({ - conceptId: 'S100000-EDSC', - longName: 'Mock PODAAC SWOT On-Demand Level 2 Raster Generation (SWODLR)', - name: 'Mock PODAAC_SWODLR', - orderOptions: { - items: [] - }, - serviceOptions: { + expect(buildSwodlrMock).toHaveBeenCalledWith( + { + conceptId: 'S100000-EDSC', + longName: 'Mock PODAAC SWOT On-Demand Level 2 Raster Generation (SWODLR)', + name: 'Mock PODAAC_SWODLR', + orderOptions: { + items: [] + }, + serviceOptions: { + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator' + }, + { + projectionName: 'WGS84 - World Geodetic System 1984' + } + ] + }, + supportedInputProjections: null, supportedOutputProjections: [ { projectionName: 'Universal Transverse Mercator' @@ -909,27 +961,18 @@ describe('when buildAccessMethods is called', () => { { projectionName: 'WGS84 - World Geodetic System 1984' } - ] - }, - supportedInputProjections: null, - supportedOutputProjections: [ - { - projectionName: 'Universal Transverse Mercator' + ], + supportedReformattings: null, + type: 'SWODLR', + url: { + description: 'Service top-level URL', + urlValue: 'https://swodlr.podaac.earthdatacloud.nasa.gov' }, - { - projectionName: 'WGS84 - World Geodetic System 1984' + variables: { + items: [] } - ], - supportedReformattings: null, - type: 'SWODLR', - url: { - description: 'Service top-level URL', - urlValue: 'https://swodlr.podaac.earthdatacloud.nasa.gov' - }, - variables: { - items: [] } - }) + ) }) describe('when the collection contains both variables associated to its services and variables directly associated to the collection and 3 service records', () => { @@ -1607,8 +1650,8 @@ describe('when buildAccessMethods is called', () => { } ] }, - echoIndex: undefined, - esiIndex: undefined, + echoIndex: 0, + esiIndex: 0, harmonyIndex: 1 } ) @@ -1721,8 +1764,8 @@ describe('when buildAccessMethods is called', () => { } ] }, - echoIndex: undefined, - esiIndex: undefined, + echoIndex: 0, + esiIndex: 0, harmonyIndex: 2 } ) @@ -2272,8 +2315,8 @@ describe('when buildAccessMethods is called', () => { } ] }, - echoIndex: undefined, - esiIndex: undefined, + echoIndex: 0, + esiIndex: 0, harmonyIndex: 1 } ) @@ -2386,8 +2429,8 @@ describe('when buildAccessMethods is called', () => { } ] }, - echoIndex: undefined, - esiIndex: undefined, + echoIndex: 0, + esiIndex: 0, harmonyIndex: 2 } ) @@ -2768,8 +2811,12 @@ describe('when buildAccessMethods is called', () => { ] }, supportedOutputProjections: [ - { projectionName: 'Polar Stereographic' }, - { projectionName: 'Geographic' } + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } ], supportedReformattings: [ { @@ -2986,8 +3033,8 @@ describe('when buildAccessMethods is called', () => { } ] }, - echoIndex: undefined, - esiIndex: undefined, + echoIndex: 0, + esiIndex: 0, harmonyIndex: 1 } ) @@ -3100,8 +3147,8 @@ describe('when buildAccessMethods is called', () => { } ] }, - echoIndex: undefined, - esiIndex: undefined, + echoIndex: 0, + esiIndex: 0, harmonyIndex: 2 } ) @@ -3109,17 +3156,12 @@ describe('when buildAccessMethods is called', () => { }) describe('calls complex compilation of mutliple different access methods', () => { - test.only('calls all access methods correctly', () => { + test('calls all access methods correctly', () => { const buildEsiEchoMock = jest.spyOn(buildEsiEcho, 'buildEsiEcho') const buildHarmonyMock = jest.spyOn(buildHarmony, 'buildHarmony') const buildOpendapMock = jest.spyOn(buildOpendap, 'buildOpendap') const buildSwodlrMock = jest.spyOn(buildSwodlr, 'buildSwodlr') - buildEsiEchoMock.mockImplementationOnce(() => jest.fn()) - buildHarmonyMock.mockImplementationOnce(() => jest.fn()) - buildOpendapMock.mockImplementationOnce(() => jest.fn()) - buildSwodlrMock.mockImplementationOnce(() => jest.fn()) - const echoOrderItem1 = { type: 'ECHO ORDERS', url: { @@ -3174,11 +3216,6 @@ describe('when buildAccessMethods is called', () => { allowMultipleValues: true } }, - aggregation: { - concatenate: { - concatenateDefault: true - } - }, supportedOutputProjections: [ { projectionName: 'Polar Stereographic' @@ -3542,7 +3579,7 @@ describe('when buildAccessMethods is called', () => { } ], variables: { - count: 4, + count: 0, items: [] } } @@ -3550,11 +3587,11 @@ describe('when buildAccessMethods is called', () => { const collectionMetadata = { services: { items: [ - opendapItem, echoOrderItem1, esiItem, echoOrderItem2, harmonyItem1, + opendapItem, swodlrItem, harmonyItem2 ] @@ -3599,11 +3636,6 @@ describe('when buildAccessMethods is called', () => { expect(buildOpendapMock).toHaveBeenCalledTimes(1) expect(buildSwodlrMock).toHaveBeenCalledTimes(1) - // Index counters for echo/esi orders & harmony - let echoIndex = 0 - let esiIndex = 0 - let harmonyIndex = 0 // Will be indexed later - const defaultAssociatedVariables = { count: 3, items: [ @@ -3691,50 +3723,489 @@ describe('when buildAccessMethods is called', () => { echoCall1, { associatedVariables: defaultAssociatedVariables, - echoIndex, - esiIndex, - harmonyIndex + echoIndex: 0, + esiIndex: 0, + harmonyIndex: 0 } ) // Increment echoIndex after expecting the esiEchoMethod to have been called for echo orders - echoIndex += 1 - expect(buildEsiEchoMock).toHaveBeenNthCalledWith( 2, esiCall, { associatedVariables: defaultAssociatedVariables, - echoIndex, - esiIndex, - harmonyIndex + echoIndex: 1, + esiIndex: 0, + harmonyIndex: 0 } ) // Increment esiIndex after expecting the esiEchoMethod to have been called for an ESI Order - esiIndex += 1 - expect(buildEsiEchoMock).toHaveBeenNthCalledWith( 3, echoCall2, { associatedVariables: defaultAssociatedVariables, - echoIndex, - esiIndex, - harmonyIndex + echoIndex: 1, + esiIndex: 1, + harmonyIndex: 0 } ) // Increment echoIndex after expecting the esiEchoMethod to have been called for echo orders - echoIndex += 1 + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 1, + { + conceptId: 'S100000-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + serviceOptions: { + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + variables: { + count: 0, + items: null + } + }, + { + associatedVariables: defaultAssociatedVariables, + echoIndex: 2, + esiIndex: 1, + harmonyIndex: 0 + } + ) - // NOT READY FOR THIS YET - // expect(buildHarmonyMock).toHaveBeenNthCalledWith(1, {}) - // expect(buildHarmonyMock).toHaveBeenNthCalledWith(2, {}) + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 2, + { + conceptId: 'S100001-EDSC', + longName: 'Mock Service Name 2', + name: 'mock-name 2', + serviceOptions: { + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: + 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example2.com' + }, + variables: { + count: 0, + items: [] + } + }, + { + associatedVariables: defaultAssociatedVariables, + echoIndex: 2, + esiIndex: 1, + harmonyIndex: 1 + } + ) - // expect(buildOpendapMock).toHaveBeenNthCalledWith(1, {}) + expect(buildOpendapMock).toHaveBeenNthCalledWith( + 1, + { + conceptId: 'S100003-EDSC', + longName: 'Mock Service Name', + name: 'mock-name', + orderOptions: { + count: 0, + items: null + }, + serviceOptions: { + subset: { + spatialSubset: { + boundingBox: { + allowMultipleValues: false + } + }, + variableSubset: { + allowMultipleValues: true + } + }, + supportedInputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedOutputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'ASCII', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'BINARY', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'ASCII', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'BINARY', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'ASCII', + 'BINARY', + 'NETCDF-4' + ] + } + ], + type: 'OPeNDAP', + url: { + description: 'Mock URL', + urlValue: 'https://example.com' + }, + variables: { + count: 4, + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'analysed_sst in units of kelvin', + longName: 'analysed_sst', + name: 'analysed_sst', + nativeId: 'e2eTestVarHiRes1', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100001-EDSC', + definition: 'analysis_error in units of kelvin', + longName: 'analysis_error', + name: 'analysis_error', + nativeId: 'e2eTestVarHiRes2', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100002-EDSC', + definition: 'mask in units of seconds since 1981-0', + longName: 'mask', + name: 'mask', + nativeId: 'e2eTestVarHiRes4', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100003-EDSC', + definition: 'sea_ice_fraction in units of fraction (between 0 ', + longName: 'sea_ice_fraction', + name: 'sea_ice_fraction', + nativeId: 'e2eTestVarHiRes3', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + } + ] + } + }, + { + associatedVariables: { + count: 4, + items: [ + { + conceptId: 'V100000-EDSC', + definition: 'analysed_sst in units of kelvin', + longName: 'analysed_sst', + name: 'analysed_sst', + nativeId: 'e2eTestVarHiRes1', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100001-EDSC', + definition: 'analysis_error in units of kelvin', + longName: 'analysis_error', + name: 'analysis_error', + nativeId: 'e2eTestVarHiRes2', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100002-EDSC', + definition: 'mask in units of seconds since 1981-0', + longName: 'mask', + name: 'mask', + nativeId: 'e2eTestVarHiRes4', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + }, + { + conceptId: 'V100003-EDSC', + definition: 'sea_ice_fraction in units of fraction (between 0 ', + longName: 'sea_ice_fraction', + name: 'sea_ice_fraction', + nativeId: 'e2eTestVarHiRes3', + scienceKeywords: [ + { + category: 'Earth Science', + term: 'Ocean Temperature', + topic: 'Oceans', + variableLevel1: 'Sea Surface Temperature' + } + ] + } + ] + }, + echoIndex, + esiIndex, + harmonyIndex + } + ) - // expect(buildSwodlrMock).toHaveBeenNthCalledWith(1, {}) + expect(buildSwodlrMock).toHaveBeenNthCalledWith( + 1, + { + conceptId: 'S100004-EDSC', + longName: 'Mock PODAAC SWOT On-Demand Level 2 Raster Generation (SWODLR)', + name: 'Mock PODAAC_SWODLR', + orderOptions: { + items: [] + }, + serviceOptions: { + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator' + }, + { + projectionName: 'WGS84 - World Geodetic System 1984' + } + ] + }, + supportedInputProjections: null, + supportedOutputProjections: [ + { + projectionName: 'Universal Transverse Mercator' + }, + { + projectionName: 'WGS84 - World Geodetic System 1984' + } + ], + supportedReformattings: null, + type: 'SWODLR', + url: { + description: 'Service top-level URL', + urlValue: 'https://swodlr.podaac.earthdatacloud.nasa.gov' + }, + variables: { + items: [] + } + } + ) }) }) }) diff --git a/static/src/js/util/accessMethods/buildAccessMethods.js b/static/src/js/util/accessMethods/buildAccessMethods.js index 0c0f55a017..df97e266a5 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods.js +++ b/static/src/js/util/accessMethods/buildAccessMethods.js @@ -70,11 +70,6 @@ export const buildAccessMethods = (collectionMetadata, isOpenSearch) => { esiIndex = newEsiIndex || esiIndex echoIndex = newEchoIndex || echoIndex - console.log(lowerServiceType) - - console.log(`esiIndex: ${esiIndex}\t newEsiIndex: ${newEsiIndex}`) - console.log(`echoIndex: ${echoIndex}\t newEchoIndex: ${newEchoIndex}`) - const updatedMethods = { ...methods, ...newAccessMethods From fa630bfaca19204e349aabdaf5da93f4525b12d5 Mon Sep 17 00:00:00 2001 From: Benjamin Poreh Date: Thu, 29 Aug 2024 15:45:56 -0400 Subject: [PATCH 20/20] EDSC-3773: merged new test and removed console.logs and fixed the order of checking results so they are accurate to the indexing of echoIndex, esiIndex, & harmonyIndex --- .../__tests__/buildAccessMethods.test.js | 188 +++++++++--------- .../buildAccessMethods/buildEsiEcho.js | 8 +- 2 files changed, 95 insertions(+), 101 deletions(-) diff --git a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js index 1109f60e04..5025a65be6 100644 --- a/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js +++ b/static/src/js/util/accessMethods/__tests__/buildAccessMethods.test.js @@ -3844,97 +3844,6 @@ describe('when buildAccessMethods is called', () => { } ) - expect(buildHarmonyMock).toHaveBeenNthCalledWith( - 2, - { - conceptId: 'S100001-EDSC', - longName: 'Mock Service Name 2', - name: 'mock-name 2', - serviceOptions: { - interpolationTypes: [ - 'Bilinear Interpolation', - 'Nearest Neighbor' - ], - subset: { - spatialSubset: { boundingBox: { allowMultipleValues: false } }, - variableSubset: { allowMultipleValues: true } - }, - supportedOutputProjections: [ - { - projectionName: 'Polar Stereographic' - }, - { - projectionName: 'Geographic' - } - ], - supportedReformattings: [ - { - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, - { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - } - ] - }, - supportedOutputProjections: [ - { - projectionName: - 'Polar Stereographic' - }, - { - projectionName: 'Geographic' - } - ], - supportedReformattings: [ - { - supportedInputFormat: 'NETCDF-4', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - }, - { - supportedInputFormat: 'GEOTIFF', - supportedOutputFormats: [ - 'GEOTIFF', - 'PNG', - 'TIFF', - 'NETCDF-4' - ] - } - ], - type: 'Harmony', - url: { - description: 'Mock URL', - urlValue: 'https://example2.com' - }, - variables: { - count: 0, - items: [] - } - }, - { - associatedVariables: defaultAssociatedVariables, - echoIndex: 2, - esiIndex: 1, - harmonyIndex: 1 - } - ) - expect(buildOpendapMock).toHaveBeenNthCalledWith( 1, { @@ -4161,9 +4070,100 @@ describe('when buildAccessMethods is called', () => { } ] }, - echoIndex, - esiIndex, - harmonyIndex + echoIndex: 2, + esiIndex: 1, + harmonyIndex: 1 + } + ) + + expect(buildHarmonyMock).toHaveBeenNthCalledWith( + 2, + { + conceptId: 'S100001-EDSC', + longName: 'Mock Service Name 2', + name: 'mock-name 2', + serviceOptions: { + interpolationTypes: [ + 'Bilinear Interpolation', + 'Nearest Neighbor' + ], + subset: { + spatialSubset: { boundingBox: { allowMultipleValues: false } }, + variableSubset: { allowMultipleValues: true } + }, + supportedOutputProjections: [ + { + projectionName: 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ] + }, + supportedOutputProjections: [ + { + projectionName: + 'Polar Stereographic' + }, + { + projectionName: 'Geographic' + } + ], + supportedReformattings: [ + { + supportedInputFormat: 'NETCDF-4', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + }, + { + supportedInputFormat: 'GEOTIFF', + supportedOutputFormats: [ + 'GEOTIFF', + 'PNG', + 'TIFF', + 'NETCDF-4' + ] + } + ], + type: 'Harmony', + url: { + description: 'Mock URL', + urlValue: 'https://example2.com' + }, + variables: { + count: 0, + items: [] + } + }, + { + associatedVariables: defaultAssociatedVariables, + echoIndex: 2, + esiIndex: 1, + harmonyIndex: 1 } ) diff --git a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js index 17afeb309a..ecf12130ac 100644 --- a/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js +++ b/static/src/js/util/accessMethods/buildAccessMethods/buildEsiEcho.js @@ -11,7 +11,6 @@ import { generateFormDigest } from '../generateFormDigest' * @returns {object} Access method for ESI or Echo Orders */ export const buildEsiEcho = (serviceItem, params) => { - console.log('calling buildEsiEcho') const accessMethods = {} // Only process orderOptions if the service type uses orderOptions // Do not include access if orders are disabled @@ -37,8 +36,8 @@ export const buildEsiEcho = (serviceItem, params) => { const { urlValue } = url const { items: orderOptionsItems } = orderOptions + if (orderOptionsItems === null) return {} - console.log('about to go through orderOptions') orderOptionsItems.forEach((orderOptionItem) => { const { @@ -61,17 +60,12 @@ export const buildEsiEcho = (serviceItem, params) => { let methodKey = camelCase(serviceType) - console.log(`methodKey: ${methodKey}`) - // `echoOrders` needs to be singular to match existing savedAccessConfigurations if (methodKey === 'echoOrders') { - console.log('in EchoOrders') methodKey = 'echoOrder' accessMethods[`${methodKey}${echoIndex}`] = method echoIndex += 1 - console.log(`new echoIndex: ${echoIndex}`) } else { - console.log('in esi') accessMethods[`${methodKey}${esiIndex}`] = method esiIndex += 1 }