Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDMIF updates for SQL/DAO and validation event handling #444

Merged
merged 630 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
630 commits
Select commit Hold shift + click to select a range
54c7bd6
Merge pull request #126 from Buildings-IOT/gcp_cleanup
naveenlakshmi Apr 18, 2022
a712e90
Merge branch 'master' of github.com:Buildings-IOT/udmi
slevertbiot Apr 18, 2022
303cbe8
#652-can now log in with google
Apr 19, 2022
d688a2b
#652-added guards
Apr 20, 2022
fbb0689
#652-add token on every outbound request
Apr 20, 2022
f274c79
#652-spiced up login page
Apr 20, 2022
46bf76a
#652-added images folder, change authToken to idToken
Apr 20, 2022
9f40332
comment changes
pcarriere-biot Apr 20, 2022
d0e742c
#652-added tests, changed header from Authorization to idToken
Apr 20, 2022
05ee485
#652-fixed tests
Apr 20, 2022
1317f81
Merge remote-tracking branch 'origin/master' into #652-Login
slevertbiot Apr 21, 2022
be525f7
Merge pull request #127 from Buildings-IOT/#652-Login
mspratt-biot Apr 21, 2022
615b7f8
918 add api token verification (#128)
slevertbiot Apr 22, 2022
96fdad7
editing function object path
naveenlakshmi Apr 22, 2022
b87803d
Added service account for gke cluster
nkotibiot Apr 25, 2022
48fcab9
Merge remote-tracking branch 'origin/master' into helm_docker_gcp
nkotibiot Apr 25, 2022
c1515b9
Merge pull request #129 from Buildings-IOT/helm_docker_gcp
nkotibiot Apr 25, 2022
b317224
Updated helm chart
nkotibiot Apr 25, 2022
06520c2
Docker build issue fixed
nkotibiot Apr 25, 2022
1a62772
updated buld dir
nkotibiot Apr 25, 2022
1760933
testing function with Map variables
naveenlakshmi Apr 26, 2022
f04963f
Build files added for local setup
nkotibiot Apr 26, 2022
dcbbffd
Merge pull request #130 from Buildings-IOT/helm_docker_gcp
nkotibiot Apr 26, 2022
1eb2f2e
updating gcf with variables with map(object)
naveenlakshmi Apr 26, 2022
de46f9f
editing function object path
naveenlakshmi Apr 22, 2022
a9d02ba
testing function with Map variables
naveenlakshmi Apr 26, 2022
d65ab75
updating gcf with variables with map(object)
naveenlakshmi Apr 26, 2022
1b8157b
updating function.tf
naveenlakshmi Apr 26, 2022
a5f0838
Fixed helm deploy issue
nkotibiot Apr 26, 2022
aa70c6d
Merge pull request #131 from Buildings-IOT/gcp_cleanup
naveenlakshmi Apr 26, 2022
c074778
Merge pull request #132 from Buildings-IOT/helm_docker_gcp
nkotibiot Apr 26, 2022
e6ad806
Fixed docker auth issue
nkotibiot Apr 26, 2022
7800e50
Merge pull request #133 from Buildings-IOT/helm_docker_gcp
nkotibiot Apr 26, 2022
7210757
modify function.tf
naveenlakshmi Apr 26, 2022
0004402
Merge pull request #134 from Buildings-IOT/gcp_cleanup
naveenlakshmi Apr 26, 2022
69d72db
Added docs for build and deploy
nkotibiot Apr 27, 2022
6d76827
update helm documnentation
nkotibiot Apr 27, 2022
1cfc2d0
Merge pull request #136 from Buildings-IOT/helm_docker_gcp
nkotibiot Apr 27, 2022
62e8e96
#961-moved google client id into envs file
Apr 26, 2022
92dba69
#961-added copy of env.js file in dockerfile
Apr 27, 2022
4604c2e
Added variables
nkotibiot Apr 27, 2022
9506700
Merge pull request #137 from Buildings-IOT/helm_docker_gcp
nkotibiot Apr 27, 2022
ae24b9c
#961-moved api uri to env
Apr 27, 2022
43d3b62
Added project id in gks
nkotibiot Apr 27, 2022
a01a070
#961-fixed typos
Apr 27, 2022
0912812
#961-added types to factory returns
Apr 27, 2022
f6e8734
Added env variables for web and api
nkotibiot Apr 27, 2022
18ef194
Merge pull request #139 from Buildings-IOT/helm_docker_gcp
nkotibiot Apr 27, 2022
3044917
Merging faucetsdn in
slevertbiot Apr 27, 2022
561d616
Corrected helm.md
nkotibiot Apr 28, 2022
8373802
Merge pull request #140 from Buildings-IOT/helm_docker_gcp
nkotibiot Apr 28, 2022
d6ea277
Merge pull request #138 from Buildings-IOT/#961-MoveSensitiveValuesToEnv
mspratt-biot Apr 29, 2022
df4b75e
#957-added handling for refreshing token
Apr 29, 2022
ea56338
Merge pull request #142 from Buildings-IOT/#957-AddTokenRefresh
mspratt-biot May 3, 2022
13125d1
deleted extra src file
naveenlakshmi May 3, 2022
b12433f
deleted unwanted files
naveenlakshmi May 3, 2022
b7941b3
Merge pull request #143 from Buildings-IOT/Modifying-function
naveenlakshmi May 3, 2022
2eab190
fixed docker pulished issue in api
nkotibiot May 4, 2022
1f00b6c
Merge pull request #144 from Buildings-IOT/helm-docker
nkotibiot May 4, 2022
0800485
#755-Added endpoints to be able to retrieve device names, makes model…
May 12, 2022
f8efe95
#755-added validation to limit input
May 12, 2022
cd85855
#755-reduced duplication
May 13, 2022
1ef9d14
Handle system state messages (#149)
slevertbiot May 13, 2022
50abd3e
#755-adding tests
May 16, 2022
75a1bb8
#755-added all tests
May 16, 2022
50d899a
#755-added more tests
May 16, 2022
c08411c
Merge pull request #150 from Buildings-IOT/#755-BackendToSupportFilte…
mspratt-biot May 16, 2022
90da08f
Refactor to Prep for Handling PointSet Messages (#151)
slevertbiot May 16, 2022
9990895
#756-setup front-end to supply needed params to backend to generate p…
May 4, 2022
3fd56c1
#756-added tests
May 5, 2022
f239bab
#756-fixed tests
May 5, 2022
33a07cc
#756-reverted api changes
May 9, 2022
579e382
#756-adjusted search filter to call service directly
May 9, 2022
5125fce
#756-made search filter work with any service
May 9, 2022
546126a
#756-removed types
May 9, 2022
5d734aa
#756-created distinct queries for each field
May 10, 2022
3bf6d07
#756-Adjusted to new API
May 16, 2022
0a0ba04
#756-removed notifyOnNetworkChange for search queries
May 16, 2022
93ad5f2
Merge pull request #148 from Buildings-IOT/#756-AutocompleteSuggestio…
mspratt-biot May 17, 2022
2670b44
#1092-added date formatting
May 17, 2022
146aa49
testing source function
naveenlakshmi May 17, 2022
00caa2b
testing source with dist
naveenlakshmi May 17, 2022
1b86b01
Merge pull request #153 from Buildings-IOT/updating-source-functions
naveenlakshmi May 17, 2022
c80fbe8
testing dist foloder
naveenlakshmi May 17, 2022
357b87f
testing sourc
naveenlakshmi May 17, 2022
03a2171
Merge pull request #154 from Buildings-IOT/updating-source-functions
naveenlakshmi May 17, 2022
e1e8ebc
testing with source
naveenlakshmi May 17, 2022
7295016
Merge pull request #155 from Buildings-IOT/updating-source-functions
naveenlakshmi May 17, 2022
0d7ddb1
testing source
naveenlakshmi May 17, 2022
bfffc5e
Merge pull request #156 from Buildings-IOT/updating-source-functions
naveenlakshmi May 17, 2022
7871f40
testing source with zip
naveenlakshmi May 17, 2022
d8de928
Merge pull request #157 from Buildings-IOT/updating-source-functions
naveenlakshmi May 17, 2022
eefca34
#1092-adjusted tests
May 17, 2022
4dd4b3d
changing index.zip to dist.zip
naveenlakshmi May 17, 2022
6903434
Merge pull request #158 from Buildings-IOT/updating-source-functions
naveenlakshmi May 17, 2022
7555b26
Merge pull request #152 from Buildings-IOT/#1092-GAR4-DateFormatChang…
mspratt-biot May 17, 2022
13c1f9e
#1094-increased whitespace
May 18, 2022
de78ee9
changing source foloder
naveenlakshmi May 18, 2022
2ffef98
Merge pull request #160 from Buildings-IOT/updating-source-functions
naveenlakshmi May 18, 2022
ce8e2d7
Cleanup artifacts from checkin
pcarriere-biot May 18, 2022
869cfcd
some more build cleanups
pcarriere-biot May 18, 2022
75933d6
testing gcf
naveenlakshmi May 18, 2022
80d8eb9
testing
naveenlakshmi May 18, 2022
07aeba3
created build.yml for event handler
naveenlakshmi May 18, 2022
f1d43ed
#1091-increased the font sizes according to gar4
May 18, 2022
d72b6e3
#1093-adjusted filter bar and other items to increase contrast
May 19, 2022
3f885a2
Merge pull request #162 from Buildings-IOT/#1093-ContrastGar4
mspratt-biot May 19, 2022
b938dcb
Merge pull request #161 from Buildings-IOT/#1091-IncreaseFontSizes
mspratt-biot May 19, 2022
36b05ec
Merge pull request #159 from Buildings-IOT/#1094-IncreaseWhitespace
mspratt-biot May 19, 2022
7a9c1f1
#1095-moved location of devices button
May 19, 2022
d3d9bdd
#1095-changed h1 to h2 for UDMI 'logo'
May 19, 2022
1b252c2
removed functions.tf
nkotibiot May 19, 2022
67760ee
Merge pull request #164 from Buildings-IOT/functions-event
nkotibiot May 19, 2022
dcef11a
Merge pull request #163 from Buildings-IOT/#1095-AdjustDevicesLinkToM…
mspratt-biot May 19, 2022
8882bae
Trigger Merge pipeline when spcific dir/sub dir changed
nkotibiot May 19, 2022
e87b37e
Merge pull request #165 from Buildings-IOT/functions-event
nkotibiot May 19, 2022
66756cb
#1090-fixed incorrect use of mat-sort-header
May 19, 2022
7b332c5
Merge pull request #166 from Buildings-IOT/#1090-EnsureKeyboardIntera…
mspratt-biot May 20, 2022
8ea0b4d
testing gcf
naveenlakshmi May 25, 2022
4bcfaba
testing gcf
naveenlakshmi May 25, 2022
e855446
Handle pointset messages (#167)
slevertbiot May 25, 2022
16f67f7
GCP clud function fixes
pcarriere-biot May 25, 2022
47ff552
Handle pointset messages (#168)
slevertbiot May 25, 2022
47c3289
GCP Function work
pcarriere-biot May 25, 2022
4851b91
Configured cloud function deployment
nkotibiot May 25, 2022
9af07be
merged from master
nkotibiot May 25, 2022
862db2f
Merge pull request #169 from Buildings-IOT/create-gcf
nkotibiot May 25, 2022
158c833
Setup env variables
nkotibiot May 25, 2022
9c20830
Merge pull request #170 from Buildings-IOT/create-gcf
nkotibiot May 25, 2022
5d9773a
Changed env varible
nkotibiot May 26, 2022
8cf4e83
set up env variable
nkotibiot May 26, 2022
3c7de46
cleanup googlefunction variables
nkotibiot May 26, 2022
e00bc54
updated event handler function
nkotibiot May 26, 2022
fd2c859
Merge pull request #171 from Buildings-IOT/env-mongo
nkotibiot May 26, 2022
f6430f0
Removed license from package.json
pcarriere-biot May 27, 2022
54f3121
updated env varibles
nkotibiot May 27, 2022
0d79e18
Merge pull request #172 from Buildings-IOT/event-handler-env
nkotibiot May 27, 2022
167152b
testing event-handler ci
naveenlakshmi May 31, 2022
02c7775
testing ci
naveenlakshmi May 31, 2022
53f1c8f
Merging in master from faucetsdn/udmi
slevertbiot May 31, 2022
6d791c2
Merge branch 'master' of github.com:Buildings-IOT/udmi
slevertbiot May 31, 2022
51f4471
Fixing static data pagination by using correct variable (#174)
slevertbiot Jun 1, 2022
66d4a60
testing gcf ci
naveenlakshmi Jun 1, 2022
177574e
testing gcf ci
naveenlakshmi Jun 1, 2022
87b567d
Merge pull request #175 from Buildings-IOT/creating-gcf-ci/cd
naveenlakshmi Jun 1, 2022
e79bdd3
testing gcf ci
naveenlakshmi Jun 1, 2022
952a8f0
Merge pull request #176 from Buildings-IOT/creating-gcf-ci/cd
naveenlakshmi Jun 1, 2022
692ad26
Handle repetitive pointset messages (#173)
slevertbiot Jun 1, 2022
10c1d4a
enabled automatic deployment in staging
nkotibiot Jun 2, 2022
9133695
Merge pull request #178 from Buildings-IOT/event-handler
nkotibiot Jun 2, 2022
566e599
changing mongo host
naveenlakshmi Jun 2, 2022
aad8024
Merge pull request #179 from Buildings-IOT/changing-Mongo-host
naveenlakshmi Jun 2, 2022
2037e62
updating Mongo-host
naveenlakshmi Jun 2, 2022
7e3e763
Merge pull request #180 from Buildings-IOT/changing-Mongo-host
naveenlakshmi Jun 2, 2022
a370da1
testing gcf ci
naveenlakshmi Jun 2, 2022
307e984
removing uneeded zip (#177)
slevertbiot Jun 3, 2022
74c2e63
testing ci/cd for gcf
naveenlakshmi Jun 3, 2022
dcaf508
testing ci/cd for gcf
naveenlakshmi Jun 3, 2022
386a83a
ci/cd/gcf
naveenlakshmi Jun 3, 2022
f478e27
Merge pull request #181 from Buildings-IOT/changing-Mongo-host
naveenlakshmi Jun 3, 2022
e9a0c9d
testing gcf/ci/cd
naveenlakshmi Jun 3, 2022
ec645fc
Merge pull request #182 from Buildings-IOT/changing-Mongo-host
naveenlakshmi Jun 3, 2022
370e29f
testing gcf
naveenlakshmi Jun 3, 2022
82d6094
Merge pull request #183 from Buildings-IOT/changing-Mongo-host
naveenlakshmi Jun 3, 2022
ac045f5
creating ci/cd/gcf
naveenlakshmi Jun 3, 2022
93af402
Merge pull request #185 from Buildings-IOT/changing-Mongo-host
naveenlakshmi Jun 3, 2022
d131ece
testing ci/cd-gcf
naveenlakshmi Jun 3, 2022
2801861
Merge pull request #186 from Buildings-IOT/changing-Mongo-host
naveenlakshmi Jun 3, 2022
e0f8b98
testing ci/cd
naveenlakshmi Jun 3, 2022
39623a7
Merge pull request #187 from Buildings-IOT/changing-Mongo-host
naveenlakshmi Jun 3, 2022
505e77e
changing mongo access admin to udmi
naveenlakshmi Jun 6, 2022
3470ac6
updated variable in api
nkotibiot Jun 6, 2022
60dad30
Merge pull request #188 from Buildings-IOT/changing-Mongo-host
naveenlakshmi Jun 6, 2022
40f4126
Merge pull request #189 from Buildings-IOT/api-variable
nkotibiot Jun 6, 2022
86d0291
Adding log to see incoming message (#190)
slevertbiot Jun 6, 2022
50a1e94
Fixed readme
pcarriere-biot Jun 6, 2022
aaac039
Update README.md
slevertbiot Jun 6, 2022
873efe5
Add log to help debug (#191)
slevertbiot Jun 6, 2022
fe20460
updated variable
nkotibiot Jun 6, 2022
8482264
Merge pull request #192 from Buildings-IOT/api-variable
nkotibiot Jun 6, 2022
f3b6d25
Fixing env var key for mongor password (#193)
slevertbiot Jun 7, 2022
f6ea118
updating mongo_host
naveenlakshmi Jun 7, 2022
544816e
Merge pull request #194 from Buildings-IOT/updating-mongohost
naveenlakshmi Jun 7, 2022
19fd7cc
Fix env var (#195)
slevertbiot Jun 8, 2022
99b305c
Fixing the data so that the tags and points are populated with empty …
slevertbiot Jun 8, 2022
90da14f
Fixing data (#197)
slevertbiot Jun 8, 2022
4b10c76
changed usage of @import to @use
Jun 8, 2022
d6506fa
Merge pull request #198 from Buildings-IOT/ChangeUseOf@ImportTo@Use
mspratt-biot Jun 8, 2022
139fc8c
#1177-added details about envs
Jun 9, 2022
f2bf2d3
Merge pull request #199 from Buildings-IOT/#1177-EnvVariablesDocs
mspratt-biot Jun 9, 2022
fa58c0b
Handle env variable by not throwing exception if the var is not avail…
slevertbiot Jun 9, 2022
d420f7a
#1179-removed state from devices service
Jun 10, 2022
a46a832
#1179-fixed tests, removed use of fragments for testing purposes
Jun 10, 2022
165066c
Merge pull request #201 from Buildings-IOT/#1179-DeviceListSometimesS…
mspratt-biot Jun 13, 2022
2bdffe1
#1182-changed the filter icon
Jun 10, 2022
285dc88
Merge pull request #202 from Buildings-IOT/#1182-FilterIconChange
mspratt-biot Jun 13, 2022
164afbe
#1181-changed theme colors, adjusted nav
Jun 13, 2022
ecd926e
Merge pull request #203 from Buildings-IOT/#1181-ColorBlindThemes
mspratt-biot Jun 13, 2022
3410a6c
#1180-moved search filter down
Jun 14, 2022
0ea8d30
#1180-made clear filters work
Jun 14, 2022
242fe61
#1180-fixed clearing/opening/closing autocomplete
Jun 14, 2022
657dbae
#1180-made ux behave nicer for autocomplete when clearing
Jun 14, 2022
818ed1b
#1180-adjusted comments
Jun 14, 2022
290a6e1
#1180-adjusted tests
Jun 15, 2022
5ad596f
#1180-added test for when clearing all filters
Jun 15, 2022
7876bdc
#1180-removed unused css import
Jun 15, 2022
21b3ed3
Terraform adjustments for successful deployment
pcarriere-biot Jun 15, 2022
3dcf245
Removed Creds
pcarriere-biot Jun 15, 2022
6c9524b
Updated gitignore
pcarriere-biot Jun 15, 2022
d9c92d5
Merge pull request #204 from Buildings-IOT/#1180-AugmentSearchFilter
mspratt-biot Jun 15, 2022
094911b
Fixed build issue in gcp
nkotibiot Jul 8, 2022
737964a
Merge pull request #206 from Buildings-IOT/gcp-build
nkotibiot Jul 8, 2022
0d581de
Adjust scripts and readmes (#205)
slevertbiot Jul 8, 2022
0da79a0
Merge branch 'master' of github.com:faucetsdn/udmi
slevertbiot Jul 8, 2022
1098476
Merge remote-tracking branch 'upstream/master'
slevertbiot Aug 2, 2022
e00520e
Merge remote-tracking branch 'upstream/master'
slevertbiot Aug 3, 2022
5a3c06f
Rename jest mongodb config file (#207)
slevertbiot Aug 4, 2022
ddf6597
Introducing a docker container to run tests (#208)
slevertbiot Aug 4, 2022
6201272
Merge remote-tracking branch 'upstream/master'
slevertbiot Aug 5, 2022
2a22fee
removing devices.json from branch, this can be generated when needed
slevertbiot Aug 5, 2022
9418183
Handle validation message (#209)
slevertbiot Aug 9, 2022
f22baa9
Handle validation message (#210)
slevertbiot Aug 11, 2022
334cfb8
Update device key (#211)
slevertbiot Aug 12, 2022
c283957
Merging faucetsdn into our master
slevertbiot Aug 12, 2022
444ed3c
Merge remote-tracking branch 'upstream/master'
slevertbiot Aug 15, 2022
bb4aea4
handling braoder set of incoming validation messages (#212)
slevertbiot Aug 16, 2022
636613a
Handling basic site message, refactored to remove duplicated logic (#…
slevertbiot Aug 18, 2022
c41c38a
Handle site errors (#216)
slevertbiot Aug 19, 2022
c9ad1ec
#1341-setup the sites screen
Aug 17, 2022
b903c5c
#1341-fixed tests
Aug 18, 2022
7363ae3
#1341-added :void
Aug 19, 2022
956d483
#1341-renamed the sites query and created a proper sites query
Aug 17, 2022
a2fdb21
#1341-fixed/added tests
Aug 19, 2022
94aafaf
#1341-created a generic dao
Aug 22, 2022
a7ccfbd
#1341-moved folders around
Aug 22, 2022
5acc361
#1341-added lodash lib, moved out common logic
Aug 22, 2022
88423be
#1341-adjusted imports
Aug 22, 2022
9d13011
#1341-fixed tests
Aug 22, 2022
d77114d
#1341-added tests
Aug 23, 2022
86660dc
#1341-added more tests
Aug 23, 2022
a9202ca
#1341-renamed searchOptions type
Aug 23, 2022
08249e9
#1341-fixed tests
Aug 25, 2022
619c498
Merge pull request #218 from Buildings-IOT/#1341-SetupSitesApiPart2
mspratt-biot Aug 26, 2022
229f8f2
Merge pull request #214 from Buildings-IOT/#1341-SetupSitesScreen
mspratt-biot Aug 26, 2022
d6dfe1f
Persisting all Site Validation Messages (#219)
slevertbiot Aug 31, 2022
3d0d5b1
Adding device validation history (#221)
slevertbiot Sep 1, 2022
543169c
Adding device validation history (#222)
slevertbiot Sep 1, 2022
785984a
Merge remote-tracking branch 'upstream/master'
slevertbiot Sep 6, 2022
4e2c802
Rolling back changes that are required for MacOS dev
slevertbiot Sep 6, 2022
0a3382d
Adding enhanced git ignore
slevertbiot Sep 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion udmif/api/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ globalConfig.json
.env

# mongo output
.mongodb
.mongodb

.jest

.cache
4,994 changes: 2,136 additions & 2,858 deletions udmif/api/package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions udmif/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
"dotenv": "^16.0.0",
"google-auth-library": "^7.14.1",
"graphql": "^16.2.0",
"lodash": "^4.17.21",
"mongodb": "^4.4.1",
"uuid": "^8.3.2",
"winston": "^3.6.0"
},
"devDependencies": {
"@shelf/jest-mongodb": "^2.2.1",
"@types/jest": "^27.4.0",
"@types/lodash": "^4.14.184",
"@types/node": "^17.0.10",
"@types/uuid": "^8.3.4",
"husky": "^7.0.4",
"jest": "^27.4.7",
"jest-junit": "^13.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { fromString } from '../../device/FilterParser';
import { Filter } from '../../device/model';
import { fromString } from '../../common/FilterParser';
import { Filter } from '../../common/model';

describe('FilterParser.fromString', () => {
test('converts a string into a filter object', () => {
Expand Down
30 changes: 30 additions & 0 deletions udmif/api/src/__tests__/common/SearchOptionsValidator.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { validateSearchOptions, validateDistinctSearchOptions } from '../../common/SearchOptionsValidator';

describe('SearchOptionsValidator.validateSearchOptions', () => {
test('defaults offset if not provided', () => {
expect(validateSearchOptions({ batchSize: 100 })).toEqual({ batchSize: 100, offset: 0 });
});

test.each([
[0, 0],
[999, 999],
[1000, 1000],
[1001, 1000],
])('limit is reduced to 1000 if a value greater than 1000', async (batchSize, expected) => {
expect(validateSearchOptions({ batchSize })).toEqual({ batchSize: expected, offset: 0 });
});
});

describe('SearchOptionsValidator.validateDistinctSearchOptions', () => {
test.each([
[0, 0],
[null, 10],
[undefined, 10],
])('limit defaults to 10 when not supplied', async (limit, expected) => {
expect(validateDistinctSearchOptions({ limit }).limit).toEqual(expected);
});

test('limit still defaults to 10 when no searchOptions are supplied', () => {
expect(validateDistinctSearchOptions().limit).toEqual(10);
});
});
96 changes: 96 additions & 0 deletions udmif/api/src/__tests__/dao/DAO.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import { Collection, MongoClient, Db } from 'mongodb';
import { DAO } from '../../dao/DAO';
import { DefaultDAO } from '../../dao/DAO';
import { Device } from '../../device/model';

describe('DAO', () => {
let deviceDao: DAO<Device>; // test with Device as an example
let deviceCollection: Collection<Device>;
let connection: MongoClient;
let db: Db;

const mockClient = jest.fn();

beforeAll(async () => {
// in memory mongo
connection = await MongoClient.connect(process.env.MONGO_URL);
db = connection.db('tmp');
});

beforeEach(async () => {
mockClient.mockReturnValue({
db: () => {
return { collection: jest.fn() };
},
});

// mock the static MongoClient.connect here
MongoClient.connect = mockClient;

deviceCollection = db.collection('device');
deviceDao = new DefaultDAO<Device>(deviceCollection);
await deviceCollection.deleteMany({});
});

afterAll(async () => {
// make sure we close it before the test completely finish
await connection.close();
});

test('getAll', async () => {
const insertedDeviceDocument: Device = { name: 'device-1', site: 'LOC' };

deviceCollection.insertOne(insertedDeviceDocument);

const devides: Device[] = await deviceDao.getAll({ batchSize: 10, offset: 0 });

expect(devides).toEqual([insertedDeviceDocument]);
});

test('getOne', async () => {
const insertedDeviceDocument: Device = { id: 'd-id-1', name: 'device-1', site: 'LOC' };

deviceCollection.insertOne(insertedDeviceDocument);

const device: Device = await deviceDao.getOne({ id: 'd-id-1' });

expect(device).toEqual(insertedDeviceDocument);
});

test('getFilteredCount', async () => {
const insertedDeviceDocument1: Device = { id: 'd-id-1', name: 'device-1', site: 'LOC' };
const insertedDeviceDocument2: Device = { id: 'd-id-2', name: 'device-2', site: 'LOC' };

deviceCollection.insertMany([insertedDeviceDocument1, insertedDeviceDocument2]);

const filteredCount: number = await deviceDao.getFilteredCount({
batchSize: 10,
offset: 0,
filter: '[{"field":"name","operator":"~","value":"2"}]',
});

expect(filteredCount).toEqual(1);
});

test('getCount', async () => {
const insertedDeviceDocument1: Device = { id: 'd-id-1', name: 'device-1', site: 'LOC' };
const insertedDeviceDocument2: Device = { id: 'd-id-2', name: 'device-2', site: 'LOC' };

deviceCollection.insertMany([insertedDeviceDocument1, insertedDeviceDocument2]);

const count: number = await deviceDao.getCount();

expect(count).toEqual(2);
});

test('getDistinct', async () => {
const insertedDeviceDocument1: Device = { id: 'd-id-1', name: 'device-1', site: 'LOC' };
const insertedDeviceDocument2: Device = { id: 'd-id-2', name: 'device-2', site: 'LOC' };

deviceCollection.insertMany([insertedDeviceDocument1, insertedDeviceDocument2]);

const deviceNames: string[] = await deviceDao.getDistinct('name', { limit: 10 });

expect(deviceNames).toEqual(['device-1', 'device-2']);
});
});
119 changes: 0 additions & 119 deletions udmif/api/src/__tests__/device/DeviceDataSource.spec.ts

This file was deleted.

9 changes: 2 additions & 7 deletions udmif/api/src/__tests__/device/MockDeviceDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { GraphQLDataSource } from 'apollo-datasource-graphql/dist/GraphQLDataSource';
import { Device, DevicesResponse, Point, SearchOptions } from '../../device/model';
import { SearchOptions } from '../../common/model';
import { Device, DevicesResponse, Point } from '../../device/model';
import { createDevices } from './data';

export default class MockDeviceDataSource extends GraphQLDataSource<object> {
Expand Down Expand Up @@ -42,12 +43,6 @@ export default class MockDeviceDataSource extends GraphQLDataSource<object> {
.sort();
}

async getSites(): Promise<string[]> {
return createDevices(10)
.map((d) => d.site)
.sort();
}

async getSections(): Promise<string[]> {
return createDevices(10)
.map((d) => d.section)
Expand Down
Loading