generated from bcgov/quickstart-openshift
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backend): Added new route for responding with Authz Documents. (#…
…182)
- Loading branch information
Showing
9 changed files
with
304 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,155 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { AppController } from './app.controller'; | ||
import { AppService } from './app.service'; | ||
import { ObjectStoreService } from './v1/object-store/object.store.service'; | ||
import { AmsOracleConnectorService } from './v1/ams-oracle-connector/ams.oracle.connector.service'; | ||
import { HttpModule } from '@nestjs/axios'; | ||
import { Test, TestingModule } from '@nestjs/testing' | ||
import { AppController } from './app.controller' | ||
import { AppService } from './app.service' | ||
import { ObjectStoreService } from './v1/object-store/object.store.service' | ||
import { AmsOracleConnectorService } from './v1/ams-oracle-connector/ams.oracle.connector.service' | ||
import { HttpModule } from '@nestjs/axios' | ||
import { OmrrResponse } from './v1/types/omrr-response' | ||
import { OmrrApplicationStatusResponse } from './v1/types/omrr-application-status' | ||
|
||
describe('AppController', () => { | ||
let appController: AppController; | ||
let amsConnectorService: AmsOracleConnectorService; | ||
let appController: AppController | ||
let amsConnectorService: AmsOracleConnectorService | ||
|
||
beforeEach(async () => { | ||
const app: TestingModule = await Test.createTestingModule({ | ||
imports: [HttpModule], | ||
controllers: [AppController], | ||
providers: [AppService, ObjectStoreService, AmsOracleConnectorService] | ||
}).compile(); | ||
amsConnectorService = await app.resolve<AmsOracleConnectorService>(AmsOracleConnectorService); | ||
appController = app.get<AppController>(AppController); | ||
}); | ||
providers: [AppService, ObjectStoreService, AmsOracleConnectorService], | ||
}).compile() | ||
amsConnectorService = await app.resolve<AmsOracleConnectorService>(AmsOracleConnectorService) | ||
appController = app.get<AppController>(AppController) | ||
}) | ||
|
||
describe('root', () => { | ||
it('should return "Hello Backend!"', () => { | ||
expect(appController.getHello()).toBe('Hello Backend!'); | ||
}); | ||
}); | ||
expect(appController.getHello()).toBe('Hello Backend!') | ||
}) | ||
}) | ||
describe('getAllOmrrRecords', () => { | ||
it('should return an object', async () => { | ||
//mock the AMSOracleConnectorService call | ||
jest.spyOn(amsConnectorService, 'getLatestOmrrDataFromCache').mockImplementation(async () => { | ||
const res: OmrrResponse = { | ||
lastModified: new Date().toISOString(), | ||
omrrData: [ | ||
{ | ||
"Manure": false, | ||
"Untreated and Unprocessed Wood Residuals": false, | ||
"Domestic Septic Tank Sludge": false, | ||
"Operation Type": null, | ||
"Latitude": 49.028961, | ||
"Yard Waste": false, | ||
"Fish Wastes": false, | ||
"Whey": false, | ||
"Animal Bedding": false, | ||
"Biosolids": false, | ||
"Hatchery Waste": false, | ||
"Last Amendment Date": new Date(), | ||
"Intended Dates of Land Application": null, | ||
"Authorization Status": "Inactive", | ||
"Authorization Number": 11123, | ||
"Waste Discharge Regulation": null, | ||
"Milk Processing Waste": false, | ||
"Material Land Applied": null, | ||
"Poultry Carcasses": false, | ||
"Authorization Type": "Notification", | ||
"Effective/Issue Date": new Date(), | ||
"Longitude": -123.805217, | ||
"Facility Location": "LOT 10, OYSTER DISTRICT", | ||
"Type of Compost Produced": null, | ||
"Facility Design Capacity (t/y)": null, | ||
"Brewery Waste/Wine Waste": false, | ||
"Regulated Party": "WYNDLOW WOOD WASTE REDUCTION INC.", | ||
"Food Waste": false | ||
}, | ||
const res: OmrrResponse = { | ||
lastModified: new Date().toISOString(), | ||
omrrData: [ | ||
{ | ||
'Manure': false, | ||
'Untreated and Unprocessed Wood Residuals': false, | ||
'Domestic Septic Tank Sludge': false, | ||
'Operation Type': null, | ||
'Latitude': 49.028961, | ||
'Yard Waste': false, | ||
'Fish Wastes': false, | ||
'Whey': false, | ||
'Animal Bedding': false, | ||
'Biosolids': false, | ||
'Hatchery Waste': false, | ||
'Last Amendment Date': new Date(), | ||
'Intended Dates of Land Application': null, | ||
'Authorization Status': 'Inactive', | ||
'Authorization Number': 11123, | ||
'Waste Discharge Regulation': null, | ||
'Milk Processing Waste': false, | ||
'Material Land Applied': null, | ||
'Poultry Carcasses': false, | ||
'Authorization Type': 'Notification', | ||
'Effective/Issue Date': new Date(), | ||
'Longitude': -123.805217, | ||
'Facility Location': 'LOT 10, OYSTER DISTRICT', | ||
'Type of Compost Produced': null, | ||
'Facility Design Capacity (t/y)': null, | ||
'Brewery Waste/Wine Waste': false, | ||
'Regulated Party': 'WYNDLOW WOOD WASTE REDUCTION INC.', | ||
'Food Waste': false, | ||
}, | ||
|
||
], | ||
} | ||
return res; | ||
}); | ||
const result = await appController.getAllOmrrRecords(); | ||
expect(result).toBeTruthy(); | ||
expect(result.omrrData).toHaveLength(1); | ||
], | ||
} | ||
return res | ||
}) | ||
const result = await appController.getAllOmrrRecords() | ||
expect(result).toBeTruthy() | ||
expect(result.omrrData).toHaveLength(1) | ||
|
||
}); | ||
}) | ||
|
||
|
||
}); | ||
}) | ||
describe('getOmrrApplicationStatus', () => { | ||
it('should return an array', async () => { | ||
const result: OmrrApplicationStatusResponse[] =[ | ||
const result: OmrrApplicationStatusResponse[] = [ | ||
{ | ||
"Authorization Number": 108485, | ||
"Job Tracking Number": 386999, | ||
"Job Type": "Authorization Amendment", | ||
"Authorization Type": "Permit", | ||
"Status": "In Review", | ||
"Received Date": "2019-09-27" | ||
'Authorization Number': 108485, | ||
'Job Tracking Number': 386999, | ||
'Job Type': 'Authorization Amendment', | ||
'Authorization Type': 'Permit', | ||
'Status': 'In Review', | ||
'Received Date': '2019-09-27', | ||
}, | ||
{ | ||
"Authorization Number": 108531, | ||
"Job Tracking Number": 384058, | ||
"Job Type": "Authorization Amendment", | ||
"Authorization Type": "Operational Certificate", | ||
"Status": "In Review", | ||
"Received Date": "2019-05-23" | ||
'Authorization Number': 108531, | ||
'Job Tracking Number': 384058, | ||
'Job Type': 'Authorization Amendment', | ||
'Authorization Type': 'Operational Certificate', | ||
'Status': 'In Review', | ||
'Received Date': '2019-05-23', | ||
}, | ||
{ | ||
"Authorization Number": 108536, | ||
"Job Tracking Number": 433877, | ||
"Job Type": "Authorization Amendment", | ||
"Authorization Type": "Permit", | ||
"Status": "Pending Final Application", | ||
"Received Date": "2024-03-07" | ||
'Authorization Number': 108536, | ||
'Job Tracking Number': 433877, | ||
'Job Type': 'Authorization Amendment', | ||
'Authorization Type': 'Permit', | ||
'Status': 'Pending Final Application', | ||
'Received Date': '2024-03-07', | ||
}, | ||
|
||
]; | ||
] | ||
jest.spyOn(amsConnectorService, 'getLatestOmrrApplicationStatusFromCache').mockImplementation(async () => { | ||
return result; | ||
}); | ||
const omrrApplicationStatus = await appController.getOmrrApplicationStatus(); | ||
expect(omrrApplicationStatus).toBeTruthy(); | ||
expect(omrrApplicationStatus).toHaveLength(3); | ||
return result | ||
}) | ||
const omrrApplicationStatus = await appController.getOmrrApplicationStatus() | ||
expect(omrrApplicationStatus).toBeTruthy() | ||
expect(omrrApplicationStatus).toHaveLength(3) | ||
|
||
}); | ||
}) | ||
|
||
}); | ||
}); | ||
}) | ||
describe('getOmrrAuthorizationDocuments', () => { | ||
it('should return an object', async () => { | ||
jest.spyOn(amsConnectorService, 'getLatestOmrrAuthzDocsFromCache').mockImplementation(async () => { | ||
return [ | ||
{ | ||
'Authorization Number': 108485, | ||
'doc_links': [{ | ||
'DocumentObjectID': 123, | ||
'Description': 'desc', | ||
'Publiclyviewable': 'Y', | ||
}], | ||
|
||
}, | ||
{ | ||
'Authorization Number': 108486, | ||
'doc_links': [{ | ||
'DocumentObjectID': 124, | ||
'Description': 'desc', | ||
'Publiclyviewable': 'Y', | ||
}], | ||
}, | ||
{ | ||
'Authorization Number': 108487, | ||
'doc_links': [{ | ||
'DocumentObjectID': 125, | ||
'Description': 'desc', | ||
'Publiclyviewable': 'Y', | ||
}], | ||
}, | ||
] | ||
}) | ||
const omrrAuthorizationDocuments = await appController.getOmrrAuthorizationDocs() | ||
expect(omrrAuthorizationDocuments).toBeTruthy() | ||
expect(omrrAuthorizationDocuments).toHaveLength(3) | ||
}) | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.