diff --git a/core-services/attendance/Attendace Service Postman Scripts.postman_collection.json b/core-services/attendance/Attendace Service Postman Scripts.postman_collection.json deleted file mode 100644 index 4f63c0b7820..00000000000 --- a/core-services/attendance/Attendace Service Postman Scripts.postman_collection.json +++ /dev/null @@ -1,3633 +0,0 @@ -{ - "info": { - "_postman_id": "25632b98-5918-4908-8a85-9500d8a81afa", - "name": "Attendace Service Postman Scripts", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "Attendance Register", - "item": [ - { - "name": "Create Attendance Register - Success - Single Register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendance Registers are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendanceRegister).to.not.be.undefined;", - " pm.expect(req.attendanceRegister).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.tenantId).to.be.not.null;", - " pm.expect(register.tenantId).to.be.not.undefined;", - " pm.expect(register.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register Name is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.name).to.be.not.null;", - " pm.expect(register.name).to.be.not.undefined;", - " pm.expect(register.name).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register start date is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.startDate).to.be.not.null;", - " pm.expect(register.startDate).to.be.not.undefined;", - " pm.expect(register.startDate).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Start date should be less than end date\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " if (Number.isFinite(register.endDate) && (register.endDate != undefined || register.endDate != null )) {", - " pm.expect(register.endDate).to.be.not.below(register.startDate);", - " }", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Register Number is enriched\", function () {", - " var res = pm.response.json();", - " var registerNumber = res.attendanceRegister[0].registerNumber;", - " pm.expect(registerNumber.substring(0,2)).to.eql(\"WR\");", - " }", - ");", - "", - "pm.test(\"Register status is set to Active if status not passed\", function () {", - " var res = pm.response.json();", - " var status = res.attendanceRegister[0].status;", - " pm.expect(status).to.eql(\"ACTIVE\");", - " }", - ");", - "", - "pm.test(\"Staff is created for register\", function () {", - " var res = pm.response.json();", - " var staff = res.attendanceRegister[0].staff;", - " pm.expect(staff).to.be.not.null;", - " pm.expect(staff).to.be.not.undefined;", - " pm.expect(staff.length).to.eql(1);", - " }", - ");", - "", - "pm.test(\"Staff created have same userId as UUID of user\", function () {", - " var res = pm.response.json();", - " var userInRequest = res.attendanceRegister[0].auditDetails.createdBy;", - " var staff = res.attendanceRegister[0].staff;", - " pm.expect(staff[0].userId).to.eql(userInRequest);", - " }", - ");", - "", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"tenantId\", responseData.attendanceRegister[0].tenantId);", - "pm.collectionVariables.set(\"stateLevelTenant\", responseData.attendanceRegister[0].tenantId.split('.', 1)[0]);", - "pm.collectionVariables.set(\"registerId\", responseData.attendanceRegister[0].id);", - "pm.collectionVariables.set(\"registerNumber\", responseData.attendanceRegister[0].registerNumber);", - "", - "pm.collectionVariables.set(\"registerStartDate\", responseData.attendanceRegister[0].startDate);", - "pm.collectionVariables.set(\"registerEndDate\", responseData.attendanceRegister[0].endDate);", - "pm.collectionVariables.set(\"invalidRegisterEndDate\", responseData.attendanceRegister[0].endDate+24*60*60*1000);", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "pm.collectionVariables.set(\"tenantId\", \"pg.citya\");", - "// pm.collectionVariables.set(\"individualId\", \"2d12b93a-829b-4aef-9073-5418e2315355\");", - "//dev", - "pm.collectionVariables.set(\"individualId-1\", \"6731ed44-2407-457d-aa3e-70ffbd1d6d21\");", - "pm.collectionVariables.set(\"individualId-2\", \"311b13c2-0029-4679-8723-fe6f57870a35\");", - "", - "", - "//qa", - "// pm.collectionVariables.set(\"individualId-1\", \"3ff2861e-8bbd-4431-a6b4-6f6a1c116356\");", - "// pm.collectionVariables.set(\"individualId-2\", \"a7d7ec01-68e0-428d-8762-c81e2fd5c864\");", - "", - "", - "pm.collectionVariables.set(\"referenceId\", \"test_contract_number_01\");", - "pm.collectionVariables.set(\"serviceCode\", \"WORKS-CONTRACT\");", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"referenceId\": \"{{referenceId}}+{{$randomPhoneNumber}}\",\n \"serviceCode\": \"{{serviceCode}}\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Success - Multiple Registers", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendance Registers are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendanceRegister).to.not.be.undefined;", - " pm.expect(req.attendanceRegister).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.tenantId).to.be.not.null;", - " pm.expect(register.tenantId).to.be.not.undefined;", - " pm.expect(register.tenantId).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register Name is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.name).to.be.not.null;", - " pm.expect(register.name).to.be.not.undefined;", - " pm.expect(register.name).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register start date is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.startDate).to.be.not.null;", - " pm.expect(register.startDate).to.be.not.undefined;", - " pm.expect(register.startDate).not.to.eql(\"\");", - " });", - " }", - ");", - " ", - "", - "pm.test(\"Start date should be less than end date\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " if (Number.isFinite(register.endDate) && (register.endDate != undefined || register.endDate != null )) {", - " pm.expect(register.endDate).to.be.not.below(register.startDate);", - " }", - " });", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Register Number is enriched\", function () {", - " var res = pm.response.json();", - " res.attendanceRegister.forEach(register => {", - " var registerNumber = register.registerNumber;", - " pm.expect(registerNumber.substring(0,2)).to.eql(\"WR\");", - " });", - " }", - ");", - "", - "pm.test(\"Staff is created for register\", function () {", - " var res = pm.response.json();", - " res.attendanceRegister.forEach(register => {", - " var staff = register.staff;", - " pm.expect(staff).to.be.not.null;", - " pm.expect(staff).to.be.not.undefined;", - " pm.expect(staff.length).to.eql(1);", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff created have same userId as UUID of user\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var res = pm.response.json();", - " res.attendanceRegister.forEach(register => {", - " var userInRequest = register.auditDetails.createdBy;", - " var staff =register.staff;", - " pm.expect(staff[0].userId).to.eql(userInRequest);", - " }); ", - " }", - ");", - "", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"registerId2\", responseData.attendanceRegister[1].id);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"referenceId\": \"{{referenceId}}+{{$randomPhoneNumber}}\",\n \"serviceCode\": \"{{serviceCode}}\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000\n },\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_02\",\n \"referenceId\": \"{{referenceId}}+{{$randomPhoneNumber}}\",\n \"serviceCode\": \"{{serviceCode}}\",\n \"startDate\": 1640995200000,\n \"additionalDetails\": {}\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Registers not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"ATTENDANCE_REGISTER\");", - " pm.expect(message).to.eql(\"Attendance Register is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": []\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - TenantId not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"TENANT_ID\");", - " pm.expect(message).to.eql(\"Tenant is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"name\": \"TestRegister_01\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Name not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"NAME\");", - " pm.expect(message).to.eql(\"Name is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"referenceId\": \"{{referenceId}}+{{$randomPhoneNumber}}\",\n \"serviceCode\": \"{{serviceCode}}\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Start Date not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"START_DATE\");", - " pm.expect(message).to.eql(\"Start date is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Start Date greater than End Date", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"DATE\");", - " pm.expect(message).to.eql(\"Start date should be less than end date\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"startDate\": 1803980800000,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Start Date Equal to 0", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"START_DATE\");", - " pm.expect(message).to.eql(\"Start date is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"startDate\": 0,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " var id = res.attendanceRegister[0].id;", - " pm.expect(id).to.eql(pm.collectionVariables.get(\"registerId\"));", - " }", - ");" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{registerId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{registerId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success - Unassociated AttendeeId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendanceRegister.length).to.equal(0);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{registerId}}&attendeeId={{$guid}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{registerId}}" - }, - { - "key": "attendeeId", - "value": "{{$guid}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success - Unassociated StaffId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendanceRegister.length).to.equal(0);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{registerId}}&staffId={{$guid}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{registerId}}" - }, - { - "key": "staffId", - "value": "{{$guid}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success - SuperUser - Non existing RegisterID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendanceRegister.length).to.equal(0);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{$guid}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{$guid}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Validation Error - Unassociated Register Id", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " var code = res.attendanceRegister.length;", - " pm.expect(code).to.eql(0);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids=96d1055c-0251-498d-b98d-26d6c232925f", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "96d1055c-0251-498d-b98d-26d6c232925f" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Validation Error - Tenant Id not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"TENANT_ID\");", - " pm.expect(message).to.eql(\"Tenant is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?ids={{registerId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "ids", - "value": "{{registerId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Success - Single Register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "", - "pm.test(\"Attendance Registers are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendanceRegister).to.not.be.undefined;", - " pm.expect(req.attendanceRegister).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.tenantId).to.be.not.null;", - " pm.expect(register.tenantId).to.be.not.undefined;", - " pm.expect(register.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register Id is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.id).to.be.not.null;", - " pm.expect(register.id).to.be.not.undefined;", - " pm.expect(register.id).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register Name is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.name).to.be.not.null;", - " pm.expect(register.name).to.be.not.undefined;", - " pm.expect(register.name).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register start date is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.startDate).to.be.not.null;", - " pm.expect(register.startDate).to.be.not.undefined;", - " pm.expect(register.startDate).not.to.eql(\"\");", - " }", - ");", - " ", - "", - "pm.test(\"Start date should be less than end date\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " if (Number.isFinite(register.endDate) && (register.endDate != undefined || register.endDate != null )) {", - " pm.expect(register.endDate).to.be.not.below(register.startDate);", - " }", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Staff is created for register\", function () {", - " var res = pm.response.json();", - " var staff = res.attendanceRegister[0].staff;", - " pm.expect(staff).to.be.not.null;", - " pm.expect(staff).to.be.not.undefined;", - " pm.expect(staff.length).to.eql(1);", - " }", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_010\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Success - Multiple Registers", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "", - "pm.test(\"Attendance Registers are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendanceRegister).to.not.be.undefined;", - " pm.expect(req.attendanceRegister).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.tenantId).to.be.not.null;", - " pm.expect(register.tenantId).to.be.not.undefined;", - " pm.expect(register.tenantId).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register Id is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.id).to.be.not.null;", - " pm.expect(register.id).to.be.not.undefined;", - " pm.expect(register.id).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register Name is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.name).to.be.not.null;", - " pm.expect(register.name).to.be.not.undefined;", - " pm.expect(register.name).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register start date is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.startDate).to.be.not.null;", - " pm.expect(register.startDate).to.be.not.undefined;", - " pm.expect(register.startDate).not.to.eql(\"\");", - " });", - " }", - ");", - " ", - "", - "pm.test(\"Start date should be less than end date\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " if (Number.isFinite(register.endDate) && (register.endDate != undefined || register.endDate != null )) {", - " pm.expect(register.endDate).to.be.not.below(register.startDate);", - " }", - " });", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_010\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n },\n {\n \"id\": \"{{registerId2}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_020\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"INACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Validation Error - Register Id not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"ATTENDANCE_REGISTER_ID\");", - " pm.expect(message).to.eql(\"Attendance register id is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_010\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Validation Error - Tenant Id not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"TENANT_ID\");", - " pm.expect(message).to.eql(\"Tenant is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"name\": \"TestRegister_010\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Validation Error - Name not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"NAME\");", - " pm.expect(message).to.eql(\"Name is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Validation Error - Start Date not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"START_DATE\");", - " pm.expect(message).to.eql(\"Start date is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_010\",\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Register Permission", - "item": [ - { - "name": "Staff - Enroll - Single Staff", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Enrollment date is enriched\", function () {", - " var res = pm.response.json();", - " var enrollmentDate = res.staff[0].enrollmentDate;", - " pm.expect(enrollmentDate).to.be.not.null;", - " }", - ");", - "", - "// let requestData = JSON.parse(pm.request.body.raw);", - "// pm.collectionVariables.set(\"userId\", requestData.staff[0].userId);", - "", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"userId\", responseData.staff[0].userId);", - "console.log(pm.collectionVariables.get(\"userId\"));", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Enroll the user to register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{$randomUUID}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Enroll - Validation Error - Staff already enrolled to the register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"response is 400. Staff is already enrolled to the register\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "console.log(pm.collectionVariables.get(\"userId\"))" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Enroll the user to register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Enroll - Validation Error - Duplicate staff objects not allowed in enrollment request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - "", - " req.staff.forEach(staff => {", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }); ", - "", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Duplicate objects in request\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Enroll the user to register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"928ca23a-9bec-11ed-a8fc-0242ac120002\",\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"928ca23a-9bec-11ed-a8fc-0242ac120002\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Enroll - Multiple staff", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - "", - " req.staff.forEach(staff => {", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }); ", - "", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Enrollment date is enriched\", function () {", - " var res = pm.response.json();", - " res.staff.forEach(staff => {", - " pm.expect(staff.enrollmentDate).to.be.not.null;", - " }); ", - " }", - ");", - "", - "let requestData = JSON.parse(pm.request.body.raw);", - "pm.collectionVariables.set(\"userId-1\", requestData.staff[0].userId);", - "pm.collectionVariables.set(\"userId-2\", requestData.staff[1].userId);", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Enroll the user to register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{$randomUUID}}\",\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{$randomUUID}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Deenroll - Single staff", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Deenrollment date is enriched\", function () {", - " var res = pm.response.json();", - " var deenrollmentDate = res.staff[0].deenrollmentDate;", - " pm.expect(deenrollmentDate).to.be.not.null;", - " }", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Deenroll staff from register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Deenroll - Validation Error - Staff already denrolled from the register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Staff already deenrolled from the register\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Deenroll staff from register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Deenroll - Validation Error - Duplicate staff objects in deenrollment request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - "", - " req.staff.forEach(staff => {", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }); ", - "", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Response is 400. Duplicate staff objects in de enrollment request\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Deenroll staff from register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId-1}}\",\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId-1}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Deenroll - Multiple staff", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - "", - " req.staff.forEach(staff => {", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }); ", - "", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Deenrollment date is enriched\", function () {", - " var res = pm.response.json();", - " res.staff.forEach(staff => {", - " pm.expect(staff.deenrollmentDate).to.be.not.null;", - " }); ", - " }", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Deenroll staff from register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId-1}}\",\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId-2}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_delete" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Individual Enrollment", - "item": [ - { - "name": "Attendee - Enroll - Attendee", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendee are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Enrollment date is enriched\", function () {", - " var res = pm.response.json();", - " var enrollmentDate = res.attendees[0].enrollmentDate;", - " pm.expect(enrollmentDate).to.be.not.null;", - " }", - ");", - "", - "// let requestData = JSON.parse(pm.request.body.raw);", - "// pm.collectionVariables.set(\"individualId\", requestData.attendees[0].individualId);", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"attendeeEnrollmentDate\", responseData.attendees[0].enrollmentDate);", - "", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Enroll attendee to register\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n } \n\n ]\n\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Enroll - Validation Error - Attendee already enrolled", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendee are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Attendee already enrolled to the register\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Enroll attendee to register\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n } \n\n ]\n\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Enroll - Validation Error - Duplicate attendee objects not allowed in request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendee are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Duplicate attendee objects in the request\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Enroll attendee to register\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n } \n\n ]\n\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Deenroll- Single Attendee", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendees are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Deenrollment date is enriched\", function () {", - " var res = pm.response.json();", - " var deenrollmentDate = res.attendees[0].deenrollmentDate;", - " pm.expect(deenrollmentDate).to.be.not.null;", - " }", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"search with from and to values\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Deenroll- Validation Error - Attendee already deenrolled from the register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendees are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Attendee already deenrolled from the register\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"search with from and to values\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Enroll - Multiple Attendees", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendee are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Enrollment date is enriched\", function () {", - " var res = pm.response.json();", - " res.attendees.forEach(attendee => {", - " pm.expect(attendee.enrollmentDate).to.be.not.null;", - " }); ", - " }", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Enroll attendee to register\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-2}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n } \n\n ]\n\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Deenroll- Validation Error - Duplicate attendee objects in deenrollment request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendees are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Duplicate attendee objects in deenrollment request.\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"search with from and to values\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Deenroll- Multiple Attendees", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendees are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Deenrollment date is enriched\", function () {", - " var res = pm.response.json();", - " res.attendees.forEach(attendee => {", - " pm.expect(attendee.denrollmentDate).to.be.not.null;", - " }); ", - " }", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"search with from and to values\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-2}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_delete" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Attendance Log", - "item": [ - { - "name": "Attendance Log - Create - Success", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - " setTimeout( () => {", - "", - " pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var id = res.attendance[0].id;", - " pm.expect(id).to.be.not.null;", - " }", - ");", - " ", - " }, 1000);", - "", - "", - "", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"attendanceLogId\", responseData.attendance[0].id);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId-1}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Update - Success", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Attendance Log updated successfully\", function () {", - " var res = pm.response.json();", - " var status = res.attendance[0].status;", - " pm.expect(status).to.eql(\"INACTIVE\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"id\": \"{{attendanceLogId}}\",\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId-1}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"INACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ],\r\n \"auditDetails\": {\r\n \"createdBy\": \"47b5ea82-249c-4435-9646-16167fec06df\",\r\n \"lastModifiedBy\": \"47b5ea82-249c-4435-9646-16167fec06df\",\r\n \"createdTime\": 1671090269007,\r\n \"lastModifiedTime\": 1671090269007\r\n }\r\n \r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Update - fail - attendanceId is not valid", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log updated successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"ATTENDANCE_LOG\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"id\": \"{{$randomUUID}}\",\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"INACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ],\r\n \"auditDetails\": {\r\n \"createdBy\": \"47b5ea82-249c-4435-9646-16167fec06df\",\r\n \"lastModifiedBy\": \"47b5ea82-249c-4435-9646-16167fec06df\",\r\n \"createdTime\": 1671090269007,\r\n \"lastModifiedTime\": 1671090269007\r\n }\r\n \r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - All logs should belong to same tenantId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"MULTIPLE_TENANTIDS\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n },\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"tenant.id\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - Validate Attendance Log time", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"INVALID_ATTENDANCE_TIME\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{invalidRegisterEndDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - Register should belongs to tenenatId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{$randomUUID}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - All logs should belong to same registerId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"MULTIPLE_REGISTERIDS\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n },\r\n {\r\n \"registerId\": \"{{$randomUUID}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - User is not authorised", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"UNAUTHORISED_USER\");", - " }", - ");" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{$randomUUID}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Rearch - Fail - TenantId is required", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"TENANT_ID\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n }\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_search", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_search" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Rearch - Fail - RegisterId is required", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"REGISTER_ID\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n }\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_search?tenantId={{tenantId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Rearch - Success", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendance).to.be.not.null;", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n }\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_search?tenantId={{tenantId}}®isterId={{registerId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "registerId", - "value": "{{registerId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - required fields are missing", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " pm.expect(res.Errors.length).to.equal(5);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": null,\r\n \"individualId\": null,\r\n \"time\": null,\r\n \"type\": null,\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": null,\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - } - ] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "if (pm.environment.get(\"base_url\").includes(\"localhost\")) {", - "", - " var tenantId = \"pb.amritsar\";", - " var id = 1;", - " var uuid = \"11b0e02b-0145-4de2-bc42-c97b96264807\";", - "", - " var roles = [{", - " \"code\": \"SUPERUSER\",", - " \"name\": \"SUPER USER\",", - " \"tenantId\": tenantId", - " }];", - "", - " var userInfo = {", - " \"id\": id,", - " \"uuid\": uuid,", - " \"userName\": \"\",", - " \"name\": \"\",", - " \"mobileNumber\": \"\",", - " \"emailId\": \"\",", - " \"type\": \"\",", - " \"roles\": roles,", - " \"active\": true,", - " \"tenantId\": \"pb.amritsar\"", - " };", - "", - " pm.request.body.raw = pm.request.body.raw.replace('\"{{token}}\"', '\"\", \\n \"userInfo\": ' + JSON.stringify(userInfo));", - "}" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], - "variable": [ - { - "key": "tenantId", - "value": "" - }, - { - "key": "stateLevelTenant", - "value": "" - }, - { - "key": "registerId", - "value": "" - }, - { - "key": "registerNumber", - "value": "" - }, - { - "key": "registerId2", - "value": "" - }, - { - "key": "registerStartDate", - "value": "" - }, - { - "key": "registerEndDate", - "value": "" - }, - { - "key": "invalidRegisterEndDate", - "value": "" - }, - { - "key": "userId", - "value": "" - }, - { - "key": "userId-1", - "value": "" - }, - { - "key": "userId-2", - "value": "" - }, - { - "key": "individualId", - "value": "" - }, - { - "key": "attendeeEnrollmentDate", - "value": "" - }, - { - "key": "individualId-1", - "value": "" - }, - { - "key": "individualId-2", - "value": "" - }, - { - "key": "attendanceLogId", - "value": "" - }, - { - "key": "referenceId", - "value": "" - }, - { - "key": "serviceCode", - "value": "" - } - ] -} \ No newline at end of file diff --git a/core-services/attendance/Attendance-Service-1.0.0.yaml b/core-services/attendance/Attendance-Service-1.0.0.yaml deleted file mode 100644 index 7a3c97e43fb..00000000000 --- a/core-services/attendance/Attendance-Service-1.0.0.yaml +++ /dev/null @@ -1,666 +0,0 @@ -openapi: 3.0.0 -info: - version: 1.0.0 - title: Attendance Service - description: '' - -paths: - - /attendance/v1/_create: - post: - tags: - - Attendance Register - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AttendanceRegisterRequest' - responses: - '202': - description: 'Request to create a register has been accepted.' - content: - application/json: - schema: - $ref: '#/components/schemas/AttendanceRegisterResponse' - '400': - description: Invalid input. - content: - '*/*': - schema: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/ErrorRes' - - /attendance/v1/_update: - post: - tags: - - Attendance Register - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AttendanceRegisterRequest' - responses: - '202': - description: 'Request to update the register has been accepted.' - content: - application/json: - schema: - $ref: '#/components/schemas/AttendanceRegisterResponse' - '400': - description: Invalid input. - content: - '*/*': - schema: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/ErrorRes' - - /attendance/v1/_search: - post: - tags: - - Attendance Register - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/RequestInfoWrapper' - parameters: - - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/parameters/tenantId' - - name: ids - description: List of register ids - in: query - schema: - type: array - items: - type: string - - name: registerNumber - description: Custom formatted Register id - in: query - schema: - type: string - - name: name - description: Name of the register - in: query - schema: - type: string - - name: referenceId - description: Reference Id - in: query - schema: - type: string - - name: serviceCode - description: Service Code - in: query - schema: - type: string - - name: fromDate - description: Return registers with any overlap in the given time period - in: query - schema: - type: number - - name: toDate - description: Return registers with any overlap in the given time period - in: query - schema: - type: number - - name: status - description: Status of the register. This can't be the only query param. It should be paired with some other search param. - in: query - schema: - type: string - - name: attendeeId - description: Get all the registers where the given Individual was registered. - in: query - schema: - type: string - - name: staffId - description: Get all the registers where the given staff was registered. - in: query - schema: - type: string - - name: sortBy - in: query - description: sort the search results by fields - schema: - type: string - enum: - - fromDate - - toDate - - lastModifiedTime - - name: sortOrder - in: query - description: sorting order of the search resulsts - schema: - type: string - enum: - - asc - - desc - - name: limit - in: query - description: limit on the resulsts - schema: - type: number - - name: offset - in: query - description: offset index of the overall search resulsts - schema: - type: number - responses: - '200': - description: 'Search results' - content: - application/json: - schema: - $ref: '#/components/schemas/AttendanceRegisterResponse' - '400': - description: Invalid input. - content: - '*/*': - schema: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/ErrorRes' - - /attendance/staff/v1/_create: - post: - description: Grant permission to a user to access and modify an attendance register. This user can enroll / denroll individuals. They will add attendance entries for the attendees. - tags: - - Register Permission - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/StaffPermissionRequest' - responses: - '202': - description: 'Grant permission request accepted' - content: - application/json: - schema: - $ref: '#/components/schemas/StaffPermissionResponse' - '400': - description: Invalid input. - content: - '*/*': - schema: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/ErrorRes' - - /attendance/staff/v1/_delete: - post: - description: Revoke permission to a user to access and modify an attendance register. This user can enroll / denroll individuals. They will add attendance entries for the attendees. - tags: - - Register Permission - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/StaffPermissionRequest' - responses: - '202': - description: 'Revoke permission request accepted' - content: - application/json: - schema: - $ref: '#/components/schemas/StaffPermissionResponse' - '400': - description: Invalid input. - content: - '*/*': - schema: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/ErrorRes' - - /attendance/attendee/v1/_create: - post: - description: Users with permission to access the register can enroll / denroll attendees. - tags: - - Individual Enrollment - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AttendeeCreateRequest' - responses: - '202': - description: 'Attendee Create request accepted' - content: - application/json: - schema: - $ref: '#/components/schemas/AttendeeCreateResponse' - '400': - description: Invalid input. - content: - '*/*': - schema: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/ErrorRes' - - /attendance/attendee/v1/_delete: - post: - description: Users with permission to access the register can enroll / denroll attendees. - tags: - - Individual Enrollment - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AttendeeDeleteRequest' - responses: - '202': - description: 'Attendee Delete request accepted' - content: - application/json: - schema: - $ref: '#/components/schemas/AttendeeDeleteResponse' - '400': - description: Invalid input. - content: - '*/*': - schema: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/ErrorRes' - - /attendance/log/v1/_create: - post: - tags: - - Attendance Log - description: It creates a new attendance record. - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AttendanceLogRequest' - responses: - '202': - description: 'Attendance Records Create Request accepted.' - content: - application/json: - schema: - $ref: '#/components/schemas/AttendanceLogResponse' - '400': - description: Invalid input. - content: - '*/*': - schema: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/ErrorRes' - - /attendance/log/v1/_update: - post: - tags: - - Attendance Log - description: It updates an attendance record. - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/AttendanceLogRequest' - responses: - '202': - description: 'Attendance Records Update Request accepted.' - content: - application/json: - schema: - $ref: '#/components/schemas/AttendanceLogResponse' - '400': - description: Invalid input. - content: - '*/*': - schema: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/ErrorRes' - - /attendance/log/v1/_search: - post: - tags: - - Attendance Log - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/RequestInfoWrapper' - parameters: - - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/parameters/tenantId' - - name: registerId - in: query - required: true - description: Id of the register - schema: - type: string - - name: fromTime - in: query - description: Starting time from which the attendance needs to be searched - schema: - type: number - - name: toTime - in: query - description: End time till which the attendance needs to be searched - schema: - type: number - - name: individualIds - in: query - description: List of individual ids - schema: - type: array - items: - type: string - - name: ids - in: query - description: List of ids - schema: - type: array - items: - type: string - - name: status - in: query - description: The status of the attendance log. - schema: - type: string - enum: - - ACTIVE - - INACTIVE - responses: - '200': - description: 'Complete table of attendance entries.' - content: - application/json: - schema: - $ref: '#/components/schemas/AttendanceLogResponse' - -components: - schemas: - AttendanceRegister: - type: object - properties: - id: - type: string - format: uuid - example: 64e33343-7b4c-4353-9abf-4de8f5bcd732 - description: System generated unique identifier of the register - readOnly: true - tenantId: - type: string - example: pb.amritsar - description: Tenant Id of the register - registerNumber: - type: string - example: REG/2022-23/001 - description: System generated id with custom formatting - readOnly: true - name: - type: string - example: Class-10-E Physics - description: Name of the register - maxLength: 140 - referenceId: - type: string - example: 64e33343-7b4c-4353-9abf-4de8f5bcd732 - description: Id of the entity to which register is associated. Example ContractId - maxLength: 256 - serviceCode: - type: string - example: WORKS-CONTRACT - description: Service to which register is associated. - maxLength: 64 - startDate: - type: number - format: timestamp - example: 1665497225000 - description: Timestamp of the start date in milliseconds - endDate: - type: number - format: timestamp - example: 1665497271000 - description: Timestamp of the end date in milliseconds. After the end date no modifications will be allowed to the register. - status: - type: string - enum: - - ACTIVE - - INACTIVE - description: Stores if the register is active or not. Inactive registers can be archieved later. - staff: - readOnly: true - type: array - items: - allOf: - - $ref: '#/components/schemas/StaffPermission' - - description: 'Entries of the staff members of the register.' - attendees: - readOnly: true - type: array - items: - allOf: - - $ref: '#/components/schemas/IndividualEntry' - - description: 'Entries of the attendees of the register.' - auditDetails: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/AuditDetails' - additionalDetails: - type: object - description: Any additional details of the register - required: - - tenantId - - name - - referenceId - - serviceCode - - AttendanceRegisterRequest: - type: object - properties: - requestInfo: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/subhashini_devguide_changes/core-services/docs/common-contract.yml#/definitions/RequestInfo' - attendanceRegister: - type: array - items: - allOf: - - $ref: '#/components/schemas/AttendanceRegister' - - description: 'Entries of the attendance register to be created.' - - AttendanceRegisterResponse: - type: object - properties: - responseInfo: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/subhashini_devguide_changes/core-services/docs/common-contract.yml#/definitions/ResponseInfo' - attendanceRegister: - type: array - items: - $ref: '#/components/schemas/AttendanceRegister' - - IndividualEntry: - type: object - properties: - id: - type: string - format: uuid - example: 64e33343-7b4c-4353-9abf-4de8f5bcd732 - description: Primary identifier of the enrollment record - readOnly: true - registerId: - type: string - format: uuid - example: 32e33343-7b4c-4353-9abf-4de8f5bcd764 - description: This field will not be shown when this object is part of the register object. It is present so that we can reuse this object for enroll and denroll requests. - individualId: - type: string - format: uuid - example: 2bafdd8d-5673-4690-b3d0-e13d7ac0cf24 - description: Reference from the Individual Registry - enrollmentDate: - type: number - description: The timestamp of the date on which the individual is enrolled onto the register. Defaults to current time. - denrollmentDate: - type: number - description: The timestamp of the date on which the individual is denrolled from the register. Defaults to current time. - tenantId: - type: string - example: pb.amritsar - description: Tenant Id - - AttendeeCreateRequest: - type: object - properties: - requestInfo: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/subhashini_devguide_changes/core-services/docs/common-contract.yml#/definitions/RequestInfo' - attendees: - type: array - items: - allOf: - - $ref: '#/components/schemas/IndividualEntry' - - required: - - registerId - - individualId - - enrollmentDate - - tenantId - - AttendeeCreateResponse: - type: object - properties: - responseInfo: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/subhashini_devguide_changes/core-services/docs/common-contract.yml#/definitions/ResponseInfo' - attendees: - type: array - items: - $ref: '#/components/schemas/IndividualEntry' - - AttendeeDeleteRequest: - type: object - properties: - requestInfo: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/subhashini_devguide_changes/core-services/docs/common-contract.yml#/definitions/RequestInfo' - attendees: - type: array - items: - allOf: - - $ref: '#/components/schemas/IndividualEntry' - - required: - - registerId - - individualId - - denrollmentDate - - tenantId - - AttendeeDeleteResponse: - type: object - properties: - responseInfo: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/subhashini_devguide_changes/core-services/docs/common-contract.yml#/definitions/ResponseInfo' - attendees: - type: array - items: - $ref: '#/components/schemas/IndividualEntry' - - StaffPermission: - type: object - properties: - id: - type: string - format: uuid - description: System generated unique identifier for the granted permission request - readOnly: true - registerId: - type: string - description: Identifier of the register. This field will not be shown when this object is part of the register object. It is present so that we can reuse this object for access permission requests. - userId: - type: string - description: Identifier of the user of the system - tenantId: - type: string - format: string - example: pb.amritsar - description: Tenant Id to which the staff belongs - enrollmentDate: - readOnly: true - type: number - description: The timestamp at which the permission is granted. It is set to the current time when the create api is called. - denrollmentDate: - readOnly: true - type: number - description: The timestamp at which the access permission is revoked. It is set to the current time when the delete api is called. - required: - - registerId - - userId - - StaffPermissionRequest: - type: object - properties: - requestInfo: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/subhashini_devguide_changes/core-services/docs/common-contract.yml#/definitions/RequestInfo' - staff: - type: array - items: - allOf: - - $ref: '#/components/schemas/StaffPermission' - - required: - - registerId - - userId - - tenantId - - StaffPermissionResponse: - type: object - properties: - responseInfo: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/subhashini_devguide_changes/core-services/docs/common-contract.yml#/definitions/ResponseInfo' - staff: - type: array - items: - $ref: '#/components/schemas/StaffPermission' - - AttendanceLog: - type: object - properties: - id: - type: string - format: uuid - description: System generated unique identifier for the entry - readOnly: true - registerId: - type: string - description: Unique identifier of the register - individualId: - type: string - format: uuid - description: The individual for which the attendance is being marked - tenantId: - type: string - example: pb.amritsar - description: Tenant Id of the register - time: - type: number - format: timestamp - description: The timestamp at which the event has been recorded. - type: - type: string - description: Configurable in MDMS. [ENTRY/EXIT/...] - status: - type: string - enum: - - ACTIVE - - INACTIVE - description: The attendance log of the cancelled event can be marked as inactive. - documentIds: - description: Used to store file store ids. Need to verify validity of them using file store service. - type: array - items: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/Document' - additionalDetails: - type: object - required: - - registerId - - individualId - - tenantId - - time - - type - - AttendanceLogRequest: - type: object - properties: - requestInfo: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/subhashini_devguide_changes/core-services/docs/common-contract.yml#/definitions/RequestInfo' - attendance: - type: array - items: - $ref: '#/components/schemas/AttendanceLog' - - AttendanceLogResponse: - type: object - properties: - responseInfo: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/subhashini_devguide_changes/core-services/docs/common-contract.yml#/definitions/ResponseInfo' - attendance: - type: array - items: - $ref: '#/components/schemas/AttendanceLog' - - RequestInfoWrapper: - type: object - properties: - requestInfo: - $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/subhashini_devguide_changes/core-services/docs/common-contract.yml#/definitions/RequestInfo' \ No newline at end of file diff --git a/core-services/attendance/CHANGELOG.md b/core-services/attendance/CHANGELOG.md deleted file mode 100644 index e5a50979d1d..00000000000 --- a/core-services/attendance/CHANGELOG.md +++ /dev/null @@ -1,6 +0,0 @@ - -All notable changes to this module will be documented in this file. - -## 0.1.0 - 2023-04-17 - -- Base version \ No newline at end of file diff --git a/core-services/attendance/LOCALSETUP.md b/core-services/attendance/LOCALSETUP.md deleted file mode 100644 index dbbd2382297..00000000000 --- a/core-services/attendance/LOCALSETUP.md +++ /dev/null @@ -1,42 +0,0 @@ -# Local Setup - -To set up the muster roll service in your local system, clone the git repo(https://github.com/egovernments/DIGIT-Works). - -## Dependencies - -- MDMS -- IDGen -- Workflow service -- Individual - - -### Infra Dependency - -- [X] Postgres DB -- [ ] Redis -- [ ] Elasticsearch (needed if there is indexer -- [X] Kafka - -## Running Locally - -To run the service locally, you need to port forward below services. - -```bash -function kgpt(){kubectl get pods -n egov --selector=app=$1 --no-headers=true | head -n1 | awk '{print $1}'} - -kubectl port-forward -n egov $(kgpt egov-user) 8085:8080 -kubectl port-forward -n egov $(kgpt egov-idgen) 8086:8080 -kubectl port-forward -n egov $(kgpt egov-mdms-service) 8087:8080 -kubectl port-forward -n egov $(kgpt egov-workflow) 8088:8080 -kubectl port-forward -n works $(kgpt project-management-service) 8089:8080 -``` - -Update below listed properties in `application.properties` before running the project: - -```ini -egov.idgen.hostname = http://127.0.0.1:8086 - -# can use non port forwarded environment host as well -egov.mdms.host = http://127.0.0.1:8087 -egov.workflow.host = http://127.0.0.1:8088 -``` diff --git a/core-services/attendance/README.md b/core-services/attendance/README.md deleted file mode 100644 index c8866f16367..00000000000 --- a/core-services/attendance/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# Attendance Service - -The attendance service provides generic attendance logging functionality based on "in" and "out" timestamps. -IN and OUT timestamps are recorded per individual. Aggregating and calculating attendance based on these timestamps -is the function of the muster roll service. - - -### Service Dependencies - -- DIGIT backbone services -- Individual -- MDMS -- ID-GEN -- Persister -- Indexer - -## Service Details - -- Allows creation/updation/search of an attendance register -- Allows mapping of staff and attendees to a register and enforces permissions. -- Logs entry and exit timestamps in epoch time for a referenced entity - -### API Specs - -https://raw.githubusercontent.com/egovernments/DIGIT-Specs/master/Domain%20Services/Works/Attendance-Service-v1.0.0.yaml - -### Postman Collection - -https://raw.githubusercontent.com/egovernments/DIGIT-Works/master/backend/attendance/Attendace%20Service%20Postman%20Scripts.postman_collection.json \ No newline at end of file diff --git a/core-services/attendance/pom.xml b/core-services/attendance/pom.xml deleted file mode 100644 index 54eda57fa8f..00000000000 --- a/core-services/attendance/pom.xml +++ /dev/null @@ -1,135 +0,0 @@ - - 4.0.0 - org.egov - attendance - jar - attendance - 0.2.0 - - 1.8 - ${java.version} - ${java.version} - 42.4.1 - 2.17.1 - - - org.springframework.boot - spring-boot-starter-parent - 2.2.13.RELEASE - - - src/main/java - - - org.springframework.boot - spring-boot-maven-plugin - - - - repackage - - - - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-jdbc - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-test - test - - - - io.swagger - swagger-core - 1.5.18 - - - - org.egov.services - tracer - 2.0.0-SNAPSHOT - - - org.egov.services - services-common - 1.1.1-SNAPSHOT - - - org.egov.services - digit-models - 1.0.0-SNAPSHOT - - - org.egov.common - health-services-models - 1.0.6-SNAPSHOT - compile - - - org.egov - mdms-client - 0.0.4-SNAPSHOT - - - org.postgresql - postgresql - - - org.jsoup - jsoup - 1.15.3 - - - org.flywaydb - flyway-core - - - - org.projectlombok - lombok - true - - - - com.fasterxml.jackson.datatype - jackson-datatype-jsr310 - - - - javax.validation - validation-api - - - - - repo.digit.org - eGov ERP Releases Repository - https://nexus-repo.digit.org/nexus/content/repositories/releases/ - - - repo.digit.org.snapshots - eGov ERP Releases Repository - https://nexus-repo.digit.org/nexus/content/repositories/snapshots/ - - - repo.digit.org.public - eGov Public Repository Group - https://nexus-repo.digit.org/nexus/content/groups/public/ - - - diff --git a/core-services/attendance/postman-test-suite-Attendace-service.json b/core-services/attendance/postman-test-suite-Attendace-service.json deleted file mode 100644 index d64786c344c..00000000000 --- a/core-services/attendance/postman-test-suite-Attendace-service.json +++ /dev/null @@ -1,3796 +0,0 @@ -{ - "info": { - "_postman_id": "25632b98-5918-4908-8a85-9500d8a81afa", - "name": "Attendace Service Postman Scripts", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "Attendance Register", - "item": [ - { - "name": "Create Attendance Register - Success - Single Register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendance Registers are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendanceRegister).to.not.be.undefined;", - " pm.expect(req.attendanceRegister).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.tenantId).to.be.not.null;", - " pm.expect(register.tenantId).to.be.not.undefined;", - " pm.expect(register.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register Name is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.name).to.be.not.null;", - " pm.expect(register.name).to.be.not.undefined;", - " pm.expect(register.name).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register start date is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.startDate).to.be.not.null;", - " pm.expect(register.startDate).to.be.not.undefined;", - " pm.expect(register.startDate).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Start date should be less than end date\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " if (Number.isFinite(register.endDate) && (register.endDate != undefined || register.endDate != null )) {", - " pm.expect(register.endDate).to.be.not.below(register.startDate);", - " }", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Register Number is enriched\", function () {", - " var res = pm.response.json();", - " var registerNumber = res.attendanceRegister[0].registerNumber;", - " pm.expect(registerNumber.substring(0,2)).to.eql(\"WR\");", - " }", - ");", - "", - "pm.test(\"Register status is set to Active if status not passed\", function () {", - " var res = pm.response.json();", - " var status = res.attendanceRegister[0].status;", - " pm.expect(status).to.eql(\"ACTIVE\");", - " }", - ");", - "", - "pm.test(\"Staff is created for register\", function () {", - " var res = pm.response.json();", - " var staff = res.attendanceRegister[0].staff;", - " pm.expect(staff).to.be.not.null;", - " pm.expect(staff).to.be.not.undefined;", - " pm.expect(staff.length).to.eql(1);", - " }", - ");", - "", - "pm.test(\"Staff created have same userId as UUID of user\", function () {", - " var res = pm.response.json();", - " var userInRequest = res.attendanceRegister[0].auditDetails.createdBy;", - " var staff = res.attendanceRegister[0].staff;", - " pm.expect(staff[0].userId).to.eql(userInRequest);", - " }", - ");", - "", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"tenantId\", responseData.attendanceRegister[0].tenantId);", - "pm.collectionVariables.set(\"stateLevelTenant\", responseData.attendanceRegister[0].tenantId.split('.', 1)[0]);", - "pm.collectionVariables.set(\"registerId\", responseData.attendanceRegister[0].id);", - "pm.collectionVariables.set(\"registerNumber\", responseData.attendanceRegister[0].registerNumber);", - "", - "pm.collectionVariables.set(\"registerStartDate\", responseData.attendanceRegister[0].startDate);", - "pm.collectionVariables.set(\"registerEndDate\", responseData.attendanceRegister[0].endDate);", - "pm.collectionVariables.set(\"invalidRegisterEndDate\", responseData.attendanceRegister[0].endDate+24*60*60*1000);" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "pm.collectionVariables.set(\"tenantId\", \"pb.amritsar\");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Success - Multiple Registers", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"UserInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo.userInfo).to.not.be.null;", - " pm.expect(req.RequestInfo.userInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"UUID is required in UserInfo\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo.userInfo.uuid).to.not.be.null;", - " pm.expect(req.RequestInfo.userInfo.uuid).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendance Registers are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendanceRegister).to.not.be.undefined;", - " pm.expect(req.attendanceRegister).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.tenantId).to.be.not.null;", - " pm.expect(register.tenantId).to.be.not.undefined;", - " pm.expect(register.tenantId).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register Name is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.name).to.be.not.null;", - " pm.expect(register.name).to.be.not.undefined;", - " pm.expect(register.name).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register start date is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.startDate).to.be.not.null;", - " pm.expect(register.startDate).to.be.not.undefined;", - " pm.expect(register.startDate).not.to.eql(\"\");", - " });", - " }", - ");", - " ", - "", - "pm.test(\"Start date should be less than end date\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " if (Number.isFinite(register.endDate) && (register.endDate != undefined || register.endDate != null )) {", - " pm.expect(register.endDate).to.be.not.below(register.startDate);", - " }", - " });", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Register Number is enriched\", function () {", - " var res = pm.response.json();", - " res.attendanceRegister.forEach(register => {", - " var registerNumber = register.registerNumber;", - " pm.expect(registerNumber.substring(0,2)).to.eql(\"WR\");", - " });", - " }", - ");", - "", - "pm.test(\"Staff is created for register\", function () {", - " var res = pm.response.json();", - " res.attendanceRegister.forEach(register => {", - " var staff = register.staff;", - " pm.expect(staff).to.be.not.null;", - " pm.expect(staff).to.be.not.undefined;", - " pm.expect(staff.length).to.eql(1);", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff created have same userId as UUID of user\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var res = pm.response.json();", - " res.attendanceRegister.forEach(register => {", - " var userInRequest = register.auditDetails.createdBy;", - " var staff =register.staff;", - " pm.expect(staff[0].userId).to.eql(userInRequest);", - " }); ", - " }", - ");", - "", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"registerId2\", responseData.attendanceRegister[1].id);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000\n },\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_02\",\n \"startDate\": 1640995200000,\n \"additionalDetails\": {}\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Registers not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"ATTENDANCE_REGISTER\");", - " pm.expect(message).to.eql(\"Attendance Register is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": []\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - TenantId not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"TENANT_ID\");", - " pm.expect(message).to.eql(\"Tenant is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"name\": \"TestRegister_01\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Name not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"NAME\");", - " pm.expect(message).to.eql(\"Name is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Start Date not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"START_DATE\");", - " pm.expect(message).to.eql(\"Start date is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Start Date greater than End Date", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"DATE\");", - " pm.expect(message).to.eql(\"Start date should be less than end date\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"startDate\": 1803980800000,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Start Date Equal to 0", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"START_DATE\");", - " pm.expect(message).to.eql(\"Start date is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"startDate\": 0,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " var id = res.attendanceRegister[0].id;", - " pm.expect(id).to.eql(pm.collectionVariables.get(\"registerId\"));", - " }", - ");" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{registerId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{registerId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success - State level tenant", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " var id = res.attendanceRegister[0].id;", - " pm.expect(id).to.eql(pm.collectionVariables.get(\"registerId\"));", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{stateLevelTenant}}&ids={{registerId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{stateLevelTenant}}" - }, - { - "key": "ids", - "value": "{{registerId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success - Unassociated AttendeeId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendanceRegister.length).to.equal(0);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"\",\n \"userInfo\": {\n \"id\": 1,\n \"uuid\": \"11b0e02b-0145-4de2-bc42-c97b96264807\",\n \"userName\": \"\",\n \"name\": \"\",\n \"mobileNumber\": \"\",\n \"emailId\": \"\",\n \"type\": \"\",\n \"roles\": [\n {\n \"code\": \"ORG_ADMIN\",\n \"name\": \"Organization admin\",\n \"tenantId\": \"pb.amritsar\"\n },\n {\n \"code\": \"ORG_STAFF\",\n \"name\": \"Organization staff\",\n \"tenantId\": \"pb.amritsar\"\n }\n ],\n \"active\": true,\n \"tenantId\": \"pb.amritsar\"\n }\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{registerId}}&attendeeId={{$guid}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{registerId}}" - }, - { - "key": "attendeeId", - "value": "{{$guid}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success - Unassociated StaffId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendanceRegister.length).to.equal(0);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"\",\n \"userInfo\": {\n \"id\": 1,\n \"uuid\": \"11b0e02b-0145-4de2-bc42-c97b96264807\",\n \"userName\": \"\",\n \"name\": \"\",\n \"mobileNumber\": \"\",\n \"emailId\": \"\",\n \"type\": \"\",\n \"roles\": [\n {\n \"code\": \"ORG_ADMIN\",\n \"name\": \"Organization admin\",\n \"tenantId\": \"pb.amritsar\"\n },\n {\n \"code\": \"ORG_STAFF\",\n \"name\": \"Organization staff\",\n \"tenantId\": \"pb.amritsar\"\n }\n ],\n \"active\": true,\n \"tenantId\": \"pb.amritsar\"\n }\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{registerId}}&staffId={{$guid}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{registerId}}" - }, - { - "key": "staffId", - "value": "{{$guid}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success - User not associated with any register - empty response array", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"User not associated with any register\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendanceRegister.length).to.equal(0);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"\",\n \"userInfo\": {\n \"id\": 1,\n \"uuid\": \"{{$guid}}\",\n \"userName\": \"\",\n \"name\": \"\",\n \"mobileNumber\": \"\",\n \"emailId\": \"\",\n \"type\": \"\",\n \"roles\": [\n {\n \"code\": \"ORG_ADMIN\",\n \"name\": \"Organization admin\",\n \"tenantId\": \"pb.amritsar\"\n },\n {\n \"code\": \"ORG_STAFF\",\n \"name\": \"Organization staff\",\n \"tenantId\": \"pb.amritsar\"\n }\n ],\n \"active\": true,\n \"tenantId\": \"pb.amritsar\"\n }\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success - SuperUser - Non existing RegisterID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendanceRegister.length).to.equal(0);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"\",\n \"userInfo\": {\n \"id\": 1,\n \"uuid\": \"11b0e02b-0145-4de2-bc42-c97b96264807\",\n \"userName\": \"\",\n \"name\": \"\",\n \"mobileNumber\": \"\",\n \"emailId\": \"\",\n \"type\": \"\",\n \"roles\": [\n {\n \"code\": \"SUPERUSER\",\n \"name\": \"Super User\",\n \"tenantId\": \"pb.amritsar\"\n }\n ],\n \"active\": true,\n \"tenantId\": \"pb.amritsar\"\n }\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{$guid}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{$guid}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Validation Error - Unassociated Register Id", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"INVALID_REGISTER_ID\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"\",\n \"userInfo\": {\n \"id\": 1,\n \"uuid\": \"11b0e02b-0145-4de2-bc42-c97b96264807\",\n \"userName\": \"\",\n \"name\": \"\",\n \"mobileNumber\": \"\",\n \"emailId\": \"\",\n \"type\": \"\",\n \"roles\": [\n {\n \"code\": \"ORG_ADMIN\",\n \"name\": \"Organization admin\",\n \"tenantId\": \"pb.amritsar\"\n },\n {\n \"code\": \"ORG_STAFF\",\n \"name\": \"Organization staff\",\n \"tenantId\": \"pb.amritsar\"\n }\n ],\n \"active\": true,\n \"tenantId\": \"pb.amritsar\"\n }\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{$guid}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{$guid}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Validation Error - Tenant Id not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"TENANT_ID\");", - " pm.expect(message).to.eql(\"Tenant is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?ids={{registerId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "ids", - "value": "{{registerId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Success - Single Register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"UserInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo.userInfo).to.not.be.null;", - " pm.expect(req.RequestInfo.userInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"UUID is required in UserInfo\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo.userInfo.uuid).to.not.be.null;", - " pm.expect(req.RequestInfo.userInfo.uuid).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendance Registers are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendanceRegister).to.not.be.undefined;", - " pm.expect(req.attendanceRegister).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.tenantId).to.be.not.null;", - " pm.expect(register.tenantId).to.be.not.undefined;", - " pm.expect(register.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register Id is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.id).to.be.not.null;", - " pm.expect(register.id).to.be.not.undefined;", - " pm.expect(register.id).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register Name is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.name).to.be.not.null;", - " pm.expect(register.name).to.be.not.undefined;", - " pm.expect(register.name).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register start date is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.startDate).to.be.not.null;", - " pm.expect(register.startDate).to.be.not.undefined;", - " pm.expect(register.startDate).not.to.eql(\"\");", - " }", - ");", - " ", - "", - "pm.test(\"Start date should be less than end date\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " if (Number.isFinite(register.endDate) && (register.endDate != undefined || register.endDate != null )) {", - " pm.expect(register.endDate).to.be.not.below(register.startDate);", - " }", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Staff is created for register\", function () {", - " var res = pm.response.json();", - " var staff = res.attendanceRegister[0].staff;", - " pm.expect(staff).to.be.not.null;", - " pm.expect(staff).to.be.not.undefined;", - " pm.expect(staff.length).to.eql(1);", - " }", - ");", - "", - "pm.test(\"Staff created have same userId as UUID of user\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var userInRequest = req.RequestInfo.userInfo.uuid;", - " var res = pm.response.json();", - " var staff = res.attendanceRegister[0].staff;", - " pm.expect(staff[0].userId).to.eql(userInRequest);", - " }", - ");", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_010\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Success - Multiple Registers", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"UserInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo.userInfo).to.not.be.null;", - " pm.expect(req.RequestInfo.userInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"UUID is required in UserInfo\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo.userInfo.uuid).to.not.be.null;", - " pm.expect(req.RequestInfo.userInfo.uuid).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendance Registers are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendanceRegister).to.not.be.undefined;", - " pm.expect(req.attendanceRegister).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.tenantId).to.be.not.null;", - " pm.expect(register.tenantId).to.be.not.undefined;", - " pm.expect(register.tenantId).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register Id is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.id).to.be.not.null;", - " pm.expect(register.id).to.be.not.undefined;", - " pm.expect(register.id).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register Name is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.name).to.be.not.null;", - " pm.expect(register.name).to.be.not.undefined;", - " pm.expect(register.name).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register start date is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.startDate).to.be.not.null;", - " pm.expect(register.startDate).to.be.not.undefined;", - " pm.expect(register.startDate).not.to.eql(\"\");", - " });", - " }", - ");", - " ", - "", - "pm.test(\"Start date should be less than end date\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " if (Number.isFinite(register.endDate) && (register.endDate != undefined || register.endDate != null )) {", - " pm.expect(register.endDate).to.be.not.below(register.startDate);", - " }", - " });", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Staff is created for register\", function () {", - " var res = pm.response.json();", - " res.attendanceRegister.forEach(register => {", - " var staff = register.staff;", - " pm.expect(staff).to.be.not.null;", - " pm.expect(staff).to.be.not.undefined;", - " pm.expect(staff.length).to.eql(1);", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff created have same userId as UUID of user\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var userInRequest = req.RequestInfo.userInfo.uuid;", - " var res = pm.response.json();", - " res.attendanceRegister.forEach(register => {", - " var staff =register.staff;", - " pm.expect(staff[0].userId).to.eql(userInRequest);", - " }); ", - " }", - ");", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_010\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n },\n {\n \"id\": \"{{registerId2}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_020\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"INACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Validation Error - Register Id not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"ATTENDANCE_REGISTER_ID\");", - " pm.expect(message).to.eql(\"Attendance register id is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_010\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Validation Error - Tenant Id not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"TENANT_ID\");", - " pm.expect(message).to.eql(\"Tenant is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"name\": \"TestRegister_010\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Validation Error - Name not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"NAME\");", - " pm.expect(message).to.eql(\"Name is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Validation Error - Start Date not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"START_DATE\");", - " pm.expect(message).to.eql(\"Start date is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_010\",\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Register Permission", - "item": [ - { - "name": "Staff - Enroll - Single Staff", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Enrollment date is enriched\", function () {", - " var res = pm.response.json();", - " var enrollmentDate = res.staff[0].enrollmentDate;", - " pm.expect(enrollmentDate).to.be.not.null;", - " }", - ");", - "", - "// let requestData = JSON.parse(pm.request.body.raw);", - "// pm.collectionVariables.set(\"userId\", requestData.staff[0].userId);", - "", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"userId\", responseData.staff[0].userId);", - "console.log(pm.collectionVariables.get(\"userId\"));", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Enroll the user to register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{$randomUUID}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Enroll - Validation Error - Staff already enrolled to the register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"response is 400. Staff is already enrolled to the register\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "console.log(pm.collectionVariables.get(\"userId\"))" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Enroll the user to register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Enroll - Validation Error - Duplicate staff objects not allowed in enrollment request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - "", - " req.staff.forEach(staff => {", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }); ", - "", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Duplicate objects in request\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Enroll the user to register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"928ca23a-9bec-11ed-a8fc-0242ac120002\",\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"928ca23a-9bec-11ed-a8fc-0242ac120002\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Enroll - Multiple staff", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - "", - " req.staff.forEach(staff => {", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }); ", - "", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Enrollment date is enriched\", function () {", - " var res = pm.response.json();", - " res.staff.forEach(staff => {", - " pm.expect(staff.enrollmentDate).to.be.not.null;", - " }); ", - " }", - ");", - "", - "let requestData = JSON.parse(pm.request.body.raw);", - "pm.collectionVariables.set(\"userId-1\", requestData.staff[0].userId);", - "pm.collectionVariables.set(\"userId-2\", requestData.staff[1].userId);", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Enroll the user to register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{$randomUUID}}\",\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{$randomUUID}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Deenroll - Single staff", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Deenrollment date is enriched\", function () {", - " var res = pm.response.json();", - " var deenrollmentDate = res.staff[0].deenrollmentDate;", - " pm.expect(deenrollmentDate).to.be.not.null;", - " }", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Deenroll staff from register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Deenroll - Validation Error - Staff already denrolled from the register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Staff already deenrolled from the register\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Deenroll staff from register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Deenroll - Validation Error - Duplicate staff objects in deenrollment request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - "", - " req.staff.forEach(staff => {", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }); ", - "", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Response is 400. Duplicate staff objects in de enrollment request\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Deenroll staff from register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId-1}}\",\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId-1}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Deenroll - Multiple staff", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - "", - " req.staff.forEach(staff => {", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }); ", - "", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Deenrollment date is enriched\", function () {", - " var res = pm.response.json();", - " res.staff.forEach(staff => {", - " pm.expect(staff.deenrollmentDate).to.be.not.null;", - " }); ", - " }", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Deenroll staff from register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId-1}}\",\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId-2}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_delete" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Individual Enrollment", - "item": [ - { - "name": "Attendee - Enroll - Attendee", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendee are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Enrollment date is enriched\", function () {", - " var res = pm.response.json();", - " var enrollmentDate = res.attendees[0].enrollmentDate;", - " pm.expect(enrollmentDate).to.be.not.null;", - " }", - ");", - "", - "// let requestData = JSON.parse(pm.request.body.raw);", - "// pm.collectionVariables.set(\"individualId\", requestData.attendees[0].individualId);", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"individualId\", responseData.attendees[0].individualId);", - "pm.collectionVariables.set(\"attendeeEnrollmentDate\", responseData.attendees[0].enrollmentDate);", - "", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Enroll attendee to register\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{$randomUUID}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n } \n\n ]\n\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Enroll - Validation Error - Attendee already enrolled", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendee are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Attendee already enrolled to the register\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Enroll attendee to register\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n } \n\n ]\n\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Enroll - Validation Error - Duplicate attendee objects not allowed in request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendee are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Duplicate attendee objects in the request\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Enroll attendee to register\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"928ca23a-9bec-11ed-a8fc-0242ac120002\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"928ca23a-9bec-11ed-a8fc-0242ac120002\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n } \n\n ]\n\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Enroll - Multiple Attendees", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendee are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Enrollment date is enriched\", function () {", - " var res = pm.response.json();", - " res.attendees.forEach(attendee => {", - " pm.expect(attendee.enrollmentDate).to.be.not.null;", - " }); ", - " }", - ");", - "", - "let requestData = JSON.parse(pm.request.body.raw);", - "pm.collectionVariables.set(\"individualId-1\", requestData.attendees[0].individualId);", - "pm.collectionVariables.set(\"individualId-2\", requestData.attendees[1].individualId);", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Enroll attendee to register\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{$randomUUID}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{$randomUUID}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n } \n\n ]\n\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Deenroll- Single Attendee", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendees are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Deenrollment date is enriched\", function () {", - " var res = pm.response.json();", - " var deenrollmentDate = res.attendees[0].deenrollmentDate;", - " pm.expect(deenrollmentDate).to.be.not.null;", - " }", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"search with from and to values\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Deenroll- Validation Error - Attendee already deenrolled from the register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendees are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Attendee already deenrolled from the register\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"search with from and to values\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Deenroll- Validation Error - Duplicate attendee objects in deenrollment request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendees are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Duplicate attendee objects in deenrollment request.\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"search with from and to values\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Deenroll- Multiple Attendees", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendees are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Deenrollment date is enriched\", function () {", - " var res = pm.response.json();", - " res.attendees.forEach(attendee => {", - " pm.expect(attendee.denrollmentDate).to.be.not.null;", - " }); ", - " }", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"search with from and to values\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-2}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_delete" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Attendance Log", - "item": [ - { - "name": "Attendance Log - Create - Success", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - " setTimeout( () => {", - "", - " pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var id = res.attendance[0].id;", - " pm.expect(id).to.be.not.null;", - " }", - ");", - " ", - " }, 1000);", - "", - "", - "", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"attendanceLogId\", responseData.attendance[0].id);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Update - Success", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Attendance Log updated successfully\", function () {", - " var res = pm.response.json();", - " var status = res.attendance[0].status;", - " pm.expect(status).to.eql(\"INACTIVE\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"id\": \"{{attendanceLogId}}\",\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"INACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ],\r\n \"auditDetails\": {\r\n \"createdBy\": \"47b5ea82-249c-4435-9646-16167fec06df\",\r\n \"lastModifiedBy\": \"47b5ea82-249c-4435-9646-16167fec06df\",\r\n \"createdTime\": 1671090269007,\r\n \"lastModifiedTime\": 1671090269007\r\n }\r\n \r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Update - fail - attendanceId is not valid", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log updated successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"ATTENDANCE_LOG\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"id\": \"{{$randomUUID}}\",\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"INACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ],\r\n \"auditDetails\": {\r\n \"createdBy\": \"47b5ea82-249c-4435-9646-16167fec06df\",\r\n \"lastModifiedBy\": \"47b5ea82-249c-4435-9646-16167fec06df\",\r\n \"createdTime\": 1671090269007,\r\n \"lastModifiedTime\": 1671090269007\r\n }\r\n \r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - All logs should belong to same tenantId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"MULTIPLE_TENANTIDS\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n },\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"tenant.id\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - Validate Attendance Log time", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"INVALID_ATTENDANCE_TIME\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{invalidRegisterEndDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - Register should belongs to tenenatId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"INVALID_TENANTID\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"tenant.Id\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - All logs should belong to same registerId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"MULTIPLE_REGISTERIDS\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n },\r\n {\r\n \"registerId\": \"{{$randomUUID}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - User is not authorised", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"UNAUTHORISED_USER\");", - " }", - ");" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{$randomUUID}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Rearch - Fail - TenantId is required", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"TENANT_ID\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n }\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_search", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_search" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Rearch - Fail - RegisterId is required", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"REGISTER_ID\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n }\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_search?tenantId={{tenantId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Rearch - Success", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendance).to.be.not.null;", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n }\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_search?tenantId={{tenantId}}®isterId={{registerId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "registerId", - "value": "{{registerId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - required fields are missing", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " pm.expect(res.Errors.length).to.equal(5);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": null,\r\n \"individualId\": null,\r\n \"time\": null,\r\n \"type\": null,\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": null,\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - } - ] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "if (pm.environment.get(\"base_url\").includes(\"localhost\")) {", - "", - " var tenantId = \"pb.amritsar\";", - " var id = 1;", - " var uuid = \"11b0e02b-0145-4de2-bc42-c97b96264807\";", - "", - " var roles = [{", - " \"code\": \"SUPERUSER\",", - " \"name\": \"SUPER USER\",", - " \"tenantId\": tenantId", - " }];", - "", - " var userInfo = {", - " \"id\": id,", - " \"uuid\": uuid,", - " \"userName\": \"\",", - " \"name\": \"\",", - " \"mobileNumber\": \"\",", - " \"emailId\": \"\",", - " \"type\": \"\",", - " \"roles\": roles,", - " \"active\": true,", - " \"tenantId\": \"pb.amritsar\"", - " };", - "", - " pm.request.body.raw = pm.request.body.raw.replace('\"{{token}}\"', '\"\", \\n \"userInfo\": ' + JSON.stringify(userInfo));", - "}" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], - "variable": [ - { - "key": "tenantId", - "value": "" - }, - { - "key": "stateLevelTenant", - "value": "" - }, - { - "key": "registerId", - "value": "" - }, - { - "key": "registerNumber", - "value": "" - }, - { - "key": "registerId2", - "value": "" - }, - { - "key": "registerStartDate", - "value": "" - }, - { - "key": "registerEndDate", - "value": "" - }, - { - "key": "invalidRegisterEndDate", - "value": "" - }, - { - "key": "userId", - "value": "" - }, - { - "key": "userId-1", - "value": "" - }, - { - "key": "userId-2", - "value": "" - }, - { - "key": "individualId", - "value": "" - }, - { - "key": "attendeeEnrollmentDate", - "value": "" - }, - { - "key": "individualId-1", - "value": "" - }, - { - "key": "individualId-2", - "value": "" - }, - { - "key": "attendanceLogId", - "value": "" - } - ] -} \ No newline at end of file diff --git a/core-services/attendance/src/main/java/org/egov/Main.java b/core-services/attendance/src/main/java/org/egov/Main.java deleted file mode 100644 index efe5addd85e..00000000000 --- a/core-services/attendance/src/main/java/org/egov/Main.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.egov; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = {"org.egov", "org.egov.web.controllers", "org.egov.config"}) -public class Main { - - public static void main(String[] args) throws Exception { - SpringApplication.run(Main.class, args); - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/config/AttendanceServiceConfiguration.java b/core-services/attendance/src/main/java/org/egov/config/AttendanceServiceConfiguration.java deleted file mode 100644 index ede3010f452..00000000000 --- a/core-services/attendance/src/main/java/org/egov/config/AttendanceServiceConfiguration.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.egov.config; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.egov.tracer.config.TracerConfiguration; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Import; -import org.springframework.stereotype.Component; - -import javax.annotation.PostConstruct; -import java.util.TimeZone; - -@Component -@Data -@Import({TracerConfiguration.class}) -@NoArgsConstructor -@AllArgsConstructor -public class AttendanceServiceConfiguration { - - @Value("${app.timezone}") - private String timeZone; - //Idgen Config - @Value("${egov.idgen.host}") - private String idGenHost; - @Value("${egov.idgen.path}") - private String idGenPath; - @Value("${egov.idgen.attendance.register.number.name}") - private String idgenAttendanceRegisterNumberName; - //MDMS - @Value("${egov.mdms.host}") - private String mdmsHost; - @Value("${egov.mdms.search.endpoint}") - private String mdmsEndPoint; - //Topic - @Value("${attendance.register.kafka.create.topic}") - private String saveAttendanceRegisterTopic; - @Value("${attendance.register.kafka.update.topic}") - private String updateAttendanceRegisterTopic; - - //Topic - @Value("${attendance.staff.kafka.create.topic}") - private String saveStaffTopic; - @Value("${attendance.staff.kafka.update.topic}") - private String updateStaffTopic; - - //Topic - @Value("${attendance.attendee.kafka.create.topic}") - private String saveAttendeeTopic; - @Value("${attendance.attendee.kafka.update.topic}") - private String updateAttendeeTopic; - - @PostConstruct - public void initialize() { - TimeZone.setDefault(TimeZone.getTimeZone(timeZone)); - } - - // kafka topics - @Value("${attendance.log.kafka.create.topic}") - private String createAttendanceLogTopic; - - @Value("${attendance.log.kafka.update.topic}") - private String updateAttendanceLogTopic; - - // service integration config - @Value("${attendance.individual.service.integration.required}") - private String individualServiceIntegrationRequired; - - @Value("${attendance.staff.service.integration.required}") - private String staffServiceIntegrationRequired; - - @Value("${attendance.document.id.verification.required}") - private String documentIdVerificationRequired; - - //attendance service log search config - - //@Value("${attendance.service.log.default.offset}") - //private Integer attendanceLogDefaultOffset; - - //@Value("${attendance.service.log.default.limit}") - //private Integer attendanceLogDefaultLimit; - - //@Value("${attendance.service.log.search.max.limit}") - //private Integer attendanceLogMaxLimit; - - //attendance service register search config - @Value("${attendance.register.default.offset}") - private Integer attendanceRegisterDefaultOffset; - - @Value("${attendance.register.default.limit}") - private Integer attendanceRegisterDefaultLimit; - - @Value("${attendance.register.search.max.limit}") - private Integer attendanceRegisterMaxLimit; - - @Value("${attendance.register.open.search.enabled.roles}") - private String registerOpenSearchEnabledRoles; - - //Individual servcie - @Value("${works.individual.host}") - private String individualHost; - @Value("${works.individual.search.endpoint}") - private String individualSearchEndpoint; - -} - - diff --git a/core-services/attendance/src/main/java/org/egov/config/MainConfiguration.java b/core-services/attendance/src/main/java/org/egov/config/MainConfiguration.java deleted file mode 100644 index e4d1cb86e3e..00000000000 --- a/core-services/attendance/src/main/java/org/egov/config/MainConfiguration.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.egov.config; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.egov.tracer.config.TracerConfiguration; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Import; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; - -import javax.annotation.PostConstruct; -import java.util.TimeZone; - - -@Import({TracerConfiguration.class}) -public class MainConfiguration { - - @Value("${app.timezone}") - private String timeZone; - - @PostConstruct - public void initialize() { - TimeZone.setDefault(TimeZone.getTimeZone(timeZone)); - } - - @Bean - public ObjectMapper objectMapper() { - return new ObjectMapper().disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).setTimeZone(TimeZone.getTimeZone(timeZone)); - } - - @Bean - @Autowired - public MappingJackson2HttpMessageConverter jacksonConverter(ObjectMapper objectMapper) { - MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter(); - converter.setObjectMapper(objectMapper); - return converter; - } -} \ No newline at end of file diff --git a/core-services/attendance/src/main/java/org/egov/enrichment/AttendanceLogEnrichment.java b/core-services/attendance/src/main/java/org/egov/enrichment/AttendanceLogEnrichment.java deleted file mode 100644 index 64f9e785ce4..00000000000 --- a/core-services/attendance/src/main/java/org/egov/enrichment/AttendanceLogEnrichment.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.egov.enrichment; - -import digit.models.coremodels.AuditDetails; -import lombok.extern.slf4j.Slf4j; -import org.egov.common.contract.request.RequestInfo; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.util.AttendanceServiceUtil; -import org.egov.web.models.AttendanceLog; -import org.egov.web.models.AttendanceLogRequest; -import org.egov.web.models.AttendanceLogSearchCriteria; -import org.egov.web.models.Document; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.List; -import java.util.UUID; - -@Component -@Slf4j -public class AttendanceLogEnrichment { - @Autowired - private AttendanceServiceUtil attendanceServiceUtil; - @Autowired - private AttendanceServiceConfiguration config; - - public void enrichAttendanceLogCreateRequest(AttendanceLogRequest attendanceLogRequest) { - String registerId = attendanceLogRequest.getAttendance().get(0).getRegisterId(); - log.info("Enriching attendance log create request for register ["+registerId+"]"); - List attendanceLogs = attendanceLogRequest.getAttendance(); - String byUser = attendanceLogRequest.getRequestInfo().getUserInfo().getUuid(); - AuditDetails auditDetails = attendanceServiceUtil.getAuditDetails(byUser, null, true); - for (AttendanceLog attendanceLog : attendanceLogs) { - attendanceLog.setAuditDetails(auditDetails); - String attendanceLogId = String.valueOf(UUID.randomUUID()); - attendanceLog.setId(attendanceLogId); - List documentIds = attendanceLog.getDocumentIds(); - for (Document documentId : documentIds) { - documentId.setId(String.valueOf(UUID.randomUUID())); - } - } - log.info("Enriched attendance log create request for register ["+registerId+"]"); - } - - public void enrichAttendanceLogUpdateRequest(AttendanceLogRequest attendanceLogRequest) { - String registerId = attendanceLogRequest.getAttendance().get(0).getRegisterId(); - log.info("Enriching attendance log update request for register ["+registerId+"]"); - List attendanceLogs = attendanceLogRequest.getAttendance(); - String byUser = attendanceLogRequest.getRequestInfo().getUserInfo().getUuid(); - for (AttendanceLog attendanceLog : attendanceLogs) { - AuditDetails auditDetails = attendanceServiceUtil.getAuditDetails(byUser, attendanceLog.getAuditDetails(), false); - attendanceLog.setAuditDetails(auditDetails); - // enrich the documentId if not present - List documentIds = attendanceLog.getDocumentIds(); - for (Document documentId : documentIds) { - if (documentId.getId() == null) { - documentId.setId(String.valueOf(UUID.randomUUID())); - } - } - } - - log.info("Enriched attendance log update request for register ["+registerId+"]"); - } - - public void enrichAttendanceLogSearchRequest(RequestInfo requestInfo, AttendanceLogSearchCriteria searchCriteria) { - -// if (searchCriteria.getLimit() == null) -// searchCriteria.setLimit(config.getAttendanceLogDefaultLimit()); -// -// if (searchCriteria.getOffset() == null) -// searchCriteria.setOffset(config.getAttendanceLogDefaultOffset()); -// -// if (searchCriteria.getLimit() != null && searchCriteria.getLimit() > config.getAttendanceLogMaxLimit()) -// searchCriteria.setLimit(config.getAttendanceLogMaxLimit()); - - } -} diff --git a/core-services/attendance/src/main/java/org/egov/enrichment/AttendeeEnrichmentService.java b/core-services/attendance/src/main/java/org/egov/enrichment/AttendeeEnrichmentService.java deleted file mode 100644 index 6a7547020ab..00000000000 --- a/core-services/attendance/src/main/java/org/egov/enrichment/AttendeeEnrichmentService.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.egov.enrichment; - -import digit.models.coremodels.AuditDetails; -import org.egov.common.contract.request.RequestInfo; -import org.egov.util.AttendanceServiceUtil; -import org.egov.web.models.AttendeeCreateRequest; -import org.egov.web.models.AttendeeDeleteRequest; -import org.egov.web.models.IndividualEntry; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.util.List; -import java.util.UUID; - -@Service -public class AttendeeEnrichmentService { - - @Autowired - private AttendanceServiceUtil attendanceServiceUtil; - - public void enrichAttendeeOnCreate(AttendeeCreateRequest attendeeCreateRequest) { - RequestInfo requestInfo = attendeeCreateRequest.getRequestInfo(); - List attendeeListFromRequest = attendeeCreateRequest.getAttendees(); - - for (IndividualEntry attendee : attendeeListFromRequest) { - AuditDetails auditDetails = attendanceServiceUtil.getAuditDetails(requestInfo.getUserInfo().getUuid(), attendee.getAuditDetails(), true); - attendee.setAuditDetails(auditDetails); - attendee.setId(UUID.randomUUID().toString()); - attendee.setDenrollmentDate(null); - if (attendee.getEnrollmentDate() == null) { - BigDecimal enrollmentDate = new BigDecimal(System.currentTimeMillis()); - attendee.setEnrollmentDate(enrollmentDate); - } - - } - } - - public void enrichAttendeeOnDelete(AttendeeDeleteRequest attendeeDeleteRequest, List attendeesFromDB) { - RequestInfo requestInfo = attendeeDeleteRequest.getRequestInfo(); - List attendeesListFromRequest = attendeeDeleteRequest.getAttendees(); - - for (IndividualEntry attendee : attendeesListFromRequest) { - for (IndividualEntry attendeeFromDB : attendeesFromDB) { - if (attendeeFromDB.getIndividualId().equals(attendee.getIndividualId()) - && attendeeFromDB.getRegisterId().equals(attendee.getRegisterId())) { - - attendee.setId(attendeeFromDB.getId()); - attendee.setEnrollmentDate(attendeeFromDB.getEnrollmentDate()); - - AuditDetails auditDetails = attendanceServiceUtil.getAuditDetails(requestInfo.getUserInfo().getUuid(), attendeeFromDB.getAuditDetails(), false); - attendee.setAuditDetails(auditDetails); - - - if (attendee.getDenrollmentDate() == null) { - BigDecimal deEnrollmentDate = new BigDecimal(System.currentTimeMillis()); - attendee.setDenrollmentDate(deEnrollmentDate); - } - } - } - } - - - } -} diff --git a/core-services/attendance/src/main/java/org/egov/enrichment/RegisterEnrichment.java b/core-services/attendance/src/main/java/org/egov/enrichment/RegisterEnrichment.java deleted file mode 100644 index c34e694998c..00000000000 --- a/core-services/attendance/src/main/java/org/egov/enrichment/RegisterEnrichment.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.egov.enrichment; - -import digit.models.coremodels.AuditDetails; -import digit.models.coremodels.IdResponse; -import lombok.extern.slf4j.Slf4j; -import org.egov.common.contract.request.RequestInfo; -import org.egov.common.models.individual.Individual; -import org.egov.common.utils.MultiStateInstanceUtil; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.repository.IdGenRepository; -import org.egov.tracer.model.CustomException; -import org.egov.util.AttendanceServiceUtil; -import org.egov.util.IndividualServiceUtil; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendanceRegisterRequest; -import org.egov.web.models.AttendanceRegisterSearchCriteria; -import org.egov.web.models.StaffPermission; -import org.egov.web.models.StaffPermissionRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import java.math.BigDecimal; -import java.util.Collections; -import java.util.List; -import java.util.UUID; -import java.util.stream.Collectors; - -@Service -@Slf4j -public class RegisterEnrichment { - - @Autowired - private AttendanceServiceUtil attendanceServiceUtil; - @Autowired - private IdGenRepository idGenRepository; - @Autowired - private AttendanceServiceConfiguration config; - @Autowired - private IndividualServiceUtil individualServiceUtil; - @Autowired - private MultiStateInstanceUtil multiStateInstanceUtil; - - /* Enrich Attendance Register on Create Request */ - public void enrichRegisterOnCreate(AttendanceRegisterRequest attendanceRegisterRequest) { - RequestInfo requestInfo = attendanceRegisterRequest.getRequestInfo(); - List attendanceRegisters = attendanceRegisterRequest.getAttendanceRegister(); - - String rootTenantId = attendanceRegisters.get(0).getTenantId().split("\\.")[0]; - - //Get Register Numbers from IdGen Service for number of registers present in AttendanceRegisters - List registerNumbers = getIdList(requestInfo, rootTenantId - , config.getIdgenAttendanceRegisterNumberName(), "", attendanceRegisters.size()); //idFormat will be fetched by idGen service - - for (int i = 0; i < attendanceRegisters.size(); i++) { - - if (registerNumbers != null && !registerNumbers.isEmpty()) { - attendanceRegisters.get(i).setRegisterNumber(registerNumbers.get(i)); - log.info("Register number " + registerNumbers.get(i) + " assigned to register " + attendanceRegisters.get(i)); - } else { - log.error("Error occurred while generating attendance register numbers from IdGen service"); - throw new CustomException("ATTENDANCE_REGISTER_NUMBER_NOT_GENERATED","Error occurred while generating attendance register numbers from IdGen service"); - } - - //Enrich attendance register id and audit details - attendanceRegisters.get(i).setId(UUID.randomUUID().toString()); - log.info("Attendance register assigned with register Id " + attendanceRegisters.get(i).getId()); - AuditDetails auditDetails = attendanceServiceUtil.getAuditDetails(requestInfo.getUserInfo().getUuid(), null, true); - attendanceRegisters.get(i).setAuditDetails(auditDetails); - log.info("Enriched register " + attendanceRegisters.get(i).getId() + " with Audit details"); - // User who creates the register, by default gets enrolled as the first staff for that register. - enrichRegisterFirstStaff(attendanceRegisters.get(i), requestInfo, auditDetails); - } - } - - /* Enrich first staff details while creating register*/ - private void enrichRegisterFirstStaff(AttendanceRegister attendanceRegister, RequestInfo requestInfo, AuditDetails auditDetails) { - String tenantId = attendanceRegister.getTenantId(); - Long userid = requestInfo.getUserInfo().getId(); - List individualList = individualServiceUtil.getIndividualDetailsFromUserId(userid, requestInfo, multiStateInstanceUtil.getStateLevelTenant(tenantId)); - String individualId = individualList.get(0).getId(); - - StaffPermission staffPermission = StaffPermission.builder() - .id(UUID.randomUUID().toString()) - .tenantId(attendanceRegister.getTenantId()) - .registerId(attendanceRegister.getId()) - .userId(individualId) - .enrollmentDate(new BigDecimal(System.currentTimeMillis())) - .auditDetails(auditDetails) - .build(); - attendanceRegister.setStaff(Collections.singletonList(staffPermission)); - log.info("First staff for attendance register is added in attendance register"); - log.info("The user " + requestInfo.getUserInfo().getUuid() + " is addedd as staff for the attendance register + " + staffPermission.getRegisterId()); - } - - /* Enrich Attendance Register on Update Request */ - public void enrichRegisterOnUpdate(AttendanceRegisterRequest attendanceRegisterRequest, List attendanceRegistersListFromDB) { - RequestInfo requestInfo = attendanceRegisterRequest.getRequestInfo(); - List attendanceRegistersListInUpdateReq = attendanceRegisterRequest.getAttendanceRegister(); - - for (AttendanceRegister attendanceRegisterInUpdateReq : attendanceRegistersListInUpdateReq) { - log.info("Enriching register " + attendanceRegisterInUpdateReq.getId()); - String registerId = String.valueOf(attendanceRegisterInUpdateReq.getId()); - AttendanceRegister attendanceRegisterFromDB = attendanceRegistersListFromDB.stream().filter(ar -> registerId.equals(String.valueOf(ar.getId()))).findFirst().orElse(null); - - // Set read only values i.e register number, attendees, staff to the attendance register update request as in attendance register from DB - attendanceRegisterInUpdateReq.setRegisterNumber(attendanceRegisterFromDB.getRegisterNumber()); - attendanceRegisterInUpdateReq.setAttendees(attendanceRegisterFromDB.getAttendees()); - attendanceRegisterInUpdateReq.setStaff(attendanceRegisterFromDB.getStaff()); - log.info("Update attendance register request for register " + attendanceRegisterInUpdateReq.getId() + " enriched with register number, attendees and staff"); - - // Set audit details for register update request - attendanceRegisterInUpdateReq.setAuditDetails(attendanceRegisterFromDB.getAuditDetails()); - AuditDetails auditDetails = attendanceServiceUtil.getAuditDetails(requestInfo.getUserInfo().getUuid(), attendanceRegisterFromDB.getAuditDetails(), false); - attendanceRegisterInUpdateReq.setAuditDetails(auditDetails); - log.info("Update attendance register request for register " + attendanceRegisterInUpdateReq.getId() + " enriched with audit details"); - } - } - - /* Adds staff details to the associated attendance register */ - public void enrichStaffInRegister(List attendanceRegisters, StaffPermissionRequest staffPermissionResponse) { - for (AttendanceRegister attendanceRegister : attendanceRegisters) { - String registerId = String.valueOf(attendanceRegister.getId()); - List staff = staffPermissionResponse.getStaff().stream().filter(st -> registerId.equals(st.getRegisterId())).collect(Collectors.toList()); - attendanceRegister.setStaff(staff); - log.info("Created staff details associated with attendance register " + attendanceRegister.getId() + " in create request"); - } - } - - /* Get id list from IdGen service */ - private List getIdList(RequestInfo requestInfo, String tenantId, String idKey, - String idformat, int count) { - List idResponses = idGenRepository.getId(requestInfo, tenantId, idKey, idformat, count).getIdResponses(); - - if (CollectionUtils.isEmpty(idResponses)) { - log.error("No ids returned from idgen Service"); - throw new CustomException("IDGEN ERROR", "No ids returned from idgen Service"); - } - - return idResponses.stream() - .map(IdResponse::getId).collect(Collectors.toList()); - } - - - public void enrichSearchRegisterRequest(RequestInfo requestInfo, AttendanceRegisterSearchCriteria searchCriteria) { - - if (searchCriteria.getLimit() == null) - searchCriteria.setLimit(config.getAttendanceRegisterDefaultLimit()); - - if (searchCriteria.getOffset() == null) - searchCriteria.setOffset(config.getAttendanceRegisterDefaultOffset()); - - if (searchCriteria.getLimit() != null && searchCriteria.getLimit() > config.getAttendanceRegisterMaxLimit()) - searchCriteria.setLimit(config.getAttendanceRegisterMaxLimit()); - - } -} diff --git a/core-services/attendance/src/main/java/org/egov/enrichment/StaffEnrichmentService.java b/core-services/attendance/src/main/java/org/egov/enrichment/StaffEnrichmentService.java deleted file mode 100644 index abbb77fbf72..00000000000 --- a/core-services/attendance/src/main/java/org/egov/enrichment/StaffEnrichmentService.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.egov.enrichment; - -import digit.models.coremodels.AuditDetails; -import org.egov.common.contract.request.RequestInfo; -import org.egov.util.AttendanceServiceUtil; -import org.egov.web.models.StaffPermission; -import org.egov.web.models.StaffPermissionRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.util.List; -import java.util.UUID; - -@Service -public class StaffEnrichmentService { - - @Autowired - private AttendanceServiceUtil attendanceServiceUtil; - - public void enrichStaffPermissionOnCreate(StaffPermissionRequest request) { - RequestInfo requestInfo = request.getRequestInfo(); - List staffPermissionListFromRequest = request.getStaff(); - - for (StaffPermission staffPermissionFromRequest : staffPermissionListFromRequest) { - AuditDetails auditDetails = attendanceServiceUtil.getAuditDetails(requestInfo.getUserInfo().getUuid(), staffPermissionFromRequest.getAuditDetails(), true); - staffPermissionFromRequest.setAuditDetails(auditDetails); - staffPermissionFromRequest.setId(UUID.randomUUID().toString()); - BigDecimal enrollmentDate = new BigDecimal(System.currentTimeMillis()); - staffPermissionFromRequest.setEnrollmentDate(enrollmentDate); - } - } - - public void enrichStaffPermissionOnDelete(StaffPermissionRequest request, List staffPermissionListFromDB) { - RequestInfo requestInfo = request.getRequestInfo(); - List staffPermissionListFromRequest = request.getStaff(); - - for (StaffPermission staffPermissionFromRequest : staffPermissionListFromRequest) { - for (StaffPermission staffPermissionFromDB : staffPermissionListFromDB) { - if (staffPermissionFromDB.getUserId().equals(staffPermissionFromRequest.getUserId()) - && staffPermissionFromDB.getRegisterId().equals(staffPermissionFromRequest.getRegisterId()) - && staffPermissionFromDB.getDenrollmentDate() == null) { - staffPermissionFromRequest.setId(staffPermissionFromDB.getId()); - staffPermissionFromRequest.setEnrollmentDate(staffPermissionFromDB.getEnrollmentDate()); - - AuditDetails auditDetails = attendanceServiceUtil.getAuditDetails(requestInfo.getUserInfo().getUuid(), staffPermissionFromDB.getAuditDetails(), false); - - staffPermissionFromRequest.setAuditDetails(auditDetails); - - BigDecimal deenrollmentDate = new BigDecimal(System.currentTimeMillis()); - staffPermissionFromRequest.setDenrollmentDate(deenrollmentDate); - } - } - } - - - } - - -} diff --git a/core-services/attendance/src/main/java/org/egov/kafka/Consumer.java b/core-services/attendance/src/main/java/org/egov/kafka/Consumer.java deleted file mode 100644 index bd8693b4cdd..00000000000 --- a/core-services/attendance/src/main/java/org/egov/kafka/Consumer.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.egov.kafka; - - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.egov.common.contract.request.RequestInfo; -import org.egov.service.AttendanceRegisterService; -import org.egov.service.OrganisationContactDetailsStaffUpdateService; -import org.egov.web.models.Organisation.OrgContactUpdateDiff; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.kafka.annotation.KafkaListener; -import org.springframework.kafka.support.KafkaHeaders; -import org.springframework.messaging.handler.annotation.Header; -import org.springframework.stereotype.Component; - -import java.math.BigDecimal; - -@Component -@Slf4j -public class Consumer { - - @Autowired - private ObjectMapper objectMapper; - @Autowired - private OrganisationContactDetailsStaffUpdateService organisationContactDetailsStaffUpdateService; - @Autowired - private AttendanceRegisterService attendanceRegisterService; - - @KafkaListener(topics = "${organisation.contact.details.update.topic}") - public void updateAttendanceStaff(String consumerRecord, - @Header(KafkaHeaders.RECEIVED_TOPIC) String topic){ - try { - OrgContactUpdateDiff orgContactUpdateDiff = objectMapper.readValue(consumerRecord, OrgContactUpdateDiff.class); - organisationContactDetailsStaffUpdateService.updateStaffPermissionsForContactDetails(orgContactUpdateDiff); - } catch(Exception e){ - log.error("Error updating staff permissions for update in organisation contact details", e); - } - } - - /** - * Update end date for approved time extension request - * @param consumerRecord - * @param topic - */ - @KafkaListener(topics = "${contracts.revision.topic}") - public void updateEndDate(String consumerRecord, @Header(KafkaHeaders.RECEIVED_TOPIC) String topic) { - try { - JsonNode attendanceContractRevisionRequest = objectMapper.readValue(consumerRecord, JsonNode.class); - RequestInfo requestInfo = objectMapper.convertValue(attendanceContractRevisionRequest.get("RequestInfo"), RequestInfo.class); - String tenantId = attendanceContractRevisionRequest.get("tenantId").asText(); - String referenceId = attendanceContractRevisionRequest.get("referenceId").asText(); - BigDecimal endDate = attendanceContractRevisionRequest.get("endDate").decimalValue(); - attendanceRegisterService.updateEndDateForRevisedContract(requestInfo, tenantId, referenceId, endDate); - }catch (Exception e) { - log.error("Error end date for contract"); - } - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/kafka/Producer.java b/core-services/attendance/src/main/java/org/egov/kafka/Producer.java deleted file mode 100644 index b226368be08..00000000000 --- a/core-services/attendance/src/main/java/org/egov/kafka/Producer.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.egov.kafka; - -import org.egov.tracer.kafka.CustomKafkaTemplate; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class Producer { - - @Autowired - private CustomKafkaTemplate kafkaTemplate; - - public void push(String topic, Object value) { - kafkaTemplate.send(topic, value); - } -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/AttendanceLogRepository.java b/core-services/attendance/src/main/java/org/egov/repository/AttendanceLogRepository.java deleted file mode 100644 index 13f19c885ea..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/AttendanceLogRepository.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.egov.repository; - -import lombok.extern.slf4j.Slf4j; -import org.egov.repository.querybuilder.AttendanceLogQueryBuilder; -import org.egov.repository.rowmapper.AttendanceLogRowMapper; -import org.egov.web.models.AttendanceLog; -import org.egov.web.models.AttendanceLogSearchCriteria; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Repository; - -import java.util.ArrayList; -import java.util.List; - -@Repository -@Slf4j -public class AttendanceLogRepository { - @Autowired - private AttendanceLogRowMapper rowMapper; - - @Autowired - private AttendanceLogQueryBuilder queryBuilder; - - @Autowired - private JdbcTemplate jdbcTemplate; - - public List getAttendanceLogs(AttendanceLogSearchCriteria searchCriteria) { - List preparedStmtList = new ArrayList<>(); - log.info("Fetching Attendance Log list. RegisterId ["+searchCriteria.getRegisterId()+"]"); - String query = queryBuilder.getAttendanceLogSearchQuery(searchCriteria, preparedStmtList); - log.info("Query build successfully. RegisterId ["+searchCriteria.getRegisterId()+"]"); - List attendanceLogList = jdbcTemplate.query(query, rowMapper, preparedStmtList.toArray()); - log.info("Fetched Attendance Log list. RegisterId ["+searchCriteria.getRegisterId()+"]"); - return attendanceLogList; - } -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/AttendeeRepository.java b/core-services/attendance/src/main/java/org/egov/repository/AttendeeRepository.java deleted file mode 100644 index c9fc386bef0..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/AttendeeRepository.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.egov.repository; - -import org.egov.repository.querybuilder.AttendeeQueryBuilder; -import org.egov.repository.rowmapper.AttendeeRowMapper; -import org.egov.web.models.AttendeeSearchCriteria; -import org.egov.web.models.IndividualEntry; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Repository; - -import java.util.ArrayList; -import java.util.List; - -@Repository -public class AttendeeRepository { - @Autowired - private AttendeeRowMapper attendeeRowMapper; - - @Autowired - private AttendeeQueryBuilder queryBuilder; - - @Autowired - private JdbcTemplate jdbcTemplate; - - public List getAttendees(AttendeeSearchCriteria searchCriteria) { - List preparedStmtList = new ArrayList<>(); - String query = queryBuilder.getAttendanceAttendeeSearchQuery(searchCriteria, preparedStmtList); - List attendanceStaffList = jdbcTemplate.query(query, attendeeRowMapper, preparedStmtList.toArray()); - return attendanceStaffList; - } -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/IdGenRepository.java b/core-services/attendance/src/main/java/org/egov/repository/IdGenRepository.java deleted file mode 100644 index da28aa64584..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/IdGenRepository.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.egov.repository; - -import digit.models.coremodels.IdGenerationRequest; -import digit.models.coremodels.IdGenerationResponse; -import digit.models.coremodels.IdRequest; -import org.egov.common.contract.request.RequestInfo; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.tracer.model.CustomException; -import org.egov.tracer.model.ServiceCallException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Repository; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.RestTemplate; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Repository -public class IdGenRepository { - - @Autowired - private RestTemplate restTemplate; - - @Autowired - private AttendanceServiceConfiguration config; - - /** - * Call iDgen to generateIds - * - * @param requestInfo The rquestInfo of the request - * @param tenantId The tenantiD of the service request - * @param name Name of the foramt - * @param format Format of the ids - * @param count Total Number of idGen ids required - * @return - */ - public IdGenerationResponse getId(RequestInfo requestInfo, String tenantId, String name, String format, int count) { - - List reqList = new ArrayList<>(); - for (int i = 0; i < count; i++) { - reqList.add(IdRequest.builder().idName(name).format(format).tenantId(tenantId).build()); - } - IdGenerationRequest req = IdGenerationRequest.builder().idRequests(reqList).requestInfo(requestInfo).build(); - IdGenerationResponse response = null; - try { - response = restTemplate.postForObject(config.getIdGenHost() + config.getIdGenPath(), req, IdGenerationResponse.class); - } catch (HttpClientErrorException e) { - throw new ServiceCallException(e.getResponseBodyAsString()); - } catch (Exception e) { - Map map = new HashMap<>(); - map.put(e.getCause().getClass().getName(), e.getMessage()); - throw new CustomException(map); - } - return response; - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/RegisterRepository.java b/core-services/attendance/src/main/java/org/egov/repository/RegisterRepository.java deleted file mode 100644 index a4de6ea2422..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/RegisterRepository.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.egov.repository; - -import lombok.extern.slf4j.Slf4j; -import org.egov.repository.querybuilder.RegisterQueryBuilder; -import org.egov.repository.rowmapper.RegisterRowMapper; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendanceRegisterSearchCriteria; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Repository; - -import java.util.ArrayList; -import java.util.List; - -@Repository -@Slf4j -public class RegisterRepository { - - @Autowired - private RegisterRowMapper rowMapper; - - @Autowired - private RegisterQueryBuilder queryBuilder; - - @Autowired - private JdbcTemplate jdbcTemplate; - - public List getRegister(AttendanceRegisterSearchCriteria searchCriteria) { - List preparedStmtList = new ArrayList<>(); - String query = queryBuilder.getAttendanceRegisterSearchQuery(searchCriteria, preparedStmtList); - log.info("Query of get register : " + query); - log.info("preparedStmtList of get register : " + preparedStmtList.toString()); - List attendanceRegisterList = jdbcTemplate.query(query, rowMapper, preparedStmtList.toArray()); - return attendanceRegisterList; - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/ServiceRequestRepository.java b/core-services/attendance/src/main/java/org/egov/repository/ServiceRequestRepository.java deleted file mode 100644 index a0c82610808..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/ServiceRequestRepository.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.egov.repository; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import lombok.extern.slf4j.Slf4j; -import org.egov.tracer.model.ServiceCallException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Repository; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.RestTemplate; - -import java.util.Map; - -@Repository -@Slf4j -public class ServiceRequestRepository { - - @Autowired - private ObjectMapper mapper; - - @Autowired - private RestTemplate restTemplate; - - - public Object fetchResult(StringBuilder uri, Object request) { - mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); - Object response = null; - try { - response = restTemplate.postForObject(uri.toString(), request, Map.class); - } catch (HttpClientErrorException e) { - log.error("External Service threw an Exception: ", e); - throw new ServiceCallException(e.getResponseBodyAsString()); - } catch (Exception e) { - log.error("Exception while fetching from searcher: ", e); - } - - return response; - } -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/StaffRepository.java b/core-services/attendance/src/main/java/org/egov/repository/StaffRepository.java deleted file mode 100644 index 20d0d433fc7..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/StaffRepository.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.egov.repository; - -import lombok.extern.slf4j.Slf4j; -import org.egov.repository.querybuilder.StaffQueryBuilder; -import org.egov.repository.rowmapper.StaffRowMapper; -import org.egov.web.models.StaffPermission; -import org.egov.web.models.StaffSearchCriteria; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Repository; - -import java.util.ArrayList; -import java.util.List; - -@Repository -@Slf4j -public class StaffRepository { - @Autowired - private StaffRowMapper rowMapper; - - @Autowired - private StaffQueryBuilder queryBuilder; - - @Autowired - private JdbcTemplate jdbcTemplate; - - public List getActiveStaff(StaffSearchCriteria searchCriteria) { - List preparedStmtList = new ArrayList<>(); - String query = queryBuilder.getActiveAttendanceStaffSearchQuery(searchCriteria, preparedStmtList); - List attendanceStaffList = jdbcTemplate.query(query, rowMapper, preparedStmtList.toArray()); - return attendanceStaffList; - } - - public List getAllStaff(StaffSearchCriteria searchCriteria) { - List preparedStmtList = new ArrayList<>(); - String query = queryBuilder.getAttendanceStaffSearchQuery(searchCriteria, preparedStmtList); - List attendanceStaffList = jdbcTemplate.query(query, rowMapper, preparedStmtList.toArray()); - return attendanceStaffList; - } -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/querybuilder/AttendanceLogQueryBuilder.java b/core-services/attendance/src/main/java/org/egov/repository/querybuilder/AttendanceLogQueryBuilder.java deleted file mode 100644 index 2a678b23dc6..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/querybuilder/AttendanceLogQueryBuilder.java +++ /dev/null @@ -1,152 +0,0 @@ -package org.egov.repository.querybuilder; - -import org.apache.commons.lang3.StringUtils; -import org.egov.tracer.model.CustomException; -import org.egov.web.models.AttendanceLogSearchCriteria; -import org.springframework.stereotype.Component; - -import java.math.BigDecimal; -import java.time.Instant; -import java.util.Collection; -import java.util.List; - -@Component -public class AttendanceLogQueryBuilder { - - private static final String ATTENDANCE_LOG_SELECT_QUERY = " SELECT log.id as logid, " + - "log.individual_id as logIndividualId, " + - "log.tenantId as logTenantId, " + - "log.register_id as logRegisterId, " + - "log.status as logStatus, " + - "log.time as logTime, " + - "log.event_type as logEventType, " + - "log.additionaldetails as logAdditionalDetails, " + - "log.createdby as logCreatedBy, " + - "log.lastmodifiedby as logLastModifiedBy, " + - "log.createdtime as logCreatedTime, " + - "log.lastmodifiedtime as logLastModifiedTime, " + - "doc.id as docId, " + - "doc.filestore_id as docFileStoreId, " + - "doc.document_type as docDocumentType, " + - "doc.attendance_log_id as docAttendanceLogId, " + - "doc.tenantid as docTenantId, " + - "doc.status as docStatus, " + - "doc.additionaldetails as docAdditionalDetails, " + - "doc.createdby as docCreatedBy, " + - "doc.lastmodifiedby as docLastModifiedBy, " + - "doc.createdtime as docCreatedTime, " + - "doc.lastmodifiedtime as docLastModifiedTime " + - "FROM eg_wms_attendance_log AS log " + - "LEFT JOIN " + - "eg_wms_attendance_document AS doc " + - "ON (log.id=doc.attendance_log_id) "; - - - public String getAttendanceLogSearchQuery(AttendanceLogSearchCriteria criteria, List preparedStmtList) { - StringBuilder query = new StringBuilder(ATTENDANCE_LOG_SELECT_QUERY); - - List ids = criteria.getIds(); - if (ids != null && !ids.isEmpty()) { - addClauseIfRequired(query, preparedStmtList); - query.append(" log.id IN (").append(createQuery(ids)).append(")"); - addToPreparedStatement(preparedStmtList, ids); - } - - if (StringUtils.isNotBlank(criteria.getTenantId())) { - addClauseIfRequired(query, preparedStmtList); - query.append(" log.tenantid=? "); - preparedStmtList.add(criteria.getTenantId()); - } - - if (StringUtils.isNotBlank(criteria.getRegisterId())) { - addClauseIfRequired(query, preparedStmtList); - query.append(" log.register_id=? "); - preparedStmtList.add(criteria.getRegisterId()); - } - - if (criteria.getFromTime() != null) { - addClauseIfRequired(query, preparedStmtList); - - //If user does not specify toDate, take today's date as toDate by default. - if (criteria.getToTime() == null) { - criteria.setToTime(BigDecimal.valueOf(Instant.now().toEpochMilli())); - } - - query.append(" log.time BETWEEN ? AND ?"); - preparedStmtList.add(criteria.getFromTime()); - preparedStmtList.add(criteria.getToTime()); - - } else { - //if only toDate is provided as parameter without fromDate parameter, throw an exception. - if (criteria.getToTime() != null) { - throw new CustomException("INVALID_SEARCH_PARAM", "Cannot specify getToTime without a getFromTime"); - } - } - - List individualIds = criteria.getIndividualIds(); - if (individualIds != null && !individualIds.isEmpty()) { - addClauseIfRequired(query, preparedStmtList); - query.append(" log.individual_id IN (").append(createQuery(individualIds)).append(")"); - addToPreparedStatement(preparedStmtList, individualIds); - } - - if (criteria.getStatus() != null) { - addClauseIfRequired(query, preparedStmtList); - query.append(" log.status=? "); - preparedStmtList.add(criteria.getStatus().toString()); - } - - addOrderByClause(query, criteria); - - addLimitAndOffset(query, criteria, preparedStmtList); - - return query.toString(); - } - - private void addOrderByClause(StringBuilder queryBuilder, AttendanceLogSearchCriteria criteria) { - - //default - if (criteria.getSortBy() == null || StringUtils.isEmpty(criteria.getSortBy().name())) { - queryBuilder.append(" ORDER BY log.lastmodifiedtime "); - } - - if (criteria.getSortOrder() == AttendanceLogSearchCriteria.SortOrder.ASC) - queryBuilder.append(" ASC "); - else queryBuilder.append(" DESC "); - } - - private void addLimitAndOffset(StringBuilder queryBuilder, AttendanceLogSearchCriteria criteria, List preparedStmtList) { - queryBuilder.append(" OFFSET ? "); - preparedStmtList.add(criteria.getOffset()); - - queryBuilder.append(" LIMIT ? "); - preparedStmtList.add(criteria.getLimit()); - - } - - private String createQuery(Collection ids) { - StringBuilder builder = new StringBuilder(); - int length = ids.size(); - for (int i = 0; i < length; i++) { - builder.append(" ? "); - if (i != length - 1) builder.append(","); - } - return builder.toString(); - } - - private void addClauseIfRequired(StringBuilder query, List preparedStmtList) { - if (preparedStmtList.isEmpty()) { - query.append(" WHERE "); - } else { - query.append(" AND "); - } - } - - private void addToPreparedStatement(List preparedStmtList, Collection ids) { -// ids.forEach(id -> { -// preparedStmtList.add(id); -// }); - - preparedStmtList.addAll(ids); - } -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/querybuilder/AttendeeQueryBuilder.java b/core-services/attendance/src/main/java/org/egov/repository/querybuilder/AttendeeQueryBuilder.java deleted file mode 100644 index 1e963ef6bad..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/querybuilder/AttendeeQueryBuilder.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.egov.repository.querybuilder; - -import org.egov.tracer.model.CustomException; -import org.egov.web.models.AttendeeSearchCriteria; -import org.springframework.stereotype.Component; - -import java.math.BigDecimal; -import java.time.Instant; -import java.util.Collection; -import java.util.List; - -@Component -public class AttendeeQueryBuilder { - - private static final String ATTENDANCE_ATTENDEE_SELECT_QUERY = " SELECT att.id, " + - "att.individual_id, " + - "att.register_id, " + - "att.enrollment_date , " + - "att.deenrollment_date, " + - "att.additionaldetails, " + - "att.createdby, " + - "att.lastmodifiedby, " + - "att.createdtime, " + - "att.lastmodifiedtime, " + - "att.tenantid " + - "FROM eg_wms_attendance_attendee att "; - - public String getAttendanceAttendeeSearchQuery(AttendeeSearchCriteria criteria, List preparedStmtList) { - StringBuilder query = new StringBuilder(ATTENDANCE_ATTENDEE_SELECT_QUERY); - - List ids=criteria.getIds(); - if (ids!=null && !ids.isEmpty()) { - addClauseIfRequired(query, preparedStmtList); - query.append(" att.id IN (").append(createQuery(ids)).append(")"); - addToPreparedStatement(preparedStmtList, ids); - } - - List individualIds=criteria.getIndividualIds(); - if (individualIds!=null && !individualIds.isEmpty()) { - addClauseIfRequired(query, preparedStmtList); - query.append(" att.individual_id IN (").append(createQuery(individualIds)).append(")"); - addToPreparedStatement(preparedStmtList, individualIds); - } - - List registerIds = criteria.getRegisterIds(); - if (registerIds != null && !registerIds.isEmpty()) { - addClauseIfRequired(query, preparedStmtList); - query.append(" att.register_id IN (").append(createQuery(registerIds)).append(")"); - addToPreparedStatement(preparedStmtList, registerIds); - } - - if (criteria.getEnrollmentDate() != null) { - addClauseIfRequired(query, preparedStmtList); - - //If user does not specify toDate, take today's date as toDate by default. - if (criteria.getDenrollmentDate() == null) { - criteria.setDenrollmentDate(BigDecimal.valueOf(Instant.now().toEpochMilli())); - } - - query.append(" att.enrollment_date BETWEEN ? AND ?"); - preparedStmtList.add(criteria.getEnrollmentDate()); - preparedStmtList.add(criteria.getDenrollmentDate()); - - } else { - //if only toDate is provided as parameter without fromDate parameter, throw an exception. - if (criteria.getDenrollmentDate() != null) { - throw new CustomException("INVALID_SEARCH_PARAM", "Cannot specify getEnrollmentDate without a getEnrollmentDate"); - } - } - - addLimitAndOffset(query, criteria, preparedStmtList); - - return query.toString(); - } - private void addLimitAndOffset(StringBuilder query, AttendeeSearchCriteria criteria, List preparedStmtList) { - query.append(" OFFSET ? "); - preparedStmtList.add(criteria.getOffset()); - - query.append(" LIMIT ? "); - preparedStmtList.add(criteria.getLimit()); - - } - - private String createQuery(Collection ids) { - StringBuilder builder = new StringBuilder(); - int length = ids.size(); - for (int i = 0; i < length; i++) { - builder.append(" ? "); - if (i != length - 1) builder.append(","); - } - return builder.toString(); - } - private void addClauseIfRequired(StringBuilder query, List preparedStmtList) { - if (preparedStmtList.isEmpty()) { - query.append(" WHERE "); - } else { - query.append(" AND "); - } - } - - private void addToPreparedStatement(List preparedStmtList, Collection ids) { - preparedStmtList.addAll(ids); - } -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/querybuilder/RegisterQueryBuilder.java b/core-services/attendance/src/main/java/org/egov/repository/querybuilder/RegisterQueryBuilder.java deleted file mode 100644 index 4357df11cd6..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/querybuilder/RegisterQueryBuilder.java +++ /dev/null @@ -1,197 +0,0 @@ -package org.egov.repository.querybuilder; - -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.tracer.model.CustomException; -import org.egov.web.models.AttendanceRegisterSearchCriteria; -import org.egov.web.models.Status; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import java.math.BigDecimal; -import java.time.Instant; -import java.util.Collection; -import java.util.List; - -@Component -@Slf4j -public class RegisterQueryBuilder { - - @Autowired - private AttendanceServiceConfiguration config; - - private static final String ATTENDANCE_REGISTER_SELECT_QUERY = " SELECT reg.id, " + - "reg.tenantid, " + - "reg.registernumber, " + - "reg.name , " + - "reg.startdate, " + - "reg.enddate, " + - "reg.status, " + - "reg.additionaldetails, " + - "reg.createdby, " + - "reg.lastmodifiedby, " + - "reg.createdtime, " + - "reg.lastmodifiedtime, " + - "reg.referenceid, " + - "reg.servicecode " + - "FROM eg_wms_attendance_register reg "; - - - private final String paginationWrapper = "SELECT * FROM " + - "(SELECT *, DENSE_RANK() OVER (ORDER BY lastmodifiedtime DESC , id) offset_ FROM " + - "({})" + - " result) result_offset " + - "WHERE offset_ > ? AND offset_ <= ?"; - - - public String getAttendanceRegisterSearchQuery(AttendanceRegisterSearchCriteria searchCriteria, List preparedStmtList) { - - log.info("Search criteria of attendance search : " + searchCriteria.toString()); - StringBuilder query = new StringBuilder(ATTENDANCE_REGISTER_SELECT_QUERY); - - if (!ObjectUtils.isEmpty(searchCriteria.getTenantId())) { - addClauseIfRequired(query, preparedStmtList); - query.append(" reg.tenantid like ? "); - preparedStmtList.add(searchCriteria.getTenantId()+"%"); - } - - List registerIds = searchCriteria.getIds(); - if (registerIds != null && !registerIds.isEmpty()) { - addClauseIfRequired(query, preparedStmtList); - query.append(" reg.id IN (").append(createQuery(registerIds)).append(")"); - preparedStmtList.addAll(registerIds); - } - - if (!ObjectUtils.isEmpty(searchCriteria.getRegisterNumber())) { - String registerNumber = searchCriteria.getRegisterNumber(); - addClauseIfRequired(query, preparedStmtList); - query.append(" reg.registernumber = ? "); - preparedStmtList.add(registerNumber); - } - - if (!ObjectUtils.isEmpty(searchCriteria.getReferenceId())) { - String referenceId = searchCriteria.getReferenceId(); - addClauseIfRequired(query, preparedStmtList); - query.append(" reg.referenceid = ? "); - preparedStmtList.add(referenceId); - } - - if (!ObjectUtils.isEmpty(searchCriteria.getServiceCode())) { - String serviceCode = searchCriteria.getServiceCode(); - addClauseIfRequired(query, preparedStmtList); - query.append(" reg.servicecode = ? "); - preparedStmtList.add(serviceCode); - } - - if (!ObjectUtils.isEmpty(searchCriteria.getName())) { - String name = searchCriteria.getName(); - addClauseIfRequired(query, preparedStmtList); - query.append(" reg.name = ? "); - preparedStmtList.add(name); - } - - if (searchCriteria.getFromDate() != null) { - addClauseIfRequired(query, preparedStmtList); - - //If user does not specify toDate, take today's date as toDate by default. - if (searchCriteria.getToDate() == null) { - searchCriteria.setToDate(BigDecimal.valueOf(Instant.now().toEpochMilli())); - } - - query.append(" reg.startdate BETWEEN ? AND ?"); - preparedStmtList.add(searchCriteria.getFromDate()); - preparedStmtList.add(searchCriteria.getToDate()); - - } else { - //if only toDate is provided as parameter without fromDate parameter, throw an exception. - if (searchCriteria.getToDate() != null) { - throw new CustomException("INVALID_SEARCH_PARAM", "Cannot specify toDate without a fromDate"); - } - } - - if (!ObjectUtils.isEmpty(searchCriteria.getStatus())) { - Status status = searchCriteria.getStatus(); - addClauseIfRequired(query, preparedStmtList); - query.append(" reg.status = ? "); - preparedStmtList.add(status.toString()); - } - - addOrderByClause(query, searchCriteria); - //addLimitAndOffset(query, searchCriteria, preparedStmtList); - return addPaginationWrapper(query.toString(), preparedStmtList, searchCriteria); - } - - private String addPaginationWrapper(String query,List preparedStmtList, - AttendanceRegisterSearchCriteria criteria){ - int limit = config.getAttendanceRegisterDefaultLimit(); - int offset = config.getAttendanceRegisterDefaultOffset(); - - String finalQuery = paginationWrapper.replace("{}",query); - - if(criteria.getLimit()!=null && criteria.getLimit()<=config.getAttendanceRegisterMaxLimit()) - limit = criteria.getLimit(); - - if(criteria.getLimit()!=null && criteria.getLimit()>config.getAttendanceRegisterMaxLimit()) - limit = config.getAttendanceRegisterMaxLimit(); - - if(criteria.getOffset()!=null) - offset = criteria.getOffset(); - - preparedStmtList.add(offset); - preparedStmtList.add(limit+offset); - - return finalQuery; - } - - private void addOrderByClause(StringBuilder queryBuilder, AttendanceRegisterSearchCriteria criteria) { - //default - if (criteria.getSortBy() == null || StringUtils.isEmpty(criteria.getSortBy().name())) { - queryBuilder.append(" ORDER BY reg.lastmodifiedtime "); - } else { - switch (AttendanceRegisterSearchCriteria.SortBy.valueOf(criteria.getSortBy().name())) { - case fromDate: - queryBuilder.append(" ORDER BY reg.startdate "); - break; - case toDate: - queryBuilder.append(" ORDER BY reg.enddate "); - break; - default: - queryBuilder.append(" ORDER BY reg.lastmodifiedtime "); - break; - } - } - - if (criteria.getSortOrder() == AttendanceRegisterSearchCriteria.SortOrder.ASC) - queryBuilder.append(" ASC "); - else queryBuilder.append(" DESC "); - } - - private void addLimitAndOffset(StringBuilder queryBuilder, AttendanceRegisterSearchCriteria criteria, List preparedStmtList) { - queryBuilder.append(" OFFSET ? "); - preparedStmtList.add(criteria.getOffset()); - - queryBuilder.append(" LIMIT ? "); - preparedStmtList.add(criteria.getLimit()); - - } - - private String createQuery(Collection ids) { - StringBuilder builder = new StringBuilder(); - int length = ids.size(); - for (int i = 0; i < length; i++) { - builder.append(" ? "); - if (i != length - 1) builder.append(","); - } - return builder.toString(); - } - - private void addClauseIfRequired(StringBuilder query, List preparedStmtList) { - if (preparedStmtList.isEmpty()) { - query.append(" WHERE "); - } else { - query.append(" AND "); - } - } -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/querybuilder/StaffQueryBuilder.java b/core-services/attendance/src/main/java/org/egov/repository/querybuilder/StaffQueryBuilder.java deleted file mode 100644 index f4aabcecd49..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/querybuilder/StaffQueryBuilder.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.egov.repository.querybuilder; - -import org.egov.web.models.StaffSearchCriteria; -import org.springframework.stereotype.Component; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -@Component -public class StaffQueryBuilder { - - private static final String ATTENDANCE_STAFF_SELECT_QUERY = " SELECT stf.id, " + - "stf.individual_id, " + - "stf.register_id, " + - "stf.tenantid, " + - "stf.enrollment_date , " + - "stf.deenrollment_date, " + - "stf.additionaldetails, " + - "stf.createdby, " + - "stf.lastmodifiedby, " + - "stf.createdtime, " + - "stf.lastmodifiedtime, " + - "stf.tenantid " + - "FROM eg_wms_attendance_staff stf "; - - public String getActiveAttendanceStaffSearchQuery(StaffSearchCriteria criteria, List preparedStmtList) { - StringBuilder query = new StringBuilder(getAttendanceStaffSearchQuery(criteria, preparedStmtList)); - addClauseIfRequired(query, preparedStmtList); - query.append(" stf.deenrollment_date is null "); - - return query.toString(); - } - - public String getAttendanceStaffSearchQuery(StaffSearchCriteria criteria, List preparedStmtList) { - StringBuilder query = new StringBuilder(ATTENDANCE_STAFF_SELECT_QUERY); - - List staffUserIds = criteria.getIndividualIds(); - if (staffUserIds != null && !staffUserIds.isEmpty()) { - addClauseIfRequired(query, preparedStmtList); - query.append(" stf.individual_id IN (").append(createQuery(staffUserIds)).append(")"); - preparedStmtList.addAll(criteria.getIndividualIds()); - } - - List registerIds = criteria.getRegisterIds(); - if (registerIds != null && !registerIds.isEmpty()) { - addClauseIfRequired(query, preparedStmtList); - query.append(" stf.register_id IN (").append(createQuery(registerIds)).append(")"); - preparedStmtList.addAll(criteria.getRegisterIds()); - } - - String tenantId = criteria.getTenantId(); - if (tenantId != null && !tenantId.isEmpty()) { - addClauseIfRequired(query, preparedStmtList); - query.append(" stf.tenantid IN (").append(createQuery(Collections.singletonList(tenantId))).append(")"); - preparedStmtList.add(criteria.getTenantId()); - } - return query.toString(); - } - private void addClauseIfRequired(StringBuilder query, List preparedStmtList) { - if (preparedStmtList.isEmpty()) { - query.append(" WHERE "); - } else { - query.append(" AND "); - } - } - - private String createQuery(Collection ids) { - StringBuilder builder = new StringBuilder(); - int length = ids.size(); - for (int i = 0; i < length; i++) { - builder.append(" ? "); - if (i != length - 1) builder.append(","); - } - return builder.toString(); - } - - - private void addLimitAndOffset(StringBuilder query, StaffSearchCriteria criteria, List preparedStmtList) { - query.append(" OFFSET ? "); - preparedStmtList.add(criteria.getOffset()); - - query.append(" LIMIT ? "); - preparedStmtList.add(criteria.getLimit()); - - } -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/rowmapper/AttendanceLogRowMapper.java b/core-services/attendance/src/main/java/org/egov/repository/rowmapper/AttendanceLogRowMapper.java deleted file mode 100644 index c2e506e221a..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/rowmapper/AttendanceLogRowMapper.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.egov.repository.rowmapper; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.egov.tracer.model.CustomException; -import org.egov.web.models.AttendanceLog; -import org.egov.web.models.Document; -import org.egov.web.models.Status; -import org.postgresql.util.PGobject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.jdbc.core.ResultSetExtractor; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.math.BigDecimal; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -@Component -@Slf4j -public class AttendanceLogRowMapper implements ResultSetExtractor> { - - @Autowired - private ObjectMapper mapper; - - @Override - public List extractData(ResultSet rs) throws SQLException, DataAccessException { - - Map attendanceLogMap = new LinkedHashMap<>(); - - while (rs.next()) { - String id = rs.getString("logid"); - String individualId = rs.getString("logIndividualId"); - String tenantId = rs.getString("logTenantId"); - String registerId = rs.getString("logRegisterId"); - String status = rs.getString("logStatus"); - BigDecimal time = rs.getBigDecimal("logTime"); - String eventType = rs.getString("logEventType"); - String createdby = rs.getString("logCreatedBy"); - String lastmodifiedby = rs.getString("logLastModifiedBy"); - Long createdtime = rs.getLong("logCreatedTime"); - Long lastmodifiedtime = rs.getLong("logLastModifiedTime"); - - AuditDetails auditDetails = AuditDetails.builder().createdBy(createdby).createdTime(createdtime) - .lastModifiedBy(lastmodifiedby).lastModifiedTime(lastmodifiedtime) - .build(); - - JsonNode additionalDetails = getAdditionalDetail("logAdditionalDetails", rs); - - AttendanceLog attendanceLog = AttendanceLog.builder() - .id(id) - .individualId(individualId) - .tenantId(tenantId) - .registerId(registerId) - .status(Status.fromValue(status)) - .time(time) - .type(eventType) - .additionalDetails(additionalDetails) - .auditDetails(auditDetails) - .build(); - - if (!attendanceLogMap.containsKey(id)) { - attendanceLogMap.put(id, attendanceLog); - } - - addDocumentsDetails(rs, attendanceLogMap.get(id)); - } - return new ArrayList<>(attendanceLogMap.values()); - } - - private void addDocumentsDetails(ResultSet rs, AttendanceLog attendanceLog) throws SQLException { - String documentId = rs.getString("docId"); - String attendanceLogId = rs.getString("docAttendanceLogId"); - if (StringUtils.isNotBlank(documentId) && attendanceLogId.equalsIgnoreCase(attendanceLog.getId().toString())) { - Document document = Document.builder() - .id(documentId) - .documentType(rs.getString("docDocumentType")) - .fileStore(rs.getString("docFileStoreId")) - .documentUid(rs.getString("docFileStoreId")) - .status(Status.fromValue(rs.getString("docStatus"))) - .build(); - - JsonNode additionalDetails = getAdditionalDetail("docAdditionalDetails", rs); - document.setAdditionalDetails(additionalDetails); - - if (attendanceLog.getDocumentIds() == null || attendanceLog.getDocumentIds().isEmpty()) { - List documentIdList = new LinkedList<>(); - documentIdList.add(document); - attendanceLog.setDocumentIds(documentIdList); - } else { - attendanceLog.getDocumentIds().add(document); - } - } - } - - private JsonNode getAdditionalDetail(String columnName, ResultSet rs) throws SQLException { - JsonNode additionalDetails = null; - try { - PGobject obj = (PGobject) rs.getObject(columnName); - if (obj != null) { - additionalDetails = mapper.readTree(obj.getValue()); - } - } catch (IOException e) { - log.error("Failed to parse additionalDetail object"); - throw new CustomException("PARSING_ERROR", "Failed to parse additionalDetail object"); - } - if (additionalDetails.isEmpty()) - additionalDetails = null; - return additionalDetails; - } -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/rowmapper/AttendeeRowMapper.java b/core-services/attendance/src/main/java/org/egov/repository/rowmapper/AttendeeRowMapper.java deleted file mode 100644 index 1583ff89e04..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/rowmapper/AttendeeRowMapper.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.egov.repository.rowmapper; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; -import org.egov.tracer.model.CustomException; -import org.egov.web.models.IndividualEntry; -import org.postgresql.util.PGobject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.jdbc.core.ResultSetExtractor; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.math.BigDecimal; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -@Component -public class AttendeeRowMapper implements ResultSetExtractor> { - - @Autowired - private ObjectMapper mapper; - - @Override - public List extractData(ResultSet rs) throws SQLException, DataAccessException { - Map attendanceAttendeeMap = new LinkedHashMap<>(); - while (rs.next()) { - String id = rs.getString("id"); - String registerId = rs.getString("register_id"); - String individuaId = rs.getString("individual_id"); - String tenantId= rs.getString("tenantid"); - BigDecimal enrollmentDate = rs.getBigDecimal("enrollment_date"); - BigDecimal deenrollmentDate = rs.getBigDecimal("deenrollment_date"); - String createdby = rs.getString("createdby"); - String lastmodifiedby = rs.getString("lastmodifiedby"); - Long createdtime = rs.getLong("createdtime"); - Long lastmodifiedtime = rs.getLong("lastmodifiedtime"); - - AuditDetails auditDetails = AuditDetails.builder().createdBy(createdby).createdTime(createdtime) - .lastModifiedBy(lastmodifiedby).lastModifiedTime(lastmodifiedtime) - .build(); - - JsonNode additionalDetails = getAdditionalDetail("additionaldetails", rs); - - IndividualEntry attendanceAttendee = IndividualEntry.builder() - .additionalDetails(additionalDetails) - .id(id) - .individualId(individuaId) - .registerId(registerId) - .tenantId(tenantId) - .additionalDetails(additionalDetails) - .enrollmentDate(enrollmentDate) - .denrollmentDate(deenrollmentDate) - .auditDetails(auditDetails) - .build(); - - if (!attendanceAttendeeMap.containsKey(id)) { - attendanceAttendeeMap.put(id, attendanceAttendee); - } - } - return new ArrayList<>(attendanceAttendeeMap.values()); - - } - - private JsonNode getAdditionalDetail(String columnName, ResultSet rs) throws SQLException { - JsonNode additionalDetails = null; - try { - PGobject obj = (PGobject) rs.getObject(columnName); - if (obj != null) { - additionalDetails = mapper.readTree(obj.getValue()); - } - } catch (IOException e) { - throw new CustomException("PARSING ERROR", "Failed to parse additionalDetail object"); - } - if (additionalDetails.isEmpty()) - additionalDetails = null; - return additionalDetails; - } -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/rowmapper/RegisterRowMapper.java b/core-services/attendance/src/main/java/org/egov/repository/rowmapper/RegisterRowMapper.java deleted file mode 100644 index e6ffb4090aa..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/rowmapper/RegisterRowMapper.java +++ /dev/null @@ -1,92 +0,0 @@ -package org.egov.repository.rowmapper; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; -import org.egov.tracer.model.CustomException; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.Status; -import org.postgresql.util.PGobject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.jdbc.core.ResultSetExtractor; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.math.BigDecimal; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -@Component -public class RegisterRowMapper implements ResultSetExtractor> { - - @Autowired - private ObjectMapper mapper; - - @Override - public List extractData(ResultSet rs) throws SQLException, DataAccessException { - - Map attendanceRegisterMap = new LinkedHashMap<>(); - - while (rs.next()) { - String id = rs.getString("id"); - String tenantId = rs.getString("tenantid"); - String registerNumber = rs.getString("registernumber"); - String name = rs.getString("name"); - BigDecimal startDate = rs.getBigDecimal("startdate"); - BigDecimal endDate = rs.getBigDecimal("enddate"); - String status = rs.getString("status"); - String createdby = rs.getString("createdby"); - String lastmodifiedby = rs.getString("lastmodifiedby"); - Long createdtime = rs.getLong("createdtime"); - Long lastmodifiedtime = rs.getLong("lastmodifiedtime"); - String referenceId = rs.getString("referenceid"); - String serviceCode = rs.getString("servicecode"); - - AuditDetails auditDetails = AuditDetails.builder().createdBy(createdby).createdTime(createdtime) - .lastModifiedBy(lastmodifiedby).lastModifiedTime(lastmodifiedtime) - .build(); - - JsonNode additionalDetails = getAdditionalDetail("additionaldetails", rs); - - AttendanceRegister attendanceRegister = AttendanceRegister.builder() - .additionalDetails(additionalDetails) - .id(id) - .tenantId(tenantId) - .status(Status.fromValue(status)) - .registerNumber(registerNumber) - .referenceId(referenceId) - .serviceCode(serviceCode) - .name(name) - .startDate(startDate) - .endDate(endDate) - .auditDetails(auditDetails) - .build(); - - if (!attendanceRegisterMap.containsKey(id)) { - attendanceRegisterMap.put(id, attendanceRegister); - } - } - return new ArrayList<>(attendanceRegisterMap.values()); - - } - - private JsonNode getAdditionalDetail(String columnName, ResultSet rs) throws SQLException { - JsonNode additionalDetails = null; - try { - PGobject obj = (PGobject) rs.getObject(columnName); - if (obj != null) { - additionalDetails = mapper.readTree(obj.getValue()); - } - } catch (IOException e) { - throw new CustomException("PARSING ERROR", "Failed to parse additionalDetail object"); - } - if (additionalDetails.isEmpty()) - additionalDetails = null; - return additionalDetails; - } -} diff --git a/core-services/attendance/src/main/java/org/egov/repository/rowmapper/StaffRowMapper.java b/core-services/attendance/src/main/java/org/egov/repository/rowmapper/StaffRowMapper.java deleted file mode 100644 index 60851bc94c4..00000000000 --- a/core-services/attendance/src/main/java/org/egov/repository/rowmapper/StaffRowMapper.java +++ /dev/null @@ -1,84 +0,0 @@ -package org.egov.repository.rowmapper; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; -import org.egov.tracer.model.CustomException; -import org.egov.web.models.StaffPermission; -import org.postgresql.util.PGobject; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.jdbc.core.ResultSetExtractor; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.math.BigDecimal; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -@Component -public class StaffRowMapper implements ResultSetExtractor> { - - @Autowired - private ObjectMapper mapper; - - @Override - public List extractData(ResultSet rs) throws SQLException, DataAccessException { - Map attendanceStaffMap = new LinkedHashMap<>(); - while (rs.next()) { - String id = rs.getString("id"); - String tenantId = rs.getString("tenantid"); - String individuaId = rs.getString("individual_id"); - String registerId = rs.getString("register_id"); - BigDecimal enrollmentDate = rs.getBigDecimal("enrollment_date"); - BigDecimal deenrollmentDate = rs.getBigDecimal("deenrollment_date"); - String createdby = rs.getString("createdby"); - String lastmodifiedby = rs.getString("lastmodifiedby"); - Long createdtime = rs.getLong("createdtime"); - Long lastmodifiedtime = rs.getLong("lastmodifiedtime"); - - AuditDetails auditDetails = AuditDetails.builder().createdBy(createdby).createdTime(createdtime) - .lastModifiedBy(lastmodifiedby).lastModifiedTime(lastmodifiedtime) - .build(); - - JsonNode additionalDetails = getAdditionalDetail("additionaldetails", rs); - - StaffPermission attendanceStaff = StaffPermission.builder() - .additionalDetails(additionalDetails) - .id(id) - .tenantId(tenantId) - .userId(individuaId) - .registerId(registerId) - .additionalDetails(additionalDetails) - .enrollmentDate(enrollmentDate) - .denrollmentDate(deenrollmentDate) - .auditDetails(auditDetails) - .build(); - - if (!attendanceStaffMap.containsKey(id)) { - attendanceStaffMap.put(id, attendanceStaff); - } - } - return new ArrayList<>(attendanceStaffMap.values()); - } - - - private JsonNode getAdditionalDetail(String columnName, ResultSet rs) throws SQLException { - JsonNode additionalDetails = null; - try { - PGobject obj = (PGobject) rs.getObject(columnName); - if (obj != null) { - additionalDetails = mapper.readTree(obj.getValue()); - } - } catch (IOException e) { - throw new CustomException("PARSING ERROR", "Failed to parse additionalDetail object"); - } - if (additionalDetails.isEmpty()) - additionalDetails = null; - return additionalDetails; - } -} diff --git a/core-services/attendance/src/main/java/org/egov/service/AttendanceLogService.java b/core-services/attendance/src/main/java/org/egov/service/AttendanceLogService.java deleted file mode 100644 index ba835a82bba..00000000000 --- a/core-services/attendance/src/main/java/org/egov/service/AttendanceLogService.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.egov.service; - -import lombok.extern.slf4j.Slf4j; -import org.egov.common.contract.response.ResponseInfo; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.enrichment.AttendanceLogEnrichment; -import org.egov.kafka.Producer; -import org.egov.repository.AttendanceLogRepository; -import org.egov.util.ResponseInfoFactory; -import org.egov.validator.AttendanceLogServiceValidator; -import org.egov.web.models.AttendanceLog; -import org.egov.web.models.AttendanceLogRequest; -import org.egov.web.models.AttendanceLogResponse; -import org.egov.web.models.AttendanceLogSearchCriteria; -import org.egov.web.models.RequestInfoWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Service -@Slf4j -public class AttendanceLogService { - @Autowired - private AttendanceLogServiceValidator attendanceLogServiceValidator; - - @Autowired - private ResponseInfoFactory responseInfoFactory; - - - @Autowired - private AttendanceLogEnrichment attendanceLogEnricher; - - @Autowired - private Producer producer; - - @Autowired - private AttendanceServiceConfiguration config; - - @Autowired - private AttendanceLogRepository attendanceLogRepository; - - /** - * Create Attendance Log - * - * @param attendanceLogRequest - * @return attendanceLogResponse - */ - public AttendanceLogResponse createAttendanceLog(AttendanceLogRequest attendanceLogRequest) { - //Validate the incoming request - attendanceLogServiceValidator.validateCreateAttendanceLogRequest(attendanceLogRequest); - //Enrich the incoming request - attendanceLogEnricher.enrichAttendanceLogCreateRequest(attendanceLogRequest); - // Push the request object to the topic for persister to listen and persist - producer.push(config.getCreateAttendanceLogTopic(), attendanceLogRequest); - // Create the response - ResponseInfo responseInfo = responseInfoFactory.createResponseInfoFromRequestInfo(attendanceLogRequest.getRequestInfo(), true); - AttendanceLogResponse attendanceLogResponse = AttendanceLogResponse.builder().responseInfo(responseInfo).attendance(attendanceLogRequest.getAttendance()).build(); - String registerId = attendanceLogRequest.getAttendance().get(0).getRegisterId(); - log.info("Attendance logs created successfully for register ["+registerId+"]"); - return attendanceLogResponse; - } - - /** - * Search attendace logs based on given search criteria - * - * @param requestInfoWrapper - * @param searchCriteria - * @return attendanceLogResponse - */ - public AttendanceLogResponse searchAttendanceLog(RequestInfoWrapper requestInfoWrapper, AttendanceLogSearchCriteria searchCriteria) { - //Validate the incoming request - attendanceLogServiceValidator.validateSearchAttendanceLogRequest(requestInfoWrapper, searchCriteria); - //Enrich the incoming request - attendanceLogEnricher.enrichAttendanceLogSearchRequest(requestInfoWrapper.getRequestInfo(), searchCriteria); - //Fetch attendance logs from registry - List attendanceLogs = attendanceLogRepository.getAttendanceLogs(searchCriteria); - // Create the response - ResponseInfo responseInfo = responseInfoFactory.createResponseInfoFromRequestInfo(requestInfoWrapper.getRequestInfo(), true); - AttendanceLogResponse attendanceLogResponse = AttendanceLogResponse.builder().responseInfo(responseInfo).attendance(attendanceLogs).build(); - log.info("Attendance log response created for register ["+searchCriteria.getRegisterId()+"]"); - return attendanceLogResponse; - } - - /** - * Update the given attendance log details - * - * @param attendanceLogRequest - * @return AttendanceLogResponse - */ - public AttendanceLogResponse updateAttendanceLog(AttendanceLogRequest attendanceLogRequest) { - //Validate the incoming request - attendanceLogServiceValidator.validateUpdateAttendanceLogRequest(attendanceLogRequest); - //Enrich the incoming request - attendanceLogEnricher.enrichAttendanceLogUpdateRequest(attendanceLogRequest); - // Push the request object to the topic for persister to listen and persist - producer.push(config.getUpdateAttendanceLogTopic(), attendanceLogRequest); - // Create the response - ResponseInfo responseInfo = responseInfoFactory.createResponseInfoFromRequestInfo(attendanceLogRequest.getRequestInfo(), true); - AttendanceLogResponse attendanceLogResponse = AttendanceLogResponse.builder().responseInfo(responseInfo).attendance(attendanceLogRequest.getAttendance()).build(); - String registerId = attendanceLogRequest.getAttendance().get(0).getRegisterId(); - log.info("Attendance logs updated successfully for register ["+registerId+"]"); - return attendanceLogResponse; - } -} diff --git a/core-services/attendance/src/main/java/org/egov/service/AttendanceRegisterService.java b/core-services/attendance/src/main/java/org/egov/service/AttendanceRegisterService.java deleted file mode 100644 index 37e8fae18ee..00000000000 --- a/core-services/attendance/src/main/java/org/egov/service/AttendanceRegisterService.java +++ /dev/null @@ -1,377 +0,0 @@ -package org.egov.service; - -import digit.models.coremodels.RequestInfoWrapper; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.egov.common.contract.request.RequestInfo; -import org.egov.common.contract.request.Role; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.enrichment.RegisterEnrichment; -import org.egov.enrichment.StaffEnrichmentService; -import org.egov.kafka.Producer; -import org.egov.repository.AttendeeRepository; -import org.egov.repository.RegisterRepository; -import org.egov.tracer.model.CustomException; -import org.egov.util.IndividualServiceUtil; -import org.egov.util.ResponseInfoFactory; -import org.egov.validator.AttendanceServiceValidator; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendanceRegisterRequest; -import org.egov.web.models.AttendanceRegisterSearchCriteria; -import org.egov.web.models.AttendeeSearchCriteria; -import org.egov.web.models.IndividualEntry; -import org.egov.web.models.StaffPermission; -import org.egov.web.models.StaffSearchCriteria; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -@Service -@Slf4j -public class AttendanceRegisterService { - @Autowired - private AttendanceServiceValidator attendanceServiceValidator; - - @Autowired - private ResponseInfoFactory responseInfoFactory; - - @Autowired - private Producer producer; - - @Autowired - private AttendanceServiceConfiguration attendanceServiceConfiguration; - - @Autowired - private RegisterEnrichment registerEnrichment; - - - @Autowired - private StaffService staffService; - - @Autowired - private RegisterRepository registerRepository; - - @Autowired - private AttendeeRepository attendeeRepository; - - @Autowired - private StaffEnrichmentService staffEnrichmentService; - @Autowired - private IndividualServiceUtil individualServiceUtil; - - /** - * Create Attendance register - * - * @param request - * @return - */ - public AttendanceRegisterRequest createAttendanceRegister(AttendanceRegisterRequest request) { - attendanceServiceValidator.validateCreateAttendanceRegister(request); - registerEnrichment.enrichRegisterOnCreate(request); - log.info("Enriched Register with Register number, Ids, first staff and audit details"); - producer.push(attendanceServiceConfiguration.getSaveAttendanceRegisterTopic(), request); - log.info("Pushed create attendance register request to kafka"); - return request; - } - - /** - * Search attendance register based on given search criteria - * - * @param requestInfoWrapper - * @param searchCriteria - * @return - */ - public List searchAttendanceRegister(RequestInfoWrapper requestInfoWrapper, AttendanceRegisterSearchCriteria searchCriteria) { - //Validate the requested parameters - attendanceServiceValidator.validateSearchRegisterRequest(requestInfoWrapper, searchCriteria); - - //Enrich requested search criteria - registerEnrichment.enrichSearchRegisterRequest(requestInfoWrapper.getRequestInfo(),searchCriteria); - - //Get the logged-in user roles - Set userRoles = getUserRoleCodes(requestInfoWrapper.getRequestInfo()); - - //Get the roles enabled for open serach - Set openSearchEnabledRoles = getRegisterOpenSearchEnabledRoles(); - - List resultAttendanceRegisters = new ArrayList<>(); - - if(isUserEnabledForOpenSearch(userRoles,openSearchEnabledRoles)){ - /* - User having the role to perform open search on attendance register. - */ - log.info("Searching registers for Superuser or Engineer"); - fetchAndFilterRegisters(searchCriteria, resultAttendanceRegisters); - }else{ - /* - Make sure response register list should contain only those register for which logged-in is associated. - */ - Long userId = requestInfoWrapper.getRequestInfo().getUserInfo().getId(); - - String individualId = individualServiceUtil.getIndividualDetailsFromUserId(userId,requestInfoWrapper.getRequestInfo(), searchCriteria.getTenantId()).get(0).getId(); - Set registers = fetchRegistersAssociatedToLoggedInStaffUser(individualId); - updateSearchCriteriaAndFetchAndFilterRegisters(registers, searchCriteria, resultAttendanceRegisters); - } - return resultAttendanceRegisters; - } - - private boolean isUserEnabledForOpenSearch(Set userRoles, Set openSearchEnabledRoles) { - for(String userRole : userRoles){ - if(openSearchEnabledRoles.contains(userRole)){ - return true; - } - } - return false; - } - - private Set getRegisterOpenSearchEnabledRoles() { - Set openSearchEnabledRoles = new HashSet<>(); - String registerOpenSearchEnabledRoles = attendanceServiceConfiguration.getRegisterOpenSearchEnabledRoles(); - if(!StringUtils.isBlank(registerOpenSearchEnabledRoles)){ - String[] roles = registerOpenSearchEnabledRoles.split(","); - for(String role :roles){ - if(!StringUtils.isBlank(role)){ - openSearchEnabledRoles.add(role); - } - } - } - return openSearchEnabledRoles; - } - - /** - * Update the search criteria with list of registerIds if it does not contain registerId - * then fetch the all registers based on the search criteria - * but keep only those registers at last which contains attendees or staff in given search criteria - * - * @param registers - * @param searchCriteria - * @param resultAttendanceRegisters - */ - public void updateSearchCriteriaAndFetchAndFilterRegisters(Set registers, AttendanceRegisterSearchCriteria searchCriteria, List resultAttendanceRegisters) { - - if (registers == null || registers.isEmpty()) { - log.info("Registers are empty or null"); - return; - } - if (searchCriteria.getIds() == null) { - log.info("Register search criteria does not contain any register ids"); - List registerIds = new ArrayList<>(); - registerIds.addAll(registers); - searchCriteria.setIds(registerIds); - } else { - log.info("Register search criteria does contains register ids"); - for (String id : searchCriteria.getIds()) { - if (!registers.contains(id)) { - log.error( "User can search only associated registers"); - throw new CustomException("INVALID_REGISTER_ID", "User can search only associated registers"); - } - } - } - fetchAndFilterRegisters(searchCriteria, resultAttendanceRegisters); - } - - /** - * Fetch the all registers based on the supplied search criteria - * but keep only those registers which contains attendees or staff given in search criteria - * - * @param searchCriteria - * @param resultAttendanceRegisters - */ - private void fetchAndFilterRegisters(AttendanceRegisterSearchCriteria searchCriteria, List resultAttendanceRegisters) { - log.info("Fetching registers based on supplied search criteria"); - // Fetch the all registers based on the supplied search criteria - List attendanceRegisters = registerRepository.getRegister(searchCriteria); - // Create a map with key as registerId and corresponding register list as value - Map> registerIdVsAttendanceRegisters = attendanceRegisters.stream().collect(Collectors.groupingBy(AttendanceRegister::getId)); - - List registerIdsToSearch = new ArrayList<>(); - registerIdsToSearch.addAll(registerIdVsAttendanceRegisters.keySet()); - - // Fetch and filer staff members based on the supplied search criteria. - log.info("Fetch all staff members based on the supplied search criteria"); - List staffMembers = fetchAllStaffMembersAssociatedToRegisterIds(registerIdsToSearch,searchCriteria); - // Create a map with key as registerId and corresponding staff list as value - Map> registerIdStaffMapping = staffMembers.stream().collect(Collectors.groupingBy(StaffPermission::getRegisterId)); - - // If staffId present in search criteria then update the registerIDToSearch list with new set of registerIds - if (searchCriteria.getStaffId() != null){ - registerIdsToSearch.clear(); - registerIdsToSearch.addAll(registerIdStaffMapping.keySet()); - } - - // Fetch and filer attendees based on the supplied search criteria. - List attendees = fetchAllAttendeesAssociatedToRegisterIds(registerIdsToSearch,searchCriteria); - // Create a map with key as registerId and corresponding attendee list as value - Map> registerIdAttendeeMapping = attendees.stream().collect(Collectors.groupingBy(IndividualEntry::getRegisterId)); - - // If AttendeeId present in search criteria then update the registerIDToSearch list with new set of registerIds - if(searchCriteria.getAttendeeId() != null){ - List registerIdsAssociatedToAttendees = new ArrayList<>(); - registerIdsAssociatedToAttendees.addAll(registerIdAttendeeMapping.keySet()); - registerIdsToSearch.clear(); - registerIdsToSearch.addAll(registerIdsAssociatedToAttendees); - } - - // Populate final list of registers to be return - for(String registerId : registerIdsToSearch ){ - List registers = registerIdVsAttendanceRegisters.get(registerId); - for(AttendanceRegister register : registers){ - register.setStaff(registerIdStaffMapping.get(registerId)); - register.setAttendees(registerIdAttendeeMapping.get(registerId)); - resultAttendanceRegisters.add(register); - } - } - } - - private List fetchAllAttendeesAssociatedToRegisterIds(List registerIdsToSearch, AttendanceRegisterSearchCriteria searchCriteria) { - AttendeeSearchCriteria attendeeSearchCriteria = null; - if(searchCriteria.getAttendeeId() != null){ - attendeeSearchCriteria = AttendeeSearchCriteria.builder().registerIds(registerIdsToSearch).individualIds(Collections.singletonList(searchCriteria.getAttendeeId())).build(); - } else { - attendeeSearchCriteria = AttendeeSearchCriteria.builder().registerIds(registerIdsToSearch).build(); - } - return attendeeRepository.getAttendees(attendeeSearchCriteria); - } - - /* Get all staff members associated for the register */ - private List fetchAllStaffMembersAssociatedToRegisterIds(List registerIdsToSearch, AttendanceRegisterSearchCriteria searchCriteria) { - StaffSearchCriteria staffSearchCriteria = null ; - if(searchCriteria.getStaffId() != null){ - staffSearchCriteria = StaffSearchCriteria.builder().registerIds(registerIdsToSearch).individualIds(Collections.singletonList(searchCriteria.getStaffId())).build(); - } else { - staffSearchCriteria = StaffSearchCriteria.builder().registerIds(registerIdsToSearch).build(); - } - return staffService.getAllStaff(staffSearchCriteria); - } - - /* Returns list of user roles */ - private Set getUserRoleCodes(RequestInfo requestInfo) { - Set userRoles = new HashSet<>(); - List roles = requestInfo.getUserInfo().getRoles(); - if(roles == null) - return userRoles; - return roles.stream().map(e->e.getCode()).collect(Collectors.toSet()); - } - - /* Get all registers associated for the logged in staff */ - private Set fetchRegistersAssociatedToLoggedInStaffUser(String uuid) { - List individualIds = new ArrayList<>(); - individualIds.add(uuid); - StaffSearchCriteria staffSearchCriteria = StaffSearchCriteria.builder().individualIds(individualIds).build(); - List staffMembers = staffService.getAllStaff(staffSearchCriteria); - return staffMembers.stream().map(e -> e.getRegisterId()).collect(Collectors.toSet()); - } - - /* Get all registers associated for the logged in attendee */ - private Set fetchRegistersAssociatedToLoggedInAttendeeUser(String uuid) { - AttendeeSearchCriteria attendeeSearchCriteria = AttendeeSearchCriteria.builder().individualIds(Collections.singletonList(uuid)).build(); - List attendees = attendeeRepository.getAttendees(attendeeSearchCriteria); - return attendees.stream().map(e -> e.getRegisterId()).collect(Collectors.toSet()); - } - - /** - * Update the given attendance register details - * - * @param attendanceRegisterRequest - * @return - */ - public AttendanceRegisterRequest updateAttendanceRegister(AttendanceRegisterRequest attendanceRegisterRequest) { - attendanceServiceValidator.validateUpdateAttendanceRegisterRequest(attendanceRegisterRequest); - log.info("Validated update attendance register request"); - - //Create requestInfoWrapper from attendanceRegister request, collect ids in list for search attendance register request parameters - RequestInfoWrapper requestInfoWrapper = RequestInfoWrapper.builder().requestInfo(attendanceRegisterRequest.getRequestInfo()).build(); - List registerIds = getAttendanceRegisterIdList(attendanceRegisterRequest); - String tenantId = attendanceRegisterRequest.getAttendanceRegister().get(0).getTenantId(); - //Get Attendance registers from DB based on register ids, tenantId and requestInfo - List attendanceRegistersFromDB = getAttendanceRegisters(requestInfoWrapper, registerIds, tenantId); - log.info("Fetched attendance registers for update request"); - - //Validate Update attendance register request against attendance registers fetched from database - attendanceServiceValidator.validateUpdateAgainstDB(attendanceRegisterRequest, attendanceRegistersFromDB); - - registerEnrichment.enrichRegisterOnUpdate(attendanceRegisterRequest, attendanceRegistersFromDB); - log.info("Enriched with register Number, Ids and AuditDetails"); - producer.push(attendanceServiceConfiguration.getUpdateAttendanceRegisterTopic(), attendanceRegisterRequest); - log.info("Pushed update attendance register request to kafka"); - - return attendanceRegisterRequest; - } - - public List getAttendanceRegisters(RequestInfoWrapper requestInfoWrapper, List registerIds, String tenantId) { - - //Search criteria for attendance register search request - AttendanceRegisterSearchCriteria searchCriteria = AttendanceRegisterSearchCriteria.builder().ids(registerIds) - .tenantId(tenantId).build(); - List attendanceRegisterList; - - // Calls search attendance register with created request. If some error in searching attendance register, throws error - try { - attendanceRegisterList = searchAttendanceRegister(requestInfoWrapper, searchCriteria); - log.info("Attendance register search successful"); - } catch (Exception e) { - log.info("Error in searching attendance register", e); - throw new CustomException("SEARCH_ATTENDANCE_REGISTER", "Error in searching attendance register"); - } - - return attendanceRegisterList; - } - - /* Get attendance registers Id list from attendance register request */ - private List getAttendanceRegisterIdList(AttendanceRegisterRequest request) { - List attendanceRegisters = request.getAttendanceRegister(); - - List registerIds = new ArrayList<>(); - for (AttendanceRegister attendanceRegister : attendanceRegisters) { - registerIds.add(String.valueOf(attendanceRegister.getId())); - } - return registerIds; - } - - /** - * Validate and update the end date of Attendance register as per revised contract - * @param requestInfo - * @param tenantId - * @param referenceId - * @param endDate - */ - public void updateEndDateForRevisedContract(RequestInfo requestInfo, String tenantId, String referenceId, BigDecimal endDate) { - AttendanceRegisterSearchCriteria attendanceRegisterSearchCriteria = AttendanceRegisterSearchCriteria.builder() - .tenantId(tenantId) - .referenceId(referenceId) - .limit(attendanceServiceConfiguration.getAttendanceRegisterDefaultLimit()) - .offset(attendanceServiceConfiguration.getAttendanceRegisterDefaultOffset()).build(); - - - List attendanceRegisters = registerRepository.getRegister(attendanceRegisterSearchCriteria); - - if (attendanceRegisters != null && !attendanceRegisters.isEmpty()) { - for (AttendanceRegister attendanceRegister : attendanceRegisters) { - int comparisonResult = endDate.compareTo(attendanceRegister.getEndDate()); - if (comparisonResult < 0) { - throw new CustomException("END_DATE_NOT_EXTENDED","End date should not be earlier than previous end date"); - } - - attendanceRegister.setEndDate(endDate); - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequest.builder() - .attendanceRegister(Collections.singletonList(attendanceRegister)). - requestInfo(requestInfo).build(); - - registerEnrichment.enrichRegisterOnUpdate(attendanceRegisterRequest, Collections.singletonList(attendanceRegister)); - producer.push(attendanceServiceConfiguration.getUpdateAttendanceRegisterTopic(), attendanceRegisterRequest); - } - }else { - throw new CustomException("ATTENDANCE_REGISTER_NOT_FOUND", "Attendance registers not found for the referenceId"); - } - - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/service/AttendeeService.java b/core-services/attendance/src/main/java/org/egov/service/AttendeeService.java deleted file mode 100644 index 268109ad38e..00000000000 --- a/core-services/attendance/src/main/java/org/egov/service/AttendeeService.java +++ /dev/null @@ -1,195 +0,0 @@ -package org.egov.service; - -import digit.models.coremodels.RequestInfoWrapper; -import lombok.extern.slf4j.Slf4j; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.enrichment.AttendeeEnrichmentService; -import org.egov.kafka.Producer; -import org.egov.repository.AttendeeRepository; -import org.egov.util.ResponseInfoFactory; -import org.egov.validator.AttendanceServiceValidator; -import org.egov.validator.AttendeeServiceValidator; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendeeCreateRequest; -import org.egov.web.models.AttendeeDeleteRequest; -import org.egov.web.models.AttendeeSearchCriteria; -import org.egov.web.models.IndividualEntry; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Service -@Slf4j -public class AttendeeService { - @Autowired - private AttendeeServiceValidator attendeeServiceValidator; - - @Autowired - private ResponseInfoFactory responseInfoFactory; - - @Autowired - private AttendeeRepository attendeeRepository; - - @Autowired - private AttendanceRegisterService attendanceRegisterService; - - @Autowired - private AttendanceServiceValidator attendanceServiceValidator; - - @Autowired - private AttendeeEnrichmentService attendeeEnrichmentService; - - @Autowired - private AttendanceServiceConfiguration attendanceServiceConfiguration; - - @Autowired - private Producer producer; - - - /** - * Create Attendee - * - * @param attendeeCreateRequest - * @return - */ - public AttendeeCreateRequest createAttendee(AttendeeCreateRequest attendeeCreateRequest) { - //incoming createRequest validation - log.info("validating create attendee request parameters"); - attendeeServiceValidator.validateAttendeeCreateRequestParameters(attendeeCreateRequest); - - //extract registerIds and attendee IndividualIds from client request - String tenantId = attendeeCreateRequest.getAttendees().get(0).getTenantId(); - List attendeeIds = extractAttendeeIdsFromCreateRequest(attendeeCreateRequest); - List registerIds = extractRegisterIdsFromCreateRequest(attendeeCreateRequest); - - //db call to get the attendeeList data - List attendeeListFromDB = getAttendees(registerIds,attendeeIds); - - //db call to get registers from db - List attendanceRegisterListFromDB = getAttendanceRegisters(attendeeCreateRequest,registerIds,tenantId); - - //validate registers from request with registers from DB - log.info("validating register ids from request against DB"); - attendanceServiceValidator.validateRegisterAgainstDB(registerIds, attendanceRegisterListFromDB, tenantId); - - - //validator call by passing attendee request and the data from db call - log.info("attendeeServiceValidator called to validate Create attendee request"); - attendeeServiceValidator.validateAttendeeOnCreate(attendeeCreateRequest, attendeeListFromDB, attendanceRegisterListFromDB); - - //enrichment call by passing attendee request and data from db call - log.info("attendeeServiceValidator called to enrich Create attendee request"); - attendeeEnrichmentService.enrichAttendeeOnCreate(attendeeCreateRequest); - - //push to producer - log.info("attendee objects pushed via producer"); - producer.push(attendanceServiceConfiguration.getSaveAttendeeTopic(), attendeeCreateRequest); - log.info("attendees present in Create attendee request are enrolled to the registers"); - return attendeeCreateRequest; - } - - public List getAttendees(List registerIds,List attendeeIds){ - AttendeeSearchCriteria attendeeSearchCriteria = AttendeeSearchCriteria.builder().registerIds(registerIds).individualIds(attendeeIds).build(); - List attendeeListFromDB = attendeeRepository.getAttendees(attendeeSearchCriteria); - log.info("attendee List received From DB : " + attendeeListFromDB.size()); - return attendeeListFromDB; - } - - public List getAttendanceRegisters(AttendeeCreateRequest attendeeCreateRequest,List registerIds,String tenantId){ - RequestInfoWrapper requestInfoWrapper = RequestInfoWrapper.builder().requestInfo(attendeeCreateRequest.getRequestInfo()).build(); - List attendanceRegisterListFromDB = attendanceRegisterService.getAttendanceRegisters(requestInfoWrapper, registerIds, tenantId); - log.info("attendance register List received From DB : " + attendanceRegisterListFromDB.size()); - return attendanceRegisterListFromDB; - } - - public List getAttendanceRegisters(AttendeeDeleteRequest attendeeDeleteRequest,List registerIds,String tenantId){ - RequestInfoWrapper requestInfoWrapper = RequestInfoWrapper.builder().requestInfo(attendeeDeleteRequest.getRequestInfo()).build(); - List attendanceRegisterListFromDB = attendanceRegisterService.getAttendanceRegisters(requestInfoWrapper, registerIds, tenantId); - log.info("attendance register List received From DB : " + attendanceRegisterListFromDB.size()); - return attendanceRegisterListFromDB; - } - - /** - * Update(Soft Delete) the given attendee - * - * @param - * @return - */ - public AttendeeDeleteRequest deleteAttendee(AttendeeDeleteRequest attendeeDeleteRequest) { - //incoming deleteRequest validation - log.info("validating delete attendee request parameters"); - Map errorMap = new HashMap<>(); - attendeeServiceValidator.validateAttendeeDeleteRequestParameters(attendeeDeleteRequest, errorMap); - - //extract registerIds and attendee IndividualIds from client request - String tenantId = attendeeDeleteRequest.getAttendees().get(0).getTenantId(); - List attendeeIds = extractAttendeeIdsFromDeleteRequest(attendeeDeleteRequest); - List registerIds = extractRegisterIdsFromDeleteRequest(attendeeDeleteRequest); - - //db call to get the attendeeList data - List attendeeListFromDB = getAttendees(registerIds,attendeeIds); - - //db call to get registers from db - List attendanceRegisterListFromDB = getAttendanceRegisters(attendeeDeleteRequest,registerIds,tenantId); - - //validate request registers with registers from DB - log.info("validating register ids from request against DB"); - attendanceServiceValidator.validateRegisterAgainstDB(registerIds, attendanceRegisterListFromDB, tenantId); - - - //validator call by passing attendee request and the data from db call - log.info("validating delete attendee request"); - attendeeServiceValidator.validateAttendeeOnDelete(attendeeDeleteRequest, attendeeListFromDB, attendanceRegisterListFromDB); - - //enrichment call by passing attendee request and data from db call - log.info("enriching delete attendee request"); - attendeeEnrichmentService.enrichAttendeeOnDelete(attendeeDeleteRequest, attendeeListFromDB); - - //push to producer - log.info("attendee objects updated via producer"); - producer.push(attendanceServiceConfiguration.getUpdateAttendeeTopic(), attendeeDeleteRequest); - log.info("attendees present in delete attendee request are deenrolled from the registers"); - return attendeeDeleteRequest; - } - - - private List extractRegisterIdsFromCreateRequest(AttendeeCreateRequest attendeeCreateRequest) { - List attendeeListFromRequest = attendeeCreateRequest.getAttendees(); - List registerIds = new ArrayList<>(); - for (IndividualEntry attendee : attendeeListFromRequest) { - registerIds.add(attendee.getRegisterId()); - } - return registerIds; - } - - private List extractAttendeeIdsFromCreateRequest(AttendeeCreateRequest attendeeCreateRequest) { - List attendeeListFromRequest = attendeeCreateRequest.getAttendees(); - List attendeeIds = new ArrayList<>(); - for (IndividualEntry attendee : attendeeListFromRequest) { - attendeeIds.add(attendee.getIndividualId()); - } - return attendeeIds; - } - - private List extractRegisterIdsFromDeleteRequest(AttendeeDeleteRequest attendeeDeleteRequest) { - List attendeeListFromRequest = attendeeDeleteRequest.getAttendees(); - List registerIds = new ArrayList<>(); - for (IndividualEntry attendee : attendeeListFromRequest) { - registerIds.add(attendee.getRegisterId()); - } - return registerIds; - } - - private List extractAttendeeIdsFromDeleteRequest(AttendeeDeleteRequest attendeeDeleteRequest) { - List attendeeListFromRequest = attendeeDeleteRequest.getAttendees(); - List attendeeIds = new ArrayList<>(); - for (IndividualEntry attendee : attendeeListFromRequest) { - attendeeIds.add(attendee.getIndividualId()); - } - return attendeeIds; - } -} diff --git a/core-services/attendance/src/main/java/org/egov/service/OrganisationContactDetailsStaffUpdateService.java b/core-services/attendance/src/main/java/org/egov/service/OrganisationContactDetailsStaffUpdateService.java deleted file mode 100644 index 0fb18e46985..00000000000 --- a/core-services/attendance/src/main/java/org/egov/service/OrganisationContactDetailsStaffUpdateService.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.egov.service; - -import digit.models.coremodels.RequestInfoWrapper; -import lombok.extern.slf4j.Slf4j; -import org.egov.common.contract.request.RequestInfo; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.util.IndividualServiceUtil; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendanceRegisterSearchCriteria; -import org.egov.web.models.Organisation.ContactDetails; -import org.egov.web.models.Organisation.OrgContactUpdateDiff; -import org.egov.web.models.StaffPermission; -import org.egov.web.models.StaffPermissionRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Slf4j -@Service -public class OrganisationContactDetailsStaffUpdateService { - - @Autowired - private AttendanceRegisterService attendanceRegisterService; - @Autowired - private StaffService staffService; - @Autowired - private IndividualServiceUtil individualServiceUtil; - - @Autowired - private AttendanceServiceConfiguration configuration; - - public void updateStaffPermissionsForContactDetails(OrgContactUpdateDiff orgContactUpdateDiff) { - RequestInfoWrapper requestInfoWrapper = RequestInfoWrapper.builder().requestInfo(orgContactUpdateDiff.getRequestInfo()).build(); - String tenantId = orgContactUpdateDiff.getTenantId(); - List oldContacts = orgContactUpdateDiff.getOldContacts(); - - for(ContactDetails oldContact : oldContacts) { - AttendanceRegisterSearchCriteria attendanceRegisterSearchCriteria = - AttendanceRegisterSearchCriteria.builder().tenantId(tenantId).staffId(oldContact.getIndividualId()).limit(configuration.getAttendanceRegisterMaxLimit()).build(); - List attendanceRegisterList = attendanceRegisterService.searchAttendanceRegister(requestInfoWrapper, attendanceRegisterSearchCriteria); - if(CollectionUtils.isEmpty(attendanceRegisterList)) { - try { - String userUuid = individualServiceUtil.getIndividualDetails(Collections.singletonList(oldContact.getIndividualId()), requestInfoWrapper.getRequestInfo(), tenantId).get(0).getUserUuid(); - attendanceRegisterSearchCriteria = AttendanceRegisterSearchCriteria.builder().tenantId(tenantId).staffId(userUuid).limit(configuration.getAttendanceRegisterMaxLimit()).build(); - attendanceRegisterList = attendanceRegisterService.searchAttendanceRegister(requestInfoWrapper, attendanceRegisterSearchCriteria); - }catch (Exception e){ - log.error(e.toString()); - } - } - List newContacts = orgContactUpdateDiff.getNewContacts(); - grantPermission(attendanceRegisterList, newContacts, orgContactUpdateDiff.getRequestInfo()); - revokePermission(attendanceRegisterList, oldContact.getIndividualId(), orgContactUpdateDiff.getRequestInfo()); - } - } - - private void revokePermission(List attendanceRegisters, String individualOrUserId, RequestInfo requestInfo) { - if(attendanceRegisters.isEmpty()) { - log.info("No attendance registers to revoke permissions on"); - return; - } - List staffPermissionList = new ArrayList<>(); - for(AttendanceRegister attendanceRegister : attendanceRegisters) { - String tenantId = attendanceRegister.getTenantId(); - StaffPermission staffPermission = StaffPermission.builder() - .tenantId(tenantId).registerId(attendanceRegister.getId()).userId(individualOrUserId).build(); - staffPermissionList.add(staffPermission); - } - StaffPermissionRequest staffPermissionRequest = StaffPermissionRequest.builder() - .requestInfo(requestInfo).staff(staffPermissionList).build(); - staffService.deleteAttendanceStaff(staffPermissionRequest); - log.info("Revoked permission for: " + individualOrUserId + " on " + attendanceRegisters.size() + " registers."); - } - - private void grantPermission(List attendanceRegisters, List newContacts, RequestInfo requestInfo) { - if(attendanceRegisters.isEmpty()) { - log.info("No attendance registers to grant permission on"); - return; - } - List staffPermissionList = new ArrayList<>(); - for(AttendanceRegister attendanceRegister : attendanceRegisters) { - String tenantId = attendanceRegister.getTenantId(); - for(ContactDetails newContact : newContacts) { - StaffPermission staffPermission = StaffPermission.builder().tenantId(tenantId) - .registerId(attendanceRegister.getId()).userId(newContact.getIndividualId()).build(); - staffPermissionList.add(staffPermission); - } - } - StaffPermissionRequest staffPermissionRequest = StaffPermissionRequest.builder() - .requestInfo(requestInfo).staff(staffPermissionList).build(); - staffService.createAttendanceStaff(staffPermissionRequest, true); - log.info("Granted permission on " + attendanceRegisters.size() + " registers for " + newContacts.size() + " new contacts."); - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/service/StaffService.java b/core-services/attendance/src/main/java/org/egov/service/StaffService.java deleted file mode 100644 index a20bc3898c7..00000000000 --- a/core-services/attendance/src/main/java/org/egov/service/StaffService.java +++ /dev/null @@ -1,179 +0,0 @@ -package org.egov.service; - -import digit.models.coremodels.RequestInfoWrapper; -import lombok.extern.slf4j.Slf4j; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.enrichment.StaffEnrichmentService; -import org.egov.kafka.Producer; -import org.egov.repository.RegisterRepository; -import org.egov.repository.StaffRepository; -import org.egov.util.ResponseInfoFactory; -import org.egov.validator.AttendanceServiceValidator; -import org.egov.validator.StaffServiceValidator; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.StaffPermission; -import org.egov.web.models.StaffPermissionRequest; -import org.egov.web.models.StaffSearchCriteria; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.ArrayList; -import java.util.List; - -@Service -@Slf4j -public class StaffService { - @Autowired - private StaffServiceValidator staffServiceValidator; - - @Autowired - private ResponseInfoFactory responseInfoFactory; - - @Autowired - private StaffEnrichmentService staffEnrichmentService; - - @Autowired - private StaffRepository staffRepository; - - @Autowired - private RegisterRepository registerRepository; - - - @Autowired - private Producer producer; - - @Autowired - private AttendanceServiceConfiguration serviceConfiguration; - - @Autowired - private AttendanceRegisterService attendanceRegisterService; - - @Autowired - private AttendanceServiceValidator attendanceServiceValidator; - - - /** - * Create attendance staff - * - * @param staffPermissionRequest - * @return - */ - public StaffPermissionRequest createAttendanceStaff(StaffPermissionRequest staffPermissionRequest, Boolean cboMigrationReq) { - //incoming createRequest validation - log.info("Validating incoming staff request"); - staffServiceValidator.validateStaffPermissionRequestParameters(staffPermissionRequest); - - //extract registerIds and staffUserIds from client request - String tenantId = staffPermissionRequest.getStaff().get(0).getTenantId(); - List staffIds = extractStaffIdsFromRequest(staffPermissionRequest); - List registerIds = extractRegisterIdsFromRequest(staffPermissionRequest); - - //db call to get the staffList data whose de enrollment date is null - List staffPermissionListFromDB = getActiveStaff(registerIds, staffIds, tenantId); - - //db call to get registers from db - List attendanceRegisterListFromDB = getRegistersFromDB(staffPermissionRequest, registerIds, tenantId); - - //validate request registers with DB registers - attendanceServiceValidator.validateRegisterAgainstDB(registerIds, attendanceRegisterListFromDB, tenantId); - - //validator call by passing staff request and the data from db call - log.info("staffServiceValidator called to validate Create StaffPermission request"); - // When changing the CBO skip this validation - if (!cboMigrationReq) { - staffServiceValidator.validateStaffPermissionOnCreate(staffPermissionRequest, staffPermissionListFromDB, attendanceRegisterListFromDB); - } - - //enrichment call by passing staff request and data from db call - log.info("staffEnrichmentService called to enrich Create StaffPermission request"); - staffEnrichmentService.enrichStaffPermissionOnCreate(staffPermissionRequest); - - //push to producer - log.info("staff objects pushed via producer"); - producer.push(serviceConfiguration.getSaveStaffTopic(), staffPermissionRequest); - log.info("staff present in Create StaffPermission request are enrolled to the register"); - return staffPermissionRequest; - } - - public List getActiveStaff(List registerIds, List staffIds, String tenantId) { - StaffSearchCriteria staffSearchCriteria = StaffSearchCriteria.builder().registerIds(registerIds).individualIds(staffIds).tenantId(tenantId).build(); - List staffPermissionListFromDB = staffRepository.getActiveStaff(staffSearchCriteria); - log.info("size of active staffPermission List received From DB :" + staffPermissionListFromDB.size()); - return staffPermissionListFromDB; - } - - public List getRegistersFromDB(StaffPermissionRequest staffPermissionRequest, List registerIds, String tenantId) { - RequestInfoWrapper requestInfoWrapper = RequestInfoWrapper.builder().requestInfo(staffPermissionRequest.getRequestInfo()).build(); - List attendanceRegisterListFromDB = attendanceRegisterService.getAttendanceRegisters(requestInfoWrapper, registerIds, tenantId); - log.info("size of Attendance Registers list received from DB : " + attendanceRegisterListFromDB.size()); - return attendanceRegisterListFromDB; - } - - /** - * Update(Soft Delete) the given attendance staff - * - * @param staffPermissionRequest - * @return - */ - public StaffPermissionRequest deleteAttendanceStaff(StaffPermissionRequest staffPermissionRequest) { - //incoming deleteRequest validation - log.info("Validating incoming staff request"); - staffServiceValidator.validateStaffPermissionRequestParameters(staffPermissionRequest); - - //extract registerIds and staffUserIds from client request - String tenantId = staffPermissionRequest.getStaff().get(0).getTenantId(); - List staffIds = extractStaffIdsFromRequest(staffPermissionRequest); - List registerIds = extractRegisterIdsFromRequest(staffPermissionRequest); - - //db call to get registers from db - List attendanceRegisterListFromDB = getRegistersFromDB(staffPermissionRequest, registerIds, tenantId); - - - //validate request registers against registers from DB - log.info("Validating register ids from request against the DB"); - attendanceServiceValidator.validateRegisterAgainstDB(registerIds, attendanceRegisterListFromDB, tenantId); - - - // db call to get staff data - StaffSearchCriteria staffSearchCriteria = StaffSearchCriteria.builder().registerIds(registerIds).tenantId(tenantId).build(); - List staffPermissionListFromDB = getAllStaff(staffSearchCriteria); - - - //validator call by passing staff request and the data from db call - log.info("staffServiceValidator called to validate Delete StaffPermission request"); - staffServiceValidator.validateStaffPermissionOnDelete(staffPermissionRequest, staffPermissionListFromDB, attendanceRegisterListFromDB); - - log.info("staffEnrichmentService called to enrich Delete StaffPermission request"); - staffEnrichmentService.enrichStaffPermissionOnDelete(staffPermissionRequest, staffPermissionListFromDB); - - log.info("staff objects pushed via producer"); - producer.push(serviceConfiguration.getUpdateStaffTopic(), staffPermissionRequest); - log.info("staff present in Delete StaffPermission request are deenrolled from the register"); - return staffPermissionRequest; - } - - public List getAllStaff(StaffSearchCriteria staffSearchCriteria) { - List staffPermissionListFromDB = staffRepository.getAllStaff(staffSearchCriteria); - log.info("size of staffPermission list received from DB : " + staffPermissionListFromDB.size()); - return staffPermissionListFromDB; - } - - private List extractRegisterIdsFromRequest(StaffPermissionRequest staffPermissionRequest) { - List staffPermissionListFromRequest = staffPermissionRequest.getStaff(); - List registerIds = new ArrayList<>(); - for (StaffPermission staffPermission : staffPermissionListFromRequest) { - registerIds.add(staffPermission.getRegisterId()); - } - return registerIds; - } - - private List extractStaffIdsFromRequest(StaffPermissionRequest staffPermissionRequest) { - List staffPermissionListFromRequest = staffPermissionRequest.getStaff(); - List staffIds = new ArrayList<>(); - for (StaffPermission staffPermission : staffPermissionListFromRequest) { - staffIds.add(staffPermission.getUserId()); - } - return staffIds; - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/util/AttendanceServiceConstants.java b/core-services/attendance/src/main/java/org/egov/util/AttendanceServiceConstants.java deleted file mode 100644 index 702bc4ba0be..00000000000 --- a/core-services/attendance/src/main/java/org/egov/util/AttendanceServiceConstants.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.egov.util; - -public class AttendanceServiceConstants { - public static final String MASTER_TENANTS = "tenants"; - public static final String MDMS_TENANT_MODULE_NAME = "tenant"; -} diff --git a/core-services/attendance/src/main/java/org/egov/util/AttendanceServiceUtil.java b/core-services/attendance/src/main/java/org/egov/util/AttendanceServiceUtil.java deleted file mode 100644 index daf344e8ac0..00000000000 --- a/core-services/attendance/src/main/java/org/egov/util/AttendanceServiceUtil.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.egov.util; - -import digit.models.coremodels.AuditDetails; -import org.springframework.stereotype.Component; - -@Component -public class AttendanceServiceUtil { - public AuditDetails getAuditDetails(String by, AuditDetails auditDetails, Boolean isCreate) { - Long time = System.currentTimeMillis(); - if (isCreate) - return AuditDetails.builder().createdBy(by).lastModifiedBy(by).createdTime(time).lastModifiedTime(time).build(); - else - return AuditDetails.builder().createdBy(auditDetails.getCreatedBy()).lastModifiedBy(by) - .createdTime(auditDetails.getCreatedTime()).lastModifiedTime(time).build(); - } -} diff --git a/core-services/attendance/src/main/java/org/egov/util/IndividualServiceUtil.java b/core-services/attendance/src/main/java/org/egov/util/IndividualServiceUtil.java deleted file mode 100644 index 89c521de0f6..00000000000 --- a/core-services/attendance/src/main/java/org/egov/util/IndividualServiceUtil.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.egov.util; - -import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.extern.slf4j.Slf4j; -import org.egov.common.contract.request.RequestInfo; -import org.egov.common.models.individual.Individual; -import org.egov.common.models.individual.IndividualBulkResponse; -import org.egov.common.models.individual.IndividualSearch; -import org.egov.common.models.individual.IndividualSearchRequest; -import org.egov.common.utils.MultiStateInstanceUtil; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.repository.ServiceRequestRepository; -import org.egov.tracer.model.CustomException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.HttpServerErrorException; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; - -import java.util.List; -import java.util.stream.Collectors; - -@Component -@Slf4j -public class IndividualServiceUtil { - - @Autowired - private ServiceRequestRepository serviceRequestRepository; - - @Autowired - private AttendanceServiceConfiguration config; - - @Autowired - private ObjectMapper mapper; - - @Autowired - private RestTemplate restTemplate; - @Autowired - private MultiStateInstanceUtil multiStateInstanceUtil; - - public List fetchIndividualIds(List individualIds, RequestInfo requestInfo, String tenantId) { - - List individualList = getIndividualDetails(individualIds, requestInfo, tenantId); - - List ids = null; - try { - ids = individualList.stream().map(Individual::getId).collect(Collectors.toList()); - } catch (Exception e) { - throw new CustomException("PARSING_ERROR", "Failed to parse Individual service response"); - } - log.info("Individual search fetched successfully"); - return ids; - } - - public List getIndividualDetails(List individualIds, RequestInfo requestInfo, String tenantId) { - - String uri = getSearchURLWithParams(tenantId).toUriString(); - - IndividualSearch individualSearch = IndividualSearch.builder().id(individualIds).build(); - IndividualSearchRequest individualSearchRequest = IndividualSearchRequest.builder() - .requestInfo(requestInfo).individual(individualSearch).build(); - - IndividualBulkResponse response = null; - log.info("call individual search with tenantId::" + tenantId + "::individual ids::" + individualIds); - - try { - response = restTemplate.postForObject(uri, individualSearchRequest, IndividualBulkResponse.class); - } catch (HttpClientErrorException | HttpServerErrorException httpClientOrServerExc) { - log.error("Error thrown from individual search service::" + httpClientOrServerExc.getStatusCode()); - throw new CustomException("INDIVIDUAL_SEARCH_SERVICE_EXCEPTION", "Error thrown from individual search service::" + httpClientOrServerExc.getStatusCode()); - } - if (response == null || CollectionUtils.isEmpty(response.getIndividual())) { - throw new CustomException("INDIVIDUAL_SEARCH_RESPONSE_IS_EMPTY", "Individuals not found"); - } - - return response.getIndividual(); - } - - private UriComponentsBuilder getSearchURLWithParams(String tenantId) { - StringBuilder uri = new StringBuilder(); - uri.append(config.getIndividualHost()).append(config.getIndividualSearchEndpoint()); - UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromHttpUrl(uri.toString()) - .queryParam("limit", 100) - .queryParam("offset", 0) - .queryParam("tenantId", tenantId); - - return uriBuilder; - } - - public List getIndividualDetailsFromUserId(Long userId, RequestInfo requestInfo, String tenantId) { - String uri = getSearchURLWithParams(multiStateInstanceUtil.getStateLevelTenant(tenantId)).toUriString(); - IndividualSearch individualSearch = IndividualSearch.builder().userId(userId).build(); - IndividualSearchRequest individualSearchRequest = IndividualSearchRequest.builder() - .requestInfo(requestInfo).individual(individualSearch).build(); - - IndividualBulkResponse response = null; - log.info("call individual search with tenantId::" + tenantId + "::user id::" + userId); - - try { - response = restTemplate.postForObject(uri, individualSearchRequest, IndividualBulkResponse.class); - } catch (HttpClientErrorException | HttpServerErrorException httpClientOrServerExc) { - log.error("Error thrown from individual search service::" + httpClientOrServerExc.getStatusCode()); - throw new CustomException("INDIVIDUAL_SEARCH_SERVICE_EXCEPTION", "Error thrown from individual search service::" + httpClientOrServerExc.getStatusCode()); - } - if (response == null || CollectionUtils.isEmpty(response.getIndividual())) { - throw new CustomException("INDIVIDUAL_SEARCH_RESPONSE_IS_EMPTY", "Individuals not found"); - } - - return response.getIndividual(); - } -} diff --git a/core-services/attendance/src/main/java/org/egov/util/MDMSUtils.java b/core-services/attendance/src/main/java/org/egov/util/MDMSUtils.java deleted file mode 100644 index d8a48ac95b4..00000000000 --- a/core-services/attendance/src/main/java/org/egov/util/MDMSUtils.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.egov.util; - -import lombok.extern.slf4j.Slf4j; -import org.egov.common.contract.request.RequestInfo; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.mdms.model.MasterDetail; -import org.egov.mdms.model.MdmsCriteria; -import org.egov.mdms.model.MdmsCriteriaReq; -import org.egov.mdms.model.ModuleDetail; -import org.egov.repository.ServiceRequestRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import static org.egov.util.AttendanceServiceConstants.MASTER_TENANTS; -import static org.egov.util.AttendanceServiceConstants.MDMS_TENANT_MODULE_NAME; - -@Component -@Slf4j -public class MDMSUtils { - - @Autowired - private ServiceRequestRepository serviceRequestRepository; - - @Autowired - private AttendanceServiceConfiguration config; - - public static final String filterCode = "$.*.code"; - - public Object mDMSCall(RequestInfo requestInfo, String tenantId) { - MdmsCriteriaReq mdmsCriteriaReq = getMDMSRequest(requestInfo, tenantId); - Object result = serviceRequestRepository.fetchResult(getMdmsSearchUrl(), mdmsCriteriaReq); - return result; - } - - public MdmsCriteriaReq getMDMSRequest(RequestInfo requestInfo, String tenantId) { - - ModuleDetail tenantModuleDetail = getTenantModuleRequestData(); - - List moduleDetails = new LinkedList<>(); - moduleDetails.add(tenantModuleDetail); - - MdmsCriteria mdmsCriteria = MdmsCriteria.builder().moduleDetails(moduleDetails).tenantId(tenantId) - .build(); - - MdmsCriteriaReq mdmsCriteriaReq = MdmsCriteriaReq.builder().mdmsCriteria(mdmsCriteria) - .requestInfo(requestInfo).build(); - return mdmsCriteriaReq; - } - - public StringBuilder getMdmsSearchUrl() { - return new StringBuilder().append(config.getMdmsHost()).append(config.getMdmsEndPoint()); - } - - private ModuleDetail getTenantModuleRequestData() { - List tenantMasterDetails = new ArrayList<>(); - - MasterDetail tenantMasterDetail = MasterDetail.builder().name(MASTER_TENANTS) - .filter(filterCode).build(); - - tenantMasterDetails.add(tenantMasterDetail); - - ModuleDetail tenantModuleDetail = ModuleDetail.builder().masterDetails(tenantMasterDetails) - .moduleName(MDMS_TENANT_MODULE_NAME).build(); - - return tenantModuleDetail; - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/util/ResponseInfoFactory.java b/core-services/attendance/src/main/java/org/egov/util/ResponseInfoFactory.java deleted file mode 100644 index 8bcab7b536d..00000000000 --- a/core-services/attendance/src/main/java/org/egov/util/ResponseInfoFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.egov.util; - -import org.egov.common.contract.request.RequestInfo; -import org.egov.common.contract.response.ResponseInfo; -import org.springframework.stereotype.Component; - -@Component -public class ResponseInfoFactory { - - public ResponseInfo createResponseInfoFromRequestInfo(final RequestInfo requestInfo, final Boolean success) { - - final String apiId = requestInfo != null ? requestInfo.getApiId() : ""; - final String ver = requestInfo != null ? requestInfo.getVer() : ""; - Long ts = null; - if (requestInfo != null) - ts = requestInfo.getTs(); - final String resMsgId = "uief87324"; // FIXME : Hard-coded - final String msgId = requestInfo != null ? requestInfo.getMsgId() : ""; - final String responseStatus = success ? "successful" : "failed"; - - return ResponseInfo.builder().apiId(apiId).ver(ver).ts(ts).resMsgId(resMsgId).msgId(msgId).resMsgId(resMsgId) - .status(responseStatus).build(); - } - -} \ No newline at end of file diff --git a/core-services/attendance/src/main/java/org/egov/validator/AttendanceLogServiceValidator.java b/core-services/attendance/src/main/java/org/egov/validator/AttendanceLogServiceValidator.java deleted file mode 100644 index a788e5bd45a..00000000000 --- a/core-services/attendance/src/main/java/org/egov/validator/AttendanceLogServiceValidator.java +++ /dev/null @@ -1,503 +0,0 @@ -package org.egov.validator; - -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.egov.common.contract.request.RequestInfo; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.repository.AttendanceLogRepository; -import org.egov.repository.AttendeeRepository; -import org.egov.repository.RegisterRepository; -import org.egov.repository.StaffRepository; -import org.egov.tracer.model.CustomException; -import org.egov.util.IndividualServiceUtil; -import org.egov.web.models.AttendanceLog; -import org.egov.web.models.AttendanceLogRequest; -import org.egov.web.models.AttendanceLogSearchCriteria; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendanceRegisterSearchCriteria; -import org.egov.web.models.AttendeeSearchCriteria; -import org.egov.web.models.IndividualEntry; -import org.egov.web.models.RequestInfoWrapper; -import org.egov.web.models.StaffPermission; -import org.egov.web.models.StaffSearchCriteria; -import org.egov.web.models.Status; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -@Component -@Slf4j -public class AttendanceLogServiceValidator { - - @Autowired - private StaffRepository attendanceStaffRepository; - - @Autowired - private RegisterRepository attendanceRegisterRepository; - - @Autowired - private AttendeeRepository attendanceAttendeeRepository; - - @Autowired - private AttendanceLogRepository attendanceLogRepository; - - @Autowired - private AttendanceServiceConfiguration config; - - @Autowired - private IndividualServiceUtil individualServiceUtil; - - public void validateCreateAttendanceLogRequest(AttendanceLogRequest attendanceLogRequest) { - log.info("Validate attendance log create request"); - validateAttendanceLogRequest(attendanceLogRequest); - - // Verify all the attendance logs should below to same registerId - validateMultipleRegisterIds(attendanceLogRequest); - - // Verify all the attendance logs should below to same tenantId - validateMultipleTenantIds(attendanceLogRequest); - - // Verify the Logged-in user is associated to the given register. - validateLoggedInUser(attendanceLogRequest); - - // Verify given attendance log against register params - validateAttendanceLogsAgainstRegisterParams(attendanceLogRequest); - - // Verify if individuals are part of the given register and individuals were active during given attendance log time. - validateAttendees(attendanceLogRequest); - - // Verify provided documentIds are valid. - validateDocumentIds(attendanceLogRequest); - log.info("Attendance log create request validation done"); - } - - private void validateMultipleTenantIds(AttendanceLogRequest attendanceLogRequest) { - List attendanceLogs = attendanceLogRequest.getAttendance(); - Set tenantIds = new HashSet<>(); - for(AttendanceLog attendanceLog : attendanceLogs){ - String tenantId = attendanceLog.getTenantId(); - if(tenantIds.isEmpty()){ - tenantIds.add(tenantId); - }else{ - if(!tenantIds.contains(tenantId)){ - log.error("Attendance logs should below to same tenantId"); - throw new CustomException("MULTIPLE_TENANTIDS","Attendance logs should belong to same tenantId"); - } - } - } - } - - private void validateMultipleRegisterIds(AttendanceLogRequest attendanceLogRequest) { - List attendanceLogs = attendanceLogRequest.getAttendance(); - Set registerIds = new HashSet<>(); - for(AttendanceLog attendanceLog : attendanceLogs){ - String registerId = attendanceLog.getRegisterId(); - if(registerIds.isEmpty()){ - registerIds.add(registerId); - }else{ - if(!registerIds.contains(registerId)){ - log.error("Attendance logs should below to same registerId"); - throw new CustomException("MULTIPLE_REGISTERIDS","Attendance logs should belong to same registerId"); - } - } - } - } - - public void validateUpdateAttendanceLogRequest(AttendanceLogRequest attendanceLogRequest) { - log.info("Validate attendance log update request"); - validateAttendanceLogRequest(attendanceLogRequest); - - // Verify all the attendance logs should below to same registerId - validateMultipleRegisterIds(attendanceLogRequest); - - // Verify all the attendance logs should below to same tenantId - validateMultipleTenantIds(attendanceLogRequest); - - // Verify the Logged-in user is associated to the given register. - validateLoggedInUser(attendanceLogRequest); - - // Verify provided log ids are present - validateAttendanceLogIds(attendanceLogRequest); - - // Verify given attendance log against register params - validateAttendanceLogsAgainstRegisterParams(attendanceLogRequest); - - // Verify if individuals are part of the given register and individuals were active during given attendance log time. - validateAttendees(attendanceLogRequest); - - // Verify provided documentIds are valid. - validateDocumentIds(attendanceLogRequest); - - log.info("Attendance log update request validation done"); - } - - private void validateAttendanceLogsAgainstRegisterParams(AttendanceLogRequest attendanceLogRequest){ - String registerId = attendanceLogRequest.getAttendance().get(0).getRegisterId(); - String tenantId = attendanceLogRequest.getAttendance().get(0).getTenantId(); - - // Fetch register for given registerId - List attendanceRegisters = fetchRegisterWithId(registerId); - - // Check existence of register - checkRegisterExistence(attendanceRegisters,registerId); - - AttendanceRegister attendanceRegister = attendanceRegisters.get(0); - - // Check register is active ? - checkRegisterStatus(attendanceRegister); - - // Check register association with tenantId - validateTenantIdAssociationWithRegisterId(attendanceRegister,tenantId); - - // Check attendance log time against register start and end date - validateAttendanceLogTimeWithRegisterStartEndDate(attendanceRegister,attendanceLogRequest); - - log.info("Attendance log verification against register params are done. RegisterId ["+registerId+"]"); - } - - private void checkRegisterStatus(AttendanceRegister attendanceRegister) { - if(Status.INACTIVE.equals(attendanceRegister.getStatus())){ - String registerId = attendanceRegister.getId(); - log.error("Register ["+registerId+"] is inactive"); - throw new CustomException("INACTIVE_REGISTER", "Given RegisterId ["+registerId+"] is inactive"); - } - } - - private void checkRegisterExistence(List attendanceRegisters,String registerId) { - if (attendanceRegisters == null || attendanceRegisters.isEmpty()) { - log.error("Register ["+registerId+"] does not exists"); - throw new CustomException("REGISTER_NOT_FOUND", "Given RegisterId ["+registerId+"] does not exists"); - } - } - - private void validateTenantIdAssociationWithRegisterId(AttendanceRegister attendanceRegister,String tenantId) { - if(!tenantId.equals(attendanceRegister.getTenantId())){ - log.error("TenantId ["+tenantId+"] is not associated with register ["+attendanceRegister.getId()+"]"); - throw new CustomException("INVALID_TENANTID", "TenantId ["+tenantId+"] is not associated with register ["+attendanceRegister.getId()+"]"); - } - } - - private List fetchRegisterWithId(String registerId) { - AttendanceRegisterSearchCriteria searchCriteria = AttendanceRegisterSearchCriteria - .builder() - .ids(Collections.singletonList(registerId)) - .build(); - return attendanceRegisterRepository.getRegister(searchCriteria); - } - - private void validateAttendanceLogTimeWithRegisterStartEndDate(AttendanceRegister attendanceRegister,AttendanceLogRequest attendanceLogRequest) { - Instant registerStartTime = Instant.ofEpochMilli(attendanceRegister.getStartDate().longValue()); - - Instant registerEndTime = null; - if(attendanceRegister.getEndDate() != null) - registerEndTime = Instant.ofEpochMilli(attendanceRegister.getEndDate().longValue()); - - List attendanceLogs = attendanceLogRequest.getAttendance(); - - if(registerEndTime != null){ - for(AttendanceLog attendanceLog : attendanceLogs){ - Instant instantAttendanceAttendeeLogTime = Instant.ofEpochMilli(attendanceLog.getTime().longValue()); - if(!(instantAttendanceAttendeeLogTime.compareTo(registerStartTime) >=0 && instantAttendanceAttendeeLogTime.compareTo(registerEndTime) <=0)){ - log.error("Attendance time ["+instantAttendanceAttendeeLogTime+"] is invalid for register ["+attendanceRegister.getId()+"]"); - throw new CustomException("INVALID_ATTENDANCE_TIME", "Attendance time ["+instantAttendanceAttendeeLogTime+"] is invalid for register ["+attendanceRegister.getId()+"]"); - } - } - }else{ - for(AttendanceLog attendanceLog : attendanceLogs){ - Instant instantAttendanceAttendeeLogTime = Instant.ofEpochMilli(attendanceLog.getTime().longValue()); - if(!(instantAttendanceAttendeeLogTime.compareTo(registerStartTime) >=0)){ - log.error("Attendance time ["+instantAttendanceAttendeeLogTime+"] is invalid for register ["+attendanceRegister.getId()+"]"); - throw new CustomException("INVALID_ATTENDANCE_TIME", "Attendance time ["+instantAttendanceAttendeeLogTime+"] is invalid for register ["+attendanceRegister.getId()+"]"); - } - } - } - } - private void validateDocumentIds(AttendanceLogRequest attendanceLogRequest) { - if ("TRUE".equalsIgnoreCase(config.getDocumentIdVerificationRequired())) { - //TODO - // For now throwing exception. Later implementation will be done - log.error("Document service not integrated yet"); - throw new CustomException("SERVICE_UNAVAILABLE", "Service not integrated yet"); - } - } - - private void validateAttendanceLogIds(AttendanceLogRequest attendanceLogRequest) { - String registerId = attendanceLogRequest.getAttendance().get(0).getRegisterId(); - List attendance = attendanceLogRequest.getAttendance(); - List providedAttendanceLogIds = attendance.stream().map(e -> String.valueOf(e.getId())).collect(Collectors.toList()); - List fetchedAttendanceLogList = fetchAttendanceLogsByIds(providedAttendanceLogIds); - Set fetchedAttendanceLogIds = fetchedAttendanceLogList.stream().map(e -> String.valueOf(e.getId())).collect(Collectors.toSet()); - for (String providedAttendanceLogId : providedAttendanceLogIds) { - if (!fetchedAttendanceLogIds.contains(providedAttendanceLogId)) { - log.error("Provided attendance id ["+providedAttendanceLogId+"] is invalid for register ["+registerId+"]"); - throw new CustomException("ATTENDANCE_LOG", "Provided attendance id ["+providedAttendanceLogId+"] is invalid for register ["+registerId+"]"); - } - } - - log.info("Attendance Log Ids are validated successfully for register ["+registerId+"]"); - } - - private List fetchAttendanceLogsByIds(List ids) { - //AttendanceLogSearchCriteria searchCriteria = AttendanceLogSearchCriteria.builder().ids(ids).status(Status.ACTIVE).build(); - AttendanceLogSearchCriteria searchCriteria = AttendanceLogSearchCriteria.builder().ids(ids).build(); - return attendanceLogRepository.getAttendanceLogs(searchCriteria); - } - - private void validateAttendees(AttendanceLogRequest attendanceLogRequest) { - - /* - For now, we are validating attendees on below basis. - 1. Verify that each attendee is associated to given register. - 2. Make the entry in attendance log table only if attendee was active during the given attendance time. - - Future: - Once Individual service will be available will integrate it for further validation. - */ - - - if ("TRUE".equalsIgnoreCase(config.getIndividualServiceIntegrationRequired())) { - //TODO - // For now throwing exception. Since individual service is under discussion. - log.error("Individual service integration is under development"); - throw new CustomException("INTEGRATION_UNDERDEVELOPMENT", "Individual service integration is under development"); - } - - // Fetch all attendees for given register_id. - String registerId = attendanceLogRequest.getAttendance().get(0).getRegisterId(); - List fetchAttendanceAttendeeLst = fetchAllAttendeesEnrolledInARegister(registerId); - - log.info("All attendees are fetched successfully for register ["+registerId+"]"); - - // Convert the fetched Attendee List into a Map with individualId as key and corresponding Attendee list as value. - Map> attendanceAttendeeListMap = fetchAttendanceAttendeeLst - .stream() - .collect(Collectors.groupingBy(IndividualEntry::getIndividualId)); - - // Identify unassociated(Attendees not associated with given register) and ineligible attendees - identifyUnassociatedAndIneligibleAttendees(attendanceLogRequest, attendanceAttendeeListMap); - log.info("Attendee validation is done for register ["+registerId+"]"); - } - - private void identifyUnassociatedAndIneligibleAttendees(AttendanceLogRequest attendanceLogRequest, Map> attendanceAttendeeListMap) { - List unassociatedAttendees = new ArrayList<>(); - Set eligibleAttendanceAttendeeIdSet = new HashSet<>(); - - List attendanceLogs = attendanceLogRequest.getAttendance(); - for (AttendanceLog attendanceLog : attendanceLogs) { - String givenIndividualId = attendanceLog.getIndividualId(); - if (attendanceAttendeeListMap.containsKey(givenIndividualId)) { - List lst = attendanceAttendeeListMap.get(givenIndividualId); - for (IndividualEntry attendee : lst) { - Instant instantAttendanceAttendeeLogTime = Instant.ofEpochMilli(attendanceLog.getTime().longValue()); - Instant instantEnrollmentDate = Instant.ofEpochMilli(attendee.getEnrollmentDate().longValue()); - if (attendee.getDenrollmentDate()==null) { - if (instantAttendanceAttendeeLogTime.compareTo(instantEnrollmentDate) >= 0) { - eligibleAttendanceAttendeeIdSet.add(attendee.getIndividualId()); - } - } else { - Instant instantDenrollmentDate = Instant.ofEpochMilli(attendee.getDenrollmentDate().longValue()); - if (instantAttendanceAttendeeLogTime.compareTo(instantEnrollmentDate) >= 0 && instantAttendanceAttendeeLogTime.compareTo(instantDenrollmentDate) <= 0) { - eligibleAttendanceAttendeeIdSet.add(attendee.getIndividualId()); - } - } - } - } else { - unassociatedAttendees.add(givenIndividualId); - } - - } - - String registerId = attendanceLogRequest.getAttendance().get(0).getRegisterId(); - - if (!unassociatedAttendees.isEmpty()) { - log.error("Attendees are not enrolled against register ["+registerId+"]"); - throw new CustomException("UNENROLLED_ATTENDEES", "Attendees are not enrolled against register ["+registerId+"]"); - } - - //find ineligible list - Set inEligibleAttendanceAttendeeIdSet = new HashSet<>(); - for (AttendanceLog attendanceLog : attendanceLogs) { - if (!eligibleAttendanceAttendeeIdSet.contains(attendanceLog.getIndividualId())) { - inEligibleAttendanceAttendeeIdSet.add(attendanceLog.getIndividualId()); - } - } - - if (!inEligibleAttendanceAttendeeIdSet.isEmpty()) { - log.error("Attendees are ineligible for given date range for register ["+registerId+"]"); - throw new CustomException("INELIGIBLE_ATTENDEES", "Attendees are ineligible for given date range for register ["+registerId+"]"); - } - } - - private List fetchAllAttendeesEnrolledInARegister(String registerId) { - AttendeeSearchCriteria searchCriteria = AttendeeSearchCriteria - .builder() - .registerIds(Collections.singletonList(registerId)) - .build(); - - return attendanceAttendeeRepository.getAttendees(searchCriteria); - } - - private void validateLoggedInUser(AttendanceLogRequest attendanceLogRequest) { - /* - For now, we are validating logged-in user on below basis. - 1. Logged-in user should be active user for provided register_id. Query eg_wms_attendance_staff table for same. - - Future - Once Staff service will be available will integrate it for further validation. - */ - - if ("TRUE".equalsIgnoreCase(config.getStaffServiceIntegrationRequired())) { - //TODO - // For now throwing exception. Since Staff service is under development. - log.error("Staff service integration is under development"); - throw new CustomException("INTEGRATION_UNDERDEVELOPMENT", "Staff service integration is under development"); - } - - String userUUID = attendanceLogRequest.getRequestInfo().getUserInfo().getUuid(); - String registerId = attendanceLogRequest.getAttendance().get(0).getRegisterId(); - String individualId = individualServiceUtil.getIndividualDetailsFromUserId(attendanceLogRequest.getRequestInfo().getUserInfo().getId(), attendanceLogRequest.getRequestInfo(), attendanceLogRequest.getAttendance().get(0).getTenantId()).get(0).getId(); - validateLoggedInUser(individualId, registerId); - log.info("User ["+userUUID+"] validation is done for register ["+registerId+"]"); - } - - public void validateSearchAttendanceLogRequest(RequestInfoWrapper requestInfoWrapper, AttendanceLogSearchCriteria searchCriteria) { - - log.info("Validate attendance log search request"); - - // Verify given parameters - validateSearchAttendanceLogParameters(requestInfoWrapper, searchCriteria); - - // Fetch register for given Id - List attendanceRegisters = fetchRegisterWithId(searchCriteria.getRegisterId()); - - if (attendanceRegisters == null || attendanceRegisters.isEmpty()) { - throw new CustomException("INVALID_REGISTERID", "Register Not found "); - } - - // Verify TenantId association with register - validateTenantIdAssociationWithRegisterId(attendanceRegisters.get(0), searchCriteria.getTenantId()); - - // Verify the Logged-in user is associated to the given register. - String individualId = individualServiceUtil.getIndividualDetailsFromUserId(requestInfoWrapper.getRequestInfo().getUserInfo().getId(), requestInfoWrapper.getRequestInfo(), searchCriteria.getTenantId()).get(0).getId(); - validateLoggedInUser(individualId, searchCriteria.getRegisterId()); - - log.info("Attendance log search request validated successfully"); - } - - private void validateSearchAttendanceLogParameters(RequestInfoWrapper requestInfoWrapper, AttendanceLogSearchCriteria searchCriteria) { - if (searchCriteria == null || requestInfoWrapper == null) { - log.error("Attendance log search criteria and request info is mandatory"); - throw new CustomException("ATTENDANCE_LOG_SEARCH_REQUEST", "Attendance log search criteria and request info is mandatory"); - } - - Map errorMap = new HashMap<>(); - - validateRequestInfo(requestInfoWrapper.getRequestInfo(), errorMap); - - if (StringUtils.isBlank(searchCriteria.getTenantId())) { - log.error("Attendance log search, Tenant is mandatory"); - throw new CustomException("TENANT_ID", "Tenant is mandatory"); - } - if (StringUtils.isBlank(searchCriteria.getRegisterId())) { - log.error("Attendance log search, RegisterId is mandatory"); - throw new CustomException("REGISTER_ID", "RegisterId is mandatory"); - } - - // Throw exception if required parameters are missing - if (!errorMap.isEmpty()) - throw new CustomException(errorMap); - - if (searchCriteria.getIndividualIds() != null && !searchCriteria.getIndividualIds().isEmpty() && searchCriteria.getIndividualIds().size() > 10) { - log.error("Attendance log search, only 10 IndividualIds are allowed to search"); - throw new CustomException("INDIVIDUALIDS", "only 10 IndividualIds are allowed to search"); - } - } - - - - private void validateLoggedInUser(String userUUID, String registerId) { - StaffSearchCriteria searchCriteria = StaffSearchCriteria - .builder() - .individualIds(Collections.singletonList(userUUID)) - .registerIds(Collections.singletonList(registerId)) - .build(); - List attendanceStaff = attendanceStaffRepository.getActiveStaff(searchCriteria); - if (attendanceStaff == null || attendanceStaff.isEmpty()) { - log.error("User ["+userUUID+"] is not authorised for register ["+registerId+"]"); - throw new CustomException("UNAUTHORISED_USER", "User ["+userUUID+"] is not authorised for register ["+registerId+"]"); - } - } - - private void validateRequestInfo(RequestInfo requestInfo, Map errorMap) { - if (requestInfo == null) { - log.error("Request info is mandatory"); - throw new CustomException("REQUEST_INFO", "Request info is mandatory"); - } - if (requestInfo.getUserInfo() == null) { - log.error("UserInfo is mandatory"); - throw new CustomException("USERINFO", "UserInfo is mandatory"); - } - if (requestInfo.getUserInfo() != null && StringUtils.isBlank(requestInfo.getUserInfo().getUuid())) { - log.error("UUID is mandatory"); - throw new CustomException("USERINFO_UUID", "UUID is mandatory"); - } - - log.info("Request Info object validation done"); - } - - private void validateAttendanceLogRequest(AttendanceLogRequest attendanceLogRequest) { - - Map errorMap = new HashMap<>(); - // Validate the Request Info object - RequestInfo requestInfo = attendanceLogRequest.getRequestInfo(); - validateRequestInfo(requestInfo, errorMap); - - // Validate the Attendance Log parameters - validateAttendanceLogParameters(attendanceLogRequest.getAttendance(), errorMap); - - // Throw exception if required parameters are missing - if (!errorMap.isEmpty()){ - log.error("Attendance log request validation failed"); - throw new CustomException(errorMap); - } - } - - private void validateAttendanceLogParameters(List attendance, Map errorMap) { - if (attendance == null || attendance.isEmpty()) { - log.error("Attendance array is mandatory"); - throw new CustomException("ATTENDANCE", "Attendance array is mandatory"); - } - - for (AttendanceLog attendeeLog : attendance) { - if (StringUtils.isBlank(attendeeLog.getTenantId())) { - log.error("TenantId is mandatory"); - errorMap.put("ATTENDANCE.TENANTID", "TenantId is mandatory"); - } - if (StringUtils.isBlank(attendeeLog.getRegisterId())) { - log.error("Attendance registerid is mandatory"); - errorMap.put("ATTENDANCE.REGISTERID", "Attendance registerid is mandatory"); - } - if (StringUtils.isBlank(attendeeLog.getIndividualId() )) { - log.error("Attendance indidualid is mandatory"); - errorMap.put("ATTENDANCE.INDIVIDUALID", "Attendance indidualid is mandatory"); - } - if (StringUtils.isBlank(attendeeLog.getType())) { - log.error("Attendance type is mandatory"); - errorMap.put("ATTENDANCE.TYPE", "Attendance type is mandatory"); - } - if (attendeeLog.getTime() == null) { - log.error("Attendance time is mandatory"); - errorMap.put("ATTENDANCE.TIME", "Attendance time is mandatory"); - } - } - } -} diff --git a/core-services/attendance/src/main/java/org/egov/validator/AttendanceServiceValidator.java b/core-services/attendance/src/main/java/org/egov/validator/AttendanceServiceValidator.java deleted file mode 100644 index a8c88ed9867..00000000000 --- a/core-services/attendance/src/main/java/org/egov/validator/AttendanceServiceValidator.java +++ /dev/null @@ -1,285 +0,0 @@ -package org.egov.validator; - -import com.jayway.jsonpath.JsonPath; -import digit.models.coremodels.RequestInfoWrapper; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.egov.common.contract.request.RequestInfo; -import org.egov.repository.RegisterRepository; -import org.egov.tracer.model.CustomException; -import org.egov.util.IndividualServiceUtil; -import org.egov.util.MDMSUtils; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendanceRegisterRequest; -import org.egov.web.models.AttendanceRegisterSearchCriteria; -import org.egov.web.models.StaffPermission; -import org.egov.web.models.Status; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import static org.egov.util.AttendanceServiceConstants.MASTER_TENANTS; -import static org.egov.util.AttendanceServiceConstants.MDMS_TENANT_MODULE_NAME; - -@Component -@Slf4j -public class AttendanceServiceValidator { - - @Autowired - private MDMSUtils mdmsUtils; - - @Autowired - private RegisterRepository registerRepository; - @Autowired - private IndividualServiceUtil individualServiceUtil; - - /* Validates create Attendance Register request body */ - public void validateCreateAttendanceRegister(AttendanceRegisterRequest request) { - Map errorMap = new HashMap<>(); - List attendanceRegisters = request.getAttendanceRegister(); - RequestInfo requestInfo = request.getRequestInfo(); - - //Verify if RequestInfo and UserInfo is present - validateRequestInfo(requestInfo, errorMap); - log.info("Request Info validated for attendance create request"); - - //Verify if attendance register request and mandatory fields are present - validateAttendanceRegisterRequest(attendanceRegisters, errorMap); - log.info("Attendance registers validated for create request"); - - //Verify referenceId and ServiceCode are present - validateReferenceIdAndServiceCodeParams(attendanceRegisters, errorMap); - log.info("Attendance registers referenceId and ServiceCode are validated"); - - String tenantId = attendanceRegisters.get(0).getTenantId(); - String rootTenantId = tenantId.split("\\.")[0]; - - //Get MDMS data using create attendance register request and tenantId - Object mdmsData = mdmsUtils.mDMSCall(requestInfo, rootTenantId); - validateMDMSData(attendanceRegisters, mdmsData, errorMap); - log.info("Request data validated with MDMS"); - - if (!errorMap.isEmpty()) - throw new CustomException(errorMap); - - //Verify that active attendance register is not already present for provided tenantId, referenceId and serviceCode - validateAttendanceRegisterAgainstDB(attendanceRegisters); - log.info("Attendance registers validated against DB"); - } - - private void validateAttendanceRegisterAgainstDB(List attendanceRegisters) { - for (AttendanceRegister attendanceRegister: attendanceRegisters) { - String tenantId = attendanceRegister.getTenantId(); - String referenceId = attendanceRegister.getReferenceId(); - String serviceCode = attendanceRegister.getServiceCode(); - - AttendanceRegisterSearchCriteria attendanceRegisterSearchCriteria = AttendanceRegisterSearchCriteria.builder() - .tenantId(tenantId) - .status(Status.ACTIVE) - .referenceId(referenceId) - .serviceCode(serviceCode) - .build(); - List registers = registerRepository.getRegister(attendanceRegisterSearchCriteria); - if(!registers.isEmpty()){ - log.error("Attendance register exists for provided referenceId ["+referenceId+"] and serviceCode ["+serviceCode+"]"); - throw new CustomException("REGISTER_ALREADY_EXISTS", "Register exists for provided referenceId ["+referenceId+"] and serviceCode ["+serviceCode+"]"); - } - } - } - - /* Validates Update Attendance register request body */ - public void validateUpdateAttendanceRegisterRequest(AttendanceRegisterRequest request) { - Map errorMap = new HashMap<>(); - List attendanceRegisters = request.getAttendanceRegister(); - RequestInfo requestInfo = request.getRequestInfo(); - - //Verify if RequestInfo and UserInfo is present - validateRequestInfo(requestInfo, errorMap); - log.info("Request Info validated for attendance update request"); - //Verify attendance register request and if mandatory fields are present - validateAttendanceRegisterRequest(attendanceRegisters, errorMap); - log.info("Attendance registers validated for update request"); - - for (AttendanceRegister attendanceRegister: attendanceRegisters) { - if (StringUtils.isBlank(attendanceRegister.getId())) { - log.error("Attendance register id is mandatory in register update request"); - errorMap.put("ATTENDANCE_REGISTER_ID", "Attendance register id is mandatory"); - } - } - - String tenantId = attendanceRegisters.get(0).getTenantId(); - String rootTenantId = tenantId.split("\\.")[0]; - - //Get MDMS data using create attendance register request and tenantId - Object mdmsData = mdmsUtils.mDMSCall(requestInfo, rootTenantId); - validateMDMSData(attendanceRegisters, mdmsData, errorMap); - log.info("Request data validated with MDMS"); - - if (!errorMap.isEmpty()) - throw new CustomException(errorMap); - } - - /* Validates attendance register data in update request against attendance register data fetched from database */ - public void validateUpdateAgainstDB(AttendanceRegisterRequest attendanceRegisterRequest, List attendanceRegistersFromDB) { - if (CollectionUtils.isEmpty(attendanceRegistersFromDB)) { - log.error("The record that you are trying to update does not exists in the system"); - throw new CustomException("INVALID_REGISTER_MODIFY", "The record that you are trying to update does not exists in the system"); - } - - for (AttendanceRegister registerFromRequest: attendanceRegisterRequest.getAttendanceRegister()) { - - AttendanceRegister registerFromDB = attendanceRegistersFromDB.stream().filter(ar -> ar.getId().equals(registerFromRequest.getId())).findFirst().orElse(null); - if (registerFromDB == null) { - log.error("The register Id " + registerFromRequest.getId() + " that you are trying to update does not exists in the system"); - throw new CustomException("INVALID_REGISTER_MODIFY", "The register Id " + registerFromRequest.getId() + " that you are trying to update does not exists in the system"); - } - - // If the user who is trying to update the register is not associated with the register, throw error that the user does not have permission to modify the attendance register - if (registerFromDB.getStaff() != null) { - Set staffUserIdsFromDB = registerFromDB.getStaff().stream().map(StaffPermission:: getUserId).collect(Collectors.toSet()); - String individualId = individualServiceUtil.getIndividualDetailsFromUserId(attendanceRegisterRequest.getRequestInfo().getUserInfo().getId(),attendanceRegisterRequest.getRequestInfo(), registerFromRequest.getTenantId()).get(0).getId(); - if (!staffUserIdsFromDB.contains(individualId)) { - log.error("The user " + attendanceRegisterRequest.getRequestInfo().getUserInfo().getUuid() + " does not have permission to modify the register " + registerFromDB.getId()); - throw new CustomException("INVALID_REGISTER_MODIFY", "The user " + attendanceRegisterRequest.getRequestInfo().getUserInfo().getUuid() + " does not have permission to modify the register " + registerFromDB.getId()); - } - } else { - log.error("The user " + attendanceRegisterRequest.getRequestInfo().getUserInfo().getUuid() + " does not have permission to modify the register " + registerFromDB.getId()); - throw new CustomException("INVALID_REGISTER_MODIFY", "The user " + attendanceRegisterRequest.getRequestInfo().getUserInfo().getUuid() + " does not have permission to modify the register " + registerFromDB.getId()); - } - } - } - - /* Validates Request Info and User Info */ - private void validateRequestInfo(RequestInfo requestInfo, Map errorMap) { - if (requestInfo == null) { - log.error("Request info is mandatory"); - throw new CustomException("REQUEST_INFO", "Request info is mandatory"); - } - if (requestInfo.getUserInfo() == null) { - log.error("UserInfo is mandatory"); - throw new CustomException("USERINFO", "UserInfo is mandatory"); - } - if (requestInfo.getUserInfo() != null && StringUtils.isBlank(requestInfo.getUserInfo().getUuid())) { - log.error("UUID is mandatory"); - throw new CustomException("USERINFO_UUID", "UUID is mandatory"); - } - } - - private void validateReferenceIdAndServiceCodeParams(List attendanceRegisters, Map errorMap) { - for (int i = 0; i < attendanceRegisters.size(); i++) { - if (StringUtils.isBlank(attendanceRegisters.get(i).getReferenceId())) { - log.error("ReferenceId is mandatory"); - errorMap.put("REFERENCE_ID", "ReferenceId is mandatory"); - } - - if (StringUtils.isBlank(attendanceRegisters.get(i).getServiceCode())) { - log.error("ServiceCode is mandatory"); - errorMap.put("SERVICE_CODE", "ServiceCode is mandatory"); - } - } - } - - /* Validates Attendance register request body for create and update apis */ - private void validateAttendanceRegisterRequest(List attendanceRegisters, Map errorMap) { - if (attendanceRegisters == null || attendanceRegisters.size() == 0) { - log.error("Attendance Register is mandatory"); - throw new CustomException("ATTENDANCE_REGISTER", "Attendance Register is mandatory"); - } - - for (int i = 0; i < attendanceRegisters.size(); i++) { - if (attendanceRegisters.get(i) == null) { - log.error("Attendance Register is mandatory"); - throw new CustomException("ATTENDANCE_REGISTER", "Attendance Register is mandatory"); - } - if (StringUtils.isBlank(attendanceRegisters.get(i).getTenantId())) { - log.error("Tenant is mandatory"); - throw new CustomException("TENANT_ID", "Tenant is mandatory"); - } - if (StringUtils.isBlank(attendanceRegisters.get(i).getName())) { - log.error("Name is mandatory"); - errorMap.put("NAME", "Name is mandatory"); - } - - if (attendanceRegisters.get(i).getStartDate() == null || - (attendanceRegisters.get(i).getStartDate() != null && attendanceRegisters.get(i).getStartDate().compareTo(BigDecimal.ZERO) == 0)) { - log.error("Start date is mandatory for attendance register " + attendanceRegisters.get(i).getName()); - throw new CustomException("START_DATE", "Start date is mandatory"); - } - if (attendanceRegisters.get(i).getStartDate().compareTo(BigDecimal.ZERO) < 0) { - log.error("Start date is less than zero " + attendanceRegisters.get(i).getName()); - throw new CustomException("START_DATE", "Start date should be valid"); - } - if (attendanceRegisters.get(i).getEndDate() != null && attendanceRegisters.get(i).getStartDate().compareTo(attendanceRegisters.get(i).getEndDate()) > 0) { - log.error("Start date should be less than end date for attendance register " + attendanceRegisters.get(i).getName()); - errorMap.put("DATE", "Start date should be less than end date"); - } - if (!attendanceRegisters.get(i).getTenantId().equals(attendanceRegisters.get(0).getTenantId())) { - log.error("All registers must have same tenant Id. Please create new request for different tenant id"); - throw new CustomException("MULTIPLE_TENANTS", "All registers must have same tenant Id. Please create new request for different tenant id"); - } - } - } - - private void validateMDMSData(List attendanceRegisters, Object mdmsData, Map errorMap) { - - final String jsonPathForTenants = "$.MdmsRes." + MDMS_TENANT_MODULE_NAME + "." + MASTER_TENANTS + ".*"; - - List tenantRes = null; - try { - tenantRes = JsonPath.read(mdmsData, jsonPathForTenants); - } catch (Exception e) { - log.error(e.getMessage()); - throw new CustomException("JSONPATH_ERROR", "Failed to parse mdms response"); - } - - if (CollectionUtils.isEmpty(tenantRes)){ - log.error("The tenant: " + attendanceRegisters.get(0).getTenantId() + " is not present in MDMS"); - errorMap.put("INVALID_TENANT", "The tenant: " + attendanceRegisters.get(0).getTenantId() + " is not present in MDMS"); - } - } - - public void validateSearchRegisterRequest(RequestInfoWrapper requestInfoWrapper, AttendanceRegisterSearchCriteria searchCriteria) { - if (searchCriteria == null || requestInfoWrapper == null) { - log.error("Register search criteria request is mandatory"); - throw new CustomException("REGISTER_SEARCH_CRITERIA_REQUEST", "Register search criteria request is mandatory"); - } - - Map errorMap = new HashMap<>(); - - validateRequestInfo(requestInfoWrapper.getRequestInfo(),errorMap); - - if (StringUtils.isBlank(searchCriteria.getTenantId())) { - log.error("Tenant is mandatory"); - throw new CustomException("TENANT_ID", "Tenant is mandatory"); - } - - // Throw exception if required parameters are missing - if (!errorMap.isEmpty()) - throw new CustomException(errorMap); - } - - public void validateRegisterAgainstDB(List registerIds, List attendanceRegisterListFromDB, String tenantId) { - - Set uniqueRegisterIdsFromRequest = new HashSet<>(registerIds); - - Set uniqueRegisterIdsFromDB = attendanceRegisterListFromDB.stream() - .map(register -> register.getId()).collect(Collectors.toSet()); - - //check if all register ids from request exist in db - for (String idFromRequest : uniqueRegisterIdsFromRequest) { - if (!uniqueRegisterIdsFromDB.contains(idFromRequest)) { - log.error("Attendance Registers with register id : " + idFromRequest + " does not exist for tenantId"); - throw new CustomException("REGISTER_ID", "Attendance Registers with register id : " + idFromRequest + " does not exist for tenantId"); - } - } - - } -} diff --git a/core-services/attendance/src/main/java/org/egov/validator/AttendeeServiceValidator.java b/core-services/attendance/src/main/java/org/egov/validator/AttendeeServiceValidator.java deleted file mode 100644 index 216d92de71b..00000000000 --- a/core-services/attendance/src/main/java/org/egov/validator/AttendeeServiceValidator.java +++ /dev/null @@ -1,383 +0,0 @@ -package org.egov.validator; - -import com.jayway.jsonpath.JsonPath; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.egov.common.contract.request.RequestInfo; -import org.egov.tracer.model.CustomException; -import org.egov.util.IndividualServiceUtil; -import org.egov.util.MDMSUtils; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendeeCreateRequest; -import org.egov.web.models.AttendeeDeleteRequest; -import org.egov.web.models.IndividualEntry; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; - -import static org.egov.util.AttendanceServiceConstants.MASTER_TENANTS; -import static org.egov.util.AttendanceServiceConstants.MDMS_TENANT_MODULE_NAME; - -@Component -@Slf4j -public class AttendeeServiceValidator { - - @Autowired - private MDMSUtils mdmsUtils; - - @Autowired - private IndividualServiceUtil individualServiceUtil; - - public void validateAttendeeCreateRequestParameters(AttendeeCreateRequest attendeeCreateRequest) { - List attendeeList = attendeeCreateRequest.getAttendees(); - Map errorMap = new HashMap<>(); - - if (attendeeList == null || attendeeList.isEmpty()) { - log.error("ATTENDEE Object is empty in attendee request"); - throw new CustomException("ATTENDEE", "ATTENDEE Object is empty in attendee request"); - } - - String tenantId = attendeeList.get(0).getTenantId(); - for (IndividualEntry attendee : attendeeList) { - - //validate request parameters for each attendee object - if (StringUtils.isBlank(attendee.getRegisterId())) { - log.error("register id is empty in attendee request"); - errorMap.put("REGISTER_ID", "Register id is mandatory"); - } - - if (StringUtils.isBlank(attendee.getIndividualId())) { - log.error("individual id is empty in attendee request"); - errorMap.put("INDIVIDUAL_ID", "Individual id is mandatory"); - } - - if (StringUtils.isBlank(attendee.getTenantId())) { - log.error("tenant id is empty in attendee request"); - errorMap.put("TENANT_ID", "Tenant id is mandatory"); - } - } - - if (!errorMap.isEmpty()) { - log.error("Attendee request validation failed"); - throw new CustomException(errorMap); - } - validateTenantIds(attendeeCreateRequest, tenantId); - validateDuplicateAttendeeObjects(attendeeCreateRequest); - - //validate tenantId with MDMS - log.info("validating tenant id from MDMS and Request info"); - validateMDMSAndRequestInfoForCreateAttendee(attendeeCreateRequest); - - //validate individualId with Individual Service - log.info("validating tenant id from MDMS and Request info"); - validateIndividualId(attendeeCreateRequest); - } - - private void validateIndividualId(AttendeeCreateRequest attendeeCreateRequest) { - RequestInfo requestInfo=attendeeCreateRequest.getRequestInfo(); - String tenantId=attendeeCreateRequest.getAttendees().get(0).getTenantId(); - List individualIds=attendeeCreateRequest.getAttendees().stream().map(attendee->attendee.getIndividualId()).collect(Collectors.toList()); - List ids= individualServiceUtil.fetchIndividualIds(individualIds,requestInfo,tenantId); - - for(String individualId:individualIds){ - if(!ids.contains(individualId)){ - throw new CustomException("INDIVIDUAL_ID_NOT_FOUND","Individual with id: "+individualId+" not found"); - } - } - } - - public void validateTenantIds(AttendeeCreateRequest attendeeCreateRequest, String tenantId) { - List attendeeList = attendeeCreateRequest.getAttendees(); - //validate if all attendee in the list have the same tenant id - for (IndividualEntry attendee : attendeeList) { - if (!attendee.getTenantId().equals(tenantId)) { - log.error("All attendees dont have the same tenant id in attendee request"); - throw new CustomException("TENANT_ID", "All Attendees to be enrolled or de enrolled must have the same tenant id. Please raise new request for different tenant id"); - } - } - - } - - public void validateDuplicateAttendeeObjects(AttendeeCreateRequest attendeeCreateRequest) { - List attendeeList = attendeeCreateRequest.getAttendees(); - - Set uniqueIds = new HashSet<>(); - for (IndividualEntry attendee : attendeeList) { - String uniqueId = attendee.getRegisterId() + attendee.getIndividualId(); - if (uniqueIds.isEmpty()) { - uniqueIds.add(attendee.getRegisterId() + attendee.getIndividualId()); - } else if (uniqueIds.contains(uniqueId)) { - log.error("Duplicate Attendee Objects found in request"); - throw new CustomException("ATTENDEE", "Duplicate attendee Objects present in request"); - } - uniqueIds.add(attendee.getRegisterId() + attendee.getIndividualId()); - } - } - - - public void validateAttendeeDeleteRequestParameters(AttendeeDeleteRequest attendeeDeleteRequest, Map errorMap) { - - List attendeeList = attendeeDeleteRequest.getAttendees(); - - if (attendeeList == null || attendeeList.isEmpty()) { - log.error("ATTENDEE Object is empty in attendee request"); - throw new CustomException("ATTENDEES", "ATTENDEE object is mandatory"); - } - - String tenantId = attendeeList.get(0).getTenantId(); - for (IndividualEntry attendee : attendeeList) { - - //validate request parameters for each attendee object - if (StringUtils.isBlank(attendee.getRegisterId())) { - log.error("REGISTER_ID is empty in attendee request"); - errorMap.put("REGISTER_ID", "Register id is mandatory"); - } - - if (StringUtils.isBlank(attendee.getIndividualId())) { - log.error("INDIVIDUAL_ID is empty in attendee request"); - errorMap.put("INDIVIDUAL_ID", "Individual id is mandatory"); - } - - if (StringUtils.isBlank(attendee.getTenantId())) { - log.error("TENANT_ID is empty in attendee request"); - errorMap.put("TENANT_ID", "Tenant id is mandatory"); - } - } - - if (!errorMap.isEmpty()) { - log.error("Attendee request validation failed"); - throw new CustomException(errorMap); - } - - validateTenantIds(attendeeDeleteRequest, tenantId); - validateDuplicateAttendeeObjects(attendeeDeleteRequest); - - //validate tenantId with MDMS - log.info("validating tenant id from MDMS and Request info"); - validateMDMSAndRequestInfoForDeleteAttendee(attendeeDeleteRequest); - - //validate individualId with Individual Service - log.info("validating tenant id from MDMS and Request info"); - validateIndividualId(attendeeDeleteRequest); - } - - private void validateIndividualId(AttendeeDeleteRequest attendeeDeleteRequest) { - RequestInfo requestInfo=attendeeDeleteRequest.getRequestInfo(); - String tenantId=attendeeDeleteRequest.getAttendees().get(0).getTenantId(); - List individualIds=attendeeDeleteRequest.getAttendees().stream().map(attendee->attendee.getIndividualId()).collect(Collectors.toList()); - List ids= individualServiceUtil.fetchIndividualIds(individualIds,requestInfo,tenantId); - - for(String individualId:individualIds){ - if(!ids.contains(individualId)){ - throw new CustomException("INDIVIDUAL_ID_NOT_FOUND","Individual with id: "+individualId+" not found"); - } - } - } - - public void validateTenantIds(AttendeeDeleteRequest attendeeDeleteRequest, String tenantId) { - List attendeeList = attendeeDeleteRequest.getAttendees(); - //validate if all attendee in the list have the same tenant id - for (IndividualEntry attendee : attendeeList) { - if (!attendee.getTenantId().equals(tenantId)) { - log.error("All attendees dont have the same tenant id in attendee request"); - throw new CustomException("TENANT_ID", "All Attendees to be enrolled or de enrolled must have the same tenant id. Please raise new request for different tenant id"); - } - } - - } - - public void validateDuplicateAttendeeObjects(AttendeeDeleteRequest attendeeDeleteRequest) { - List attendeeList = attendeeDeleteRequest.getAttendees(); - - Set uniqueIds = new HashSet<>(); - for (IndividualEntry attendee : attendeeList) { - String uniqueId = attendee.getRegisterId() + attendee.getIndividualId(); - if (uniqueIds.isEmpty()) { - uniqueIds.add(attendee.getRegisterId() + attendee.getIndividualId()); - } else if (uniqueIds.contains(uniqueId)) { - log.error("Duplicate Attendee Objects found in request"); - throw new CustomException("ATTENDEE", "Duplicate attendee Objects present in request"); - } - uniqueIds.add(attendee.getRegisterId() + attendee.getIndividualId()); - } - } - - public void validateMDMSAndRequestInfoForCreateAttendee(AttendeeCreateRequest attendeeCreateRequest) { - - RequestInfo requestInfo = attendeeCreateRequest.getRequestInfo(); - List attendeeListFromRequest = attendeeCreateRequest.getAttendees(); - Map errorMap = new HashMap<>(); - - String tenantId = attendeeListFromRequest.get(0).getTenantId(); - //split the tenantId - String rootTenantId = tenantId.split("\\.")[0]; - - Object mdmsData = mdmsUtils.mDMSCall(requestInfo, rootTenantId); - - //check tenant Id - log.info("validate tenantId with MDMS"); - validateMDMSData(tenantId, mdmsData, errorMap); - - - //validate request-info - log.info("validate request info coming from api request"); - validateRequestInfo(requestInfo, errorMap); - - if (!errorMap.isEmpty()) - throw new CustomException(errorMap); - } - - public void validateMDMSAndRequestInfoForDeleteAttendee(AttendeeDeleteRequest attendeeDeleteRequest) { - - RequestInfo requestInfo = attendeeDeleteRequest.getRequestInfo(); - List attendeeListFromRequest = attendeeDeleteRequest.getAttendees(); - Map errorMap = new HashMap<>(); - - String tenantId = attendeeListFromRequest.get(0).getTenantId(); - //split the tenantId - String rootTenantId = tenantId.split("\\.")[0]; - - Object mdmsData = mdmsUtils.mDMSCall(requestInfo, rootTenantId); - - //check tenant Id - log.info("validate tenantId with MDMS"); - validateMDMSData(tenantId, mdmsData, errorMap); - - - //validate request-info - log.info("validate request info coming from api request"); - validateRequestInfo(requestInfo, errorMap); - - if (!errorMap.isEmpty()) - throw new CustomException(errorMap); - } - - - public void validateAttendeeOnCreate(AttendeeCreateRequest attendeeCreateRequest - , List attendeeListFromDB, List attendanceRegisterListFromDB) { - - List attendeeListFromRequest = attendeeCreateRequest.getAttendees(); - - - // attendee cannot be added to register if register's end date has passed - log.info("verifying that attendee cannot be added to register if register's end date has passed"); - BigDecimal currentDate = new BigDecimal(System.currentTimeMillis()); - for (AttendanceRegister attendanceRegister : attendanceRegisterListFromDB) { - int dateComparisonResult = attendanceRegister.getEndDate().compareTo(currentDate); - if (dateComparisonResult < 0) { - throw new CustomException("END_DATE", "Attendee cannot be enrolled as END_DATE of register id " + attendanceRegister.getId() + " has already passed."); - } - } - - //attendee enrollment date, if present in request should be after start date and before end date of register - log.info("checking attendee enrollment date should be after start date and before end date of register"); - for (AttendanceRegister attendanceRegister : attendanceRegisterListFromDB) { - for (IndividualEntry attendeeFromRequest : attendeeListFromRequest) { - if (attendanceRegister.getId().equals(attendeeFromRequest.getRegisterId())) { - if (attendeeFromRequest.getEnrollmentDate() != null) { - int startDateCompare = attendeeFromRequest.getEnrollmentDate().compareTo(attendanceRegister.getStartDate()); - int endDateCompare = attendanceRegister.getEndDate().compareTo(attendeeFromRequest.getEnrollmentDate()); - if (startDateCompare < 0 || endDateCompare < 0) { - throw new CustomException("ENROLLMENT_DATE" - , "Enrollment date for attendee : " + attendeeFromRequest.getIndividualId() + " must be within start and end date of the register"); - } - } - } - } - } - - //check if attendee is already enrolled to the register - log.info("checking if attendee is already enrolled to the register"); - for (IndividualEntry attendeeFromRequest : attendeeListFromRequest) { - for (IndividualEntry attendeeFromDB : attendeeListFromDB) { - if (attendeeFromRequest.getRegisterId().equals(attendeeFromDB.getRegisterId()) - && attendeeFromRequest.getIndividualId().equals(attendeeFromDB.getIndividualId())) {//attendee present in db - if (attendeeFromDB.getDenrollmentDate() == null) { // already enrolled to the register - throw new CustomException("INDIVIDUAL_ID", "Attendee " + attendeeFromRequest.getIndividualId() + " is already enrolled in the register " + attendeeFromRequest.getRegisterId()); - - } - } - } - } - } - - public void validateAttendeeOnDelete(AttendeeDeleteRequest attendeeDeleteRequest, - List attendeeListFromDB, List attendanceRegisterListFromDB) { - - List attendeeListFromRequest = attendeeDeleteRequest.getAttendees(); - - - //attendee de-enrollment date, if present in request should be before end date and after start date of register - log.info("verifying attendee de-enrollment date, if present in request should be before end date and after start date of register"); - for (AttendanceRegister attendanceRegister : attendanceRegisterListFromDB) { - for (IndividualEntry attendeeFromRequest : attendeeListFromRequest) { - if (attendeeFromRequest.getDenrollmentDate() != null) { - int startDateCompare = attendeeFromRequest.getDenrollmentDate().compareTo(attendanceRegister.getStartDate()); - int endDateCompare = attendanceRegister.getEndDate().compareTo(attendeeFromRequest.getDenrollmentDate()); - if (startDateCompare < 0 || endDateCompare < 0) { - throw new CustomException("DE ENROLLMENT_DATE" - , "De enrollment date for attendee : " + attendeeFromRequest.getIndividualId() + " must be between start date and end date of the register"); - } - } - } - } - - //check if attendee is already de-enrolled from the register - log.info("checking if attendee is already de-enrolled from the register"); - boolean attendeeDeEnrolled = true; - for (IndividualEntry attendeeFromRequest : attendeeListFromRequest) { - for (IndividualEntry attendeeFromDB : attendeeListFromDB) { - if (attendeeFromRequest.getRegisterId().equals(attendeeFromDB.getRegisterId()) && attendeeFromDB.getIndividualId().equals(attendeeFromRequest.getIndividualId())) { //attendee present in db - if (attendeeFromDB.getDenrollmentDate() == null) { - attendeeDeEnrolled = false; - break; - } - } - } - if (attendeeDeEnrolled) { - throw new CustomException("INDIVIDUAL_ID", "Attendee " + attendeeFromRequest.getIndividualId() + " is already de enrolled from the register " + attendeeFromRequest.getRegisterId()); - } - } - - } - - private void validateRequestInfo(RequestInfo requestInfo, Map errorMap) { - if (requestInfo == null) { - log.error("Request info is null"); - throw new CustomException("REQUEST_INFO", "Request info is mandatory"); - } - if (requestInfo.getUserInfo() == null) { - log.error("User info is null"); - throw new CustomException("USERINFO", "UserInfo is mandatory"); - } - if (requestInfo.getUserInfo() != null && StringUtils.isBlank(requestInfo.getUserInfo().getUuid())) { - log.error("User's UUID field is empty"); - throw new CustomException("USERINFO_UUID", "User's UUID is mandatory"); - } - } - - private void validateMDMSData(String tenantId, Object mdmsData, Map errorMap) { - final String jsonPathForTenants = "$.MdmsRes." + MDMS_TENANT_MODULE_NAME + "." + MASTER_TENANTS + ".*"; - - List tenantRes = null; - try { - tenantRes = JsonPath.read(mdmsData, jsonPathForTenants); - } catch (Exception e) { - log.error(e.getMessage()); - throw new CustomException("JSONPATH_ERROR", "Failed to parse mdms response"); - } - - if (CollectionUtils.isEmpty(tenantRes)) - errorMap.put("INVALID_TENANT", "The tenant: " + tenantId + " is not present in MDMS"); - } -} - - diff --git a/core-services/attendance/src/main/java/org/egov/validator/StaffServiceValidator.java b/core-services/attendance/src/main/java/org/egov/validator/StaffServiceValidator.java deleted file mode 100644 index 9c2d594e564..00000000000 --- a/core-services/attendance/src/main/java/org/egov/validator/StaffServiceValidator.java +++ /dev/null @@ -1,271 +0,0 @@ -package org.egov.validator; - -import com.jayway.jsonpath.JsonPath; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.egov.common.contract.request.RequestInfo; -import org.egov.service.AttendanceRegisterService; -import org.egov.tracer.model.CustomException; -import org.egov.util.MDMSUtils; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.StaffPermission; -import org.egov.web.models.StaffPermissionRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import static org.egov.util.AttendanceServiceConstants.MASTER_TENANTS; -import static org.egov.util.AttendanceServiceConstants.MDMS_TENANT_MODULE_NAME; - - -@Component -@Slf4j -public class StaffServiceValidator { - - @Autowired - private MDMSUtils mdmsUtils; - - @Autowired - private AttendanceRegisterService attendanceRegisterService; - - - public void validateMDMSAndRequestInfoForStaff(StaffPermissionRequest request) { - RequestInfo requestInfo = request.getRequestInfo(); - List staffPermissionListFromRequest = request.getStaff(); - Map errorMap = new HashMap<>(); - - String tenantId = staffPermissionListFromRequest.get(0).getTenantId(); - //split the tenantId - String rootTenantId = tenantId.split("\\.")[0]; - - Object mdmsData = mdmsUtils.mDMSCall(requestInfo, rootTenantId); - - //validate request-info - log.info("validate request info coming from api request"); - validateRequestInfo(requestInfo, errorMap); - - //check tenant Id - log.info("validate tenantId with MDMS"); - validateMDMSData(tenantId, mdmsData, errorMap); - - if (!errorMap.isEmpty()) - throw new CustomException(errorMap); - } - - private void validateRequestInfo(RequestInfo requestInfo, Map errorMap) { - if (requestInfo == null) { - log.error("Request info is null"); - throw new CustomException("REQUEST_INFO", "Request info is mandatory"); - } - if (requestInfo.getUserInfo() == null) { - log.error("UserInfo is null"); - throw new CustomException("USERINFO", "UserInfo is mandatory"); - } - if (requestInfo.getUserInfo() != null && StringUtils.isBlank(requestInfo.getUserInfo().getUuid())) { - log.error("User's UUID field is empty"); - throw new CustomException("USERINFO_UUID", "User's UUID is mandatory"); - } - } - - - public void validateStaffPermissionRequestParameters(StaffPermissionRequest staffPermissionRequest) { - List staffPermissionList = staffPermissionRequest.getStaff(); - Map errorMap = new HashMap<>(); - - if (staffPermissionList == null || staffPermissionList.isEmpty()) { - log.error("Staff Object is empty in staff request"); - throw new CustomException("STAFF", "Staff is mandatory"); - } - - String baseTenantId = staffPermissionList.get(0).getTenantId(); - for (StaffPermission staffPermission : staffPermissionList) { - - //validate request parameters for each staff object - if (StringUtils.isBlank(staffPermission.getRegisterId())) { - log.error("Register id is empty in staff request"); - errorMap.put("REGISTER_ID", "Register id is mandatory"); - } - - if (StringUtils.isBlank(staffPermission.getUserId())) { - log.error("User id is empty in staff request"); - errorMap.put("USER_ID", "User id is mandatory"); - } - - if (StringUtils.isBlank(staffPermission.getTenantId())) { - log.error("Tenant id is empty in staff request"); - errorMap.put("TENANT_ID", "Tenant id is mandatory"); - } - } - - if (!errorMap.isEmpty()) { - log.error("Attendee request validation failed"); - throw new CustomException(errorMap); - } - - validateTenantIds(staffPermissionRequest, baseTenantId); - validateDuplicateStaffObjects(staffPermissionRequest); - - - //validate tenant id with mdms and request info - log.info("validating tenant id from MDMS and Request info"); - validateMDMSAndRequestInfoForStaff(staffPermissionRequest); - } - - public void validateTenantIds(StaffPermissionRequest staffPermissionRequest, String tenantId) { - List staffPermissionList = staffPermissionRequest.getStaff(); - //validate if all staff in the list have the same tenant id - for (StaffPermission staffPermission : staffPermissionList) { - if (!staffPermission.getTenantId().equals(tenantId)) { - log.error("All staff objects do not have the same tenant id"); - throw new CustomException("TENANT_ID", "All Staff to be enrolled or de enrolled must have the same tenant id. Please raise new request for different tenant id"); - } - } - - } - - public void validateDuplicateStaffObjects(StaffPermissionRequest staffPermissionRequest) { - List staffPermissionList = staffPermissionRequest.getStaff(); - - Set uniqueIds = new HashSet<>(); - for (StaffPermission staffPermission : staffPermissionList) { - String uniqueId = staffPermission.getRegisterId() + staffPermission.getUserId(); - if (uniqueIds.isEmpty()) { - uniqueIds.add(staffPermission.getRegisterId() + staffPermission.getUserId()); - } else if (uniqueIds.contains(uniqueId)) { - log.error("Duplicate Staff Objects found in request"); - throw new CustomException("STAFF", "Duplicate Staff Objects present in request"); - } - uniqueIds.add(staffPermission.getRegisterId() + staffPermission.getUserId()); - } - } - - public void validateStaffPermissionOnCreate(StaffPermissionRequest request, List staffPermissionListFromDB, - List attendanceRegisterListFromDB) { - - List staffPermissionListFromRequest = request.getStaff(); - - // staff cannot be added to register if register's end date has passed - log.info("checking that staff cannot be added to register if register's end date has passed"); - BigDecimal enrollmentDate = new BigDecimal(System.currentTimeMillis()); - for (AttendanceRegister attendanceRegister : attendanceRegisterListFromDB) { - int dateComparisonResult = attendanceRegister.getEndDate().compareTo(enrollmentDate); - if (dateComparisonResult < 0) { - log.error("Staff cannot be enrolled as END_DATE of register id " + attendanceRegister.getId() + " has already passed."); - throw new CustomException("END_DATE", "Staff cannot be enrolled as END_DATE of register id " + attendanceRegister.getId() + " has already passed."); - } - } - - //check if staff user id exists in staff table for the given register id. If yes check the deenrollment date. If staffId does not exist new staff can still be enrolled to the register - if (staffPermissionListFromDB != null) { - for (StaffPermission staffFromRequest : staffPermissionListFromRequest) {//list of staff from request - StaffPermission staff = staffPermissionListFromDB.stream() - .filter(s -> s.getUserId().equals(staffFromRequest.getUserId()) && s.getRegisterId().equals(staffFromRequest.getRegisterId())) - .findFirst().orElse(null); - if (staff != null && staff.getDenrollmentDate() == null) { - throw new CustomException("USER_id", "Staff " + staff.getUserId() + " is already enrolled in the register " + staff.getRegisterId()); - } - } - } - - } - - - public void validateStaffPermissionOnDelete(StaffPermissionRequest staffPermissionRequest - , List staffPermissionListFromDB, List attendanceRegisterListFromDB) { - - RequestInfo requestInfo = staffPermissionRequest.getRequestInfo(); - List staffPermissionListFromRequest = staffPermissionRequest.getStaff(); - - boolean staffExists = false; - boolean staffDeenrolled = true; - - - //check is staff user id exists in staff table. If yes check if the de enrollment date is null - log.info("checking if the de enrollment date of staff is null"); - for (StaffPermission staffPermissionFromRequest : staffPermissionListFromRequest) { - for (StaffPermission staffPermissionFromDB : staffPermissionListFromDB) { - if (staffPermissionFromRequest.getRegisterId().equals(staffPermissionFromDB.getRegisterId()) && - staffPermissionFromRequest.getUserId().equals(staffPermissionFromDB.getUserId())) { - staffExists = true; - if (staffPermissionFromDB.getDenrollmentDate() == null) { - staffDeenrolled = false; - break; - } - } - } - if (!staffExists) - throw new CustomException("USER_ID", "Staff with the given user id: " + staffPermissionFromRequest.getUserId() + " is not linked with the given register id");//handled - if (staffDeenrolled) - throw new CustomException("USER_ID", "Staff with the given user id : " + staffPermissionFromRequest.getUserId() + " is already de enrolled from the register"); - } - - - //staff list size associated with the register (At least one staff should remain with a register before de enrollment) - //initialize request and DB hashmaps with registerId as key - log.info("checking that atleast one staff should remain enrolled to a register before de enrollment"); - HashMap staffCountInEachRegisterIdFromRequest = new HashMap<>(); - HashMap staffCountInEachRegisterIdFromDB = new HashMap<>(); - for (AttendanceRegister attendanceRegister : attendanceRegisterListFromDB) { - staffCountInEachRegisterIdFromRequest.put(attendanceRegister.getId().toString(), 0); - staffCountInEachRegisterIdFromDB.put(attendanceRegister.getId().toString(), 0); - } - - - // from staffRequest - number of de enrollments from each register - for (StaffPermission staffPermissionFromRequest : staffPermissionListFromRequest) { - String staffRegisterId = staffPermissionFromRequest.getRegisterId(); - if (staffCountInEachRegisterIdFromRequest.containsKey(staffRegisterId)) { - int count = staffCountInEachRegisterIdFromRequest.get(staffRegisterId); - count++; - staffCountInEachRegisterIdFromRequest.put(staffRegisterId, count); - } - } - - - // from StaffDB data number of staff enrolled to each register in db - for (StaffPermission staffPermissionFromDB : staffPermissionListFromDB) { - String staffRegisterId = staffPermissionFromDB.getRegisterId(); - if (staffCountInEachRegisterIdFromDB.containsKey(staffRegisterId) && staffPermissionFromDB.getDenrollmentDate() == null) { - int count = staffCountInEachRegisterIdFromDB.get(staffRegisterId); - count++; - staffCountInEachRegisterIdFromDB.put(staffRegisterId, count); - } - } - - //match the regitser ids between request and db. subtract the staff, If <1 throw error - for (String registerId : staffCountInEachRegisterIdFromRequest.keySet()) { - if (staffCountInEachRegisterIdFromDB.containsKey(registerId)) { - int result = staffCountInEachRegisterIdFromDB.get(registerId) - staffCountInEachRegisterIdFromRequest.get(registerId); - if (result < 1) { - throw new CustomException("MIN_STAFF_REQUIRED", "Atleast one staff should be associated" + - "with the register. Number of staff in register id : " + registerId + " after de enrollment operation would be " + result); - } - } - } - } - - - private void validateMDMSData(String tenantId, Object mdmsData, Map errorMap) { - final String jsonPathForTenants = "$.MdmsRes." + MDMS_TENANT_MODULE_NAME + "." + MASTER_TENANTS + ".*"; - - List tenantRes = null; - try { - tenantRes = JsonPath.read(mdmsData, jsonPathForTenants); - } catch (Exception e) { - log.error(e.getMessage()); - throw new CustomException("JSONPATH_ERROR", "Failed to parse mdms response"); - } - - if (CollectionUtils.isEmpty(tenantRes)) - errorMap.put("INVALID_TENANT", "The tenant: " + tenantId + " is not present in MDMS"); - } - - -} diff --git a/core-services/attendance/src/main/java/org/egov/web/controllers/AttendanceApiController.java b/core-services/attendance/src/main/java/org/egov/web/controllers/AttendanceApiController.java deleted file mode 100644 index 23a4b0ef330..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/controllers/AttendanceApiController.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.egov.web.controllers; - - -import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.RequestInfoWrapper; -import io.swagger.annotations.ApiParam; -import org.egov.common.contract.response.ResponseInfo; -import org.egov.service.AttendanceRegisterService; -import org.egov.util.ResponseInfoFactory; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendanceRegisterRequest; -import org.egov.web.models.AttendanceRegisterResponse; -import org.egov.web.models.AttendanceRegisterSearchCriteria; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; -import java.util.List; - -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Controller -@RequestMapping("/v1") -public class AttendanceApiController { - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private HttpServletRequest request; - - @Autowired - private ResponseInfoFactory responseInfoCreator; - - @Autowired - private AttendanceRegisterService attendanceRegisterService; - @Autowired - private ResponseInfoFactory responseInfoFactory; - - @RequestMapping(value = "/_create", method = RequestMethod.POST) - public ResponseEntity createAttendanceRegister(@ApiParam(value = "", allowableValues = "application/json") @RequestHeader(value = "Content-Type", required = false) String contentType, @ApiParam(value = "") @Valid @RequestBody AttendanceRegisterRequest attendanceRegisterRequest) { - AttendanceRegisterRequest enrichedAttendanceRegisterRequest = attendanceRegisterService.createAttendanceRegister(attendanceRegisterRequest); - - ResponseInfo responseInfo = responseInfoFactory.createResponseInfoFromRequestInfo(attendanceRegisterRequest.getRequestInfo(), true); - AttendanceRegisterResponse attendanceRegisterResponse = AttendanceRegisterResponse.builder().responseInfo(responseInfo).attendanceRegister(enrichedAttendanceRegisterRequest.getAttendanceRegister()).build(); - return new ResponseEntity(attendanceRegisterResponse, HttpStatus.OK); - } - - @RequestMapping(value = "/_search", method = RequestMethod.POST) - public ResponseEntity searchAttendanceRegister(@Valid @ModelAttribute AttendanceRegisterSearchCriteria searchCriteria, @Valid @RequestBody RequestInfoWrapper requestInfoWrapper) { - List attendanceRegisterList = attendanceRegisterService.searchAttendanceRegister(requestInfoWrapper, searchCriteria); - ResponseInfo responseInfo = responseInfoCreator.createResponseInfoFromRequestInfo(requestInfoWrapper.getRequestInfo(), true); - AttendanceRegisterResponse attendanceRegisterResponse = AttendanceRegisterResponse.builder().responseInfo(responseInfo).attendanceRegister(attendanceRegisterList).build(); - return new ResponseEntity(attendanceRegisterResponse, HttpStatus.OK); - } - - @RequestMapping(value = "/_update", method = RequestMethod.POST) - public ResponseEntity updateAttendanceRegister(@ApiParam(value = "", allowableValues = "application/json") @RequestHeader(value = "Content-Type", required = false) String contentType, @ApiParam(value = "") @Valid @RequestBody AttendanceRegisterRequest attendanceRegisterRequest) { - AttendanceRegisterRequest enrichedAttendanceRegisterRequest = attendanceRegisterService.updateAttendanceRegister(attendanceRegisterRequest); - - ResponseInfo responseInfo = responseInfoFactory.createResponseInfoFromRequestInfo(attendanceRegisterRequest.getRequestInfo(), true); - AttendanceRegisterResponse attendanceRegisterResponse = AttendanceRegisterResponse.builder().responseInfo(responseInfo).attendanceRegister(enrichedAttendanceRegisterRequest.getAttendanceRegister()).build(); - return new ResponseEntity(attendanceRegisterResponse, HttpStatus.OK); - } - - -} diff --git a/core-services/attendance/src/main/java/org/egov/web/controllers/AttendanceLogApiController.java b/core-services/attendance/src/main/java/org/egov/web/controllers/AttendanceLogApiController.java deleted file mode 100644 index 1deab99977a..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/controllers/AttendanceLogApiController.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.egov.web.controllers; - -import com.fasterxml.jackson.databind.ObjectMapper; -import io.swagger.annotations.ApiParam; -import org.egov.service.AttendanceLogService; -import org.egov.web.models.AttendanceLogRequest; -import org.egov.web.models.AttendanceLogResponse; -import org.egov.web.models.AttendanceLogSearchCriteria; -import org.egov.web.models.RequestInfoWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.ModelAttribute; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -@Controller -@RequestMapping("/log/v1") -public class AttendanceLogApiController { - - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private HttpServletRequest request; - - @Autowired - private AttendanceLogService attendanceLogService; - - @RequestMapping(value = "/_create", method = RequestMethod.POST) - public ResponseEntity attendanceLogV1CreatePOST(@ApiParam(value = "", allowableValues = "application/json") @RequestHeader(value = "Content-Type", required = false) String contentType, @ApiParam(value = "") @Valid @RequestBody AttendanceLogRequest attendanceLogRequest) { - AttendanceLogResponse attendanceLogResponse = attendanceLogService.createAttendanceLog(attendanceLogRequest); - return new ResponseEntity(attendanceLogResponse, HttpStatus.OK); - } - - @RequestMapping(value = "/_search", method = RequestMethod.POST) - public ResponseEntity attendanceLogV1SearchPOST(@Valid @ModelAttribute AttendanceLogSearchCriteria searchCriteria, @ApiParam(value = "") @Valid @RequestBody RequestInfoWrapper requestInfoWrapper) { - AttendanceLogResponse attendanceLogResponse = attendanceLogService.searchAttendanceLog(requestInfoWrapper, searchCriteria); - return new ResponseEntity(attendanceLogResponse, HttpStatus.OK); - } - - @RequestMapping(value = "/_update", method = RequestMethod.POST) - public ResponseEntity attendanceLogV1UpdatePOST(@ApiParam(value = "", allowableValues = "application/json") @RequestHeader(value = "Content-Type", required = false) String contentType, @ApiParam(value = "") @Valid @RequestBody AttendanceLogRequest attendanceLogRequest) { - AttendanceLogResponse attendanceLogResponse = attendanceLogService.updateAttendanceLog(attendanceLogRequest); - return new ResponseEntity(attendanceLogResponse, HttpStatus.OK); - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/web/controllers/AttendeeApiController.java b/core-services/attendance/src/main/java/org/egov/web/controllers/AttendeeApiController.java deleted file mode 100644 index 60844961927..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/controllers/AttendeeApiController.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.egov.web.controllers; - -import com.fasterxml.jackson.databind.ObjectMapper; -import io.swagger.annotations.ApiParam; -import org.egov.common.contract.response.ResponseInfo; -import org.egov.service.AttendeeService; -import org.egov.util.ResponseInfoFactory; -import org.egov.web.models.AttendeeCreateRequest; -import org.egov.web.models.AttendeeCreateResponse; -import org.egov.web.models.AttendeeDeleteRequest; -import org.egov.web.models.AttendeeDeleteResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -@Controller -@RequestMapping("/attendee/v1") -public class AttendeeApiController { - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private HttpServletRequest request; - - @Autowired - private AttendeeService attendeeService; - - @Autowired - private ResponseInfoFactory responseInfoFactory; - - @RequestMapping(value = "/_create", method = RequestMethod.POST) - public ResponseEntity createAttendee(@ApiParam(value = "", allowableValues = "application/json") @RequestHeader(value = "Content-Type", required = false) String contentType, @ApiParam(value = "") @Valid @RequestBody AttendeeCreateRequest attendeeCreateRequest) { - AttendeeCreateRequest enrichedRequest = attendeeService.createAttendee(attendeeCreateRequest); - ResponseInfo responseInfo = responseInfoFactory.createResponseInfoFromRequestInfo(attendeeCreateRequest.getRequestInfo(), true); - AttendeeCreateResponse attendeeCreateResponse = AttendeeCreateResponse.builder().responseInfo(responseInfo).attendees(enrichedRequest.getAttendees()).build(); - return new ResponseEntity(attendeeCreateResponse, HttpStatus.OK); - } - - - @RequestMapping(value = "/_delete", method = RequestMethod.POST) - public ResponseEntity deleteAttendee(@ApiParam(value = "", allowableValues = "application/json") @RequestHeader(value = "Content-Type", required = false) String contentType, @ApiParam(value = "") @Valid @RequestBody AttendeeDeleteRequest attendeeDeleteRequest) { - AttendeeDeleteRequest enrichedRequest = attendeeService.deleteAttendee(attendeeDeleteRequest); - ResponseInfo responseInfo = responseInfoFactory.createResponseInfoFromRequestInfo(attendeeDeleteRequest.getRequestInfo(), true); - AttendeeDeleteResponse attendeeDeleteResponse = AttendeeDeleteResponse.builder().responseInfo(responseInfo).attendees(enrichedRequest.getAttendees()).build(); - return new ResponseEntity(attendeeDeleteResponse, HttpStatus.OK); - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/web/controllers/StaffApiController.java b/core-services/attendance/src/main/java/org/egov/web/controllers/StaffApiController.java deleted file mode 100644 index 523fdeddb77..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/controllers/StaffApiController.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.egov.web.controllers; - -import com.fasterxml.jackson.databind.ObjectMapper; -import io.swagger.annotations.ApiParam; -import org.egov.common.contract.response.ResponseInfo; -import org.egov.service.StaffService; -import org.egov.util.ResponseInfoFactory; -import org.egov.web.models.StaffPermissionRequest; -import org.egov.web.models.StaffPermissionResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -import javax.servlet.http.HttpServletRequest; -import javax.validation.Valid; - -@Controller -@RequestMapping("/staff/v1") -public class StaffApiController { - - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private HttpServletRequest request; - - @Autowired - private StaffService staffService; - - @Autowired - private ResponseInfoFactory responseInfoFactory; - - @RequestMapping(value = "/_create", method = RequestMethod.POST) - public ResponseEntity createStaff(@ApiParam(value = "", allowableValues = "application/json") @RequestHeader(value = "Content-Type", required = false) String contentType, @ApiParam(value = "") @Valid @RequestBody StaffPermissionRequest staffPermissionRequest) { - StaffPermissionRequest enrichedRequest = staffService.createAttendanceStaff(staffPermissionRequest, false); - ResponseInfo responseInfo = responseInfoFactory.createResponseInfoFromRequestInfo(staffPermissionRequest.getRequestInfo(), true); - StaffPermissionResponse staffPermissionResponse = StaffPermissionResponse.builder().responseInfo(responseInfo) - .staff(enrichedRequest.getStaff()).build(); - return new ResponseEntity(staffPermissionResponse, HttpStatus.OK); - } - - @RequestMapping(value = "/_delete", method = RequestMethod.POST) - public ResponseEntity deleteStaff(@ApiParam(value = "", allowableValues = "application/json") @RequestHeader(value = "Content-Type", required = false) String contentType, @ApiParam(value = "") @Valid @RequestBody StaffPermissionRequest staffPermissionRequest) { - StaffPermissionRequest enrichedRequest = staffService.deleteAttendanceStaff(staffPermissionRequest); - ResponseInfo responseInfo = responseInfoFactory.createResponseInfoFromRequestInfo(staffPermissionRequest.getRequestInfo(), true); - StaffPermissionResponse staffPermissionResponse = StaffPermissionResponse.builder().responseInfo(responseInfo) - .staff(enrichedRequest.getStaff()).build(); - return new ResponseEntity(staffPermissionResponse, HttpStatus.OK); - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceLog.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendanceLog.java deleted file mode 100644 index 1da8c810f6e..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceLog.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import digit.models.coremodels.AuditDetails; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - -/** - * AttendanceLog - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AttendanceLog { - @JsonProperty("id") - private String id = null; - - @JsonProperty("registerId") - private String registerId = null; - - @JsonProperty("individualId") - private String individualId = null; - - @JsonProperty("tenantId") - private String tenantId = null; - - @JsonProperty("time") - private BigDecimal time = null; - - @JsonProperty("type") - private String type = null; - - @JsonProperty("status") - private Status status = null; - - @JsonProperty("documentIds") - @Valid - private List documentIds = null; - - @JsonProperty("auditDetails") - private AuditDetails auditDetails = null; - - @JsonProperty("additionalDetails") - private Object additionalDetails = null; - - - public AttendanceLog addDocumentIdsItem(Document documentIdsItem) { - if (this.documentIds == null) { - this.documentIds = new ArrayList<>(); - } - this.documentIds.add(documentIdsItem); - return this; - } - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceLogRequest.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendanceLogRequest.java deleted file mode 100644 index d401167a257..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceLogRequest.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.egov.common.contract.request.RequestInfo; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import java.util.ArrayList; -import java.util.List; - -/** - * AttendanceLogRequest - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AttendanceLogRequest { - @JsonProperty("RequestInfo") - private RequestInfo requestInfo = null; - - @JsonProperty("attendance") - @Valid - private List attendance = null; - - - public AttendanceLogRequest addAttendanceItem(AttendanceLog attendanceItem) { - if (this.attendance == null) { - this.attendance = new ArrayList<>(); - } - this.attendance.add(attendanceItem); - return this; - } - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceLogResponse.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendanceLogResponse.java deleted file mode 100644 index fe581e7f350..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceLogResponse.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.egov.common.contract.response.ResponseInfo; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import java.util.ArrayList; -import java.util.List; - -/** - * AttendanceLogResponse - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AttendanceLogResponse { - @JsonProperty("ResponseInfo") - private ResponseInfo responseInfo = null; - - @JsonProperty("attendance") - @Valid - private List attendance = null; - - - public AttendanceLogResponse addAttendanceItem(AttendanceLog attendanceItem) { - if (this.attendance == null) { - this.attendance = new ArrayList<>(); - } - this.attendance.add(attendanceItem); - return this; - } - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceLogSearchCriteria.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendanceLogSearchCriteria.java deleted file mode 100644 index 77c80abec1c..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceLogSearchCriteria.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.math.BigDecimal; -import java.util.List; - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AttendanceLogSearchCriteria { - - @JsonProperty("ids") - private List ids; - - @JsonProperty("tenantId") - private String tenantId; - - @JsonProperty("registerId") - private String registerId; - - @JsonProperty("fromTime") - private BigDecimal fromTime; - - @JsonProperty("toTime") - private BigDecimal toTime; - - @JsonProperty("individualIds") - private List individualIds; - - @JsonProperty("status") - private Status status; - - @JsonProperty("limit") - private Integer limit; - - @JsonProperty("offset") - private Integer offset; - - @JsonProperty("sortBy") - private SortBy sortBy; - - @JsonProperty("sortOrder") - private SortOrder sortOrder; - - public enum SortOrder { - ASC, - DESC - } - - public enum SortBy { - lastModifiedTime - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceRegister.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendanceRegister.java deleted file mode 100644 index 74d3af82333..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceRegister.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import digit.models.coremodels.AuditDetails; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - -/** - * AttendanceRegister - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AttendanceRegister { - @JsonProperty("id") - private String id = null; - - @JsonProperty("tenantId") - private String tenantId = null; - - @JsonProperty("registerNumber") - private String registerNumber = null; - - @JsonProperty("name") - private String name = null; - - @JsonProperty("referenceId") - private String referenceId; - - @JsonProperty("serviceCode") - private String serviceCode; - - @JsonProperty("startDate") - private BigDecimal startDate = null; - - @JsonProperty("endDate") - private BigDecimal endDate = null; - - @JsonProperty("status") - private Status status = Status.ACTIVE; - - @JsonProperty("staff") - @Valid - private List staff = null; - - @JsonProperty("attendees") - @Valid - private List attendees = null; - - @JsonProperty("auditDetails") - private AuditDetails auditDetails = null; - - @JsonProperty("additionalDetails") - private Object additionalDetails = null; - - - public AttendanceRegister addStaffItem(StaffPermission staffItem) { - if (this.staff == null) { - this.staff = new ArrayList<>(); - } - this.staff.add(staffItem); - return this; - } - - public AttendanceRegister addAttendeesItem(IndividualEntry attendeesItem) { - if (this.attendees == null) { - this.attendees = new ArrayList<>(); - } - this.attendees.add(attendeesItem); - return this; - } - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceRegisterRequest.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendanceRegisterRequest.java deleted file mode 100644 index 593402b649d..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceRegisterRequest.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.egov.common.contract.request.RequestInfo; -import org.springframework.validation.annotation.Validated; - -import java.util.List; - -/** - * AttendanceRegisterRequest - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AttendanceRegisterRequest { - @JsonProperty("RequestInfo") - private RequestInfo requestInfo = null; - - @JsonProperty("attendanceRegister") - private List attendanceRegister = null; - - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceRegisterResponse.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendanceRegisterResponse.java deleted file mode 100644 index 022f6fdf109..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceRegisterResponse.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.egov.common.contract.response.ResponseInfo; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import java.util.ArrayList; -import java.util.List; - -/** - * AttendanceRegisterResponse - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AttendanceRegisterResponse { - @JsonProperty("ResponseInfo") - private ResponseInfo responseInfo = null; - - @JsonProperty("attendanceRegister") - @Valid - private List attendanceRegister = null; - - - public AttendanceRegisterResponse addAttendanceRegisterItem(AttendanceRegister attendanceRegisterItem) { - if (this.attendanceRegister == null) { - this.attendanceRegister = new ArrayList<>(); - } - this.attendanceRegister.add(attendanceRegisterItem); - return this; - } - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceRegisterSearchCriteria.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendanceRegisterSearchCriteria.java deleted file mode 100644 index 06869e833a3..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendanceRegisterSearchCriteria.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; - -import java.math.BigDecimal; -import java.util.List; - - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -@ToString -public class AttendanceRegisterSearchCriteria { - - @JsonProperty("tenantId") - private String tenantId; - - @JsonProperty("ids") - private List ids; - - @JsonProperty("registerNumber") - private String registerNumber; - - @JsonProperty("name") - private String name; - - @JsonProperty("fromDate") - private BigDecimal fromDate; - - @JsonProperty("toDate") - private BigDecimal toDate; - - @JsonProperty("status") - private Status status; - - @JsonProperty("attendeeId") - private String attendeeId; - - @JsonProperty("staffId") - private String staffId; - - @JsonProperty("referenceId") - private String referenceId; - - @JsonProperty("serviceCode") - private String serviceCode; - - @JsonProperty("limit") - private Integer limit; - - @JsonProperty("offset") - private Integer offset; - - @JsonProperty("sortBy") - private SortBy sortBy; - - @JsonProperty("sortOrder") - private SortOrder sortOrder; - - public enum SortOrder { - ASC, - DESC - } - - public enum SortBy { - lastModifiedTime, - fromDate, - toDate - } - -} diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendeeCreateRequest.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendeeCreateRequest.java deleted file mode 100644 index bbb9ef4ab24..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendeeCreateRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.egov.common.contract.request.RequestInfo; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import java.util.ArrayList; -import java.util.List; - -/** - * AttendeeCreateRequest - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AttendeeCreateRequest { - @JsonProperty("RequestInfo") - private RequestInfo requestInfo = null; - - @JsonProperty("attendees") - @Valid - private List attendees = null; - - public AttendeeCreateRequest addAttendeesItem(IndividualEntry attendeesItem) { - if (this.attendees == null) { - this.attendees = new ArrayList<>(); - } - this.attendees.add(attendeesItem); - return this; - } - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendeeCreateResponse.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendeeCreateResponse.java deleted file mode 100644 index 4a9745c8ccf..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendeeCreateResponse.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.egov.common.contract.response.ResponseInfo; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import java.util.ArrayList; -import java.util.List; - -/** - * AttendeeCreateResponse - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AttendeeCreateResponse { - @JsonProperty("ResponseInfo") - private ResponseInfo responseInfo = null; - - @JsonProperty("attendees") - @Valid - private List attendees = null; - - - public AttendeeCreateResponse addAttendeesItem(IndividualEntry attendeesItem) { - if (this.attendees == null) { - this.attendees = new ArrayList<>(); - } - this.attendees.add(attendeesItem); - return this; - } - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendeeDeleteRequest.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendeeDeleteRequest.java deleted file mode 100644 index 48e7def64a2..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendeeDeleteRequest.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.egov.common.contract.request.RequestInfo; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import java.util.ArrayList; -import java.util.List; - -/** - * AttendeeDeleteRequest - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AttendeeDeleteRequest { - @JsonProperty("RequestInfo") - private RequestInfo requestInfo = null; - - @JsonProperty("attendees") - @Valid - private List attendees = null; - - public AttendeeDeleteRequest addAttendeesItem(IndividualEntry attendeesItem) { - if (this.attendees == null) { - this.attendees = new ArrayList<>(); - } - this.attendees.add(attendeesItem); - return this; - } - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendeeDeleteResponse.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendeeDeleteResponse.java deleted file mode 100644 index 89fce4ccc4f..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendeeDeleteResponse.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.egov.common.contract.response.ResponseInfo; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import java.util.ArrayList; -import java.util.List; - -/** - * AttendeeDeleteResponse - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AttendeeDeleteResponse { - @JsonProperty("ResponseInfo") - private ResponseInfo responseInfo; - - @JsonProperty("attendees") - @Valid - private List attendees = null; - - - public AttendeeDeleteResponse addAttendeesItem(IndividualEntry attendeesItem) { - if (this.attendees == null) { - this.attendees = new ArrayList<>(); - } - this.attendees.add(attendeesItem); - return this; - } - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/AttendeeSearchCriteria.java b/core-services/attendance/src/main/java/org/egov/web/models/AttendeeSearchCriteria.java deleted file mode 100644 index 41be1e2e04d..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/AttendeeSearchCriteria.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.math.BigDecimal; -import java.util.List; - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AttendeeSearchCriteria { - - @JsonProperty("ids") - private List ids; - - @JsonProperty("individualIds") - private List individualIds; - - @JsonProperty("registerIds") - private List registerIds; - - @JsonProperty("enrollmentDate") - private BigDecimal enrollmentDate = null; - - @JsonProperty("denrollmentDate") - private BigDecimal denrollmentDate = null; - - @JsonProperty("limit") - private Integer limit; - - @JsonProperty("offset") - private Integer offset; -} diff --git a/core-services/attendance/src/main/java/org/egov/web/models/Document.java b/core-services/attendance/src/main/java/org/egov/web/models/Document.java deleted file mode 100644 index 3dbbde0be74..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/Document.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class Document { - @JsonProperty("id") - private String id = null; - - @JsonProperty("documentType") - private String documentType = null; - - @JsonProperty("fileStore") - private String fileStore = null; - - @JsonProperty("documentUid") - private String documentUid = null; - - @JsonProperty("additionalDetails") - private Object additionalDetails = null; - - @JsonProperty("status") - @Builder.Default - private Status status = Status.ACTIVE; -} \ No newline at end of file diff --git a/core-services/attendance/src/main/java/org/egov/web/models/IndividualEntry.java b/core-services/attendance/src/main/java/org/egov/web/models/IndividualEntry.java deleted file mode 100644 index 4c85d144de7..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/IndividualEntry.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import digit.models.coremodels.AuditDetails; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.springframework.validation.annotation.Validated; - -import java.math.BigDecimal; - -/** - * IndividualEntry - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class IndividualEntry { - @JsonProperty("id") - private String id = null; - - @JsonProperty("tenantId") - private String tenantId = null; - - @JsonProperty("registerId") - private String registerId = null; - - @JsonProperty("individualId") - private String individualId = null; - - @JsonProperty("enrollmentDate") - private BigDecimal enrollmentDate = null; - - @JsonProperty("denrollmentDate") - private BigDecimal denrollmentDate = null; - - @JsonProperty("auditDetails") - private AuditDetails auditDetails = null; - - @JsonProperty("additionalDetails") - private Object additionalDetails = null; - - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/Organisation/ContactDetails.java b/core-services/attendance/src/main/java/org/egov/web/models/Organisation/ContactDetails.java deleted file mode 100644 index da1b95c2785..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/Organisation/ContactDetails.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.egov.web.models.Organisation; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.egov.common.models.core.Role; -import org.springframework.validation.annotation.Validated; - -import javax.validation.Valid; -import javax.validation.constraints.Size; -import java.util.List; - -/** - * Captures details of a contact person - */ -@ApiModel(description = "Captures details of a contact person") -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2023-02-15T14:49:42.141+05:30") - -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class ContactDetails { - - @JsonProperty("id") - @Valid - private String id = null; - - @JsonProperty("tenantId") - private String tenantId = null; - - @JsonProperty("individualId") - private String individualId = null; - - @JsonProperty("orgId") - private String orgId = null; - - @JsonProperty("contactName") - @Size(min = 2, max = 64) - private String contactName = null; - - @JsonProperty("contactMobileNumber") - @Size(max = 20) - private String contactMobileNumber = null; - - @JsonProperty("contactEmail") - @Size(min = 5, max = 200) - private String contactEmail = null; - - @JsonProperty("active") - private Boolean active; - - @JsonProperty("roles") - @Valid - private List roles; - - @Size(max=50) - @JsonProperty("type") - private String type; - - @Size(max=64) - //@DiffIgnore - @JsonProperty("createdBy") - private String createdBy; - - //@DiffIgnore - @JsonProperty("createdDate") - private Long createdDate; - - @Size(max=64) - //@DiffIgnore - @JsonProperty("lastModifiedBy") - private String lastModifiedBy; - - //@DiffIgnore - @JsonProperty("lastModifiedDate") - private Long lastModifiedDate; - -} diff --git a/core-services/attendance/src/main/java/org/egov/web/models/Organisation/OrgContactUpdateDiff.java b/core-services/attendance/src/main/java/org/egov/web/models/Organisation/OrgContactUpdateDiff.java deleted file mode 100644 index aa4a91ee880..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/Organisation/OrgContactUpdateDiff.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.egov.web.models.Organisation; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.egov.common.contract.request.RequestInfo; - -import java.util.List; - -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class OrgContactUpdateDiff { - - @JsonProperty("RequestInfo") - private RequestInfo requestInfo; - - private String tenantId; - - private String organisationId; - - private List oldContacts; - - private List newContacts; - -} diff --git a/core-services/attendance/src/main/java/org/egov/web/models/RequestInfoWrapper.java b/core-services/attendance/src/main/java/org/egov/web/models/RequestInfoWrapper.java deleted file mode 100644 index b503df65e07..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/RequestInfoWrapper.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.egov.common.contract.request.RequestInfo; -import org.springframework.validation.annotation.Validated; - -/** - * RequestInfoWrapper - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class RequestInfoWrapper { - @JsonProperty("RequestInfo") - private RequestInfo requestInfo = null; - - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/StaffPermission.java b/core-services/attendance/src/main/java/org/egov/web/models/StaffPermission.java deleted file mode 100644 index 428926f22c0..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/StaffPermission.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import digit.models.coremodels.AuditDetails; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.springframework.validation.annotation.Validated; - -import java.math.BigDecimal; - -/** - * StaffPermission - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class StaffPermission { - @JsonProperty("id") - private String id = null; - - @JsonProperty("tenantId") - private String tenantId = null; - - @JsonProperty("registerId") - private String registerId = null; - - @JsonProperty("userId") - private String userId = null; - - @JsonProperty("enrollmentDate") - private BigDecimal enrollmentDate = null; - - @JsonProperty("denrollmentDate") - private BigDecimal denrollmentDate = null; - - @JsonProperty("auditDetails") - private AuditDetails auditDetails = null; - - @JsonProperty("additionalDetails") - private Object additionalDetails = null; - - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/StaffPermissionRequest.java b/core-services/attendance/src/main/java/org/egov/web/models/StaffPermissionRequest.java deleted file mode 100644 index 09a2d4e91d6..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/StaffPermissionRequest.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.egov.common.contract.request.RequestInfo; -import org.springframework.validation.annotation.Validated; - -import java.util.List; - -/** - * StaffPermissionRequest - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class StaffPermissionRequest { - @JsonProperty("RequestInfo") - private RequestInfo requestInfo = null; - - @JsonProperty("staff") - private List staff = null; - - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/StaffPermissionResponse.java b/core-services/attendance/src/main/java/org/egov/web/models/StaffPermissionResponse.java deleted file mode 100644 index c3dd6c40fa8..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/StaffPermissionResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.egov.common.contract.response.ResponseInfo; -import org.springframework.validation.annotation.Validated; - -import java.util.List; - -/** - * StaffPermissionResponse - */ -@Validated -@javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-11-14T14:44:21.051+05:30") - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class StaffPermissionResponse { - @JsonProperty("ResponseInfo") - private ResponseInfo responseInfo = null; - - @JsonProperty("staff") - private List staff = null; - - -} - diff --git a/core-services/attendance/src/main/java/org/egov/web/models/StaffSearchCriteria.java b/core-services/attendance/src/main/java/org/egov/web/models/StaffSearchCriteria.java deleted file mode 100644 index e83287100e5..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/StaffSearchCriteria.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import java.util.List; - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class StaffSearchCriteria { - - @JsonProperty("tenantId") - private String tenantId; - - @JsonProperty("individualIds") - private List individualIds; - - @JsonProperty("registerIds") - private List registerIds; - - @JsonProperty("limit") - private Integer limit; - - @JsonProperty("offset") - private Integer offset; -} diff --git a/core-services/attendance/src/main/java/org/egov/web/models/Status.java b/core-services/attendance/src/main/java/org/egov/web/models/Status.java deleted file mode 100644 index 1f86601f113..00000000000 --- a/core-services/attendance/src/main/java/org/egov/web/models/Status.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.egov.web.models; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * Stores if the register is active or not. Inactive registers can be archieved later. - */ -public enum Status { - - ACTIVE("ACTIVE"), - - INACTIVE("INACTIVE"); - - private final String value; - - Status(String value) { - this.value = value; - } - - @Override - @JsonValue - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static Status fromValue(String text) { - for (Status b : Status.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } -} - diff --git a/core-services/attendance/src/main/resources/Attendace Service Postman Scripts.postman_scripts_collection.json b/core-services/attendance/src/main/resources/Attendace Service Postman Scripts.postman_scripts_collection.json deleted file mode 100644 index d27e9f0effc..00000000000 --- a/core-services/attendance/src/main/resources/Attendace Service Postman Scripts.postman_scripts_collection.json +++ /dev/null @@ -1,3671 +0,0 @@ -{ - "info": { - "_postman_id": "25632b98-5918-4908-8a85-9500d8a81afa", - "name": "Attendace Service Postman Scripts", - "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" - }, - "item": [ - { - "name": "Attendance Register", - "item": [ - { - "name": "Create Attendance Register - Success - Single Register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendance Registers are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendanceRegister).to.not.be.undefined;", - " pm.expect(req.attendanceRegister).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.tenantId).to.be.not.null;", - " pm.expect(register.tenantId).to.be.not.undefined;", - " pm.expect(register.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register Name is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.name).to.be.not.null;", - " pm.expect(register.name).to.be.not.undefined;", - " pm.expect(register.name).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register start date is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.startDate).to.be.not.null;", - " pm.expect(register.startDate).to.be.not.undefined;", - " pm.expect(register.startDate).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Start date should be less than end date\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " if (Number.isFinite(register.endDate) && (register.endDate != undefined || register.endDate != null )) {", - " pm.expect(register.endDate).to.be.not.below(register.startDate);", - " }", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Register Number is enriched\", function () {", - " var res = pm.response.json();", - " var registerNumber = res.attendanceRegister[0].registerNumber;", - " pm.expect(registerNumber.substring(0,2)).to.eql(\"WR\");", - " }", - ");", - "", - "pm.test(\"Register status is set to Active if status not passed\", function () {", - " var res = pm.response.json();", - " var status = res.attendanceRegister[0].status;", - " pm.expect(status).to.eql(\"ACTIVE\");", - " }", - ");", - "", - "pm.test(\"Staff is created for register\", function () {", - " var res = pm.response.json();", - " var staff = res.attendanceRegister[0].staff;", - " pm.expect(staff).to.be.not.null;", - " pm.expect(staff).to.be.not.undefined;", - " pm.expect(staff.length).to.eql(1);", - " }", - ");", - "", - "pm.test(\"Staff created have same userId as UUID of user\", function () {", - " var res = pm.response.json();", - " var userInRequest = res.attendanceRegister[0].auditDetails.createdBy;", - " var staff = res.attendanceRegister[0].staff;", - " pm.expect(staff[0].userId).to.eql(userInRequest);", - " }", - ");", - "", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"tenantId\", responseData.attendanceRegister[0].tenantId);", - "pm.collectionVariables.set(\"stateLevelTenant\", responseData.attendanceRegister[0].tenantId.split('.', 1)[0]);", - "pm.collectionVariables.set(\"registerId\", responseData.attendanceRegister[0].id);", - "pm.collectionVariables.set(\"registerNumber\", responseData.attendanceRegister[0].registerNumber);", - "", - "pm.collectionVariables.set(\"registerStartDate\", responseData.attendanceRegister[0].startDate);", - "pm.collectionVariables.set(\"registerEndDate\", responseData.attendanceRegister[0].endDate);", - "pm.collectionVariables.set(\"invalidRegisterEndDate\", responseData.attendanceRegister[0].endDate+24*60*60*1000);" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "pm.collectionVariables.set(\"tenantId\", \"pb.amritsar\");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Success - Multiple Registers", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendance Registers are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendanceRegister).to.not.be.undefined;", - " pm.expect(req.attendanceRegister).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.tenantId).to.be.not.null;", - " pm.expect(register.tenantId).to.be.not.undefined;", - " pm.expect(register.tenantId).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register Name is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.name).to.be.not.null;", - " pm.expect(register.name).to.be.not.undefined;", - " pm.expect(register.name).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register start date is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.startDate).to.be.not.null;", - " pm.expect(register.startDate).to.be.not.undefined;", - " pm.expect(register.startDate).not.to.eql(\"\");", - " });", - " }", - ");", - " ", - "", - "pm.test(\"Start date should be less than end date\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " if (Number.isFinite(register.endDate) && (register.endDate != undefined || register.endDate != null )) {", - " pm.expect(register.endDate).to.be.not.below(register.startDate);", - " }", - " });", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Register Number is enriched\", function () {", - " var res = pm.response.json();", - " res.attendanceRegister.forEach(register => {", - " var registerNumber = register.registerNumber;", - " pm.expect(registerNumber.substring(0,2)).to.eql(\"WR\");", - " });", - " }", - ");", - "", - "pm.test(\"Staff is created for register\", function () {", - " var res = pm.response.json();", - " res.attendanceRegister.forEach(register => {", - " var staff = register.staff;", - " pm.expect(staff).to.be.not.null;", - " pm.expect(staff).to.be.not.undefined;", - " pm.expect(staff.length).to.eql(1);", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff created have same userId as UUID of user\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var res = pm.response.json();", - " res.attendanceRegister.forEach(register => {", - " var userInRequest = register.auditDetails.createdBy;", - " var staff =register.staff;", - " pm.expect(staff[0].userId).to.eql(userInRequest);", - " }); ", - " }", - ");", - "", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"registerId2\", responseData.attendanceRegister[1].id);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000\n },\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_02\",\n \"startDate\": 1640995200000,\n \"additionalDetails\": {}\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Registers not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"ATTENDANCE_REGISTER\");", - " pm.expect(message).to.eql(\"Attendance Register is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": []\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - TenantId not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"TENANT_ID\");", - " pm.expect(message).to.eql(\"Tenant is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"name\": \"TestRegister_01\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Name not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"NAME\");", - " pm.expect(message).to.eql(\"Name is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Start Date not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"START_DATE\");", - " pm.expect(message).to.eql(\"Start date is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Start Date greater than End Date", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"DATE\");", - " pm.expect(message).to.eql(\"Start date should be less than end date\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"startDate\": 1803980800000,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Create Attendance Register - Validation Error - Start Date Equal to 0", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"START_DATE\");", - " pm.expect(message).to.eql(\"Start date is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_01\",\n \"startDate\": 0,\n \"endDate\": 1703980800000\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " var id = res.attendanceRegister[0].id;", - " pm.expect(id).to.eql(pm.collectionVariables.get(\"registerId\"));", - " }", - ");" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{registerId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{registerId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success - State level tenant", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " var id = res.attendanceRegister[0].id;", - " pm.expect(id).to.eql(pm.collectionVariables.get(\"registerId\"));", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{stateLevelTenant}}&ids={{registerId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{stateLevelTenant}}" - }, - { - "key": "ids", - "value": "{{registerId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success - Unassociated AttendeeId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendanceRegister.length).to.equal(0);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{registerId}}&attendeeId={{$guid}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{registerId}}" - }, - { - "key": "attendeeId", - "value": "{{$guid}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success - Unassociated StaffId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendanceRegister.length).to.equal(0);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{registerId}}&staffId={{$guid}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{registerId}}" - }, - { - "key": "staffId", - "value": "{{$guid}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Success - SuperUser - Non existing RegisterID", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendanceRegister.length).to.equal(0);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids={{$guid}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "{{$guid}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Validation Error - Unassociated Register Id", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " var code = res.attendanceRegister.length;", - " pm.expect(code).to.eql(0);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?tenantId={{tenantId}}&ids=96d1055c-0251-498d-b98d-26d6c232925f", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "ids", - "value": "96d1055c-0251-498d-b98d-26d6c232925f" - } - ] - } - }, - "response": [] - }, - { - "name": "Search Attendance Register - Validation Error - Tenant Id not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"TENANT_ID\");", - " pm.expect(message).to.eql(\"Tenant is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"action\": \"\",\n \"did\": 1,\n \"key\": \"\",\n \"msgId\": \"20170310130900|en_IN\",\n \"requesterId\": \"\",\n \"ts\": 1513579888683,\n \"ver\": \".01\",\n \"authToken\": \"{{token}}\"\n }\n}\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_search?ids={{registerId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_search" - ], - "query": [ - { - "key": "ids", - "value": "{{registerId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Success - Single Register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "", - "pm.test(\"Attendance Registers are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendanceRegister).to.not.be.undefined;", - " pm.expect(req.attendanceRegister).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.tenantId).to.be.not.null;", - " pm.expect(register.tenantId).to.be.not.undefined;", - " pm.expect(register.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register Id is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.id).to.be.not.null;", - " pm.expect(register.id).to.be.not.undefined;", - " pm.expect(register.id).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register Name is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.name).to.be.not.null;", - " pm.expect(register.name).to.be.not.undefined;", - " pm.expect(register.name).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Register start date is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " pm.expect(register.startDate).to.be.not.null;", - " pm.expect(register.startDate).to.be.not.undefined;", - " pm.expect(register.startDate).not.to.eql(\"\");", - " }", - ");", - " ", - "", - "pm.test(\"Start date should be less than end date\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var register = req.attendanceRegister[0];", - " if (Number.isFinite(register.endDate) && (register.endDate != undefined || register.endDate != null )) {", - " pm.expect(register.endDate).to.be.not.below(register.startDate);", - " }", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Staff is created for register\", function () {", - " var res = pm.response.json();", - " var staff = res.attendanceRegister[0].staff;", - " pm.expect(staff).to.be.not.null;", - " pm.expect(staff).to.be.not.undefined;", - " pm.expect(staff.length).to.eql(1);", - " }", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_010\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Success - Multiple Registers", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "", - "pm.test(\"Attendance Registers are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendanceRegister).to.not.be.undefined;", - " pm.expect(req.attendanceRegister).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.tenantId).to.be.not.null;", - " pm.expect(register.tenantId).to.be.not.undefined;", - " pm.expect(register.tenantId).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register Id is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.id).to.be.not.null;", - " pm.expect(register.id).to.be.not.undefined;", - " pm.expect(register.id).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register Name is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.name).to.be.not.null;", - " pm.expect(register.name).to.be.not.undefined;", - " pm.expect(register.name).not.to.eql(\"\");", - " });", - " }", - ");", - "", - "pm.test(\"Register start date is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " pm.expect(register.startDate).to.be.not.null;", - " pm.expect(register.startDate).to.be.not.undefined;", - " pm.expect(register.startDate).not.to.eql(\"\");", - " });", - " }", - ");", - " ", - "", - "pm.test(\"Start date should be less than end date\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendanceRegister.forEach(register => {", - " if (Number.isFinite(register.endDate) && (register.endDate != undefined || register.endDate != null )) {", - " pm.expect(register.endDate).to.be.not.below(register.startDate);", - " }", - " });", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_010\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n },\n {\n \"id\": \"{{registerId2}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_020\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"INACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Validation Error - Register Id not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"ATTENDANCE_REGISTER_ID\");", - " pm.expect(message).to.eql(\"Attendance register id is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_010\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Validation Error - Tenant Id not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"TENANT_ID\");", - " pm.expect(message).to.eql(\"Tenant is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"name\": \"TestRegister_010\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Validation Error - Name not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"NAME\");", - " pm.expect(message).to.eql(\"Name is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"startDate\": 1640995200000,\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Update Attendance Register - Validation Error - Start Date not provided", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Correct Error with message and code is received\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " var message = res.Errors[0].message;", - " pm.expect(code).to.eql(\"START_DATE\");", - " pm.expect(message).to.eql(\"Start date is mandatory\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Create Attendance Register\",\n \"authToken\": \"{{token}}\"\n },\n \"attendanceRegister\": [\n {\n \"id\": \"{{registerId}}\",\n \"tenantId\": \"{{tenantId}}\",\n \"name\": \"TestRegister_010\",\n \"endDate\": 1703980800000,\n \"status\": \"ACTIVE\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "v1", - "_update" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Register Permission", - "item": [ - { - "name": "Staff - Enroll - Single Staff", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Enrollment date is enriched\", function () {", - " var res = pm.response.json();", - " var enrollmentDate = res.staff[0].enrollmentDate;", - " pm.expect(enrollmentDate).to.be.not.null;", - " }", - ");", - "", - "// let requestData = JSON.parse(pm.request.body.raw);", - "// pm.collectionVariables.set(\"userId\", requestData.staff[0].userId);", - "", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"userId\", responseData.staff[0].userId);", - "console.log(pm.collectionVariables.get(\"userId\"));", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Enroll the user to register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{$randomUUID}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Enroll - Validation Error - Staff already enrolled to the register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"response is 400. Staff is already enrolled to the register\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "console.log(pm.collectionVariables.get(\"userId\"))" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Enroll the user to register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Enroll - Validation Error - Duplicate staff objects not allowed in enrollment request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - "", - " req.staff.forEach(staff => {", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }); ", - "", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Duplicate objects in request\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Enroll the user to register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"928ca23a-9bec-11ed-a8fc-0242ac120002\",\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"928ca23a-9bec-11ed-a8fc-0242ac120002\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Enroll - Multiple staff", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - "", - " req.staff.forEach(staff => {", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }); ", - "", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Enrollment date is enriched\", function () {", - " var res = pm.response.json();", - " res.staff.forEach(staff => {", - " pm.expect(staff.enrollmentDate).to.be.not.null;", - " }); ", - " }", - ");", - "", - "let requestData = JSON.parse(pm.request.body.raw);", - "pm.collectionVariables.set(\"userId-1\", requestData.staff[0].userId);", - "pm.collectionVariables.set(\"userId-2\", requestData.staff[1].userId);", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Enroll the user to register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{$randomUUID}}\",\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{$randomUUID}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Deenroll - Single staff", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Deenrollment date is enriched\", function () {", - " var res = pm.response.json();", - " var deenrollmentDate = res.staff[0].deenrollmentDate;", - " pm.expect(deenrollmentDate).to.be.not.null;", - " }", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Deenroll staff from register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Deenroll - Validation Error - Staff already denrolled from the register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var staff = req.staff[0];", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Staff already deenrolled from the register\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Deenroll staff from register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Deenroll - Validation Error - Duplicate staff objects in deenrollment request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - "", - " req.staff.forEach(staff => {", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }); ", - "", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Response is 400. Duplicate staff objects in de enrollment request\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Deenroll staff from register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId-1}}\",\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId-1}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Staff - Deenroll - Multiple staff", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Staff are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.staff).to.not.be.undefined;", - " pm.expect(req.staff).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - "", - " req.staff.forEach(staff => {", - " pm.expect(staff.tenantId).to.be.not.null;", - " pm.expect(staff.tenantId).to.be.not.undefined;", - " pm.expect(staff.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Staff registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.registerId).to.be.not.null;", - " pm.expect(staff.registerId).to.be.not.undefined;", - " pm.expect(staff.registerId).not.to.eql(\"\");", - " }); ", - "", - " }", - ");", - "", - "pm.test(\"Staff userId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.staff.forEach(staff => {", - " pm.expect(staff.userId).to.be.not.null;", - " pm.expect(staff.userId).to.be.not.undefined;", - " pm.expect(staff.userId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Deenrollment date is enriched\", function () {", - " var res = pm.response.json();", - " res.staff.forEach(staff => {", - " pm.expect(staff.deenrollmentDate).to.be.not.null;", - " }); ", - " }", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"Deenroll staff from register\",\n \"authToken\":\"{{token}}\"\n },\n \"staff\":[\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId-1}}\",\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\":\"{{registerId}}\",\n \"userId\":\"{{userId-2}}\",\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/staff/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "staff", - "v1", - "_delete" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Individual Enrollment", - "item": [ - { - "name": "Attendee - Enroll - Attendee", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendee are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Enrollment date is enriched\", function () {", - " var res = pm.response.json();", - " var enrollmentDate = res.attendees[0].enrollmentDate;", - " pm.expect(enrollmentDate).to.be.not.null;", - " }", - ");", - "", - "// let requestData = JSON.parse(pm.request.body.raw);", - "// pm.collectionVariables.set(\"individualId\", requestData.attendees[0].individualId);", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"individualId\", responseData.attendees[0].individualId);", - "pm.collectionVariables.set(\"attendeeEnrollmentDate\", responseData.attendees[0].enrollmentDate);", - "", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Enroll attendee to register\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{$randomUUID}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n } \n\n ]\n\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Enroll - Validation Error - Attendee already enrolled", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendee are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Attendee already enrolled to the register\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Enroll attendee to register\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n } \n\n ]\n\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Enroll - Validation Error - Duplicate attendee objects not allowed in request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendee are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Duplicate attendee objects in the request\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Enroll attendee to register\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"928ca23a-9bec-11ed-a8fc-0242ac120002\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"928ca23a-9bec-11ed-a8fc-0242ac120002\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n } \n\n ]\n\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Enroll - Multiple Attendees", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendee are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Enrollment date is enriched\", function () {", - " var res = pm.response.json();", - " res.attendees.forEach(attendee => {", - " pm.expect(attendee.enrollmentDate).to.be.not.null;", - " }); ", - " }", - ");", - "", - "let requestData = JSON.parse(pm.request.body.raw);", - "pm.collectionVariables.set(\"individualId-1\", requestData.attendees[0].individualId);", - "pm.collectionVariables.set(\"individualId-2\", requestData.attendees[1].individualId);", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\": {\n \"apiId\": \"mukta-services\",\n \"ver\": null,\n \"ts\": null,\n \"action\": null,\n \"did\": null,\n \"key\": null,\n \"msgId\": \"Enroll attendee to register\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{$randomUUID}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{$randomUUID}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n } \n\n ]\n\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Deenroll- Single Attendee", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendees are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Deenrollment date is enriched\", function () {", - " var res = pm.response.json();", - " var deenrollmentDate = res.attendees[0].deenrollmentDate;", - " pm.expect(deenrollmentDate).to.be.not.null;", - " }", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"search with from and to values\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Deenroll- Validation Error - Attendee already deenrolled from the register", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendees are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " var attendee = req.attendees[0];", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Attendee already deenrolled from the register\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"search with from and to values\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Deenroll- Validation Error - Duplicate attendee objects in deenrollment request", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendees are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is 400. Duplicate attendee objects in deenrollment request.\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"search with from and to values\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_delete" - ] - } - }, - "response": [] - }, - { - "name": "Attendee - Deenroll- Multiple Attendees", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"RequestInfo is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.RequestInfo).to.not.be.null;", - " pm.expect(req.RequestInfo).to.not.be.undefined;", - " }", - ");", - "", - "pm.test(\"Attendees are required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " pm.expect(req.attendees).to.not.be.undefined;", - " pm.expect(req.attendees).to.not.be.null;", - " }", - ");", - "", - "pm.test(\"TenantId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.tenantId).to.be.not.null;", - " pm.expect(attendee.tenantId).to.be.not.undefined;", - " pm.expect(attendee.tenantId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee registerId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.registerId).to.be.not.null;", - " pm.expect(attendee.registerId).to.be.not.undefined;", - " pm.expect(attendee.registerId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "pm.test(\"Attendee individualId is required\", function () {", - " var req = JSON.parse(pm.request.body.raw);", - " req.attendees.forEach(attendee => {", - " pm.expect(attendee.individualId).to.be.not.null;", - " pm.expect(attendee.individualId).to.be.not.undefined;", - " pm.expect(attendee.individualId).not.to.eql(\"\");", - " }); ", - " }", - ");", - "", - "", - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Deenrollment date is enriched\", function () {", - " var res = pm.response.json();", - " res.attendees.forEach(attendee => {", - " pm.expect(attendee.denrollmentDate).to.be.not.null;", - " }); ", - " }", - ");", - "", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"RequestInfo\":{\n \"apiId\":\"mukta-services\",\n \"ver\":null,\n \"ts\":null,\n \"action\":null,\n \"did\":null,\n \"key\":null,\n \"msgId\":\"search with from and to values\",\n \"authToken\":\"{{token}}\"\n },\n \"attendees\":[\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-1}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n },\n {\n \"registerId\": \"{{registerId}}\",\n \"individualId\": \"{{individualId-2}}\",\n \"enrollmentDate\":null,\n \"denrollmentDate\":null,\n \"tenantId\":\"{{tenantId}}\"\n }\n ]\n}", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/attendee/v1/_delete", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "attendee", - "v1", - "_delete" - ] - } - }, - "response": [] - } - ] - }, - { - "name": "Attendance Log", - "item": [ - { - "name": "Attendance Log - Create - Success", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - " setTimeout( () => {", - "", - " pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var id = res.attendance[0].id;", - " pm.expect(id).to.be.not.null;", - " }", - ");", - " ", - " }, 1000);", - "", - "", - "", - "let responseData = pm.response.json();", - "pm.collectionVariables.set(\"attendanceLogId\", responseData.attendance[0].id);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Update - Success", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Attendance Log updated successfully\", function () {", - " var res = pm.response.json();", - " var status = res.attendance[0].status;", - " pm.expect(status).to.eql(\"INACTIVE\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"id\": \"{{attendanceLogId}}\",\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"INACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ],\r\n \"auditDetails\": {\r\n \"createdBy\": \"47b5ea82-249c-4435-9646-16167fec06df\",\r\n \"lastModifiedBy\": \"47b5ea82-249c-4435-9646-16167fec06df\",\r\n \"createdTime\": 1671090269007,\r\n \"lastModifiedTime\": 1671090269007\r\n }\r\n \r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Update - fail - attendanceId is not valid", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log updated successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"ATTENDANCE_LOG\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"id\": \"{{$randomUUID}}\",\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"INACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ],\r\n \"auditDetails\": {\r\n \"createdBy\": \"47b5ea82-249c-4435-9646-16167fec06df\",\r\n \"lastModifiedBy\": \"47b5ea82-249c-4435-9646-16167fec06df\",\r\n \"createdTime\": 1671090269007,\r\n \"lastModifiedTime\": 1671090269007\r\n }\r\n \r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_update", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_update" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - All logs should belong to same tenantId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"MULTIPLE_TENANTIDS\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n },\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"tenant.id\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - Validate Attendance Log time", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"INVALID_ATTENDANCE_TIME\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{invalidRegisterEndDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - Register should belongs to tenenatId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{$randomUUID}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - All logs should belong to same registerId", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"MULTIPLE_REGISTERIDS\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{registerId}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n },\r\n {\r\n \"registerId\": \"{{$randomUUID}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - User is not authorised", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"UNAUTHORISED_USER\");", - " }", - ");" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": \"{{$randomUUID}}\",\r\n \"individualId\": \"{{individualId}}\",\r\n \"time\": {{attendeeEnrollmentDate}},\r\n \"type\": \"ENTRY\",\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": \"{{tenantId}}\",\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Rearch - Fail - TenantId is required", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"TENANT_ID\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n }\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_search", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_search" - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Rearch - Fail - RegisterId is required", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " var code = res.Errors[0].code;", - " pm.expect(code).to.eql(\"REGISTER_ID\");", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n }\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_search?tenantId={{tenantId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Rearch - Success", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(200))", - ");", - "", - "pm.test(\"Attendance Log created successfully\", function () {", - " var res = pm.response.json();", - " pm.expect(res.attendance).to.be.not.null;", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n }\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_search?tenantId={{tenantId}}®isterId={{registerId}}", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_search" - ], - "query": [ - { - "key": "tenantId", - "value": "{{tenantId}}" - }, - { - "key": "registerId", - "value": "{{registerId}}" - } - ] - } - }, - "response": [] - }, - { - "name": "Attendance Log - Create - Fail - required fields are missing", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Response is successful\", () => ", - " pm.expect(pm.response.to.have.status(400)));", - "", - "pm.test(\"Register Search response is received\", function () {", - " var res = pm.response.json();", - " pm.expect(res.Errors.length).to.equal(5);", - " }", - ");" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\r\n \"RequestInfo\": {\r\n \"apiId\": \"mukta-services\",\r\n \"action\": \"\",\r\n \"did\": 1,\r\n \"key\": \"\",\r\n \"msgId\": \"20170310130900|en_IN\",\r\n \"requesterId\": \"\",\r\n \"ts\": 1513579888683,\r\n \"ver\": \".01\",\r\n \"authToken\":\"{{token}}\"\r\n },\r\n \"attendance\": [\r\n {\r\n \"registerId\": null,\r\n \"individualId\": null,\r\n \"time\": null,\r\n \"type\": null,\r\n \"status\": \"ACTIVE\",\r\n \"tenantId\": null,\r\n \"documentIds\":[\r\n {\r\n \"documentType\": \"documentType\",\r\n \"fileStore\": \"fileStore\",\r\n \"documentUid\": \"documentUid\"\r\n }\r\n \r\n ]\r\n }\r\n ]\r\n}\r\n", - "options": { - "raw": { - "language": "json" - } - } - }, - "url": { - "raw": "{{base_url}}/attendance/log/v1/_create", - "host": [ - "{{base_url}}" - ], - "path": [ - "attendance", - "log", - "v1", - "_create" - ] - } - }, - "response": [] - } - ] - } - ], - "event": [ - { - "listen": "prerequest", - "script": { - "type": "text/javascript", - "exec": [ - "if (pm.environment.get(\"base_url\").includes(\"localhost\")) {", - "", - " var tenantId = \"pb.amritsar\";", - " var id = 1;", - " var uuid = \"11b0e02b-0145-4de2-bc42-c97b96264807\";", - "", - " var roles = [{", - " \"code\": \"SUPERUSER\",", - " \"name\": \"SUPER USER\",", - " \"tenantId\": tenantId", - " }];", - "", - " var userInfo = {", - " \"id\": id,", - " \"uuid\": uuid,", - " \"userName\": \"\",", - " \"name\": \"\",", - " \"mobileNumber\": \"\",", - " \"emailId\": \"\",", - " \"type\": \"\",", - " \"roles\": roles,", - " \"active\": true,", - " \"tenantId\": \"pb.amritsar\"", - " };", - "", - " pm.request.body.raw = pm.request.body.raw.replace('\"{{token}}\"', '\"\", \\n \"userInfo\": ' + JSON.stringify(userInfo));", - "}" - ] - } - }, - { - "listen": "test", - "script": { - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], - "variable": [ - { - "key": "tenantId", - "value": "" - }, - { - "key": "stateLevelTenant", - "value": "" - }, - { - "key": "registerId", - "value": "" - }, - { - "key": "registerNumber", - "value": "" - }, - { - "key": "registerId2", - "value": "" - }, - { - "key": "registerStartDate", - "value": "" - }, - { - "key": "registerEndDate", - "value": "" - }, - { - "key": "invalidRegisterEndDate", - "value": "" - }, - { - "key": "userId", - "value": "" - }, - { - "key": "userId-1", - "value": "" - }, - { - "key": "userId-2", - "value": "" - }, - { - "key": "individualId", - "value": "" - }, - { - "key": "attendeeEnrollmentDate", - "value": "" - }, - { - "key": "individualId-1", - "value": "" - }, - { - "key": "individualId-2", - "value": "" - }, - { - "key": "attendanceLogId", - "value": "" - } - ] -} \ No newline at end of file diff --git a/core-services/attendance/src/main/resources/application.properties b/core-services/attendance/src/main/resources/application.properties deleted file mode 100644 index 014b80f276d..00000000000 --- a/core-services/attendance/src/main/resources/application.properties +++ /dev/null @@ -1,91 +0,0 @@ -server.contextPath=/attendance -server.servlet.contextPath=/attendance -server.port=8023 -app.timezone=UTC -org.egov.detailed.tracing.enabled=true - -#-----------------KAFKA SERVER CONFIGURATIONS--------------------------------# -kafka.config.bootstrap_server_config=localhost:9092 -spring.kafka.consumer.properties.spring.deserializer.value.delegate.class=org.springframework.kafka.support.serializer.JsonDeserializer -spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer -spring.kafka.consumer.group-id=egov-attendance-service -spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer -spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer -#-----------------KAFKA CONSUMER CONFIGURATIONS--------------------------------# -kafka.consumer.config.auto_commit=true -kafka.consumer.config.auto_commit_interval=100 -kafka.consumer.config.session_timeout=15000 -kafka.consumer.config.auto_offset_reset=earliest -#-----------------KAFKA PRODUCER CONFIGURATIONS--------------------------------# -kafka.producer.config.retries_config=0 -kafka.producer.config.batch_size_config=16384 -kafka.producer.config.linger_ms_config=1 -kafka.producer.config.buffer_memory_config=33554432 - -#----------------Postgres Configurations----------------# -spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.url=jdbc:postgresql://localhost:5432/digit-works -spring.datasource.username=postgres -spring.datasource.password=root - -#----------------flyway config----------------# -spring.flyway.enabled=true -spring.flyway.table=attendance_service_schema -spring.flyway.baseline-on-migrate=true - -#----------------MDMS config---------------------# -egov.mdms.host=https://works-dev.digit.org -egov.mdms.search.endpoint=/egov-mdms-service/v1/_search - -#----------------Idgen Config---------------------# -egov.idgen.host=https://works-dev.digit.org -egov.idgen.path=/egov-idgen/id/_generate -egov.idgen.attendance.register.number.name=attendance.register.number - -#---------------Individual service----------------# -works.individual.host=https://works-dev.digit.org -#works.individual.host=http://localhost:9090 -works.individual.search.endpoint=/individual/v1/_search - - -#----------Individual/Staff service integration--------------# -attendance.individual.service.integration.required=false -attendance.staff.service.integration.required=false - -#----------Document Id Verification ----------------------# -attendance.document.id.verification.required=false - -#---------- Attendance log Search config ------------------# -#attendance.service.log.default.offset=0 -#attendance.service.log.default.limit=100 -#attendance.service.log.search.max.limit=200 - -#---------------- Attendance log Topic Config----------------# -attendance.log.kafka.create.topic=save-attendance-log -attendance.log.kafka.update.topic=update-attendance-log - -#--------------Attendance Register Topic Config------------------# -attendance.register.kafka.create.topic=save-attendance -attendance.register.kafka.update.topic=update-attendance -attendance.register.default.offset=0 -attendance.register.default.limit=10 -attendance.register.search.max.limit=1000 - -#-------------- Staff Topic Config------------------# -attendance.staff.kafka.create.topic=save-staff -attendance.staff.kafka.update.topic=update-staff - -#-------------- Attendee Topic Config------------------# -attendance.attendee.kafka.create.topic=save-attendee -attendance.attendee.kafka.update.topic=update-attendee - -#-------------- Update staff for change in contact detail of an organisation------------------# -organisation.contact.details.update.topic=organisation.contact.details.update - -#------------------------Attendance Register Time Extension topic------------------------------# -contracts.revision.topic=contracts-revision - -#------------------------------------------------------------------------------------------------# -#---Attendance Register Search : Comma separated roles that can do open search ------------------# -#------------------------------------------------------------------------------------------------# -attendance.register.open.search.enabled.roles=SUPERUSER,EMPLOYEE \ No newline at end of file diff --git a/core-services/attendance/src/main/resources/attendance-service-db-schema.png b/core-services/attendance/src/main/resources/attendance-service-db-schema.png deleted file mode 100644 index 8fc615db963..00000000000 Binary files a/core-services/attendance/src/main/resources/attendance-service-db-schema.png and /dev/null differ diff --git a/core-services/attendance/src/main/resources/attendance-service-test-coverage-report.png b/core-services/attendance/src/main/resources/attendance-service-test-coverage-report.png deleted file mode 100644 index a4246e0442f..00000000000 Binary files a/core-services/attendance/src/main/resources/attendance-service-test-coverage-report.png and /dev/null differ diff --git a/core-services/attendance/src/main/resources/db/Dockerfile b/core-services/attendance/src/main/resources/db/Dockerfile deleted file mode 100644 index a5699ff7d99..00000000000 --- a/core-services/attendance/src/main/resources/db/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM egovio/flyway:4.1.2 - -COPY ./migration/main /flyway/sql - -COPY migrate.sh /usr/bin/migrate.sh - -RUN chmod +x /usr/bin/migrate.sh - -CMD ["/usr/bin/migrate.sh"] diff --git a/core-services/attendance/src/main/resources/db/migrate.sh b/core-services/attendance/src/main/resources/db/migrate.sh deleted file mode 100644 index 43960b25cdb..00000000000 --- a/core-services/attendance/src/main/resources/db/migrate.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate \ No newline at end of file diff --git a/core-services/attendance/src/main/resources/db/migration/main/V20221122105730__create_attendance_table.sql b/core-services/attendance/src/main/resources/db/migration/main/V20221122105730__create_attendance_table.sql deleted file mode 100644 index 749f02fee46..00000000000 --- a/core-services/attendance/src/main/resources/db/migration/main/V20221122105730__create_attendance_table.sql +++ /dev/null @@ -1,91 +0,0 @@ -CREATE TABLE eg_wms_attendance_register( -id character varying(256), -tenantid character varying(64) NOT NULL, -registernumber character varying(128) NOT NULL, -name character varying(128), -startdate bigint NOT NULL, -enddate bigint NOT NULL, -status character varying(64) NOT NULL, -additionaldetails JSONB, -createdby character varying(256) NOT NULL, -lastmodifiedby character varying(256), -createdtime bigint, -lastmodifiedtime bigint, -CONSTRAINT uk_eg_wms_attendance_register UNIQUE (registernumber), -CONSTRAINT pk_eg_wms_attendance_register PRIMARY KEY (id) -); - -CREATE TABLE eg_wms_attendance_staff( -id character varying(256), -individual_id character varying(64) NOT NULL, -register_id character varying(64) NOT NULL, -enrollment_date bigint NOT NULL, -deenrollment_date bigint NOT NULL, -additionaldetails JSONB, -createdby character varying(256) NOT NULL, -lastmodifiedby character varying(256), -createdtime bigint, -lastmodifiedtime bigint, -CONSTRAINT pk_eg_wms_attendance_staff PRIMARY KEY (id), -CONSTRAINT fk_eg_wms_attendance_staff FOREIGN KEY (register_id) REFERENCES eg_wms_attendance_register (id) -); - -CREATE TABLE eg_wms_staff_permissions( -id character varying(256), -permission_type character varying(64) NOT NULL, -staff_id character varying(64) NOT NULL, -register_id character varying(64) NOT NULL, -additionaldetails JSONB, -createdby character varying(256) NOT NULL, -lastmodifiedby character varying(256), -createdtime bigint, -lastmodifiedtime bigint, -CONSTRAINT pk_eg_wms_staff_permissions PRIMARY KEY (id), -CONSTRAINT fk_eg_wms_register_staff_permissions FOREIGN KEY (register_id) REFERENCES eg_wms_attendance_register (id), -CONSTRAINT fk_eg_wms_staff_permissions FOREIGN KEY (staff_id) REFERENCES eg_wms_attendance_staff (id) -); - -CREATE TABLE eg_wms_attendance_attendee( -id character varying(256), -individual_id character varying(64) NOT NULL, -register_id character varying(64) NOT NULL, -enrollment_date bigint NOT NULL, -deenrollment_date bigint NOT NULL, -additionaldetails JSONB, -createdby character varying(256) NOT NULL, -lastmodifiedby character varying(256), -createdtime bigint, -lastmodifiedtime bigint, -CONSTRAINT pk_eg_wms_attendance_attendee PRIMARY KEY (id), -CONSTRAINT fk_eg_wms_attendance_attendee FOREIGN KEY (register_id) REFERENCES eg_wms_attendance_register (id) -); - -CREATE TABLE eg_wms_attendance_log( -id character varying(256), -individual_id character varying(64) NOT NULL, -register_id character varying(64) NOT NULL, -status character varying(64), -time bigint NOT NULL, -event_type character varying(64), -additionaldetails JSONB, -createdby character varying(256) NOT NULL, -lastmodifiedby character varying(256), -createdtime bigint, -lastmodifiedtime bigint, -CONSTRAINT pk_eg_wms_attendance_log PRIMARY KEY (id), -CONSTRAINT fk_eg_wms_attendance_log FOREIGN KEY (register_id) REFERENCES eg_wms_attendance_register (id) -); - -CREATE TABLE eg_wms_attendance_document( -id character varying(256), -filestore_id character varying(64) NOT NULL, -document_type character varying(64), -attendance_log_id character varying(64) NOT NULL, -additionaldetails JSONB, -createdby character varying(256) NOT NULL, -lastmodifiedby character varying(256), -createdtime bigint, -lastmodifiedtime bigint, -CONSTRAINT pk_eg_wms_attendance_document PRIMARY KEY (id), -CONSTRAINT fk_eg_wms_attendance_document FOREIGN KEY (attendance_log_id) REFERENCES eg_wms_attendance_log (id) -); \ No newline at end of file diff --git a/core-services/attendance/src/main/resources/db/migration/main/V20221124154130__alter_attendance_table.sql b/core-services/attendance/src/main/resources/db/migration/main/V20221124154130__alter_attendance_table.sql deleted file mode 100644 index 3d50ee881db..00000000000 --- a/core-services/attendance/src/main/resources/db/migration/main/V20221124154130__alter_attendance_table.sql +++ /dev/null @@ -1,36 +0,0 @@ -ALTER TABLE eg_wms_attendance_register ALTER COLUMN registernumber TYPE character varying(256); -ALTER TABLE eg_wms_attendance_register ALTER COLUMN name TYPE character varying(256); - -ALTER TABLE eg_wms_attendance_attendee ALTER COLUMN individual_id TYPE character varying(256); -ALTER TABLE eg_wms_attendance_attendee ALTER COLUMN register_id TYPE character varying(256); -ALTER TABLE eg_wms_attendance_attendee ADD COLUMN attendee_type character varying(256); -ALTER TABLE eg_wms_attendance_attendee ADD COLUMN permission_type character varying(256); -ALTER TABLE eg_wms_attendance_attendee ADD COLUMN tenantid character varying(64); - -ALTER TABLE eg_wms_attendance_log ALTER COLUMN individual_id TYPE character varying(256); -ALTER TABLE eg_wms_attendance_log ALTER COLUMN register_id TYPE character varying(256); -ALTER TABLE eg_wms_attendance_log ADD COLUMN tenantid character varying(64); - -ALTER TABLE eg_wms_attendance_document ALTER COLUMN filestore_id TYPE character varying(256); -ALTER TABLE eg_wms_attendance_document ALTER COLUMN attendance_log_id TYPE character varying(256); -ALTER TABLE eg_wms_attendance_document ALTER COLUMN document_type TYPE character varying(256); -ALTER TABLE eg_wms_attendance_document ADD COLUMN tenantid character varying(64); - - -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_log_tenantId ON eg_wms_attendance_log (tenantId); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_log_register_id ON eg_wms_attendance_log (register_id); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_log_time ON eg_wms_attendance_log (time); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_log_individual_id ON eg_wms_attendance_log (individual_id); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_log_status ON eg_wms_attendance_log (status); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_log_createdtime ON eg_wms_attendance_log (createdtime); - -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_register_tenantId ON eg_wms_attendance_register (tenantId); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_register_id ON eg_wms_attendance_register (id); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_register_registernumber ON eg_wms_attendance_register (registernumber); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_register_name ON eg_wms_attendance_register (name); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_register_startdate ON eg_wms_attendance_register (startdate); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_register_enddate ON eg_wms_attendance_register (enddate); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_register_status ON eg_wms_attendance_register (status); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_register_createdtime ON eg_wms_attendance_register (createdtime); - -DROP TABLE IF EXISTS eg_wms_attendance_staff, eg_wms_staff_permissions CASCADE; \ No newline at end of file diff --git a/core-services/attendance/src/main/resources/db/migration/main/V20221130172200__create_attendance_staff_table.sql b/core-services/attendance/src/main/resources/db/migration/main/V20221130172200__create_attendance_staff_table.sql deleted file mode 100644 index 736d2802323..00000000000 --- a/core-services/attendance/src/main/resources/db/migration/main/V20221130172200__create_attendance_staff_table.sql +++ /dev/null @@ -1,17 +0,0 @@ -CREATE TABLE eg_wms_attendance_staff( -id character varying(256), -individual_id character varying(256) NOT NULL, -register_id character varying(256) NOT NULL, -tenantid character varying(64), -enrollment_date bigint NOT NULL, -deenrollment_date bigint, -additionaldetails JSONB, -createdby character varying(256) NOT NULL, -lastmodifiedby character varying(256), -createdtime bigint, -lastmodifiedtime bigint, -CONSTRAINT pk_eg_wms_attendance_staff PRIMARY KEY (id), -CONSTRAINT fk_eg_wms_attendance_staff FOREIGN KEY (register_id) REFERENCES eg_wms_attendance_register (id) -); - -ALTER TABLE eg_wms_attendance_attendee ALTER COLUMN deenrollment_date DROP NOT NULL; \ No newline at end of file diff --git a/core-services/attendance/src/main/resources/db/migration/main/V20221208175400__alter_attendance_attendee_table.sql b/core-services/attendance/src/main/resources/db/migration/main/V20221208175400__alter_attendance_attendee_table.sql deleted file mode 100644 index 65e87f7e6dc..00000000000 --- a/core-services/attendance/src/main/resources/db/migration/main/V20221208175400__alter_attendance_attendee_table.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE eg_wms_attendance_attendee DROP COLUMN attendee_type; -ALTER TABLE eg_wms_attendance_attendee DROP COLUMN permission_type; -ALTER TABLE eg_wms_attendance_document ADD COLUMN status character varying(64); -ALTER TABLE eg_wms_attendance_register ALTER COLUMN enddate DROP NOT NULL; \ No newline at end of file diff --git a/core-services/attendance/src/main/resources/db/migration/main/V20230404011400__alter_attendance_attendee_table.sql b/core-services/attendance/src/main/resources/db/migration/main/V20230404011400__alter_attendance_attendee_table.sql deleted file mode 100644 index 34641634808..00000000000 --- a/core-services/attendance/src/main/resources/db/migration/main/V20230404011400__alter_attendance_attendee_table.sql +++ /dev/null @@ -1,4 +0,0 @@ -ALTER TABLE eg_wms_attendance_register ADD COLUMN referenceid character varying(256); -ALTER TABLE eg_wms_attendance_register ADD COLUMN servicecode character varying(64); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_register_reference_id ON eg_wms_attendance_register (referenceid); -CREATE INDEX IF NOT EXISTS index_eg_wms_attendance_register_service_code ON eg_wms_attendance_register (servicecode); \ No newline at end of file diff --git a/core-services/attendance/src/test/java/org/egov/TestConfiguration.java b/core-services/attendance/src/test/java/org/egov/TestConfiguration.java deleted file mode 100644 index d13056a19e6..00000000000 --- a/core-services/attendance/src/test/java/org/egov/TestConfiguration.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.egov; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.kafka.core.KafkaTemplate; - -import static org.mockito.Mockito.mock; - -@Configuration -public class TestConfiguration { - @Bean - @SuppressWarnings("unchecked") - public KafkaTemplate kafkaTemplate() { - return mock(KafkaTemplate.class); - } -} \ No newline at end of file diff --git a/core-services/attendance/src/test/java/org/egov/enrichment/AttendanceLogEnrichmentTest.java b/core-services/attendance/src/test/java/org/egov/enrichment/AttendanceLogEnrichmentTest.java deleted file mode 100644 index 606b6913854..00000000000 --- a/core-services/attendance/src/test/java/org/egov/enrichment/AttendanceLogEnrichmentTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.egov.enrichment; - -import digit.models.coremodels.AuditDetails; -import lombok.extern.slf4j.Slf4j; -import org.egov.helper.AttendanceLogRequestTestBuilder; -import org.egov.util.AttendanceServiceUtil; -import org.egov.web.models.AttendanceLogRequest; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.lenient; - -@Slf4j -@ExtendWith(MockitoExtension.class) -public class AttendanceLogEnrichmentTest { - - @InjectMocks - private AttendanceLogEnrichment attendanceLogEnrichment; - - @Mock - private AttendanceServiceUtil attendanceServiceUtil; - - @DisplayName("Method validateAttendanceLogRequest: With good request") - @Test - public void enrichAttendanceLogCreateRequestTest_1(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addAttendanceLogWithoutIdAndAuditDetails().build(); - String byUser = attendanceLogRequest.getRequestInfo().getUserInfo().getUuid(); - Long time = System.currentTimeMillis(); - AuditDetails auditDetails = AuditDetails.builder().createdBy(byUser).lastModifiedBy(byUser).createdTime(time).lastModifiedTime(time).build(); - lenient().when(attendanceServiceUtil.getAuditDetails(any(String.class),eq(null),eq(true))).thenReturn(auditDetails); - attendanceLogEnrichment.enrichAttendanceLogCreateRequest(attendanceLogRequest); - assertNotNull(attendanceLogRequest.getAttendance().get(0).getId()); - assertNotNull(attendanceLogRequest.getAttendance().get(0).getAuditDetails()); - assertNotNull(attendanceLogRequest.getAttendance().get(0).getDocumentIds().get(0).getId()); - } -} diff --git a/core-services/attendance/src/test/java/org/egov/enrichment/AttendeeEnrichmentServiceTest.java b/core-services/attendance/src/test/java/org/egov/enrichment/AttendeeEnrichmentServiceTest.java deleted file mode 100644 index c8b4af9f365..00000000000 --- a/core-services/attendance/src/test/java/org/egov/enrichment/AttendeeEnrichmentServiceTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.egov.enrichment; - -import lombok.extern.slf4j.Slf4j; -import org.egov.helper.AttendeeRequestBuilderTest; -import org.egov.util.AttendanceServiceUtil; -import org.egov.web.models.AttendeeCreateRequest; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -@Slf4j -@ExtendWith(MockitoExtension.class) -public class AttendeeEnrichmentServiceTest { - - @Mock - private AttendanceServiceUtil attendanceServiceUtil; - - - @InjectMocks - private AttendeeEnrichmentService attendeeEnrichmentService; - - - - @DisplayName("update enrollmentDate for attendee if enrollment date is null") - @Test - public void shouldEnrichEnrollmentDateWhenEnrollmentDateIsNull() { - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - - attendeeCreateRequest.getAttendees().get(0).setEnrollmentDate(null); - attendeeEnrichmentService.enrichAttendeeOnCreate(attendeeCreateRequest); - - assertNotNull(attendeeCreateRequest.getAttendees().get(0).getEnrollmentDate()); - } -} diff --git a/core-services/attendance/src/test/java/org/egov/enrichment/RegisterEnrichmentTest.java b/core-services/attendance/src/test/java/org/egov/enrichment/RegisterEnrichmentTest.java deleted file mode 100644 index a4a5740f7e7..00000000000 --- a/core-services/attendance/src/test/java/org/egov/enrichment/RegisterEnrichmentTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.egov.enrichment; - -import digit.models.coremodels.IdGenerationResponse; -import digit.models.coremodels.IdResponse; -import lombok.extern.slf4j.Slf4j; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.helper.AttendanceRegisterRequestBuilderTest; -import org.egov.repository.IdGenRepository; -import org.egov.tracer.model.CustomException; -import org.egov.util.AttendanceServiceUtil; -import org.egov.util.IndividualServiceUtil; -import org.egov.web.models.AttendanceRegisterRequest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import java.util.ArrayList; -import java.util.List; - -import static junit.framework.TestCase.assertTrue; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.when; - -@Slf4j -@ExtendWith(MockitoExtension.class) -public class RegisterEnrichmentTest { - - @InjectMocks - private RegisterEnrichment registerEnrichment; - - @Mock - private AttendanceServiceConfiguration config; - - @Mock - private IdGenRepository idGenRepository; - - @Mock - private AttendanceServiceUtil attendanceServiceUtil; - @Mock - private IndividualServiceUtil individualServiceUtil; - - @BeforeEach - void setupBeforeEach() { - when(config.getIdgenAttendanceRegisterNumberName()).thenReturn("attendance.register.number"); - // when(config.getIdgenAttendanceRegisterNumberFormat()).thenReturn("WR/[fy:yyyy-yy]/[cy:MM]/[cy:dd]/[SEQ_ATTENDANCE_REGISTER_NUM]"); - } - - - @DisplayName("Method enrichCreateAttendanceRegister: With IDGEN ERROR code") - @Test - public void enrichCreateAttendanceRegisterTest_1(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().withRequestInfo().addGoodRegister().build(); - - List idResponses = new ArrayList<>(); - IdGenerationResponse idGenerationResponse = IdGenerationResponse.builder().idResponses(idResponses).build(); - - lenient().when(idGenRepository.getId(eq(attendanceRegisterRequest.getRequestInfo()), eq("pb"), eq("attendance.register.number"), eq(""), eq(1))) - .thenReturn(idGenerationResponse); - - CustomException exception = assertThrows(CustomException.class,()->registerEnrichment.enrichRegisterOnCreate(attendanceRegisterRequest)); - assertTrue(exception.getCode().contentEquals("IDGEN ERROR")); - } - - -// @DisplayName("Method enrichCreateAttendanceRegister: With IDGEN ERROR code") -// @Test -// public void enrichCreateAttendanceRegisterTest_2(){ -// AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().withRequestInfo().attendanceRegistersWithoutIdAuditDetailsAndNumber().build(); -// -// IdResponse idResponse = IdResponse.builder().id("WR/2022-23/01/05/01").build(); -// List idResponses = new ArrayList<>(); -// idResponses.add(idResponse); -// IdGenerationResponse idGenerationResponse = IdGenerationResponse.builder().idResponses(idResponses).build(); -// -// lenient().when(idGenRepository.getId(eq(attendanceRegisterRequest.getRequestInfo()), eq("pb"), eq("attendance.register.number"), eq(""), eq(1))) -// .thenReturn(idGenerationResponse); -// -// AuditDetails auditDetails = AuditDetailsTestBuilder.builder().withAuditDetails().build(); -// when(attendanceServiceUtil.getAuditDetails(attendanceRegisterRequest.getRequestInfo().getUserInfo().getUuid(),null,true)).thenReturn(auditDetails); -// Individual dummyIndividual = Individual.builder().individualId(UUID.randomUUID().toString()).build(); -// when(individualServiceUtil.getIndividualDetails(any(), any(), any())).thenReturn(Collections.singletonList(dummyIndividual)); -// -// registerEnrichment.enrichRegisterOnCreate(attendanceRegisterRequest); -// -// assertTrue(attendanceRegisterRequest.getAttendanceRegister().get(0).getId()!=null); -// -// } - -} diff --git a/core-services/attendance/src/test/java/org/egov/enrichment/StaffEnrichmentServiceTest.java b/core-services/attendance/src/test/java/org/egov/enrichment/StaffEnrichmentServiceTest.java deleted file mode 100644 index a327b2a45b8..00000000000 --- a/core-services/attendance/src/test/java/org/egov/enrichment/StaffEnrichmentServiceTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.egov.enrichment; - -import lombok.extern.slf4j.Slf4j; -import org.egov.helper.StaffRequestBuilderTest; -import org.egov.util.AttendanceServiceUtil; -import org.egov.web.models.StaffPermissionRequest; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.junit.jupiter.api.Assertions.assertNotNull; - -@Slf4j -@ExtendWith(MockitoExtension.class) -public class StaffEnrichmentServiceTest { - - @Mock - private AttendanceServiceUtil attendanceServiceUtil; - - @InjectMocks - private StaffEnrichmentService staffEnrichmentService; - - @DisplayName("update enrollmentDate for staff") - @Test - public void shouldEnrichEnrollmentDateWhenEnrollmentDateIsNull() { - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - - staffPermissionRequest.getStaff().get(0).setEnrollmentDate(null); - staffEnrichmentService.enrichStaffPermissionOnCreate(staffPermissionRequest); - - assertNotNull(staffPermissionRequest.getStaff().get(0).getEnrollmentDate()); - } -} diff --git a/core-services/attendance/src/test/java/org/egov/helper/AdditionalFields.java b/core-services/attendance/src/test/java/org/egov/helper/AdditionalFields.java deleted file mode 100644 index b44d55cd0b1..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/AdditionalFields.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.egov.helper; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -import javax.validation.Valid; -import java.util.ArrayList; -import java.util.List; - -/** - * AdditionalFields - */ - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class AdditionalFields { - @JsonProperty("schema") - private String schema = null; - - @JsonProperty("version") - private Integer version = null; - - @JsonProperty("fields") - @Valid - private List fields = null; - - - public AdditionalFields addFieldsItem(Field fieldsItem) { - if (this.fields == null) { - this.fields = new ArrayList<>(); - } - this.fields.add(fieldsItem); - return this; - } - -} \ No newline at end of file diff --git a/core-services/attendance/src/test/java/org/egov/helper/AttendanceLogRequestTestBuilder.java b/core-services/attendance/src/test/java/org/egov/helper/AttendanceLogRequestTestBuilder.java deleted file mode 100644 index 1e11a4ab2a6..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/AttendanceLogRequestTestBuilder.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.egov.helper; - -import org.egov.web.models.AttendanceLog; -import org.egov.web.models.AttendanceLogRequest; - -import java.util.ArrayList; - -public class AttendanceLogRequestTestBuilder { - - private AttendanceLogRequest.AttendanceLogRequestBuilder builder ; - - public AttendanceLogRequestTestBuilder(){ - this.builder = AttendanceLogRequest.builder(); - } - - public static AttendanceLogRequestTestBuilder builder(){ - return new AttendanceLogRequestTestBuilder(); - } - - public AttendanceLogRequest build(){ - return this.builder.build(); - } - - public AttendanceLogRequestTestBuilder withRequestInfo(){ - this.builder.requestInfo(RequestInfoTestBuilder.builder().withCompleteRequestInfo().build()); - return this; - } - - public AttendanceLogRequestTestBuilder withoutRequestInfo(){ - this.builder.requestInfo(null); - return this; - } - - public AttendanceLogRequestTestBuilder withRequestInfoButWithoutUserInfo(){ - this.builder.requestInfo(RequestInfoTestBuilder.builder().requestInfoWithoutUserInfo().build()); - return this; - } - - public AttendanceLogRequestTestBuilder withRequestInfoWithUserInfoButWithOutUUID(){ - this.builder.requestInfo(RequestInfoTestBuilder.builder().requestInfoWithUserInfoButWithOutUUID().build()); - return this; - } - - public AttendanceLogRequestTestBuilder addGoodAttendanceLog(){ - ArrayList logs = new ArrayList<>(); - logs.add(AttendanceLogTestBuilder.builder().addGoodAttendanceLog().build()); - this.builder.attendance(logs); - return this; - } - - public AttendanceLogRequestTestBuilder addAttendanceLogWithoutIdAndAuditDetails(){ - ArrayList logs = new ArrayList<>(); - logs.add(AttendanceLogTestBuilder.builder().addAttendanceLogWithoutIdAndAuditDetails().build()); - this.builder.attendance(logs); - return this; - } - - public AttendanceLogRequestTestBuilder withoutAttendanceLog(){ - this.builder.attendance(null); - return this; - } - - public AttendanceLogRequestTestBuilder attendanceLogWithoutTenantId(){ - ArrayList logs = new ArrayList<>(); - logs.add(AttendanceLogTestBuilder.builder().attendanceLogWithoutTenantId().build()); - this.builder.attendance(logs); - return this; - } - - - public AttendanceLogRequestTestBuilder attendanceLogWithoutIndividualId(){ - ArrayList logs = new ArrayList<>(); - logs.add(AttendanceLogTestBuilder.builder().attendanceLogWithoutIndividualId().build()); - this.builder.attendance(logs); - return this; - } - - public AttendanceLogRequestTestBuilder attendanceLogWithoutType(){ - ArrayList logs = new ArrayList<>(); - logs.add(AttendanceLogTestBuilder.builder().attendanceLogWithoutType().build()); - this.builder.attendance(logs); - return this; - } - - public AttendanceLogRequestTestBuilder attendanceLogWithoutTime(){ - ArrayList logs = new ArrayList<>(); - logs.add(AttendanceLogTestBuilder.builder().attendanceLogWithoutTime().build()); - this.builder.attendance(logs); - return this; - } - - public AttendanceLogRequestTestBuilder attendanceLogWithoutRegisterId() { - ArrayList logs = new ArrayList<>(); - logs.add(AttendanceLogTestBuilder.builder().attendanceLogWithoutRegisterId().build()); - this.builder.attendance(logs); - return this; - } -} diff --git a/core-services/attendance/src/test/java/org/egov/helper/AttendanceLogTestBuilder.java b/core-services/attendance/src/test/java/org/egov/helper/AttendanceLogTestBuilder.java deleted file mode 100644 index 4f3b3100973..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/AttendanceLogTestBuilder.java +++ /dev/null @@ -1,123 +0,0 @@ -package org.egov.helper; - -import org.egov.web.models.AttendanceLog; -import org.egov.web.models.Status; - -import java.math.BigDecimal; -import java.util.Collections; - -public class AttendanceLogTestBuilder { - private AttendanceLog.AttendanceLogBuilder builder ; - public AttendanceLogTestBuilder(){ - this.builder = AttendanceLog.builder(); - } - - public static AttendanceLogTestBuilder builder(){ - return new AttendanceLogTestBuilder(); - } - - public AttendanceLog build(){ - return this.builder.build(); - } - - public AttendanceLogTestBuilder addGoodAttendanceLog(){ - this.builder - .id("some-id") - .tenantId("some-tenantId") - .registerId("some-registerId") - .individualId("some-individualId") - .time(BigDecimal.valueOf(1672813896627L)) - .type("some-type") - .status(Status.ACTIVE) - .documentIds(Collections.singletonList(DocumentTestBuilder.builder().addGoodDocument().build())) - .auditDetails(AuditDetailsTestBuilder.builder().withAuditDetails().build()) - ; - return this; - } - - public AttendanceLogTestBuilder addAttendanceLogWithoutIdAndAuditDetails(){ - this.builder - .tenantId("some-tenantId") - .registerId("some-registerId") - .individualId("some-individualId") - .time(BigDecimal.valueOf(1672813896627L)) - .type("some-type") - .status(Status.ACTIVE) - .documentIds(Collections.singletonList(DocumentTestBuilder.builder().addDocumentWithoutId().build())) - .auditDetails(null) - ; - return this; - } - - public AttendanceLogTestBuilder attendanceLogWithoutTenantId(){ - this.builder - .id("some-id") - .registerId("some-registerId") - .individualId("some-individualId") - .time(BigDecimal.valueOf(1L)) - .type("some-type") - .status(Status.ACTIVE) - .documentIds(Collections.singletonList(DocumentTestBuilder.builder().addGoodDocument().build())) - .auditDetails(AuditDetailsTestBuilder.builder().withAuditDetails().build()) - ; - return this; - } - - public AttendanceLogTestBuilder attendanceLogWithoutRegisterId(){ - this.builder - .id("some-id") - .tenantId("some-tenantId") - .individualId("some-individualId") - .time(BigDecimal.valueOf(1L)) - .type("some-type") - .status(Status.ACTIVE) - .documentIds(Collections.singletonList(DocumentTestBuilder.builder().addGoodDocument().build())) - .auditDetails(AuditDetailsTestBuilder.builder().withAuditDetails().build()) - ; - return this; - } - - public AttendanceLogTestBuilder attendanceLogWithoutIndividualId(){ - this.builder - .id("some-id") - .tenantId("some-tenantId") - .registerId("some-registerId") - .time(BigDecimal.valueOf(1L)) - .type("some-type") - .status(Status.ACTIVE) - .documentIds(Collections.singletonList(DocumentTestBuilder.builder().addGoodDocument().build())) - .auditDetails(AuditDetailsTestBuilder.builder().withAuditDetails().build()) - ; - return this; - } - - public AttendanceLogTestBuilder attendanceLogWithoutType(){ - this.builder - .id("some-id") - .tenantId("some-tenantId") - .registerId("some-registerId") - .individualId("some-individualId") - .time(BigDecimal.valueOf(1L)) - .status(Status.ACTIVE) - .documentIds(Collections.singletonList(DocumentTestBuilder.builder().addGoodDocument().build())) - .auditDetails(AuditDetailsTestBuilder.builder().withAuditDetails().build()) - ; - return this; - } - - public AttendanceLogTestBuilder attendanceLogWithoutTime(){ - this.builder - .id("some-id") - .tenantId("some-tenantId") - .registerId("some-registerId") - .individualId("some-individualId") - .type("some-type") - .status(Status.ACTIVE) - .documentIds(Collections.singletonList(DocumentTestBuilder.builder().addGoodDocument().build())) - .auditDetails(AuditDetailsTestBuilder.builder().withAuditDetails().build()) - ; - return this; - } - - -} diff --git a/core-services/attendance/src/test/java/org/egov/helper/AttendanceRegisterBuilderTest.java b/core-services/attendance/src/test/java/org/egov/helper/AttendanceRegisterBuilderTest.java deleted file mode 100644 index 5a45b759b80..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/AttendanceRegisterBuilderTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.egov.helper; - -import digit.models.coremodels.AuditDetails; -import lombok.extern.slf4j.Slf4j; -import org.egov.common.contract.request.RequestInfo; -import org.egov.common.contract.request.Role; -import org.egov.common.contract.request.User; -import org.egov.common.contract.response.ResponseInfo; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.IndividualEntry; -import org.egov.web.models.StaffPermission; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -@Slf4j -public class AttendanceRegisterBuilderTest { - - public static AttendanceRegister getAttendanceRegister(){ - AttendanceRegister attendanceRegister=AttendanceRegister.builder().id("97ed7da3-753e-426a-b0b0-95dd61029785") - .registerNumber("RGN-67124").name("self help3").startDate(new BigDecimal("1673740800000")) - .endDate(new BigDecimal("1692057600000")).auditDetails(getAuditDetails()).attendees(getAttendees()) - .tenantId("pb.amritsar").staff(getStaff()).build(); - return attendanceRegister; - } - - public static AttendanceRegister getAttendanceRegisterWithoutEndDate(){ - AttendanceRegister attendanceRegister=AttendanceRegister.builder().id("97ed7da3-753e-426a-b0b0-95dd61029785") - .registerNumber("RGN-67124").name("self help3").startDate(new BigDecimal("1673740800000")) - .auditDetails(getAuditDetails()).attendees(getAttendees()) - .tenantId("pb.amritsar").staff(getStaff()).build(); - return attendanceRegister; - } - public static List getAttendees() { - IndividualEntry attendeeOne = IndividualEntry.builder().tenantId("pb.amritsar").id("047dc725-3088-45b4-877a-6bfbaf377df9") - .individualId("8ybdd-3rdh3").registerId("97ed7da3-753e-426a-b0b0-95dd61029785").enrollmentDate(new BigDecimal("1672129633890")) - .denrollmentDate(null).auditDetails(getAuditDetails()).build(); - - IndividualEntry attendeeTwo = IndividualEntry.builder().tenantId("pb.amritsar").id("11b88488-9a7a-48da-b110-dfdc077ef467") - .individualId("8ybdd-3rdha").registerId("97ed7da3-753e-426a-b0b0-95dd61029785").enrollmentDate(new BigDecimal("1671701038563")) - .denrollmentDate(null).auditDetails(getAuditDetails()).build(); - - List attendees=new ArrayList<>(Arrays.asList(attendeeOne,attendeeTwo)); - return attendees; - } - - public static List getStaff(){ - StaffPermission staffOne=StaffPermission.builder().id("03901adb-07c3-4539-9346-4ee5c87e5e1c").userId("8ybdd-3rdhd") - .registerId("97ed7da3-753e-426a-b0b0-95dd61029785").tenantId("pb.amritsar").enrollmentDate(new BigDecimal("1670421853937")) - .denrollmentDate(null).auditDetails(getAuditDetails()).build(); - - StaffPermission staffTwo=StaffPermission.builder().id("156d07fd-2c0c-4882-be03-6b68b98fb15e").userId("8ybdd-3rdhe") - .registerId("97ed7da3-753e-426a-b0b0-95dd61029785").tenantId("pb.amritsar").enrollmentDate(new BigDecimal("1670424209106")) - .denrollmentDate(null).auditDetails(getAuditDetails()).build(); - - List staffList=new ArrayList<>(Arrays.asList(staffOne,staffTwo)); - return staffList; - } - - - - public static AuditDetails getAuditDetails(){ - AuditDetails auditDetails=AuditDetails.builder().createdBy("11b0e02b-0145-4de2-bc42-c97b96264807") - .lastModifiedBy("11b0e02b-0145-4de2-bc42-c97b96264807").createdTime(Long.valueOf("1672129633890")) - .lastModifiedTime(Long.valueOf("1672129855564")).build(); - return auditDetails; - } - - public static List getAttendanceRegisterList(){ - - AttendanceRegister attendanceRegisterOne=AttendanceRegister.builder().id("54215cb7-c7f7-4521-8965-09647454a1f0") - .registerNumber("RGN-67124").name("self help3").startDate(new BigDecimal("1673740800000")) - .endDate(new BigDecimal("1692057600000")).tenantId("pb.amritsar").auditDetails(getAuditDetails()).build(); - - AttendanceRegister attendanceRegisterTwo=AttendanceRegister.builder().id("54215cb7-c7f7-4521-8965-09647454a1f1") - .registerNumber("RGN-67124").name("self help3").startDate(new BigDecimal("1673740800000")) - .endDate(new BigDecimal("1692057600000")).auditDetails(getAuditDetails()).tenantId("pb.amritsar").build(); - - AttendanceRegister attendanceRegisterThree=AttendanceRegister.builder().id("54215cb7-c7f7-4521-8965-09647454a1f2") - .registerNumber("RGN-67124").name("self help3").startDate(new BigDecimal("1673740800000")) - .endDate(new BigDecimal("1692057600000")).auditDetails(getAuditDetails()).tenantId("pb.amritsar").build(); - - List attendanceRegisterList=new ArrayList<>(Arrays.asList(attendanceRegisterOne,attendanceRegisterTwo,attendanceRegisterThree)); - - return attendanceRegisterList; - - - } - - public static RequestInfo getRequestInfo(){ - Role role = new Role(1L,"Organization staff","ORG_STAFF","pb.amritsar"); - List roles = new ArrayList<>(); - roles.add(role); - User userInfo = User.builder().id(172L).uuid("5ce80dd3-b1c0-42fd-b8f6-a2be456db31c").userName("8070102021").name("test3").mobileNumber("8070102021") - .emailId("xyz@egovernments.org").type("EMPLOYEE").roles(roles).build(); - RequestInfo requestInfo = RequestInfo.builder().apiId("attendance-services").msgId("search with from and to values").userInfo(userInfo).build(); - return requestInfo; - } - - public static ResponseInfo getResponseInfo_Success() { - ResponseInfo responseInfo = ResponseInfo.builder().apiId("attendance-services").ver(null).ts(null).resMsgId(null).msgId("search with from and to values") - .status("successful").build(); - return responseInfo; - } -} diff --git a/core-services/attendance/src/test/java/org/egov/helper/AttendanceRegisterRequestBuilderTest.java b/core-services/attendance/src/test/java/org/egov/helper/AttendanceRegisterRequestBuilderTest.java deleted file mode 100644 index e85e94bf423..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/AttendanceRegisterRequestBuilderTest.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.egov.helper; - -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendanceRegisterRequest; -import org.egov.web.models.IndividualEntry; -import org.egov.web.models.StaffPermission; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; - -public class AttendanceRegisterRequestBuilderTest { - - private AttendanceRegisterRequest.AttendanceRegisterRequestBuilder builder ; - - public AttendanceRegisterRequestBuilderTest(){ - this.builder = AttendanceRegisterRequest.builder(); - } - - public static AttendanceRegisterRequestBuilderTest builder(){ - return new AttendanceRegisterRequestBuilderTest(); - } - - public AttendanceRegisterRequest build(){ - return this.builder.build(); - } - - public AttendanceRegisterRequestBuilderTest withRequestInfo(){ - this.builder.requestInfo(RequestInfoTestBuilder.builder().withCompleteRequestInfo().build()); - return this; - } - - public AttendanceRegisterRequestBuilderTest requestInfoWithoutUserInfo(){ - this.builder.requestInfo(RequestInfoTestBuilder.builder().requestInfoWithoutUserInfo().build()); - return this; - } - - public AttendanceRegisterRequestBuilderTest requestInfoWithUserInfoButWithOutUUID(){ - this.builder.requestInfo(RequestInfoTestBuilder.builder().requestInfoWithUserInfoButWithOutUUID().build()); - return this; - } - - public AttendanceRegisterRequestBuilderTest addGoodRegister(){ - ArrayList registers = new ArrayList<>(); - AttendanceRegister attendanceRegister=AttendanceRegister.builder() - .id("97ed7da3-753e-426a-b0b0-95dd61029785") - .registerNumber("RGN-67124") - .tenantId("pb.amritsar") - .name("self help3") - .startDate(new BigDecimal("1673740800000")) - .endDate(new BigDecimal("1692057600000")) - .serviceCode("serviceCode") - .referenceId("referenceId") - .auditDetails(AuditDetailsTestBuilder.builder().build()) - .attendees(Collections.singletonList(IndividualEntry.builder().build())) - .staff(Collections.singletonList(StaffPermission.builder().build())) - .build(); - registers.add(attendanceRegister); - this.builder.attendanceRegister(registers); - return this; - } - - - public AttendanceRegisterRequestBuilderTest attendanceRegistersWithoutIdAuditDetailsAndNumber(){ - ArrayList registers = new ArrayList<>(); - AttendanceRegister attendanceRegister=AttendanceRegister.builder() - .tenantId("pb.amritsar") - .name("self help3") - .startDate(new BigDecimal("1673740800000")) - .endDate(new BigDecimal("1692057600000")) - .auditDetails(null) - .attendees(Collections.singletonList(IndividualEntry.builder().build())) - .staff(Collections.singletonList(StaffPermission.builder().build())) - .build(); - registers.add(attendanceRegister); - this.builder.attendanceRegister(registers); - return this; - } - - public AttendanceRegisterRequestBuilderTest attendanceRegistersWithMultipleTenantIds(){ - ArrayList registers = new ArrayList<>(); - AttendanceRegister attendanceRegister1=AttendanceRegister.builder() - .id("97ed7da3-753e-426a-b0b0-95dd61029785") - .registerNumber("RGN-67124") - .tenantId("pb.amritsar") - .name("self help3") - .startDate(new BigDecimal("1673740800000")) - .endDate(new BigDecimal("1692057600000")) - .auditDetails(AuditDetailsTestBuilder.builder().build()) - .attendees(Collections.singletonList(IndividualEntry.builder().build())) - .staff(Collections.singletonList(StaffPermission.builder().build())) - .build(); - - AttendanceRegister attendanceRegister2=AttendanceRegister.builder() - .id("97ed7da3-753e-426a-b0b0-95dd61029785") - .registerNumber("RGN-67124") - .tenantId("pb.jalandhar") - .name("self help3") - .startDate(new BigDecimal("1673740800000")) - .endDate(new BigDecimal("1692057600000")) - .auditDetails(AuditDetailsTestBuilder.builder().build()) - .attendees(Collections.singletonList(IndividualEntry.builder().build())) - .staff(Collections.singletonList(StaffPermission.builder().build())) - .build(); - - registers.add(attendanceRegister1); - registers.add(attendanceRegister2); - this.builder.attendanceRegister(registers); - return this; - } - - public AttendanceRegisterRequestBuilderTest attendanceRegisterWithoutTenantId(){ - ArrayList registers = new ArrayList<>(); - AttendanceRegister attendanceRegister=AttendanceRegister.builder() - .id("97ed7da3-753e-426a-b0b0-95dd61029785") - .registerNumber("RGN-67124") - .name("self help3") - .startDate(new BigDecimal("1673740800000")) - .endDate(new BigDecimal("1692057600000")) - .auditDetails(AuditDetailsTestBuilder.builder().build()) - .attendees(Collections.singletonList(IndividualEntry.builder().build())) - .staff(Collections.singletonList(StaffPermission.builder().build())) - .build(); - registers.add(attendanceRegister); - this.builder.attendanceRegister(registers); - return this; - } - - public AttendanceRegisterRequestBuilderTest attendanceRegisterWithoutName(){ - ArrayList registers = new ArrayList<>(); - AttendanceRegister attendanceRegister=AttendanceRegister.builder() - .id("97ed7da3-753e-426a-b0b0-95dd61029785") - .registerNumber("RGN-67124") - .tenantId("tenant.id") - .startDate(new BigDecimal("1673740800000")) - .endDate(new BigDecimal("1692057600000")) - .auditDetails(AuditDetailsTestBuilder.builder().build()) - .attendees(Collections.singletonList(IndividualEntry.builder().build())) - .staff(Collections.singletonList(StaffPermission.builder().build())) - .build(); - registers.add(attendanceRegister); - this.builder.attendanceRegister(registers); - return this; - } - - public AttendanceRegisterRequestBuilderTest attendanceRegisterWithoutStartDate(){ - ArrayList registers = new ArrayList<>(); - AttendanceRegister attendanceRegister=AttendanceRegister.builder() - .id("97ed7da3-753e-426a-b0b0-95dd61029785") - .registerNumber("RGN-67124") - .name("some-name") - .tenantId("tenant.id") - .endDate(new BigDecimal("1692057600000")) - .auditDetails(AuditDetailsTestBuilder.builder().build()) - .attendees(Collections.singletonList(IndividualEntry.builder().build())) - .staff(Collections.singletonList(StaffPermission.builder().build())) - .build(); - registers.add(attendanceRegister); - this.builder.attendanceRegister(registers); - return this; - } - - public AttendanceRegisterRequestBuilderTest attendanceRegisterWithStartDateGTEndDate(){ - ArrayList registers = new ArrayList<>(); - AttendanceRegister attendanceRegister=AttendanceRegister.builder() - .id("97ed7da3-753e-426a-b0b0-95dd61029785") - .registerNumber("RGN-67124") - .name("some-name") - .tenantId("tenant.id") - .startDate(new BigDecimal("1692057600000")) - .endDate(new BigDecimal("1673740800000")) - .auditDetails(AuditDetailsTestBuilder.builder().build()) - .attendees(Collections.singletonList(IndividualEntry.builder().build())) - .staff(Collections.singletonList(StaffPermission.builder().build())) - .build(); - registers.add(attendanceRegister); - this.builder.attendanceRegister(registers); - return this; - } - -} diff --git a/core-services/attendance/src/test/java/org/egov/helper/AttendeeRequestBuilderTest.java b/core-services/attendance/src/test/java/org/egov/helper/AttendeeRequestBuilderTest.java deleted file mode 100644 index ee49a09103f..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/AttendeeRequestBuilderTest.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.egov.helper; - -import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.io.FileUtils; -import org.egov.common.contract.request.RequestInfo; -import org.egov.common.contract.request.Role; -import org.egov.common.contract.request.User; -import org.egov.common.contract.response.ResponseInfo; -import org.egov.web.models.AttendeeCreateRequest; -import org.egov.web.models.IndividualEntry; - -import java.io.File; -import java.math.BigDecimal; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -@Slf4j -public class AttendeeRequestBuilderTest { - - public static AttendeeCreateRequest getAttendeeCreateRequest(){ - AttendeeCreateRequest attendeeCreateRequest=AttendeeCreateRequest.builder().requestInfo(getRequestInfo()) - .attendees(getAttendees()).build(); - return attendeeCreateRequest; - } - - public static List getAttendees(){ - IndividualEntry attendeeOne=IndividualEntry.builder().tenantId("pb.amritsar").id("047dc725-3088-45b4-877a-6bfbaf377df9") - .individualId("8ybdd-3rdh3").registerId("97ed7da3-753e-426a-b0b0-95dd61029785").enrollmentDate(new BigDecimal("1676101018000")) - .denrollmentDate(new BigDecimal("1676073600000")).auditDetails(getAuditDetails()).build(); - - IndividualEntry attendeeTwo=IndividualEntry.builder().tenantId("pb.amritsar").id("11b88488-9a7a-48da-b110-dfdc077ef467") - .individualId("8ybdd-3rdha").registerId("97ed7da3-753e-426a-b0b0-95dd61029785").enrollmentDate(new BigDecimal("1676101018000")) - .denrollmentDate(new BigDecimal("1671707969802")).auditDetails(getAuditDetails()).build(); - - - - List attendeeList=new ArrayList<>(Arrays.asList(attendeeOne,attendeeTwo)); - return attendeeList; - } - - public static AuditDetails getAuditDetails(){ - AuditDetails auditDetails=AuditDetails.builder().createdBy("11b0e02b-0145-4de2-bc42-c97b96264807") - .lastModifiedBy("11b0e02b-0145-4de2-bc42-c97b96264807").createdTime(Long.valueOf("1672129633890")) - .lastModifiedTime(Long.valueOf("1672129855564")).build(); - return auditDetails; - } - - public static RequestInfo getRequestInfo(){ - Role role = new Role(1L,"Organization staff","ORG_STAFF","pb.amritsar"); - List roles = new ArrayList<>(); - roles.add(role); - User userInfo = User.builder().id(172L).uuid("5ce80dd3-b1c0-42fd-b8f6-a2be456db31c").userName("8070102021").name("test3").mobileNumber("8070102021") - .emailId("xyz@egovernments.org").type("EMPLOYEE").roles(roles).build(); - RequestInfo requestInfo = RequestInfo.builder().apiId("attendance-services").msgId("search with from and to values").userInfo(userInfo).build(); - return requestInfo; - } - - public static Object getMdmsResponseForValidTenant() { - - Object mdmsResponse = null; - - try { - ObjectMapper objectMapper = new ObjectMapper(); - File file = new File("src/test/resources/TenantMDMSData.json"); - String exampleRequest = FileUtils.readFileToString(file, StandardCharsets.UTF_8); - mdmsResponse = objectMapper.readValue(exampleRequest, Object.class); - } catch (Exception exception) { - log.error("AttendeeRequestBuilderTest::getMdmsResponse::Exception while parsing mdms json"); - } - return mdmsResponse; - } - - public static Object getMdmsResponseForInvalidTenant() { - - Object mdmsResponse = null; - - try { - ObjectMapper objectMapper = new ObjectMapper(); - File file = new File("src/test/resources/InvalidTenantMDMSData.json"); - String exampleRequest = FileUtils.readFileToString(file, StandardCharsets.UTF_8); - mdmsResponse = objectMapper.readValue(exampleRequest, Object.class); - } catch (Exception exception) { - log.error("AttendeeRequestBuilderTest::getMdmsResponse::Exception while parsing mdms json"); - } - return mdmsResponse; - } - - public static ResponseInfo getResponseInfo_Success() { - ResponseInfo responseInfo = ResponseInfo.builder().apiId("attendance-services").ver(null).ts(null).resMsgId(null).msgId("search with from and to values") - .status("successful").build(); - return responseInfo; - } -} diff --git a/core-services/attendance/src/test/java/org/egov/helper/AuditDetailsTestBuilder.java b/core-services/attendance/src/test/java/org/egov/helper/AuditDetailsTestBuilder.java deleted file mode 100644 index 2dd9a6fa044..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/AuditDetailsTestBuilder.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.egov.helper; - -import digit.models.coremodels.AuditDetails; - -public class AuditDetailsTestBuilder { - private AuditDetails.AuditDetailsBuilder builder; - - public AuditDetailsTestBuilder() { - this.builder = AuditDetails.builder(); - } - - public static AuditDetailsTestBuilder builder() { - return new AuditDetailsTestBuilder(); - } - - public AuditDetails build() { - return this.builder.build(); - } - - public AuditDetailsTestBuilder withAuditDetails() { - this.builder.createdTime(System.currentTimeMillis()) - .createdBy("some-uuid") - .lastModifiedTime(System.currentTimeMillis()) - .lastModifiedBy("some-uuid"); - return this; - } -} \ No newline at end of file diff --git a/core-services/attendance/src/test/java/org/egov/helper/DocumentTestBuilder.java b/core-services/attendance/src/test/java/org/egov/helper/DocumentTestBuilder.java deleted file mode 100644 index ef1a0872e51..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/DocumentTestBuilder.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.egov.helper; - - -import org.egov.web.models.Document; -import org.egov.web.models.Status; - -public class DocumentTestBuilder { - private Document.DocumentBuilder builder; - - public DocumentTestBuilder(){ - this.builder = Document.builder(); - } - - public Document build(){ - return this.builder.build(); - } - - public static DocumentTestBuilder builder(){ - return new DocumentTestBuilder(); - } - - public DocumentTestBuilder addGoodDocument(){ - this.builder - .id("Id-1") - .fileStore("FileStore-1") - .documentUid("DocumentUid-1") - .additionalDetails(new Object()) - .status(Status.fromValue("ACTIVE")) - .additionalDetails(AdditionalFields.builder().build()); - - return this; - } - - public DocumentTestBuilder addDocumentWithoutId(){ - this.builder - .fileStore("FileStore-1") - .documentUid("DocumentUid-1") - .additionalDetails(new Object()) - .status(Status.fromValue("ACTIVE")) - .additionalDetails(AdditionalFields.builder().build()); - - return this; - } - -} diff --git a/core-services/attendance/src/test/java/org/egov/helper/Field.java b/core-services/attendance/src/test/java/org/egov/helper/Field.java deleted file mode 100644 index f23ea8cea75..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/Field.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.egov.helper; - -import com.fasterxml.jackson.annotation.JsonProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - -/** - * Field - */ - - -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class Field { - @JsonProperty("key") - private String key = null; - - @JsonProperty("value") - private String value = null; - - -} \ No newline at end of file diff --git a/core-services/attendance/src/test/java/org/egov/helper/IndividualEntryBuilderTest.java b/core-services/attendance/src/test/java/org/egov/helper/IndividualEntryBuilderTest.java deleted file mode 100644 index 484f9d5f7a3..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/IndividualEntryBuilderTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.egov.helper; - - - -import org.egov.web.models.IndividualEntry; - -import java.math.BigDecimal; - -public class IndividualEntryBuilderTest { - private IndividualEntry.IndividualEntryBuilder builder; - public IndividualEntryBuilderTest() { - this.builder = IndividualEntry.builder(); - } - - public static StaffPermissionBuilderTest builder() { - return new StaffPermissionBuilderTest(); - } - - public IndividualEntry build() { - return this.builder.build(); - } - - public void addGoodStaffPermission(){ - this.builder.id("some_id") - .tenantId("some_tenantId") - .registerId("some_registerId") - .individualId("some_individualId") - .enrollmentDate(BigDecimal.valueOf(1640995200000L)) - .denrollmentDate(BigDecimal.valueOf(1703980800000L)) - .auditDetails(AuditDetailsTestBuilder.builder().withAuditDetails().build()) - .additionalDetails(AdditionalFields.builder().build()); - } - -} diff --git a/core-services/attendance/src/test/java/org/egov/helper/RequestInfoTestBuilder.java b/core-services/attendance/src/test/java/org/egov/helper/RequestInfoTestBuilder.java deleted file mode 100644 index a4173a112b3..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/RequestInfoTestBuilder.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.egov.helper; - -import org.egov.common.contract.request.RequestInfo; - - -public class RequestInfoTestBuilder { - private RequestInfo.RequestInfoBuilder builder; - - public RequestInfoTestBuilder() { - this.builder = RequestInfo.builder(); - } - - public static RequestInfoTestBuilder builder() { - return new RequestInfoTestBuilder(); - } - - public RequestInfo build() { - return this.builder.build(); - } - - public RequestInfoTestBuilder withCompleteRequestInfo() { - this.builder.userInfo(UserTestBuilder.builder().withCompleteUserInfo().build()) - .action("create") - .apiId("some-api-id") - .authToken("some-auth-token") - .did("some-did") - .correlationId("some-correlation-id") - .key("some-key") - .msgId("some-msg-id") - .ts(System.currentTimeMillis()) - .ver("1"); - return this; - } - - public RequestInfoTestBuilder requestInfoWithUserInfoButWithOutUUID() { - this.builder.userInfo(UserTestBuilder.builder().userInfoWithOutUUID().build()) - .action("create") - .apiId("some-api-id") - .authToken("some-auth-token") - .did("some-did") - .correlationId("some-correlation-id") - .key("some-key") - .msgId("some-msg-id") - .ts(System.currentTimeMillis()) - .ver("1"); - return this; - } - - public RequestInfoTestBuilder requestInfoWithoutUserInfo() { - this.builder.userInfo(null) - .action("create") - .apiId("some-api-id") - .authToken("some-auth-token") - .did("some-did") - .correlationId("some-correlation-id") - .key("some-key") - .msgId("some-msg-id") - .ts(System.currentTimeMillis()) - .ver("1"); - return this; - } -} \ No newline at end of file diff --git a/core-services/attendance/src/test/java/org/egov/helper/StaffPermissionBuilderTest.java b/core-services/attendance/src/test/java/org/egov/helper/StaffPermissionBuilderTest.java deleted file mode 100644 index 3d784d5235b..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/StaffPermissionBuilderTest.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.egov.helper; - -import org.egov.web.models.StaffPermission; - -import java.math.BigDecimal; - -public class StaffPermissionBuilderTest { - - private StaffPermission.StaffPermissionBuilder builder; - public StaffPermissionBuilderTest() { - this.builder = StaffPermission.builder(); - } - - public static StaffPermissionBuilderTest builder() { - return new StaffPermissionBuilderTest(); - } - - public StaffPermission build() { - return this.builder.build(); - } - - public void addGoodStaffPermission(){ - this.builder.id("some_id") - .tenantId("some_tenantId") - .registerId("some_registerId") - .userId("some_userId") - .enrollmentDate(BigDecimal.valueOf(1640995200000L)) - .denrollmentDate(BigDecimal.valueOf(1703980800000L)) - .auditDetails(AuditDetailsTestBuilder.builder().withAuditDetails().build()) - .additionalDetails(AdditionalFields.builder().build()); - } - -} diff --git a/core-services/attendance/src/test/java/org/egov/helper/StaffRequestBuilderTest.java b/core-services/attendance/src/test/java/org/egov/helper/StaffRequestBuilderTest.java deleted file mode 100644 index d0ab6f0b901..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/StaffRequestBuilderTest.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.egov.helper; - -import com.fasterxml.jackson.databind.ObjectMapper; -import digit.models.coremodels.AuditDetails; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.io.FileUtils; -import org.egov.common.contract.request.RequestInfo; -import org.egov.common.contract.request.Role; -import org.egov.common.contract.request.User; -import org.egov.common.contract.response.ResponseInfo; -import org.egov.web.models.StaffPermission; -import org.egov.web.models.StaffPermissionRequest; - -import java.io.File; -import java.math.BigDecimal; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -@Slf4j -public class StaffRequestBuilderTest { - - public static StaffPermissionRequest getStaffPermissionRequest() { - StaffPermissionRequest staffPermissionRequest = StaffPermissionRequest.builder().requestInfo(getRequestInfo()) - .staff(getStaff()).build(); - return staffPermissionRequest; - } - - - public static List getStaff() { - StaffPermission staffOne = StaffPermission.builder().id("03901adb-07c3-4539-9346-4ee5c87e5e1c").userId("8ybdd-3rdhd") - .registerId("97ed7da3-753e-426a-b0b0-95dd61029785").tenantId("pb.amritsar").enrollmentDate(new BigDecimal("1670421853937")) - .denrollmentDate(null).auditDetails(getAuditDetails()).build(); - - StaffPermission staffTwo = StaffPermission.builder().id("156d07fd-2c0c-4882-be03-6b68b98fb15e").userId("8ybdd-3rdhe") - .registerId("97ed7da3-753e-426a-b0b0-95dd61029785").tenantId("pb.amritsar").enrollmentDate(new BigDecimal("1670424209106")) - .denrollmentDate(null).auditDetails(getAuditDetails()).build(); - - List staffList = new ArrayList<>(Arrays.asList(staffOne, staffTwo)); - return staffList; - } - - - public static AuditDetails getAuditDetails() { - AuditDetails auditDetails = AuditDetails.builder().createdBy("11b0e02b-0145-4de2-bc42-c97b96264807") - .lastModifiedBy("11b0e02b-0145-4de2-bc42-c97b96264807").createdTime(Long.valueOf("1672129633890")) - .lastModifiedTime(Long.valueOf("1672129855564")).build(); - return auditDetails; - } - - public static RequestInfo getRequestInfo() { - Role role = new Role(1L, "Organization staff", "ORG_STAFF", "pb.amritsar"); - List roles = new ArrayList<>(); - roles.add(role); - User userInfo = User.builder().id(172L).uuid("5ce80dd3-b1c0-42fd-b8f6-a2be456db31c").userName("8070102021").name("test3").mobileNumber("8070102021") - .emailId("xyz@egovernments.org").type("EMPLOYEE").roles(roles).build(); - RequestInfo requestInfo = RequestInfo.builder().apiId("attendance-services").msgId("search with from and to values").userInfo(userInfo).build(); - return requestInfo; - } - - public static Object getMdmsResponseForValidTenant() { - - Object mdmsResponse = null; - - try { - ObjectMapper objectMapper = new ObjectMapper(); - File file = new File("src/test/resources/TenantMDMSData.json"); - String exampleRequest = FileUtils.readFileToString(file, StandardCharsets.UTF_8); - mdmsResponse = objectMapper.readValue(exampleRequest, Object.class); - } catch (Exception exception) { - log.error("AttendeeRequestBuilderTest::getMdmsResponse::Exception while parsing mdms json"); - } - return mdmsResponse; - } - - public static Object getMdmsResponseForInvalidTenant() { - - Object mdmsResponse = null; - - try { - ObjectMapper objectMapper = new ObjectMapper(); - File file = new File("src/test/resources/InvalidTenantMDMSData.json"); - String exampleRequest = FileUtils.readFileToString(file, StandardCharsets.UTF_8); - mdmsResponse = objectMapper.readValue(exampleRequest, Object.class); - } catch (Exception exception) { - log.error("AttendeeRequestBuilderTest::getMdmsResponse::Exception while parsing mdms json"); - } - return mdmsResponse; - } - - public static ResponseInfo getResponseInfo_Success() { - ResponseInfo responseInfo = ResponseInfo.builder().apiId("attendance-services").ver(null).ts(null).resMsgId(null).msgId("search with from and to values") - .status("successful").build(); - return responseInfo; - } -} diff --git a/core-services/attendance/src/test/java/org/egov/helper/UserTestBuilder.java b/core-services/attendance/src/test/java/org/egov/helper/UserTestBuilder.java deleted file mode 100644 index 2aca7685ecc..00000000000 --- a/core-services/attendance/src/test/java/org/egov/helper/UserTestBuilder.java +++ /dev/null @@ -1,58 +0,0 @@ -package org.egov.helper; - -import org.egov.common.contract.request.Role; -import org.egov.common.contract.request.User; - -import java.util.ArrayList; -import java.util.List; - -public class UserTestBuilder { - private User.UserBuilder builder; - - public UserTestBuilder() { - this.builder = User.builder(); - } - - public static UserTestBuilder builder() { - return new UserTestBuilder(); - } - - public User build() { - return this.builder.build(); - } - - public UserTestBuilder withCompleteUserInfo() { - Role role = Role.builder() - .id(123L) - .name("System Administrator") - .build(); - List roles = new ArrayList<>(); - roles.add(role); - this.builder.userName("some-username") - .roles(roles) - .id(123L) - .name("some-name") - .type("EMPLOYEE") - .emailId("some-email-id") - .mobileNumber("9893212345") - .uuid("some-uuid"); - return this; - } - - public UserTestBuilder userInfoWithOutUUID() { - Role role = Role.builder() - .id(123L) - .name("System Administrator") - .build(); - List roles = new ArrayList<>(); - roles.add(role); - this.builder.userName("some-username") - .roles(roles) - .id(123L) - .name("some-name") - .type("EMPLOYEE") - .emailId("some-email-id") - .mobileNumber("9893212345"); - return this; - } -} \ No newline at end of file diff --git a/core-services/attendance/src/test/java/org/egov/service/AttendanceLogServiceTest.java b/core-services/attendance/src/test/java/org/egov/service/AttendanceLogServiceTest.java deleted file mode 100644 index ef3743f700a..00000000000 --- a/core-services/attendance/src/test/java/org/egov/service/AttendanceLogServiceTest.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.egov.service; - -import lombok.extern.slf4j.Slf4j; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.enrichment.AttendanceLogEnrichment; -import org.egov.helper.AttendanceLogRequestTestBuilder; -import org.egov.kafka.Producer; -import org.egov.util.ResponseInfoFactory; -import org.egov.validator.AttendanceLogServiceValidator; -import org.egov.web.models.AttendanceLogRequest; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import static org.hibernate.validator.internal.util.Contracts.assertNotNull; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.eq; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -@Slf4j -@ExtendWith(MockitoExtension.class) -public class AttendanceLogServiceTest { - - @InjectMocks - private AttendanceLogService attendanceLogService; - - @Mock - private AttendanceLogServiceValidator attendanceLogServiceValidator; - - - @Mock - private ResponseInfoFactory responseInfoFactory; - - - @Mock - private AttendanceLogEnrichment attendanceLogEnricher; - - @Mock - private Producer producer; - - @Mock - private AttendanceServiceConfiguration config; - - - @DisplayName("create attendance log successfully") - @Test - public void createAttendanceLogTest_1(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - when(config.getCreateAttendanceLogTopic()).thenReturn("save-attendance-log"); - - attendanceLogService.createAttendanceLog(attendanceLogRequest); - - verify(attendanceLogServiceValidator, times(1)).validateCreateAttendanceLogRequest(attendanceLogRequest); - - verify(attendanceLogEnricher, times(1)).enrichAttendanceLogCreateRequest(attendanceLogRequest); - - verify(producer, times(1)).push(eq("save-attendance-log"), any(AttendanceLogRequest.class)); - - assertNotNull(attendanceLogRequest.getAttendance()); - } -} diff --git a/core-services/attendance/src/test/java/org/egov/validator/AttendanceLogServiceValidatorTest.java b/core-services/attendance/src/test/java/org/egov/validator/AttendanceLogServiceValidatorTest.java deleted file mode 100644 index e723bb14f86..00000000000 --- a/core-services/attendance/src/test/java/org/egov/validator/AttendanceLogServiceValidatorTest.java +++ /dev/null @@ -1,458 +0,0 @@ -package org.egov.validator; - -import lombok.extern.slf4j.Slf4j; -import org.egov.config.AttendanceServiceConfiguration; -import org.egov.helper.AttendanceLogRequestTestBuilder; -import org.egov.helper.AttendanceRegisterBuilderTest; -import org.egov.repository.AttendeeRepository; -import org.egov.repository.RegisterRepository; -import org.egov.repository.StaffRepository; -import org.egov.tracer.model.CustomException; -import org.egov.web.models.AttendanceLog; -import org.egov.web.models.AttendanceLogRequest; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendeeSearchCriteria; -import org.egov.web.models.IndividualEntry; -import org.egov.web.models.Status; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.test.util.ReflectionTestUtils; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; - -@Slf4j -@ExtendWith(MockitoExtension.class) -public class AttendanceLogServiceValidatorTest { - - @InjectMocks - private AttendanceLogServiceValidator attendanceLogServiceValidator; - - @Mock - private AttendanceServiceConfiguration config; - - @Mock - private StaffRepository attendanceStaffRepository; - - @Mock - private RegisterRepository attendanceRegisterRepository; - - @Mock - private AttendeeRepository attendanceAttendeeRepository; - - @DisplayName("Method validateAttendanceLogRequest: With good request") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogRequest_1(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - assertDoesNotThrow(()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogRequest", attendanceLogRequest)); - } - - @DisplayName("Method validateAttendanceLogRequest: With null RequestInfo object") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogRequest_2(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withoutRequestInfo().addGoodAttendanceLog().build(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogRequest", attendanceLogRequest)); - assertTrue(exception.getCode().equals("REQUEST_INFO")); - } - - @DisplayName("Method validateAttendanceLogRequest: RequestInfo object with null UserInfo") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogRequest_3(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfoButWithoutUserInfo().addGoodAttendanceLog().build(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogRequest", attendanceLogRequest)); - assertTrue(exception.getCode().equals("USERINFO")); - } - - @DisplayName("Method validateAttendanceLogRequest: RequestInfo object with UserInfo but without UUID") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogRequest_4(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfoWithUserInfoButWithOutUUID().addGoodAttendanceLog().build(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogRequest", attendanceLogRequest)); - assertTrue(exception.getCode().equals("USERINFO_UUID")); - } - - @DisplayName("Method validateAttendanceLogRequest: RequestInfo object with UserInfo but without UUID") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogRequest_5(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfoWithUserInfoButWithOutUUID().addGoodAttendanceLog().build(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogRequest", attendanceLogRequest)); - assertTrue(exception.getCode().equals("USERINFO_UUID")); - } - - @DisplayName("Method validateAttendanceLogRequest: RequestInfo object with UserInfo but without Attendance Log list") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogRequest_6(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().withoutAttendanceLog().build(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogRequest", attendanceLogRequest)); - assertTrue(exception.getCode().equals("ATTENDANCE")); - } - - @DisplayName("Method validateAttendanceLogRequest: RequestInfo object with UserInfo but without Attendance Log TenantId") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogRequest_7(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().attendanceLogWithoutTenantId().build(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogRequest", attendanceLogRequest)); - assertTrue(exception.toString().contains("TenantId is mandatory")); - } - - @DisplayName("Method validateAttendanceLogRequest: RequestInfo object with UserInfo but without Attendance Log RegisterId") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogRequest_8(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().attendanceLogWithoutRegisterId().build(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogRequest", attendanceLogRequest)); - log.info(exception.toString()); - assertTrue(exception.toString().contains("Attendance registerid is mandatory")); - } - - @DisplayName("Method validateAttendanceLogRequest: RequestInfo object with UserInfo but without Attendance Log IndividualId") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogRequest_9(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().attendanceLogWithoutIndividualId().build(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogRequest", attendanceLogRequest)); - assertTrue(exception.toString().contains("Attendance indidualid is mandatory")); - } - - @DisplayName("Method validateAttendanceLogRequest: RequestInfo object with UserInfo but without Attendance Log Type") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogRequest_10(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().attendanceLogWithoutType().build(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogRequest", attendanceLogRequest)); - assertTrue(exception.toString().contains("Attendance type is mandatory")); - } - - @DisplayName("Method validateAttendanceLogRequest: RequestInfo object with UserInfo but without Attendance Log Time") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogRequest_11(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().attendanceLogWithoutTime().build();; - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogRequest", attendanceLogRequest)); - assertTrue(exception.toString().contains("Attendance time is mandatory")); - } - - - @DisplayName("Method validateLoggedInUser: should throw exception with code INTEGRATION_UNDERDEVELOPMENT") - @Test - public void validateCreateAttendanceLogRequest_validateLoggedInUser_1(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - when(config.getStaffServiceIntegrationRequired()).thenReturn("TRUE"); - - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateLoggedInUser", attendanceLogRequest)); - assertTrue(exception.getCode().equals("INTEGRATION_UNDERDEVELOPMENT")); - } - -// @DisplayName("Method validateLoggedInUser: should through exception with error code UNAUTHORISED_USER") -// @Test -// public void validateCreateAttendanceLogRequest_validateLoggedInUser_2(){ -// AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); -// when(config.getStaffServiceIntegrationRequired()).thenReturn("FALSE"); -// when(attendanceStaffRepository.getActiveStaff(any(StaffSearchCriteria.class))).thenReturn(null); -// -// CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateLoggedInUser", attendanceLogRequest)); -// assertTrue(exception.getCode().equals("UNAUTHORISED_USER")); -// -// } - -// @DisplayName("Method validateLoggedInUser: should through exception with error code UNAUTHORISED_USER") -// @Test -// public void validateCreateAttendanceLogRequest_validateLoggedInUser_3(){ -// AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); -// when(config.getStaffServiceIntegrationRequired()).thenReturn("FALSE"); -// List attendanceStaff = new ArrayList<>(); -// when(attendanceStaffRepository.getActiveStaff(any(StaffSearchCriteria.class))).thenReturn(attendanceStaff); -// -// CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateLoggedInUser", attendanceLogRequest)); -// assertTrue(exception.getCode().equals("UNAUTHORISED_USER")); -// -// } - -// @DisplayName("Method validateLoggedInUser: should run successfully") -// @Test -// public void validateCreateAttendanceLogRequest_validateLoggedInUser_4(){ -// AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); -// when(config.getStaffServiceIntegrationRequired()).thenReturn("FALSE"); -// StaffPermission staff = StaffPermission.builder() -// .id("staff-uuid") -// .tenantId("tenantId") -// .userId("staffId") -// .registerId("registerId") -// .enrollmentDate(BigDecimal.valueOf(1L)) -// .denrollmentDate(BigDecimal.valueOf(1L)) -// .auditDetails(AuditDetailsTestBuilder.builder().withAuditDetails().build()) -// .additionalDetails(AdditionalFields.builder().build()) -// .build(); -// List attendanceStaff = new ArrayList<>(); -// attendanceStaff.add(staff); -// when(attendanceStaffRepository.getActiveStaff(any(StaffSearchCriteria.class))).thenReturn(attendanceStaff); -// -// assertDoesNotThrow(()->ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateLoggedInUser", attendanceLogRequest)); -// -// } - - @DisplayName("Method validateTenantIdAssociationWithRegisterId: should through exception with error code INVALID_TENANTID") - @Test - public void validateCreateAttendanceLogRequest_validateTenantIdAssociationWithRegisterId_1(){ - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateTenantIdAssociationWithRegisterId", attendanceRegister,"other.tenantId")); - assertTrue(exception.getCode().equals("INVALID_TENANTID")); - } - @DisplayName("Method validateTenantIdAssociationWithRegisterId: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_validateTenantIdAssociationWithRegisterId_2(){ - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - assertDoesNotThrow(()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateTenantIdAssociationWithRegisterId", attendanceRegister,"pb.amritsar")); - } - - @DisplayName("Method validateAttendees: should through exception with error code INTEGRATION_UNDERDEVELOPMENT") - @Test - public void validateCreateAttendanceLogRequest_validateAttendees_1(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - when(config.getIndividualServiceIntegrationRequired()).thenReturn("TRUE"); - - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendees", attendanceLogRequest)); - assertTrue(exception.getCode().equals("INTEGRATION_UNDERDEVELOPMENT")); - } - - @DisplayName("Method validateAttendees: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_validateAttendees_2(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - when(config.getIndividualServiceIntegrationRequired()).thenReturn("FALSE"); - - IndividualEntry individual = IndividualEntry.builder() - .registerId("some-registerId") - .id("uuid") - .individualId("some-individualId") - .enrollmentDate(BigDecimal.valueOf(1640995200000L)) - .denrollmentDate(BigDecimal.valueOf(1703980800000L)) - .build(); - List individualEntries = new ArrayList<>(); - individualEntries.add(individual); - when(attendanceAttendeeRepository.getAttendees(any(AttendeeSearchCriteria.class))).thenReturn(individualEntries); - assertDoesNotThrow( ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendees", attendanceLogRequest)); - } - - @DisplayName("Method validateAttendees: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_validateAttendees_3(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - when(config.getIndividualServiceIntegrationRequired()).thenReturn("FALSE"); - - IndividualEntry individual = IndividualEntry.builder() - .registerId("some-registerId") - .id("uuid") - .individualId("some-individualId") - .enrollmentDate(BigDecimal.valueOf(1640995200000L)) - .build(); - List individualEntries = new ArrayList<>(); - individualEntries.add(individual); - when(attendanceAttendeeRepository.getAttendees(any(AttendeeSearchCriteria.class))).thenReturn(individualEntries); - assertDoesNotThrow( ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendees", attendanceLogRequest)); - } - - @DisplayName("Method validateAttendees: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_validateAttendees_4(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - when(config.getIndividualServiceIntegrationRequired()).thenReturn("FALSE"); - - IndividualEntry individual = IndividualEntry.builder() - .registerId("some-registerId") - .id("uuid") - .individualId("some-individualId") - .enrollmentDate(BigDecimal.valueOf(1672813896627L)) - .build(); - List individualEntries = new ArrayList<>(); - individualEntries.add(individual); - when(attendanceAttendeeRepository.getAttendees(any(AttendeeSearchCriteria.class))).thenReturn(individualEntries); - assertDoesNotThrow( ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendees", attendanceLogRequest)); - } - - @DisplayName("Method validateAttendees: should through exception with error code INELIGIBLE_ATTENDEES") - @Test - public void validateCreateAttendanceLogRequest_validateAttendees_5(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - when(config.getIndividualServiceIntegrationRequired()).thenReturn("FALSE"); - - IndividualEntry individual = IndividualEntry.builder() - .registerId("some-registerId") - .id("uuid") - .individualId("some-individualId") - .enrollmentDate(BigDecimal.valueOf(1705491134000L)) - .build(); - List individualEntries = new ArrayList<>(); - individualEntries.add(individual); - when(attendanceAttendeeRepository.getAttendees(any(AttendeeSearchCriteria.class))).thenReturn(individualEntries); - CustomException exception = assertThrows(CustomException.class, ( ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendees", attendanceLogRequest))); - assertTrue(exception.getCode().equals("INELIGIBLE_ATTENDEES")); - } - - @DisplayName("Method validateAttendees: should through exception with error code INELIGIBLE_ATTENDEES") - @Test - public void validateCreateAttendanceLogRequest_validateAttendees_6(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - when(config.getIndividualServiceIntegrationRequired()).thenReturn("FALSE"); - - IndividualEntry individual = IndividualEntry.builder() - .registerId("some-registerId") - .id("uuid") - .individualId("some-individualId") - .enrollmentDate(BigDecimal.valueOf(1579260734000L)) - .denrollmentDate(BigDecimal.valueOf(1589715134000L)) - .build(); - List individualEntries = new ArrayList<>(); - individualEntries.add(individual); - when(attendanceAttendeeRepository.getAttendees(any(AttendeeSearchCriteria.class))).thenReturn(individualEntries); - CustomException exception = assertThrows(CustomException.class, ( ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendees", attendanceLogRequest))); - assertTrue(exception.getCode().equals("INELIGIBLE_ATTENDEES")); - } - - @DisplayName("Method validateDocumentIds: should through exception with error code SERVICE_UNAVAILABLE") - @Test - public void validateCreateAttendanceLogRequest_validateDocumentIds_1(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - when(config.getDocumentIdVerificationRequired()).thenReturn("TRUE"); - CustomException exception = assertThrows(CustomException.class, ( ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateDocumentIds", attendanceLogRequest))); - assertTrue(exception.getCode().equals("SERVICE_UNAVAILABLE")); - } - - @DisplayName("Method validateDocumentIds: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_validateDocumentIds_2(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - when(config.getDocumentIdVerificationRequired()).thenReturn("FALSE"); - assertDoesNotThrow( ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateDocumentIds", attendanceLogRequest)); - } - - @DisplayName("Method validateAttendanceLogTimeWithRegisterStartEndDate: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogTimeWithRegisterStartEndDate_1(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - AttendanceLog attendanceLog = attendanceLogRequest.getAttendance().get(0); - attendanceLog.setTime(new BigDecimal("1673740800000")); - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - assertDoesNotThrow( ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogTimeWithRegisterStartEndDate",attendanceRegister, attendanceLogRequest)); - } - - @DisplayName("Method validateAttendanceLogTimeWithRegisterStartEndDate: should through exception with error code INVALID_ATTENDANCE_TIME") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogTimeWithRegisterStartEndDate_2(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - AttendanceLog attendanceLog = attendanceLogRequest.getAttendance().get(0); - attendanceLog.setTime(new BigDecimal("1573740800000")); - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogTimeWithRegisterStartEndDate",attendanceRegister, attendanceLogRequest)); - assertTrue(exception.getCode().equals("INVALID_ATTENDANCE_TIME")); - } - - @DisplayName("Method validateAttendanceLogTimeWithRegisterStartEndDate: should through exception with error code INVALID_ATTENDANCE_TIME") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogTimeWithRegisterStartEndDate_3(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - AttendanceLog attendanceLog = attendanceLogRequest.getAttendance().get(0); - attendanceLog.setTime(new BigDecimal("1792057600000")); - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogTimeWithRegisterStartEndDate",attendanceRegister, attendanceLogRequest)); - assertTrue(exception.getCode().equals("INVALID_ATTENDANCE_TIME")); - } - - @DisplayName("Method validateAttendanceLogTimeWithRegisterStartEndDate: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogTimeWithRegisterStartEndDate_4(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - AttendanceLog attendanceLog = attendanceLogRequest.getAttendance().get(0); - attendanceLog.setTime(new BigDecimal("1673740800000")); - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - assertDoesNotThrow(()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogTimeWithRegisterStartEndDate",attendanceRegister, attendanceLogRequest)); - } - - @DisplayName("Method validateAttendanceLogTimeWithRegisterStartEndDate: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogTimeWithRegisterStartEndDate_5(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - AttendanceLog attendanceLog = attendanceLogRequest.getAttendance().get(0); - attendanceLog.setTime(new BigDecimal("1692057600000")); - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - assertDoesNotThrow(()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogTimeWithRegisterStartEndDate",attendanceRegister, attendanceLogRequest)); - } - - @DisplayName("Method validateAttendanceLogTimeWithRegisterStartEndDate: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogTimeWithRegisterStartEndDate_6(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - AttendanceLog attendanceLog = attendanceLogRequest.getAttendance().get(0); - attendanceLog.setTime(new BigDecimal("1673740800000")); - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegisterWithoutEndDate(); - assertDoesNotThrow(()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogTimeWithRegisterStartEndDate",attendanceRegister, attendanceLogRequest)); - } - - @DisplayName("Method validateAttendanceLogTimeWithRegisterStartEndDate: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogTimeWithRegisterStartEndDate_7(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - AttendanceLog attendanceLog = attendanceLogRequest.getAttendance().get(0); - attendanceLog.setTime(new BigDecimal("1773740800000")); - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegisterWithoutEndDate(); - assertDoesNotThrow(()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogTimeWithRegisterStartEndDate",attendanceRegister, attendanceLogRequest)); - } - - @DisplayName("Method validateAttendanceLogTimeWithRegisterStartEndDate: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_validateAttendanceLogTimeWithRegisterStartEndDate_8(){ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - AttendanceLog attendanceLog = attendanceLogRequest.getAttendance().get(0); - attendanceLog.setTime(new BigDecimal("1573740800000")); - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegisterWithoutEndDate(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "validateAttendanceLogTimeWithRegisterStartEndDate",attendanceRegister, attendanceLogRequest)); - assertTrue(exception.getCode().equals("INVALID_ATTENDANCE_TIME")); - } - @DisplayName("Method checkRegisterStatus: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_checkRegisterStatus_1(){ - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - attendanceRegister.setStatus(Status.ACTIVE); - assertDoesNotThrow( ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "checkRegisterStatus",attendanceRegister)); - } - @DisplayName("Method checkRegisterStatus: should through exception with error code INACTIVE_REGISTER") - @Test - public void validateCreateAttendanceLogRequest_checkRegisterStatus_2(){ - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - attendanceRegister.setStatus(Status.INACTIVE); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "checkRegisterStatus",attendanceRegister)); - assertTrue(exception.getCode().equals("INACTIVE_REGISTER")); - } - - @DisplayName("Method checkRegisterExistence: should run successfully") - @Test - public void validateCreateAttendanceLogRequest_checkRegisterExistence_1(){ - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - List attendanceRegisters = Collections.singletonList(attendanceRegister); - assertDoesNotThrow( ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "checkRegisterExistence",attendanceRegisters,"TestRegisterId")); - } - - @DisplayName("Method checkRegisterExistence: should through exception with error code REGISTER_NOT_FOUND") - @Test - public void validateCreateAttendanceLogRequest_checkRegisterExistence_2(){ - List attendanceRegisters = null; - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "checkRegisterExistence",attendanceRegisters,"TestRegisterId")); - assertTrue(exception.getCode().equals("REGISTER_NOT_FOUND")); - } - - @DisplayName("Method checkRegisterExistence: should through exception with error code REGISTER_NOT_FOUND") - @Test - public void validateCreateAttendanceLogRequest_checkRegisterExistence_3(){ - List attendanceRegisters = new ArrayList<>(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceLogServiceValidator, "checkRegisterExistence",attendanceRegisters,"TestRegisterId")); - assertTrue(exception.getCode().equals("REGISTER_NOT_FOUND")); - } -} diff --git a/core-services/attendance/src/test/java/org/egov/validator/AttendanceServiceValidatorTest.java b/core-services/attendance/src/test/java/org/egov/validator/AttendanceServiceValidatorTest.java deleted file mode 100644 index ab670ad60e6..00000000000 --- a/core-services/attendance/src/test/java/org/egov/validator/AttendanceServiceValidatorTest.java +++ /dev/null @@ -1,181 +0,0 @@ -package org.egov.validator; - -import lombok.extern.slf4j.Slf4j; -import org.egov.common.contract.request.RequestInfo; -import org.egov.helper.AttendanceRegisterRequestBuilderTest; -import org.egov.helper.AttendeeRequestBuilderTest; -import org.egov.repository.RegisterRepository; -import org.egov.tracer.model.CustomException; -import org.egov.util.MDMSUtils; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendanceRegisterRequest; -import org.egov.web.models.AttendanceRegisterSearchCriteria; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.test.util.ReflectionTestUtils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.when; - -@Slf4j -@ExtendWith(MockitoExtension.class) -public class AttendanceServiceValidatorTest { - - @InjectMocks - private AttendanceServiceValidator attendanceServiceValidator; - - @Mock - private MDMSUtils mdmsUtils; - - @Mock - private RegisterRepository registerRepository; - - @DisplayName("Method validateRequestInfo: With good request") - @Test - public void validateCreateAttendanceRegister_validateRequestInfo_1(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().withRequestInfo().addGoodRegister().build(); - assertDoesNotThrow(()-> ReflectionTestUtils.invokeMethod(attendanceServiceValidator, "validateRequestInfo", attendanceRegisterRequest.getRequestInfo(), new HashMap<>())); - } - - @DisplayName("Method validateRequestInfo: Should throw exception with error code REQUEST_INFO") - @Test - public void validateCreateAttendanceRegister_validateRequestInfo_2(){ - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceServiceValidator, "validateRequestInfo", null,new HashMap<>())); - assertTrue(exception.getCode().equals("REQUEST_INFO")); - } - - @DisplayName("Method validateRequestInfo: Should throw exception with error code USERINFO") - @Test - public void validateCreateAttendanceRegister_validateRequestInfo_3(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().requestInfoWithoutUserInfo().addGoodRegister().build(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceServiceValidator, "validateRequestInfo", attendanceRegisterRequest.getRequestInfo(),new HashMap<>())); - assertTrue(exception.getCode().equals("USERINFO")); - } - - @DisplayName("Method validateRequestInfo: Should throw exception with error code USERINFO") - @Test - public void validateCreateAttendanceRegister_validateRequestInfo_4(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().requestInfoWithUserInfoButWithOutUUID().build(); - CustomException exception = assertThrows(CustomException.class, ()-> ReflectionTestUtils.invokeMethod(attendanceServiceValidator, "validateRequestInfo", attendanceRegisterRequest.getRequestInfo(),new HashMap<>())); - assertTrue(exception.getCode().equals("USERINFO_UUID")); - } - - @DisplayName("Method validateAttendanceRegisterRequest: Should run successfully") - @Test - public void validateCreateAttendanceRegister_validateAttendanceRegisterRequest_1(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().addGoodRegister().build(); - assertDoesNotThrow(()-> ReflectionTestUtils.invokeMethod(attendanceServiceValidator, "validateAttendanceRegisterRequest", attendanceRegisterRequest.getAttendanceRegister(),new HashMap<>())); - } - - @DisplayName("Method validateAttendanceRegisterRequest: Should throw exception with error code ATTENDANCE_REGISTER") - @Test - public void validateCreateAttendanceRegister_validateAttendanceRegisterRequest_2(){ - CustomException exception = assertThrows(CustomException.class,()-> ReflectionTestUtils.invokeMethod(attendanceServiceValidator, "validateAttendanceRegisterRequest", null,new HashMap<>())); - assertTrue(exception.getCode().equals("ATTENDANCE_REGISTER")); - } - - @DisplayName("Method validateAttendanceRegisterRequest: Should throw exception with error code ATTENDANCE_REGISTER") - @Test - public void validateCreateAttendanceRegister_validateAttendanceRegisterRequest_3(){ - // Empty list - List attendanceRegisters = new ArrayList<>(); - CustomException exception = assertThrows(CustomException.class,()-> ReflectionTestUtils.invokeMethod(attendanceServiceValidator, "validateAttendanceRegisterRequest", attendanceRegisters,new HashMap<>())); - assertTrue(exception.getCode().equals("ATTENDANCE_REGISTER")); - } - - @DisplayName("Method validateAttendanceRegisterRequest: Error code TENANT_ID") - @Test - public void validateCreateAttendanceRegister_validateAttendanceRegisterRequest_4(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().attendanceRegisterWithoutTenantId().build(); - List attendanceRegister = attendanceRegisterRequest.getAttendanceRegister(); - Map errorMap = new HashMap<>(); - CustomException exception = assertThrows(CustomException.class,()->ReflectionTestUtils.invokeMethod(attendanceServiceValidator, "validateAttendanceRegisterRequest", attendanceRegister, errorMap)); - assertTrue(exception.getCode().equals("TENANT_ID")); - } - - @DisplayName("Method validateAttendanceRegisterRequest: Error code NAME") - @Test - public void validateCreateAttendanceRegister_validateAttendanceRegisterRequest_5(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().attendanceRegisterWithoutName().build(); - Map errorMap = new HashMap<>(); - ReflectionTestUtils.invokeMethod(attendanceServiceValidator, "validateAttendanceRegisterRequest", attendanceRegisterRequest.getAttendanceRegister(),errorMap); - assertTrue(errorMap.keySet().contains("NAME")); - } - - @DisplayName("Method validateAttendanceRegisterRequest: Error code START_DATE") - @Test - public void validateCreateAttendanceRegister_validateAttendanceRegisterRequest_6(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().attendanceRegisterWithoutStartDate().build(); - Map errorMap = new HashMap<>(); - CustomException exception = assertThrows(CustomException.class,()->ReflectionTestUtils.invokeMethod(attendanceServiceValidator, "validateAttendanceRegisterRequest", attendanceRegisterRequest.getAttendanceRegister(),errorMap)); - assertTrue(exception.getCode().equals("START_DATE")); - } - - @DisplayName("Method validateAttendanceRegisterRequest: Error code DATE") - @Test - public void validateCreateAttendanceRegister_validateAttendanceRegisterRequest_7(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().attendanceRegisterWithStartDateGTEndDate().build(); - Map errorMap = new HashMap<>(); - ReflectionTestUtils.invokeMethod(attendanceServiceValidator, "validateAttendanceRegisterRequest", attendanceRegisterRequest.getAttendanceRegister(),errorMap); - assertTrue(errorMap.keySet().contains("DATE")); - } - - @DisplayName("Method validateAttendanceRegisterRequest: Error code DATE") - @Test - public void validateCreateAttendanceRegister_validateMultipleTenantIds(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().withRequestInfo().attendanceRegistersWithMultipleTenantIds().build(); - Map errorMap = new HashMap<>(); - CustomException exception = assertThrows(CustomException.class,()->ReflectionTestUtils.invokeMethod(attendanceServiceValidator, "validateCreateAttendanceRegister", attendanceRegisterRequest)); - assertTrue(exception.getCode().equals("MULTIPLE_TENANTS")); - } - - @DisplayName("Method validateCreateAttendanceRegister: run successfully") - @Test - public void validateCreateAttendanceRegister_validateCreateAttendanceRegister_1(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().withRequestInfo().addGoodRegister().build(); - Object mdmsResponse = AttendeeRequestBuilderTest.getMdmsResponseForValidTenant(); - lenient().when(mdmsUtils.mDMSCall(any(RequestInfo.class), - any(String.class))).thenReturn(mdmsResponse); - List registers = new ArrayList<>(); - AttendanceRegister register = AttendanceRegister.builder().build(); - registers.add(register); - when(registerRepository.getRegister(any(AttendanceRegisterSearchCriteria.class))).thenReturn(registers); - CustomException exception = assertThrows(CustomException.class, ()->attendanceServiceValidator.validateCreateAttendanceRegister(attendanceRegisterRequest)); - assertTrue(exception.getCode().equals("REGISTER_ALREADY_EXISTS")); - } - - @Test - public void validateCreateAttendanceRegister_validateCreateAttendanceRegister_3(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().withRequestInfo().addGoodRegister().build(); - Object mdmsResponse = AttendeeRequestBuilderTest.getMdmsResponseForValidTenant(); - lenient().when(mdmsUtils.mDMSCall(any(RequestInfo.class), - any(String.class))).thenReturn(mdmsResponse); - List registers = new ArrayList<>(); - when(registerRepository.getRegister(any(AttendanceRegisterSearchCriteria.class))).thenReturn(registers); - attendanceServiceValidator.validateCreateAttendanceRegister(attendanceRegisterRequest); - } - - @DisplayName("Method validateCreateAttendanceRegister: Error code INVALID_TENANT") - @Test - public void validateCreateAttendanceRegister_validateCreateAttendanceRegister_2(){ - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().withRequestInfo().addGoodRegister().build(); - Object mdmsResponse = AttendeeRequestBuilderTest.getMdmsResponseForInvalidTenant(); - lenient().when(mdmsUtils.mDMSCall(any(RequestInfo.class), - any(String.class))).thenReturn(mdmsResponse); - CustomException exception = assertThrows(CustomException.class,()->attendanceServiceValidator.validateCreateAttendanceRegister(attendanceRegisterRequest)); - assertTrue(exception.getMessage().contains("INVALID_TENANT")); - } -} diff --git a/core-services/attendance/src/test/java/org/egov/validator/AttendeeServiceValidatorTest.java b/core-services/attendance/src/test/java/org/egov/validator/AttendeeServiceValidatorTest.java deleted file mode 100644 index 6cfca07e9e8..00000000000 --- a/core-services/attendance/src/test/java/org/egov/validator/AttendeeServiceValidatorTest.java +++ /dev/null @@ -1,177 +0,0 @@ -package org.egov.validator; - - -import lombok.extern.slf4j.Slf4j; -import org.egov.common.contract.request.RequestInfo; -import org.egov.helper.AttendanceRegisterBuilderTest; -import org.egov.helper.AttendeeRequestBuilderTest; -import org.egov.tracer.model.CustomException; -import org.egov.util.MDMSUtils; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.AttendeeCreateRequest; -import org.egov.web.models.IndividualEntry; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import java.math.BigDecimal; -import java.util.Collections; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.when; - -@Slf4j -@ExtendWith(MockitoExtension.class) -public class AttendeeServiceValidatorTest { - - @InjectMocks - private AttendeeServiceValidator attendeeServiceValidator; - - @Mock - private MDMSUtils mdmsUtils; - - - @BeforeEach - void setupBeforeEach() { - Object mdmsResponse = AttendeeRequestBuilderTest.getMdmsResponseForValidTenant(); - lenient().when(mdmsUtils.mDMSCall(any(RequestInfo.class), - any(String.class))).thenReturn(mdmsResponse); - } - - @DisplayName("attendees is null in attendee request") - @Test - void shouldThrowExceptionWhenAttendeesIsNull_InAttendeeRequest() { - - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - attendeeCreateRequest.setAttendees(null); - - assertThrows(CustomException.class, () -> attendeeServiceValidator.validateAttendeeCreateRequestParameters(attendeeCreateRequest)); - } - - @DisplayName("register id is null in attendee request") - @Test - void shouldThrowExceptionWhenRegisterIdIsNull_InAttendeeRequest() { - - IndividualEntry attendee = IndividualEntry.builder().tenantId("pb.amritsar").id("047dc725-3088-45b4-877a-6bfbaf377df9") - .individualId("8ybdd-3rdh3").registerId("").enrollmentDate(new BigDecimal("1672129633890")) - .denrollmentDate(new BigDecimal("1676073600000")).build(); - - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - attendeeCreateRequest.setAttendees(Collections.singletonList(attendee)); - - assertThrows(CustomException.class, () -> attendeeServiceValidator.validateAttendeeCreateRequestParameters(attendeeCreateRequest)); - } - - @DisplayName("individual id is null in attendee request") - @Test - void shouldThrowExceptionWhenIndividualIdIsNull_InAttendeeRequest() { - - IndividualEntry attendee = IndividualEntry.builder().tenantId("pb.amritsar").id("047dc725-3088-45b4-877a-6bfbaf377df9") - .individualId("").registerId("97ed7da3-753e-426a-b0b0-95dd61029785").enrollmentDate(new BigDecimal("1672129633890")) - .denrollmentDate(new BigDecimal("1676073600000")).build(); - - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - attendeeCreateRequest.setAttendees(Collections.singletonList(attendee)); - - assertThrows(CustomException.class, () -> attendeeServiceValidator.validateAttendeeCreateRequestParameters(attendeeCreateRequest)); - } - - @DisplayName("tenantId is null in attendee request") - @Test - void shouldThrowExceptionWhenTenantIdIsNull_InAttendeeRequest() { - - IndividualEntry attendee = IndividualEntry.builder().tenantId("").id("047dc725-3088-45b4-877a-6bfbaf377df9") - .individualId("8ybdd-3rdh3").registerId("97ed7da3-753e-426a-b0b0-95dd61029785").enrollmentDate(new BigDecimal("1672129633890")) - .denrollmentDate(new BigDecimal("1676073600000")).build(); - - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - attendeeCreateRequest.setAttendees(Collections.singletonList(attendee)); - - assertThrows(CustomException.class, () -> attendeeServiceValidator.validateAttendeeCreateRequestParameters(attendeeCreateRequest)); - } - - @DisplayName("tenantId is same for all attendees in the attendee request") - @Test - void shouldThrowExceptionWhenTenantIdsAreNotSame_InAttendeeRequest() { - - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - attendeeCreateRequest.getAttendees().get(0).setTenantId("od"); - - assertThrows(CustomException.class, () -> attendeeServiceValidator.validateAttendeeCreateRequestParameters(attendeeCreateRequest)); - } - - @DisplayName("verify tenantId with mdms when tenantId is present in mdms") - @Test - void shouldNotThrowExceptionWhenTenantIdPresent_InMDMS() { - - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - - assertDoesNotThrow(() -> attendeeServiceValidator.validateMDMSAndRequestInfoForCreateAttendee(attendeeCreateRequest)); - } - - @DisplayName("verify tenantId with mdms when tenantId is not present in mdms") - @Test - void shouldThrowExceptionWhenTenantIdNotPresent_InMDMS() { - - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - attendeeCreateRequest.getAttendees().get(0).setTenantId("od.odisha"); - - Object mdmsResponse = AttendeeRequestBuilderTest.getMdmsResponseForInvalidTenant(); - when(mdmsUtils.mDMSCall(any(RequestInfo.class), - any(String.class))).thenReturn(mdmsResponse); - - assertThrows(CustomException.class, () -> attendeeServiceValidator.validateMDMSAndRequestInfoForCreateAttendee(attendeeCreateRequest)); - } - - //tests for create attendee validation - - @DisplayName("attendee cannot be added to register if register's end date has passed") - @Test - void shouldThrowExceptionWhenRegisterEndDateHasPassed() { - - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - List attendees = attendanceRegister.getAttendees(); - - attendanceRegister.setEndDate(new BigDecimal("1578728218000")); //set a past date - - assertThrows(CustomException.class, () -> attendeeServiceValidator - .validateAttendeeOnCreate(attendeeCreateRequest, attendees, Collections.singletonList(attendanceRegister))); - } - - @DisplayName("attendee enrollment date should be after start date and before end date of register") - @Test - void shouldThrowExceptionWhenEnrollmentDateIsBeforeStartDateOfRegister() { - - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - List attendees = attendanceRegister.getAttendees(); - - attendeeCreateRequest.getAttendees().get(0).setEnrollmentDate(new BigDecimal("1673422618000")); - - assertThrows(CustomException.class, () -> attendeeServiceValidator - .validateAttendeeOnCreate(attendeeCreateRequest, attendees, Collections.singletonList(attendanceRegister))); - } - - @DisplayName("check if attendee is already enrolled to the register") - @Test - void shouldThrowExceptionWhenAttendeeAlreadyEnrolledToRegister() { - - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - AttendanceRegister attendanceRegister = AttendanceRegisterBuilderTest.getAttendanceRegister(); - List attendees = attendanceRegister.getAttendees(); - - assertThrows(CustomException.class, () -> attendeeServiceValidator - .validateAttendeeOnCreate(attendeeCreateRequest, attendees, Collections.singletonList(attendanceRegister))); - - } - -} diff --git a/core-services/attendance/src/test/java/org/egov/validator/StaffServiceValidatorTest.java b/core-services/attendance/src/test/java/org/egov/validator/StaffServiceValidatorTest.java deleted file mode 100644 index 073f70199df..00000000000 --- a/core-services/attendance/src/test/java/org/egov/validator/StaffServiceValidatorTest.java +++ /dev/null @@ -1,172 +0,0 @@ -package org.egov.validator; - -import lombok.extern.slf4j.Slf4j; -import org.egov.common.contract.request.RequestInfo; -import org.egov.helper.AttendanceRegisterBuilderTest; -import org.egov.helper.AttendeeRequestBuilderTest; -import org.egov.helper.StaffRequestBuilderTest; -import org.egov.service.AttendanceRegisterService; -import org.egov.tracer.model.CustomException; -import org.egov.util.MDMSUtils; -import org.egov.web.models.AttendanceRegister; -import org.egov.web.models.StaffPermission; -import org.egov.web.models.StaffPermissionRequest; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import java.math.BigDecimal; -import java.util.List; - -import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.when; - -@Slf4j -@ExtendWith(MockitoExtension.class) -public class StaffServiceValidatorTest { - - @Mock - private MDMSUtils mdmsUtils; - - @Mock - private AttendanceRegisterService attendanceRegisterService; - - @InjectMocks - private StaffServiceValidator staffServiceValidator; - - @BeforeEach - void setupBeforeEach() { - Object mdmsResponse = AttendeeRequestBuilderTest.getMdmsResponseForValidTenant(); - lenient().when(mdmsUtils.mDMSCall(any(RequestInfo.class), - any(String.class))).thenReturn(mdmsResponse); - } - - - //validate staff request parameters - @DisplayName("staff is null in staff Permission request") - @Test - void shouldThrowExceptionWhenStaffIsNull_InStaffPermissionRequest() { - - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - staffPermissionRequest.setStaff(null); - - assertThrows(CustomException.class, () -> staffServiceValidator.validateStaffPermissionRequestParameters(staffPermissionRequest)); - } - - @DisplayName("register id is null in staff Permission request") - @Test - void shouldThrowExceptionWhenRegisterIdIsNull_InStaffPermissionRequest() { - - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - staffPermissionRequest.getStaff().get(0).setRegisterId(null); - - assertThrows(CustomException.class, () -> staffServiceValidator.validateStaffPermissionRequestParameters(staffPermissionRequest)); - } - - @DisplayName("tenant id is null in staff Permission request") - @Test - void shouldThrowExceptionWhenTenantIdIsNull_InStaffPermissionRequest() { - - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - staffPermissionRequest.getStaff().get(0).setTenantId(null); - - assertThrows(CustomException.class, () -> staffServiceValidator.validateStaffPermissionRequestParameters(staffPermissionRequest)); - } - - @DisplayName("All staff must have same tenant id in staff Permission request") - @Test - void shouldThrowExceptionWhenTenantIdIsNotSame_InStaffPermissionRequest() { - - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - staffPermissionRequest.getStaff().get(0).setTenantId("od"); - - assertThrows(CustomException.class, () -> staffServiceValidator.validateStaffPermissionRequestParameters(staffPermissionRequest)); - } - - @DisplayName("Duplicate staff objects in staff Permission request") - @Test - void shouldThrowExceptionWhenDuplicateStaffIsPresent_InStaffPermissionRequest() { - - StaffPermission staffOne = StaffPermission.builder().id("03901adb-07c3-4539-9346-4ee5c87e5e1c").userId("8ybdd-3rdhd") - .registerId("97ed7da3-753e-426a-b0b0-95dd61029785").tenantId("pb.amritsar").enrollmentDate(new BigDecimal("1670421853937")) - .denrollmentDate(null).build(); - - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - staffPermissionRequest.getStaff().set(1, staffOne); - - assertThrows(CustomException.class, () -> staffServiceValidator.validateStaffPermissionRequestParameters(staffPermissionRequest)); - } - - - //validate tenant id with mdms - @DisplayName("verify tenantId with mdms when tenantId is present in mdms") - @Test - void shouldNotThrowExceptionWhenTenantIdPresent_InMDMS() { - - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - - assertDoesNotThrow(() -> staffServiceValidator.validateMDMSAndRequestInfoForStaff(staffPermissionRequest)); - } - - @DisplayName("verify tenantId with mdms when tenantId is not present in mdms") - @Test - void shouldThrowExceptionWhenTenantIdNotPresent_InMDMS() { - - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - staffPermissionRequest.getStaff().get(0).setTenantId("od.odisha"); - - Object mdmsResponse = AttendeeRequestBuilderTest.getMdmsResponseForInvalidTenant(); - when(mdmsUtils.mDMSCall(any(RequestInfo.class), - any(String.class))).thenReturn(mdmsResponse); - - assertThrows(CustomException.class, () -> staffServiceValidator.validateMDMSAndRequestInfoForStaff(staffPermissionRequest)); - } - - //check if staff tenant id is same as register tenant id - @DisplayName("check if staff tenant id is same as register tenant id") - @Test - void shouldThrowExceptionWhenStaffTenantIdNotSameAsRegisterTenantId() { - - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - List staffPermissionList = AttendanceRegisterBuilderTest.getStaff(); - List attendanceRegisterList = AttendanceRegisterBuilderTest.getAttendanceRegisterList(); - - attendanceRegisterList.get(0).setTenantId("od.odisha"); - - assertThrows(CustomException.class, () -> staffServiceValidator.validateStaffPermissionOnCreate(staffPermissionRequest, staffPermissionList, attendanceRegisterList)); - } - - @DisplayName("check if register end date has passed") - @Test - void shouldThrowExceptionIfRegisterEndDateHasPassed() { - - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - List staffPermissionList = AttendanceRegisterBuilderTest.getStaff(); - List attendanceRegisterList = AttendanceRegisterBuilderTest.getAttendanceRegisterList(); - - attendanceRegisterList.get(0).setEndDate(new BigDecimal("1547733538000")); - - assertThrows(CustomException.class, () -> staffServiceValidator.validateStaffPermissionOnCreate(staffPermissionRequest, staffPermissionList, attendanceRegisterList)); - } - - @DisplayName("check if staff is already enrolled to the given register") - @Test - void shouldThrowExceptionIfStaffIsAlreadyEnrolledToTheRegister() { - - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - List staffPermissionList = AttendanceRegisterBuilderTest.getStaff(); - List attendanceRegisterList = AttendanceRegisterBuilderTest.getAttendanceRegisterList(); - - - assertThrows(CustomException.class, () -> staffServiceValidator.validateStaffPermissionOnCreate(staffPermissionRequest, staffPermissionList, attendanceRegisterList)); - } - - -} diff --git a/core-services/attendance/src/test/java/org/egov/web/controllers/AttendanceApiControllerTest.java b/core-services/attendance/src/test/java/org/egov/web/controllers/AttendanceApiControllerTest.java deleted file mode 100644 index 068c0910681..00000000000 --- a/core-services/attendance/src/test/java/org/egov/web/controllers/AttendanceApiControllerTest.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.egov.web.controllers; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.egov.Main; -import org.egov.TestConfiguration; -import org.egov.common.contract.request.RequestInfo; -import org.egov.common.contract.response.ResponseInfo; -import org.egov.helper.AttendanceRegisterBuilderTest; -import org.egov.helper.AttendanceRegisterRequestBuilderTest; -import org.egov.repository.AttendanceLogRepository; -import org.egov.repository.AttendeeRepository; -import org.egov.repository.RegisterRepository; -import org.egov.repository.StaffRepository; -import org.egov.service.AttendanceRegisterService; -import org.egov.tracer.model.CustomException; -import org.egov.tracer.model.ErrorRes; -import org.egov.util.ResponseInfoFactory; -import org.egov.web.models.AttendanceRegisterRequest; -import org.egov.web.models.AttendanceRegisterResponse; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.http.MediaType; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; - -import javax.servlet.http.HttpServletRequest; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -/** - * API tests for AttendanceApiController - */ -@ContextConfiguration(classes = Main.class) -@WebMvcTest(AttendanceApiController.class) -@Import(TestConfiguration.class) -@AutoConfigureMockMvc -public class AttendanceApiControllerTest { - - @Autowired - private MockMvc mockMvc; - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private HttpServletRequest request; - - @MockBean - private ResponseInfoFactory responseInfoFactory; - - @MockBean - private AttendanceLogRepository attendanceLogRepository; - - @MockBean - private AttendanceRegisterService attendanceRegisterService; - - @MockBean - private AttendeeRepository attendeeRepository; - - @MockBean - private RegisterRepository registerRepository; - - @MockBean - private StaffRepository staffRepository; - - @MockBean - private JdbcTemplate jdbcTemplate; - - @Test - @DisplayName("should pass for correct API operation for create attendance register") - public void RegisterCreatePostSuccess() throws Exception { - - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().addGoodRegister() - .requestInfoWithoutUserInfo().build(); - ResponseInfo responseInfo = AttendanceRegisterBuilderTest.getResponseInfo_Success(); - - when(attendanceRegisterService.createAttendanceRegister(any(AttendanceRegisterRequest.class))).thenReturn(attendanceRegisterRequest); - when(responseInfoFactory.createResponseInfoFromRequestInfo(any(RequestInfo.class), eq(true))).thenReturn(responseInfo); - - ObjectMapper objectMapper = new ObjectMapper(); - String content = objectMapper.writeValueAsString(attendanceRegisterRequest); - MvcResult result = mockMvc.perform(post("/v1/_create").contentType(MediaType - .APPLICATION_JSON).content(content)) - .andExpect(status().isOk()).andReturn(); - String responseStr = result.getResponse().getContentAsString(); - - AttendanceRegisterResponse response = objectMapper.readValue(responseStr, AttendanceRegisterResponse.class); - - assertEquals("successful", response.getResponseInfo().getStatus()); - - } - - @Test - @DisplayName("should fail for incomplete attendance register object in API request") - public void RegisterCreatePostFailure() throws Exception { - - AttendanceRegisterRequest attendanceRegisterRequest = AttendanceRegisterRequestBuilderTest.builder().attendanceRegisterWithoutStartDate() - .withRequestInfo().build(); - - when(attendanceRegisterService.createAttendanceRegister(any(AttendanceRegisterRequest.class))) - .thenThrow(new CustomException("START_DATE", "Start date is mandatory")); - - ObjectMapper objectMapper = new ObjectMapper(); - String content = objectMapper.writeValueAsString(attendanceRegisterRequest); - MvcResult result = mockMvc.perform(post("/v1/_create").contentType(MediaType.APPLICATION_JSON).content(content)) - .andExpect(status().isBadRequest()).andReturn(); - - String responseStr = result.getResponse().getContentAsString(); - ErrorRes response = objectMapper.readValue(responseStr, - ErrorRes.class); - - assertEquals("Start date is mandatory", response.getErrors().get(0).getMessage()); - } -} diff --git a/core-services/attendance/src/test/java/org/egov/web/controllers/AttendanceLogApiControllerTest.java b/core-services/attendance/src/test/java/org/egov/web/controllers/AttendanceLogApiControllerTest.java deleted file mode 100644 index 73230c97ca9..00000000000 --- a/core-services/attendance/src/test/java/org/egov/web/controllers/AttendanceLogApiControllerTest.java +++ /dev/null @@ -1,94 +0,0 @@ -package org.egov.web.controllers; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.egov.Main; -import org.egov.TestConfiguration; -import org.egov.common.contract.response.ResponseInfo; -import org.egov.helper.AttendanceLogRequestTestBuilder; -import org.egov.kafka.Producer; -import org.egov.repository.AttendanceLogRepository; -import org.egov.service.AttendanceLogService; -import org.egov.util.ResponseInfoFactory; -import org.egov.web.models.AttendanceLogRequest; -import org.egov.web.models.AttendanceLogResponse; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.http.MediaType; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - - - -@ContextConfiguration(classes = Main.class) -@WebMvcTest(AttendanceLogApiController.class) -@Import(TestConfiguration.class) -@AutoConfigureMockMvc - -public class AttendanceLogApiControllerTest { - @Autowired - private MockMvc mockMvc; - - @Autowired - private ObjectMapper objectMapper; - - @MockBean - private AttendanceLogService attendanceLogService; - - @MockBean - private ResponseInfoFactory responseInfoFactory; - - @MockBean - private Producer producer; - - @MockBean - private AttendanceLogRepository attendanceLogRepository; - - @MockBean - private JdbcTemplate jdbcTemplate; - - - @DisplayName("attendance log request should pass and create attendance log") - @Test - public void attendanceLogV1CreatePOSTSuccess() throws Exception{ - AttendanceLogRequest attendanceLogRequest = AttendanceLogRequestTestBuilder.builder().withRequestInfo().addGoodAttendanceLog().build(); - - ResponseInfo responseInfo = ResponseInfo.builder() - .apiId(attendanceLogRequest.getRequestInfo().getApiId()) - .ver(attendanceLogRequest.getRequestInfo().getVer()) - .ts(attendanceLogRequest.getRequestInfo().getTs()) - .resMsgId("uief87324") - .msgId(attendanceLogRequest.getRequestInfo().getMsgId()) - .status("successful").build(); - - AttendanceLogResponse attendanceLogResponse = AttendanceLogResponse.builder().responseInfo(responseInfo).attendance(attendanceLogRequest.getAttendance()).build(); - - - when(attendanceLogService.createAttendanceLog(any(AttendanceLogRequest.class))).thenReturn(attendanceLogResponse); - - MvcResult result = mockMvc.perform(post("/log/v1/_create").contentType(MediaType - .APPLICATION_JSON).content(objectMapper.writeValueAsString(attendanceLogRequest))) - .andExpect(status().isOk()).andReturn(); - - String responseStr = result.getResponse().getContentAsString(); - AttendanceLogResponse response = objectMapper.readValue(responseStr, - AttendanceLogResponse.class); - - assertEquals(1, response.getAttendance().size()); - assertNotNull(response.getAttendance().get(0).getId()); - assertEquals("successful", response.getResponseInfo().getStatus()); - } -} diff --git a/core-services/attendance/src/test/java/org/egov/web/controllers/AttendeeApiControllerTest.java b/core-services/attendance/src/test/java/org/egov/web/controllers/AttendeeApiControllerTest.java deleted file mode 100644 index b0a7f360df7..00000000000 --- a/core-services/attendance/src/test/java/org/egov/web/controllers/AttendeeApiControllerTest.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.egov.web.controllers; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.egov.Main; -import org.egov.TestConfiguration; -import org.egov.common.contract.request.RequestInfo; -import org.egov.common.contract.response.ResponseInfo; -import org.egov.enrichment.StaffEnrichmentService; -import org.egov.helper.AttendeeRequestBuilderTest; -import org.egov.repository.AttendanceLogRepository; -import org.egov.repository.AttendeeRepository; -import org.egov.repository.RegisterRepository; -import org.egov.repository.StaffRepository; -import org.egov.service.AttendanceRegisterService; -import org.egov.service.AttendeeService; -import org.egov.service.StaffService; -import org.egov.tracer.model.CustomException; -import org.egov.tracer.model.ErrorRes; -import org.egov.util.ResponseInfoFactory; -import org.egov.web.models.AttendeeCreateRequest; -import org.egov.web.models.AttendeeCreateResponse; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.http.MediaType; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@ContextConfiguration(classes=Main.class) -@WebMvcTest(AttendeeApiController.class) -@Import({TestConfiguration.class}) -//@SpringBootTest(classes = Main.class) -@AutoConfigureMockMvc -public class AttendeeApiControllerTest { - @Autowired - private MockMvc mockMvc; - - @Autowired - private ObjectMapper objectMapper; - - @MockBean - private AttendeeService attendeeService; - @MockBean - private ResponseInfoFactory responseInfoFactory; - - @MockBean - private AttendeeRepository attendeeRepository; - - @MockBean - private StaffEnrichmentService staffEnrichmentService; - - @MockBean - private AttendanceRegisterService attendanceRegisterService; - - @MockBean - private StaffRepository staffRepository; - - @MockBean - private StaffService staffService; - - @MockBean - private AttendanceLogRepository attendanceLogRepository; - - @MockBean - private RegisterRepository registerRepository; - - - @Test - @DisplayName("should pass for correct API operation") - public void attendeeCreatePostSuccess() throws Exception { - - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - ResponseInfo responseInfo = AttendeeRequestBuilderTest.getResponseInfo_Success(); - - when(attendeeService.createAttendee(any(AttendeeCreateRequest.class))).thenReturn(attendeeCreateRequest); - when(responseInfoFactory.createResponseInfoFromRequestInfo(any(RequestInfo.class), eq(true))).thenReturn(responseInfo); - - ObjectMapper objectMapper = new ObjectMapper(); - String content = objectMapper.writeValueAsString(attendeeCreateRequest); - MvcResult result = mockMvc.perform(post("/attendee/v1/_create").contentType(MediaType - .APPLICATION_JSON).content(content)) - .andExpect(status().isOk()).andReturn(); - String responseStr = result.getResponse().getContentAsString(); - - AttendeeCreateResponse response = objectMapper.readValue(responseStr, AttendeeCreateResponse.class); - - assertEquals("successful", response.getResponseInfo().getStatus()); - - } - - @Test - @DisplayName("should fail for incomplete attendee object in API request") - public void attendeeCreatePostFailure() throws Exception { - - AttendeeCreateRequest attendeeCreateRequest = AttendeeRequestBuilderTest.getAttendeeCreateRequest(); - - attendeeCreateRequest.getAttendees().get(0).setIndividualId(null); - - when(attendeeService.createAttendee(any(AttendeeCreateRequest.class))).thenThrow(new CustomException("ATTENDEE", "ATTENDEE is mandatory")); - - ObjectMapper objectMapper = new ObjectMapper(); - String content = objectMapper.writeValueAsString(attendeeCreateRequest); - MvcResult result=mockMvc.perform(post("/attendee/v1/_create").contentType(MediaType - .APPLICATION_JSON).content(content)) - .andExpect(status().isBadRequest()).andReturn(); - - String responseStr = result.getResponse().getContentAsString(); - ErrorRes response = objectMapper.readValue(responseStr, - ErrorRes.class); - - assertEquals("ATTENDEE is mandatory",response.getErrors().get(0).getMessage()); - } - -} diff --git a/core-services/attendance/src/test/java/org/egov/web/controllers/StaffApiControllerTest.java b/core-services/attendance/src/test/java/org/egov/web/controllers/StaffApiControllerTest.java deleted file mode 100644 index 285ef21cca4..00000000000 --- a/core-services/attendance/src/test/java/org/egov/web/controllers/StaffApiControllerTest.java +++ /dev/null @@ -1,108 +0,0 @@ -package org.egov.web.controllers; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.egov.Main; -import org.egov.TestConfiguration; -import org.egov.common.contract.request.RequestInfo; -import org.egov.common.contract.response.ResponseInfo; -import org.egov.helper.StaffRequestBuilderTest; -import org.egov.repository.AttendanceLogRepository; -import org.egov.service.StaffService; -import org.egov.tracer.model.CustomException; -import org.egov.tracer.model.ErrorRes; -import org.egov.util.ResponseInfoFactory; -import org.egov.web.models.StaffPermissionRequest; -import org.egov.web.models.StaffPermissionResponse; -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.Import; -import org.springframework.http.MediaType; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; - -import javax.servlet.http.HttpServletRequest; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@ContextConfiguration(classes = Main.class) -@WebMvcTest(StaffApiController.class) -@Import(TestConfiguration.class) -@AutoConfigureMockMvc -public class StaffApiControllerTest { - - @Autowired - private MockMvc mockMvc; - - @Autowired - private ObjectMapper objectMapper; - - @Autowired - private HttpServletRequest request; - - @MockBean - private ResponseInfoFactory responseInfoFactory; - - @MockBean - private StaffService staffService; - - @MockBean - private AttendanceLogRepository attendanceLogRepository; - - @MockBean - private JdbcTemplate jdbcTemplate; - - @Test - @DisplayName("should pass for correct API operation") - public void staffCreatePostSuccess() throws Exception { - - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - ResponseInfo responseInfo = StaffRequestBuilderTest.getResponseInfo_Success(); - - when(staffService.createAttendanceStaff(any(StaffPermissionRequest.class), eq(false))).thenReturn(staffPermissionRequest); - when(responseInfoFactory.createResponseInfoFromRequestInfo(any(RequestInfo.class), eq(true))).thenReturn(responseInfo); - - ObjectMapper objectMapper = new ObjectMapper(); - String content = objectMapper.writeValueAsString(staffPermissionRequest); - MvcResult result = mockMvc.perform(post("/staff/v1/_create").contentType(MediaType - .APPLICATION_JSON).content(content)) - .andExpect(status().isOk()).andReturn(); - String responseStr = result.getResponse().getContentAsString(); - - StaffPermissionResponse response = objectMapper.readValue(responseStr, StaffPermissionResponse.class); - - assertEquals("successful", response.getResponseInfo().getStatus()); - - } - - @Test - @DisplayName("should fail for incomplete staff object in API request") - public void staffCreatePostFailure() throws Exception { - - StaffPermissionRequest staffPermissionRequest = StaffRequestBuilderTest.getStaffPermissionRequest(); - staffPermissionRequest.setStaff(null); - - when(staffService.createAttendanceStaff(any(StaffPermissionRequest.class), eq(false))).thenThrow(new CustomException("STAFF", "Staff is mandatory")); - - ObjectMapper objectMapper = new ObjectMapper(); - String content = objectMapper.writeValueAsString(staffPermissionRequest); - MvcResult result=mockMvc.perform(post("/staff/v1/_create").contentType(MediaType.APPLICATION_JSON).content(content)) - .andExpect(status().isBadRequest()).andReturn(); - - String responseStr = result.getResponse().getContentAsString(); - ErrorRes response = objectMapper.readValue(responseStr, - ErrorRes.class); - - assertEquals("Staff is mandatory",response.getErrors().get(0).getMessage()); - } -} diff --git a/core-services/attendance/src/test/resources/AttendeeCreateRequest.json b/core-services/attendance/src/test/resources/AttendeeCreateRequest.json deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/core-services/attendance/src/test/resources/InvalidTenantMDMSData.json b/core-services/attendance/src/test/resources/InvalidTenantMDMSData.json deleted file mode 100644 index d510372f9e1..00000000000 --- a/core-services/attendance/src/test/resources/InvalidTenantMDMSData.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "ResponseInfo": null, - "MdmsRes": { - "tenant": { - "tenants": [] - } - } -} \ No newline at end of file diff --git a/core-services/attendance/src/test/resources/TenantMDMSData.json b/core-services/attendance/src/test/resources/TenantMDMSData.json deleted file mode 100644 index a28cc965f7e..00000000000 --- a/core-services/attendance/src/test/resources/TenantMDMSData.json +++ /dev/null @@ -1,402 +0,0 @@ -{ - "ResponseInfo": null, - "MdmsRes": { - "tenant": { - "tenants": [ - { - "code": "pb", - "name": "Punjab", - "description": "Punjab", - "logoId": "https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.jalandhar/logo.png", - "imageId": "https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.jalandhar/logo.png", - "domainUrl": "www.mcjalandhar.in", - "type": "CITY", - "twitterUrl": "https://twitter.com/search?q=%23jalandhar", - "facebookUrl": "https://www.facebook.com/city/jalandhar-Punjab", - "emailId": "complaints.mcj@gmail.com", - "OfficeTimings": { - "Mon - Fri": "9.00 AM - 6.00 PM" - }, - "city": { - "name": "Punjab", - "localName": "Punjab", - "districtCode": "0", - "districtName": "Punjab", - "districtTenantCode": "pb.punjab", - "regionName": "Punjab", - "ulbGrade": "ST", - "longitude": 75.3412, - "latitude": 31.1471, - "shapeFileLocation": null, - "captcha": null, - "code": "0", - "ddrName": null - }, - "address": "5 Punjab Municipal Bhawan, 3, Dakshin Marg, 35A, Sector 35A, Chandigarh, 160022", - "pincode": [], - "contactNumber": "0181-2227015", - "pdfHeader": "PB_PDF_HEADER", - "pdfContactDetails": "PB_CONTACT_DETAILS" - }, - { - "code": "pb.jalandhar", - "name": "Jalandhar", - "description": "Jalandhar", - "logoId": "", - "imageId": "", - "domainUrl": "www.mcjalandhar.in", - "type": "CITY", - "twitterUrl": "https://twitter.com/search?q=%23jalandhar", - "facebookUrl": "https://www.facebook.com/city/jalandhar-Punjab", - "emailId": "complaints.mcj@gmail.com", - "OfficeTimings": { - "Mon - Fri": "9.00 AM - 6.00 PM" - }, - "city": { - "name": "Jalandhar", - "localName": "Janlandhar", - "districtCode": "10", - "districtName": "Jalandhar", - "districtTenantCode": "pb.jalandhar", - "regionName": "Jalandhar Region", - "ulbGrade": "Municipal Corporation", - "ulbType": "Municipal Corporation", - "longitude": 75.5761829, - "latitude": 31.3260152, - "shapeFileLocation": null, - "captcha": null, - "code": "1013", - "regionCode": "4", - "municipalityName": "Janlandhar", - "ddrName": "Jalandhar-MC" - }, - "address": "Municipal Corporation Office, Dr. B.R.Ambedkar Admin Complex, Nehru Garden, Jalandhar City-144001", - "pincode": [ - 144001, - 144002, - 144003, - 144004, - 144005, - 144006, - 144007, - 144008, - 144009, - 144010 - ], - "contactNumber": "0181-2227015", - "pdfHeader": "PB_JALANDHAR_PDF_HEADER", - "pdfContactDetails": "PB_JALANDHAR_CONTACT_DETAILS" - }, - { - "code": "pb.phagwara", - "name": "Phagwara", - "description": "Phagwara", - "logoId": "https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.phagwara/logo.png", - "imageId": "https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.phagwara/logo.png", - "domainUrl": "http://www.mcphagwara.com/index.php", - "type": "CITY", - "twitterUrl": null, - "facebookUrl": null, - "emailId": "comm.mcpgr@punjab.gov.in", - "OfficeTimings": { - "Mon - Fri": "9.00 AM - 6.00 PM" - }, - "city": { - "name": "Phagwara", - "localName": "Phagwara", - "districtCode": "10", - "districtName": "Jalandhar", - "districtTenantCode": "pb.jalandhar", - "regionName": "Jalandhar Region", - "ulbGrade": "Municipal Corporation", - "ulbType": "Municipal Corporation", - "longitude": 75.7708, - "latitude": 31.224, - "shapeFileLocation": null, - "captcha": null, - "code": "1014", - "regionCode": "4", - "municipalityName": "Phagwara", - "ddrName": "Phagwara-MC" - }, - "address": "Town Hall, Phagwara, Punjab - 144401", - "pincode": [ - 144401, - 144402, - 144403 - ], - "contactNumber": "01824-260426", - "pdfHeader": "PB_PHAGWARA_PDF_HEADER", - "pdfContactDetails": "PB_PHAGWARA_CONTACT_DETAILS" - }, - { - "code": "pb.amritsar", - "name": "Amritsar", - "description": null, - "logoId": "https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.amritsar/logo.png", - "imageId": "/pb-egov-assets/pb.amritsar/logo.png", - "domainUrl": "www.amritsarcorp.com", - "type": "CITY", - "twitterUrl": "https://twitter.com/search?q=%23AMRITSAR", - "facebookUrl": "https://www.facebook.com/city/Amritsar-Punjab", - "emailId": "cmcasr@gmail.com", - "OfficeTimings": { - "Mon - Fri": "9.00 AM - 6.00 PM", - "Sat": "9.00 AM - 12.00 PM" - }, - "city": { - "name": "Amritsar", - "localName": "Amritsar", - "districtCode": "1", - "districtName": "Amritsar", - "districtTenantCode": "pb.amritsar", - "regionName": "Amritsar Region", - "ulbGrade": "Municipal Corporation", - "ulbType": "Municipal Corporation", - "longitude": 74.8723, - "latitude": 31.634, - "shapeFileLocation": null, - "captcha": null, - "code": "107", - "regionCode": "1", - "municipalityName": "Amritsar", - "ddrName": "Amritsar-MC" - }, - "address": "Municipal Corporation Amritsar, C Block, Ranjit Avenue, Amritsar, Punjab", - "pincode": [ - 143001, - 143002, - 143003, - 143004, - 143005, - 143006, - 143007, - 143008, - 143009, - 143010 - ], - "contactNumber": "0183-2545155", - "helpLineNumber": "0183-2210300", - "pdfHeader": "PB_AMRITSAR_PDF_HEADER", - "pdfContactDetails": "PB_AMRITSAR_CONTACT_DETAILS" - }, - { - "code": "pb.nawanshahr", - "name": "Nawanshahr", - "description": null, - "logoId": "https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.nawanshahr/logo.png", - "imageId": "https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.nawanshahr/logo.png", - "domainUrl": "www.nawanshahr.com", - "type": "CITY", - "twitterUrl": null, - "facebookUrl": null, - "emailId": "", - "OfficeTimings": { - "Mon - Fri": "9.00 AM - 6.00 PM" - }, - "city": { - "name": "Nawanshahr", - "localName": "Nawanshahr", - "districtCode": "17", - "districtName": "Nawanshar", - "districtTenantCode": "pb.nawanshar", - "regionName": "Jalandhar Region", - "ulbGrade": "MC Class I", - "ulbType": "Municipal Council", - "longitude": 76.0392, - "latitude": 31.0913, - "shapeFileLocation": null, - "captcha": null, - "code": "1703", - "regionCode": "4", - "municipalityName": "SBS Nagar", - "ddrName": "Jalandhar-DDR" - }, - "address": "Committee Bazar", - "pincode": [ - 144513, - 144514, - 144516, - 144517 - ], - "contactNumber": "1823220085", - "helpLineNumber": "", - "pdfHeader": "PB_NAWANSHAHR_PDF_HEADER", - "pdfContactDetails": "PB_NAWANSHAHR_CONTACT_DETAILS" - }, - { - "code": "pb.mohali", - "name": "Mohali", - "description": "Mohali", - "logoId": "https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.mohali/logo.png", - "imageId": "https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.mohali/logo.png", - "domainUrl": "www.mcjalandhar.in", - "type": "CITY", - "twitterUrl": "https://twitter.com/search?q=%23mohali", - "facebookUrl": "https://www.facebook.com/city/mohali-Punjab", - "emailId": "complaints.mcj@gmail.com", - "OfficeTimings": { - "Mon - Fri": "9.00 AM - 6.00 PM" - }, - "city": { - "name": "Mohali", - "localName": "Mohali", - "districtCode": "15", - "districtName": "Mohali", - "districtTenantCode": "pb.mohali", - "regionName": "Patiala Region", - "ulbGrade": "Municipal Corporation", - "ulbType": "Municipal Corporation", - "longitude": 76.7179, - "latitude": 30.7046, - "shapeFileLocation": null, - "captcha": null, - "code": "1508", - "regionCode": "6", - "municipalityName": "SAS Nagar", - "ddrName": "Mohali-MC" - }, - "address": "Sector 68, Sahibzada Ajit Singh Nagar, Punjab 160062", - "pincode": [ - 140301, - 140302, - 140303, - 140304, - 140305, - 140306, - 140307 - ], - "contactNumber": "0172-5044907", - "pdfHeader": "PB_MOHALI_PDF_HEADER", - "pdfContactDetails": "PB_MOHALI_CONTACT_DETAILS" - }, - { - "code": "pb.nayagaon", - "name": "Nayagaon", - "description": "Nayagaon", - "logoId": "https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.nayagaon/logo.png", - "imageId": null, - "domainUrl": "http://lgpunjab.gov.in/eSewa/nayagaon", - "type": "CITY", - "twitterUrl": null, - "facebookUrl": null, - "emailId": "eonpnayagaon@ymail.com", - "OfficeTimings": { - "Mon - Fri": "9.00 AM - 5.00 PM" - }, - "city": { - "name": "Nayagaon", - "localName": "NayaGaon", - "districtCode": "15", - "districtName": "Mohali", - "districtTenantCode": "pb.mohali", - "regionName": "Patiala Region", - "ulbGrade": "MC Class II", - "ulbType": "Municipal Council", - "longitude": 76.7943, - "latitude": 30.7761, - "shapeFileLocation": null, - "captcha": null, - "code": "1506", - "regionCode": "6", - "municipalityName": "NayaGaon", - "ddrName": "Patiala-DDR" - }, - "address": "Not available", - "pincode": [ - 147001, - 147002, - 147003, - 147004, - 147005 - ], - "contactNumber": "Not available", - "pdfHeader": "PB_NAYAGAON_PDF_HEADER", - "pdfContactDetails": "PB_NAYAGAON_CONTACT_DETAILS" - }, - { - "code": "pb.derabassi", - "name": "Derabassi", - "description": "Derabassi", - "logoId": "https://s3.ap-south-1.amazonaws.com/pb-egov-assets/pb.derabassi/logo.png", - "imageId": null, - "domainUrl": "http://lgpunjab.gov.in/eSewa/derabassi", - "type": "CITY", - "twitterUrl": null, - "facebookUrl": null, - "emailId": "eomcdera@gmail.com", - "OfficeTimings": { - "Mon - Fri": "9.00 AM - 5.00 PM" - }, - "city": { - "name": "Derabassi", - "localName": "DeraBassi", - "districtCode": "15", - "districtName": "Mohali", - "districtTenantCode": "pb.mohali", - "regionName": "Patiala Region", - "ulbGrade": "MC Class I", - "ulbType": "Municipal Council", - "longitude": 76.8433, - "latitude": 30.5964, - "shapeFileLocation": null, - "captcha": null, - "code": "1502", - "regionCode": "6", - "municipalityName": "DerraBassi", - "ddrName": "Patiala-DDR" - }, - "address": "Not available", - "pincode": [ - 140506, - 140507 - ], - "contactNumber": "1762281025", - "pdfHeader": "PB_DERABASSI_PDF_HEADER", - "pdfContactDetails": "PB_DERABASSI_CONTACT_DETAILS" - }, - { - "code": "pb.patiala", - "name": "Patiala", - "description": "Patiala", - "logoId": "http://mseva.lgpunjab.gov.in/pb-egov-assets/pb.patiala/logo.png", - "imageId": null, - "domainUrl": "https://patiala.nic.in/", - "type": "CITY", - "twitterUrl": null, - "facebookUrl": null, - "emailId": "dc.ptl@punjab.gov.in", - "OfficeTimings": { - "Mon - Fri": "9.00 AM - 6.00 PM" - }, - "city": { - "name": "Patiala", - "localName": "Patiala", - "districtCode": "19", - "districtName": "Patiala", - "districtTenantCode": "pb.patiala", - "regionName": "Patiala Region", - "ulbGrade": "Municipal Corporation", - "ulbType": "Municipal Corporation", - "longitude": 76.3869, - "latitude": 30.3398, - "shapeFileLocation": null, - "captcha": null, - "code": "1910", - "regionCode": "6", - "municipalityName": "Patiala", - "ddrName": "Patiala-MC" - }, - "address": "Office of the Deputy Commissioner District Administrative Complex, Patiala-147001", - "contactNumber": "0175-2311300", - "pincode": [ - 140506, - 140507 - ], - "pdfHeader": "PB_PATIALA_PDF_HEADER", - "pdfContactDetails": "PB_PATIALA_CONTACT_DETAILS" - } - ] - } - } -} \ No newline at end of file diff --git a/core-services/egov-hrms/CHANGELOG.md b/core-services/egov-hrms/CHANGELOG.md index 0b29fa88acc..79728eda4ce 100644 --- a/core-services/egov-hrms/CHANGELOG.md +++ b/core-services/egov-hrms/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this module will be documented in this file. ## 1.2.7 - 2024-05-29 - Integrated Boundary v2 functionality - Individual model copied and replicated to the 2.9 version +- Upgraded Flyway base image version to 10.7.1 for DB Migration ## 1.2.6 - 2024-03-06 - Added client Referenceid to Individual to avoid errors during down sync in APK diff --git a/core-services/egov-hrms/pom.xml b/core-services/egov-hrms/pom.xml index 49979c02a0e..0a0507aa5a4 100644 --- a/core-services/egov-hrms/pom.xml +++ b/core-services/egov-hrms/pom.xml @@ -39,6 +39,7 @@ org.flywaydb flyway-core + 9.22.3 org.postgresql diff --git a/core-services/egov-hrms/src/main/java/org/egov/hrms/web/models/IndividualSearch.java b/core-services/egov-hrms/src/main/java/org/egov/hrms/web/models/IndividualSearch.java index d0034dc4d9a..dfae3a41092 100644 --- a/core-services/egov-hrms/src/main/java/org/egov/hrms/web/models/IndividualSearch.java +++ b/core-services/egov-hrms/src/main/java/org/egov/hrms/web/models/IndividualSearch.java @@ -49,37 +49,49 @@ public class IndividualSearch extends EgovOfflineSearchModel { private List mobileNumber = null; @JsonProperty("socialCategory") + @Exclude private String socialCategory = null; @JsonProperty("wardCode") + @Exclude private String wardCode = null; + //Exclude annotation to exclude the field during dynamic sql query generation, because this field is not available in table and generic query fails @JsonProperty("individualName") + @Exclude private String individualName = null; @JsonProperty("createdFrom") + @Exclude private BigDecimal createdFrom = null; @JsonProperty("createdTo") + @Exclude private BigDecimal createdTo = null; @JsonProperty("identifier") @Valid + @Exclude private Identifier identifier = null; @JsonProperty("boundaryCode") + @Exclude private String boundaryCode = null; @JsonProperty("roleCodes") + @Exclude private List roleCodes = null; @JsonProperty("username") + @Exclude private List username; @JsonProperty("userId") + @Exclude private List userId; @JsonProperty("userUuid") + @Exclude @Size(min = 1) private List userUuid; diff --git a/core-services/egov-hrms/src/main/java/org/egov/hrms/web/validator/EmployeeValidator.java b/core-services/egov-hrms/src/main/java/org/egov/hrms/web/validator/EmployeeValidator.java index e19f1f4b063..2a474e9d708 100644 --- a/core-services/egov-hrms/src/main/java/org/egov/hrms/web/validator/EmployeeValidator.java +++ b/core-services/egov-hrms/src/main/java/org/egov/hrms/web/validator/EmployeeValidator.java @@ -148,6 +148,8 @@ public Map> getBoundaryList(RequestInfo requestInfo,Employe log.info("successfully fetch boundary"); } catch (Exception e) { log.error("error while fetching boundary"); + log.error("Error while fetching boundaries from Boundary Service", e); + throw new CustomException("BOUNDARY_SERVICE_SEARCH_ERROR","Error while fetching boundaries from Boundary Service : " + e.getMessage()); } } diff --git a/core-services/egov-hrms/src/main/resources/db/Dockerfile b/core-services/egov-hrms/src/main/resources/db/Dockerfile index a5699ff7d99..e7da01d7f0b 100644 --- a/core-services/egov-hrms/src/main/resources/db/Dockerfile +++ b/core-services/egov-hrms/src/main/resources/db/Dockerfile @@ -1,4 +1,4 @@ -FROM egovio/flyway:4.1.2 +FROM egovio/flyway:10.7.1 COPY ./migration/main /flyway/sql @@ -6,4 +6,4 @@ COPY migrate.sh /usr/bin/migrate.sh RUN chmod +x /usr/bin/migrate.sh -CMD ["/usr/bin/migrate.sh"] +ENTRYPOINT ["/usr/bin/migrate.sh"] \ No newline at end of file diff --git a/core-services/egov-hrms/src/main/resources/db/migrate.sh b/core-services/egov-hrms/src/main/resources/db/migrate.sh index 43960b25cdb..f9d6617822c 100644 --- a/core-services/egov-hrms/src/main/resources/db/migrate.sh +++ b/core-services/egov-hrms/src/main/resources/db/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate \ No newline at end of file +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate diff --git a/core-services/egov-hrms/src/test/resources/db/Dockerfile b/core-services/egov-hrms/src/test/resources/db/Dockerfile index fcb806edf0c..e7da01d7f0b 100644 --- a/core-services/egov-hrms/src/test/resources/db/Dockerfile +++ b/core-services/egov-hrms/src/test/resources/db/Dockerfile @@ -1,13 +1,9 @@ -FROM egovio/flyway:4.1.2 +FROM egovio/flyway:10.7.1 COPY ./migration/main /flyway/sql -COPY ./migration/seed /flyway/seed - -COPY ./migration/dev /flyway/dev - COPY migrate.sh /usr/bin/migrate.sh RUN chmod +x /usr/bin/migrate.sh -CMD ["/usr/bin/migrate.sh"] +ENTRYPOINT ["/usr/bin/migrate.sh"] \ No newline at end of file diff --git a/core-services/egov-hrms/src/test/resources/db/migrate.sh b/core-services/egov-hrms/src/test/resources/db/migrate.sh index 54d07c0940a..f9d6617822c 100644 --- a/core-services/egov-hrms/src/test/resources/db/migrate.sh +++ b/core-services/egov-hrms/src/test/resources/db/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate diff --git a/core-services/egov-survey-services/src/main/resources/db/Dockerfile b/core-services/egov-survey-services/src/main/resources/db/Dockerfile index a5699ff7d99..e7da01d7f0b 100644 --- a/core-services/egov-survey-services/src/main/resources/db/Dockerfile +++ b/core-services/egov-survey-services/src/main/resources/db/Dockerfile @@ -1,4 +1,4 @@ -FROM egovio/flyway:4.1.2 +FROM egovio/flyway:10.7.1 COPY ./migration/main /flyway/sql @@ -6,4 +6,4 @@ COPY migrate.sh /usr/bin/migrate.sh RUN chmod +x /usr/bin/migrate.sh -CMD ["/usr/bin/migrate.sh"] +ENTRYPOINT ["/usr/bin/migrate.sh"] \ No newline at end of file diff --git a/core-services/egov-survey-services/src/main/resources/db/migrate.sh b/core-services/egov-survey-services/src/main/resources/db/migrate.sh index 43960b25cdb..f9d6617822c 100644 --- a/core-services/egov-survey-services/src/main/resources/db/migrate.sh +++ b/core-services/egov-survey-services/src/main/resources/db/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate \ No newline at end of file +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate diff --git a/core-services/pgr-services/pom.xml b/core-services/pgr-services/pom.xml index a9746f2fd2a..f261a90cef5 100644 --- a/core-services/pgr-services/pom.xml +++ b/core-services/pgr-services/pom.xml @@ -107,7 +107,7 @@ org.postgresql postgresql - 42.2.2.jre7 + 42.7.1 org.egov @@ -115,10 +115,10 @@ 0.0.2-SNAPSHOT compile - org.flywaydb flyway-core + 9.22.3 com.itextpdf diff --git a/core-services/pgr-services/src/main/resources/db/Dockerfile b/core-services/pgr-services/src/main/resources/db/Dockerfile index a5699ff7d99..e7da01d7f0b 100644 --- a/core-services/pgr-services/src/main/resources/db/Dockerfile +++ b/core-services/pgr-services/src/main/resources/db/Dockerfile @@ -1,4 +1,4 @@ -FROM egovio/flyway:4.1.2 +FROM egovio/flyway:10.7.1 COPY ./migration/main /flyway/sql @@ -6,4 +6,4 @@ COPY migrate.sh /usr/bin/migrate.sh RUN chmod +x /usr/bin/migrate.sh -CMD ["/usr/bin/migrate.sh"] +ENTRYPOINT ["/usr/bin/migrate.sh"] \ No newline at end of file diff --git a/core-services/pgr-services/src/main/resources/db/migrate.sh b/core-services/pgr-services/src/main/resources/db/migrate.sh index 43960b25cdb..f9d6617822c 100644 --- a/core-services/pgr-services/src/main/resources/db/migrate.sh +++ b/core-services/pgr-services/src/main/resources/db/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate \ No newline at end of file +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate diff --git a/core-services/service-request/pom.xml b/core-services/service-request/pom.xml index 6dfbc669431..3c16fbe8189 100644 --- a/core-services/service-request/pom.xml +++ b/core-services/service-request/pom.xml @@ -41,13 +41,14 @@ spring-boot-starter-jdbc - org.flywaydb - flyway-core + org.flywaydb + flyway-core + 9.22.3 - org.postgresql - postgresql - 42.2.2.jre7 + org.postgresql + postgresql + 42.7.1 org.springframework.boot diff --git a/core-services/service-request/src/main/resources/db/Dockerfile b/core-services/service-request/src/main/resources/db/Dockerfile index 60fc07ce69f..e7da01d7f0b 100644 --- a/core-services/service-request/src/main/resources/db/Dockerfile +++ b/core-services/service-request/src/main/resources/db/Dockerfile @@ -1,4 +1,4 @@ -FROM egovio/flyway:4.1.2 +FROM egovio/flyway:10.7.1 COPY ./migration/main /flyway/sql @@ -6,4 +6,4 @@ COPY migrate.sh /usr/bin/migrate.sh RUN chmod +x /usr/bin/migrate.sh -CMD ["/usr/bin/migrate.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/migrate.sh"] \ No newline at end of file diff --git a/core-services/service-request/src/main/resources/db/migrate.sh b/core-services/service-request/src/main/resources/db/migrate.sh index 43960b25cdb..f9d6617822c 100644 --- a/core-services/service-request/src/main/resources/db/migrate.sh +++ b/core-services/service-request/src/main/resources/db/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate \ No newline at end of file +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate diff --git a/health-services/facility/CHANGELOG.md b/health-services/facility/CHANGELOG.md index 7d61aeac33a..7d24c53744d 100644 --- a/health-services/facility/CHANGELOG.md +++ b/health-services/facility/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this module will be documented in this file. - Integrated Core 2.9LTS - Upgraded to health models 1.0.20 and health common 1.0.16 - Integrated Boundary v2 functionality +- Upgraded PostgresSQL Driver version to 42.7.1 +- Upgraded Flyway base image version to 10.7.1 for DB Migration +- Upgraded Flyway-Core to 9.22.3 ## 1.0.0 diff --git a/health-services/facility/pom.xml b/health-services/facility/pom.xml index c714a29de25..1eb0038656a 100644 --- a/health-services/facility/pom.xml +++ b/health-services/facility/pom.xml @@ -45,7 +45,7 @@ org.egov.common health-services-common - 1.0.16-SNAPSHOT + 1.0.17-SNAPSHOT org.egov.common @@ -61,11 +61,12 @@ org.flywaydb flyway-core + 9.22.3 org.postgresql postgresql - 42.2.2.jre7 + 42.7.1 org.springframework.boot diff --git a/health-services/facility/src/main/java/org/egov/facility/validator/FBoundaryValidator.java b/health-services/facility/src/main/java/org/egov/facility/validator/FBoundaryValidator.java index dc0dc2b157d..2919150eb65 100644 --- a/health-services/facility/src/main/java/org/egov/facility/validator/FBoundaryValidator.java +++ b/health-services/facility/src/main/java/org/egov/facility/validator/FBoundaryValidator.java @@ -117,7 +117,7 @@ public Map> validate(FacilityBulkRequest request) { } catch (Exception e) { log.error("Exception while searching boundaries for tenantId: {}", tenantId, e); // Throw a custom exception if an error occurs during boundary search - throw new CustomException("BOUNDARY_SEARCH_ERROR", e.getMessage()); + throw new CustomException("BOUNDARY_SERVICE_SEARCH_ERROR","Error in while fetching boundaries from Boundary Service : " + e.getMessage()); } } }); diff --git a/health-services/facility/src/main/resources/db/Dockerfile b/health-services/facility/src/main/resources/db/Dockerfile index 60fc07ce69f..e7da01d7f0b 100644 --- a/health-services/facility/src/main/resources/db/Dockerfile +++ b/health-services/facility/src/main/resources/db/Dockerfile @@ -1,4 +1,4 @@ -FROM egovio/flyway:4.1.2 +FROM egovio/flyway:10.7.1 COPY ./migration/main /flyway/sql @@ -6,4 +6,4 @@ COPY migrate.sh /usr/bin/migrate.sh RUN chmod +x /usr/bin/migrate.sh -CMD ["/usr/bin/migrate.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/migrate.sh"] \ No newline at end of file diff --git a/health-services/facility/src/main/resources/db/migrate.sh b/health-services/facility/src/main/resources/db/migrate.sh index 43960b25cdb..f9d6617822c 100644 --- a/health-services/facility/src/main/resources/db/migrate.sh +++ b/health-services/facility/src/main/resources/db/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate \ No newline at end of file +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate diff --git a/health-services/household/CHANGELOG.md b/health-services/household/CHANGELOG.md index b5b4a01a43a..3eed6ddb78c 100644 --- a/health-services/household/CHANGELOG.md +++ b/health-services/household/CHANGELOG.md @@ -6,6 +6,9 @@ All notable changes to this module will be documented in this file. - Upgraded to health models 1.0.20 and health common 1.0.16 - Boundary v2 Integration - MDMS v2 integration +- Upgraded PostgresSQL Driver version to 42.7.1 +- Upgraded Flyway base image version to 10.7.1 for DB Migration +- Upgraded Flyway-Core to 9.22.3 ## 1.1.2 - 2024-05-10 - Integrated Boundary v2 functionality diff --git a/health-services/household/pom.xml b/health-services/household/pom.xml index 25aa6b469a5..1d59cc57c94 100644 --- a/health-services/household/pom.xml +++ b/health-services/household/pom.xml @@ -45,7 +45,7 @@ org.egov.common health-services-common - 1.0.16-SNAPSHOT + 1.0.17-SNAPSHOT org.egov.common diff --git a/health-services/household/src/main/java/org/egov/household/household/member/validators/HmExistentEntityValidator.java b/health-services/household/src/main/java/org/egov/household/household/member/validators/HmExistentEntityValidator.java index 609001e7c71..1e335cd753e 100644 --- a/health-services/household/src/main/java/org/egov/household/household/member/validators/HmExistentEntityValidator.java +++ b/health-services/household/src/main/java/org/egov/household/household/member/validators/HmExistentEntityValidator.java @@ -5,12 +5,15 @@ import java.util.Map; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.household.HouseholdMember; import org.egov.common.models.household.HouseholdMemberBulkRequest; import org.egov.common.models.household.HouseholdMemberSearch; import org.egov.common.validator.Validator; import org.egov.household.repository.HouseholdMemberRepository; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import static org.egov.common.utils.CommonUtils.getIdFieldName; @@ -24,6 +27,9 @@ * * @author kanishq-egov */ +@Component +@Order(value = 1) +@Slf4j public class HmExistentEntityValidator implements Validator { private final HouseholdMemberRepository householdMemberRepository; diff --git a/health-services/household/src/main/java/org/egov/household/household/member/validators/HmNonExistentEntityValidator.java b/health-services/household/src/main/java/org/egov/household/household/member/validators/HmNonExistentEntityValidator.java index e7b195dd694..6440a640f3a 100644 --- a/health-services/household/src/main/java/org/egov/household/household/member/validators/HmNonExistentEntityValidator.java +++ b/health-services/household/src/main/java/org/egov/household/household/member/validators/HmNonExistentEntityValidator.java @@ -9,19 +9,17 @@ import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; -import org.egov.common.models.household.Household; import org.egov.common.models.household.HouseholdMember; import org.egov.common.models.household.HouseholdMemberBulkRequest; import org.egov.common.models.household.HouseholdMemberSearch; -import org.egov.common.models.household.HouseholdSearch; import org.egov.common.validator.Validator; import org.egov.household.repository.HouseholdMemberRepository; +import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import static org.egov.common.utils.CommonUtils.checkNonExistentEntities; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.getIdToObjMap; import static org.egov.common.utils.CommonUtils.getMethod; import static org.egov.common.utils.CommonUtils.getObjClass; @@ -73,7 +71,6 @@ public Map> validate(HouseholdMemberBulkRequest req // Create a map of household members with their IDs as keys Map iMap = getIdToObjMap(householdMembers .stream().filter(notHavingErrors()).collect(Collectors.toList()), idMethod); - // Check if the map is not empty // Lists to store IDs and client reference IDs List idList = new ArrayList<>(); @@ -84,9 +81,9 @@ public Map> validate(HouseholdMemberBulkRequest req clientReferenceIdList.add(householdMember.getClientReferenceId()); }); + // Check if the map is not empty if (!iMap.isEmpty()) { - // Extract IDs from the map - List householdMemberIds = new ArrayList<>(iMap.keySet()); + // Create a search object for querying existing entities HouseholdMemberSearch householdMemberSearch = HouseholdMemberSearch.builder() .clientReferenceId(clientReferenceIdList) @@ -100,7 +97,8 @@ public Map> validate(HouseholdMemberBulkRequest req householdMembers.get(0).getTenantId(), null, false).getResponse(); } catch (Exception e) { // Handle query builder exception - throw new RuntimeException(e); + log.error("Search failed for HouseholdMember with error: {}", e.getMessage(), e); + throw new CustomException("HOUSEHOLD_MEMBER_SEARCH_FAILED", "Search Failed for HouseholdMember, " + e.getMessage()); } // Check for non-existent household members diff --git a/health-services/household/src/main/java/org/egov/household/validators/household/HBoundaryValidator.java b/health-services/household/src/main/java/org/egov/household/validators/household/HBoundaryValidator.java index b0998f29cde..a92ad1aad3e 100644 --- a/health-services/household/src/main/java/org/egov/household/validators/household/HBoundaryValidator.java +++ b/health-services/household/src/main/java/org/egov/household/validators/household/HBoundaryValidator.java @@ -117,7 +117,7 @@ public Map> validate(HouseholdBulkRequest request) { } catch (Exception e) { log.error("Exception while searching boundaries for tenantId: {}", tenantId, e); // Throw a custom exception if an error occurs during boundary search - throw new CustomException("BOUNDARY_SEARCH_ERROR", e.getMessage()); + throw new CustomException("BOUNDARY_SERVICE_SEARCH_ERROR","Error in while fetching boundaries from Boundary Service : " + e.getMessage()); } } }); diff --git a/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java b/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java index 980702a693d..57162432093 100644 --- a/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java +++ b/health-services/household/src/main/java/org/egov/household/validators/household/HExistentEntityValidator.java @@ -5,12 +5,15 @@ import java.util.Map; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.household.Household; import org.egov.common.models.household.HouseholdBulkRequest; import org.egov.common.models.household.HouseholdSearch; import org.egov.common.validator.Validator; import org.egov.household.repository.HouseholdRepository; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import static org.egov.common.utils.CommonUtils.getIdFieldName; @@ -23,6 +26,9 @@ * This validator checks if the provided household entities already exist in the database based on their client reference IDs. * @author kanishq-egov */ +@Component +@Order(value = 1) +@Slf4j public class HExistentEntityValidator implements Validator { private final HouseholdRepository householdRepository; diff --git a/health-services/household/src/main/java/org/egov/household/validators/household/HNonExistentEntityValidator.java b/health-services/household/src/main/java/org/egov/household/validators/household/HNonExistentEntityValidator.java index e18090664ea..f6a3a129f31 100644 --- a/health-services/household/src/main/java/org/egov/household/validators/household/HNonExistentEntityValidator.java +++ b/health-services/household/src/main/java/org/egov/household/validators/household/HNonExistentEntityValidator.java @@ -15,6 +15,7 @@ import org.egov.common.models.household.HouseholdSearch; import org.egov.common.validator.Validator; import org.egov.household.repository.HouseholdRepository; +import org.egov.tracer.model.CustomException; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; @@ -88,7 +89,8 @@ public Map> validate(HouseholdBulkRequest request) { entities.get(0).getTenantId(), null, false).getResponse(); } catch (Exception e) { // Handle query builder exception - throw new RuntimeException(e); + log.error("Search failed for Household with error: {}", e.getMessage(), e); + throw new CustomException("HOUSEHOLD_SEARCH_FAILED", "Search Failed for Household, " + e.getMessage()); } // Check for non-existent entities List nonExistentEntities = checkNonExistentEntities(eMap, diff --git a/health-services/household/src/main/resources/db/migrate.sh b/health-services/household/src/main/resources/db/migrate.sh index 5593a173eba..f9d6617822c 100644 --- a/health-services/household/src/main/resources/db/migrate.sh +++ b/health-services/household/src/main/resources/db/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate \ No newline at end of file +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate diff --git a/health-services/individual/CHANGELOG.md b/health-services/individual/CHANGELOG.md index 2d094bdd706..26df13994d2 100644 --- a/health-services/individual/CHANGELOG.md +++ b/health-services/individual/CHANGELOG.md @@ -7,6 +7,9 @@ All notable changes to this module will be documented in this file. - Upgraded to health models 1.0.20 and health common 1.0.16 - Boundary v2 Integration - MDMS v2 integration +- Upgraded PostgresSQL Driver version to 42.7.1 +- Upgraded Flyway base image version to 10.7.1 for DB Migration +- Upgraded Flyway-Core to 9.22.3 ## 1.1.4 - 2024-05-10 - Integrated Boundary v2 functionality diff --git a/health-services/individual/pom.xml b/health-services/individual/pom.xml index b886ac048bd..f739e08e736 100644 --- a/health-services/individual/pom.xml +++ b/health-services/individual/pom.xml @@ -53,7 +53,7 @@ org.egov.common health-services-common - 1.0.16-SNAPSHOT + 1.0.17-SNAPSHOT org.egov.common diff --git a/health-services/individual/src/main/java/org/egov/individual/repository/IndividualRepository.java b/health-services/individual/src/main/java/org/egov/individual/repository/IndividualRepository.java index 3d9b4bb19c8..11a942b5050 100644 --- a/health-services/individual/src/main/java/org/egov/individual/repository/IndividualRepository.java +++ b/health-services/individual/src/main/java/org/egov/individual/repository/IndividualRepository.java @@ -283,11 +283,6 @@ private String getQueryForIndividual(IndividualSearch searchObject, Integer limi paramsMap.put("userUuid", searchObject.getUserUuid()); } - if(!StringUtils.isEmpty(searchObject.getType())){ - query = query + "AND type = :type "; - paramsMap.put("type", searchObject.getType()); - } - query = query + "ORDER BY createdtime DESC LIMIT :limit OFFSET :offset"; paramsMap.put("tenantId", tenantId); diff --git a/health-services/individual/src/main/java/org/egov/individual/validators/IBoundaryValidator.java b/health-services/individual/src/main/java/org/egov/individual/validators/IBoundaryValidator.java index 53c94861783..83eb2b343af 100644 --- a/health-services/individual/src/main/java/org/egov/individual/validators/IBoundaryValidator.java +++ b/health-services/individual/src/main/java/org/egov/individual/validators/IBoundaryValidator.java @@ -119,7 +119,7 @@ public Map> validate(IndividualBulkRequest request) { } catch (Exception e) { log.error("Exception while searching boundaries for tenantId: {}", tenantId, e); // Throw a custom exception if an error occurs during boundary search - throw new CustomException("BOUNDARY_SEARCH_ERROR", e.getMessage()); + throw new CustomException("BOUNDARY_SERVICE_SEARCH_ERROR","Error in while fetching boundaries from Boundary Service : " + e.getMessage()); } } }); diff --git a/health-services/individual/src/main/java/org/egov/individual/validators/IExistentEntityValidator.java b/health-services/individual/src/main/java/org/egov/individual/validators/IExistentEntityValidator.java index 8e3b40a0843..a5f75eaa0b8 100644 --- a/health-services/individual/src/main/java/org/egov/individual/validators/IExistentEntityValidator.java +++ b/health-services/individual/src/main/java/org/egov/individual/validators/IExistentEntityValidator.java @@ -5,12 +5,15 @@ import java.util.Map; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.individual.Individual; import org.egov.common.models.individual.IndividualBulkRequest; import org.egov.common.models.individual.IndividualSearch; import org.egov.common.validator.Validator; import org.egov.individual.repository.IndividualRepository; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import static org.egov.common.utils.CommonUtils.getIdFieldName; @@ -23,6 +26,9 @@ * This validator checks if the provided individual entities already exist in the database based on their client reference IDs. * @author kanishq-egov */ +@Component +@Order(value = 1) +@Slf4j public class IExistentEntityValidator implements Validator { private final IndividualRepository individualRepository; diff --git a/health-services/individual/src/main/java/org/egov/individual/validators/INonExistentEntityValidator.java b/health-services/individual/src/main/java/org/egov/individual/validators/INonExistentEntityValidator.java index ce2946ab8c9..02b5b128599 100644 --- a/health-services/individual/src/main/java/org/egov/individual/validators/INonExistentEntityValidator.java +++ b/health-services/individual/src/main/java/org/egov/individual/validators/INonExistentEntityValidator.java @@ -14,6 +14,7 @@ import org.egov.common.models.individual.IndividualSearch; import org.egov.common.validator.Validator; import org.egov.individual.repository.IndividualRepository; +import org.egov.tracer.model.CustomException; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; @@ -72,8 +73,7 @@ public Map> validate(IndividualBulkRequest request) { }); // Check if the entity map is not empty if (!eMap.isEmpty()) { - // Extract entity IDs - List entityIds = new ArrayList<>(eMap.keySet()); + // Create a search object for querying existing entities IndividualSearch individualSearch = IndividualSearch.builder() .id(idList) @@ -88,7 +88,8 @@ public Map> validate(IndividualBulkRequest request) { } catch (Exception e) { // Handle query builder exception existingEntities = new ArrayList<>(); - throw new RuntimeException(e); + log.error("Search failed for Individual with error: {}", e.getMessage(), e); + throw new CustomException("INDIVIDUAL_SEARCH_FAILED", "Search Failed for Individual, " + e.getMessage()); } // Check for non-existent entities List nonExistentEntities = checkNonExistentEntities(eMap, diff --git a/health-services/individual/src/main/java/org/egov/individual/validators/NonExistentEntityValidator.java b/health-services/individual/src/main/java/org/egov/individual/validators/NonExistentEntityValidator.java index 03c091d385d..fa9b3617ca9 100644 --- a/health-services/individual/src/main/java/org/egov/individual/validators/NonExistentEntityValidator.java +++ b/health-services/individual/src/main/java/org/egov/individual/validators/NonExistentEntityValidator.java @@ -4,8 +4,10 @@ import org.egov.common.models.Error; import org.egov.common.models.individual.Individual; import org.egov.common.models.individual.IndividualBulkRequest; +import org.egov.common.models.individual.IndividualSearch; import org.egov.common.validator.Validator; import org.egov.individual.repository.IndividualRepository; +import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; @@ -56,10 +58,31 @@ public Map> validate(IndividualBulkRequest request) { Method idMethod = getMethod(GET_ID, objClass); Map iMap = getIdToObjMap(individuals .stream().filter(notHavingErrors()).collect(Collectors.toList()), idMethod); + // Lists to store IDs and client reference IDs + List idList = new ArrayList<>(); + List clientReferenceIdList = new ArrayList<>(); + // Extract IDs and client reference IDs from individual entities + individuals.forEach(individual -> { + idList.add(individual.getId()); + clientReferenceIdList.add(individual.getClientReferenceId()); + }); if (!iMap.isEmpty()) { - List individualIds = new ArrayList<>(iMap.keySet()); - List existingIndividuals = individualRepository.findById(individualIds, - getIdFieldName(idMethod), false).getResponse(); + // Create a search object for querying existing entities + IndividualSearch individualSearch = IndividualSearch.builder() + .id(idList) + .clientReferenceId(clientReferenceIdList) + .build(); + + List existingIndividuals; + try { + // Query the repository to find existing entities + existingIndividuals = individualRepository.find(individualSearch, individuals.size(), 0, + individuals.get(0).getTenantId(), null, false).getResponse(); + } catch (Exception e) { + // Handle query builder exception + log.error("Search failed for Individual with error: {}", e.getMessage(), e); + throw new CustomException("INDIVIDUAL_SEARCH_FAILED", "Search Failed for Individual, " + e.getMessage()); + } List nonExistentIndividuals = checkNonExistentEntities(iMap, existingIndividuals, idMethod); nonExistentIndividuals.forEach(individual -> { diff --git a/health-services/individual/src/main/resources/db/Dockerfile b/health-services/individual/src/main/resources/db/Dockerfile index 60fc07ce69f..e7da01d7f0b 100644 --- a/health-services/individual/src/main/resources/db/Dockerfile +++ b/health-services/individual/src/main/resources/db/Dockerfile @@ -1,4 +1,4 @@ -FROM egovio/flyway:4.1.2 +FROM egovio/flyway:10.7.1 COPY ./migration/main /flyway/sql @@ -6,4 +6,4 @@ COPY migrate.sh /usr/bin/migrate.sh RUN chmod +x /usr/bin/migrate.sh -CMD ["/usr/bin/migrate.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/migrate.sh"] \ No newline at end of file diff --git a/health-services/individual/src/main/resources/db/migrate.sh b/health-services/individual/src/main/resources/db/migrate.sh index 43960b25cdb..f9d6617822c 100644 --- a/health-services/individual/src/main/resources/db/migrate.sh +++ b/health-services/individual/src/main/resources/db/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate \ No newline at end of file +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate diff --git a/health-services/individual/src/test/java/org/egov/individual/validator/NonExistentEntityValidatorTest.java b/health-services/individual/src/test/java/org/egov/individual/validator/NonExistentEntityValidatorTest.java index fe54f1e585a..06ec0dc7f1c 100644 --- a/health-services/individual/src/test/java/org/egov/individual/validator/NonExistentEntityValidatorTest.java +++ b/health-services/individual/src/test/java/org/egov/individual/validator/NonExistentEntityValidatorTest.java @@ -8,6 +8,7 @@ import org.egov.common.models.individual.Identifier; import org.egov.common.models.individual.Individual; import org.egov.common.models.individual.IndividualBulkRequest; +import org.egov.common.models.individual.IndividualSearch; import org.egov.common.models.individual.Skill; import org.egov.individual.helper.IndividualBulkRequestTestBuilder; import org.egov.individual.helper.IndividualTestBuilder; @@ -28,6 +29,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyList; import static org.mockito.ArgumentMatchers.anyString; @@ -65,10 +67,13 @@ void shouldNotGiveErrorWhenEntityExists() { IndividualBulkRequest individualBulkRequest = IndividualBulkRequestTestBuilder.builder().withIndividuals(individual).build(); List existingIndividuals = new ArrayList<>(); existingIndividuals.add(individual); - lenient().when(individualRepository.findById(anyList(), anyString(), eq(false))).thenReturn(SearchResponse.builder() - .totalCount(Long.valueOf(existingIndividuals.size())) - .response(existingIndividuals) - .build()); + lenient().when(individualRepository.find(any(), any(), any(), any(), any(), any(Boolean.class))) + .thenReturn( + SearchResponse.builder() + .totalCount(Long.valueOf(existingIndividuals.size())) + .response(existingIndividuals) + .build() + ); assertTrue(nonExistentEntityValidator.validate(individualBulkRequest).isEmpty()); } @@ -80,7 +85,8 @@ void shouldGiveErrorWhenEntityDoesNotExist() { .withId("some-id") .build()) .build(); - when(individualRepository.findById(anyList(), anyString(), anyBoolean())).thenReturn(SearchResponse.builder().build()); + when(individualRepository.find(any(), any(), any(), any(), any(), any(Boolean.class))) + .thenReturn(SearchResponse.builder().build()); Map> errorDetailsMap = new HashMap<>(); errorDetailsMap = nonExistentEntityValidator.validate(individualBulkRequest); List errorList = errorDetailsMap.values().stream().flatMap(Collection::stream).collect(Collectors.toList()); diff --git a/health-services/libraries/health-services-common/CHANGELOG.md b/health-services/libraries/health-services-common/CHANGELOG.md index 9479b054b01..14669d15d9f 100644 --- a/health-services/libraries/health-services-common/CHANGELOG.md +++ b/health-services/libraries/health-services-common/CHANGELOG.md @@ -6,7 +6,7 @@ All notable changes to this module will be documented in this file. - Integrated Core 2.9LTS - Refactored existing code to utilize new reusable functions, reducing redundancy. - Improved overall code structure for more efficient execution and easier future modifications. - +- Changed Dockerfile, base image required for Java 17. ## 1.0.12 - The exception was replaced with CustomException in the service request client. diff --git a/health-services/libraries/health-services-common/pom.xml b/health-services/libraries/health-services-common/pom.xml index 6eaa45c5acc..a48b96a222d 100644 --- a/health-services/libraries/health-services-common/pom.xml +++ b/health-services/libraries/health-services-common/pom.xml @@ -8,7 +8,7 @@ health-services-common jar health-services-common - 1.0.16-SNAPSHOT + 1.0.17-SNAPSHOT Shared classes among services diff --git a/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/query/builder/GenericQueryBuilder.java b/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/query/builder/GenericQueryBuilder.java index 482069b68bb..c223723f443 100644 --- a/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/query/builder/GenericQueryBuilder.java +++ b/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/query/builder/GenericQueryBuilder.java @@ -4,6 +4,7 @@ import org.egov.common.data.query.exception.QueryBuilderException; import org.egov.common.utils.ObjectUtils; +import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; import java.time.LocalDate; @@ -43,7 +44,7 @@ static String generateClause(String clauseName, String separator, List q // If there are no query parameters, return an empty string if (queryParameters.isEmpty()) { - return " "; + return ""; } // Append the clause name to the clauseBuilder @@ -89,7 +90,7 @@ static List getFieldsWithCondition(Object object, QueryFieldChecker chec List whereClauses = new ArrayList<>(); // Iterate through all declared fields of the object - Arrays.stream(object.getClass().getDeclaredFields()).forEach(field -> { + getAllDeclaredFields(object.getClass()).forEach(field -> { // Check if the field is of type LocalDate or enum if (field.getType().equals(LocalDate.class) || field.getType().isEnum() || Modifier.isStatic(field.getModifiers())) { // Skip processing for LocalDate and enum fields @@ -148,4 +149,21 @@ else if (field.getType().isAssignableFrom(ArrayList.class) return whereClauses; } + + /** + * This method retrieves all declared fields from the given class and its superclasses. + * + * @param clazz the class whose fields are to be retrieved + * @return a list of all declared fields in the class and its superclasses, excluding Object class fields + */ + static List getAllDeclaredFields(Class clazz) { + List fields = new ArrayList<>(); + while (clazz != null && clazz != Object.class) { + for (Field field : clazz.getDeclaredFields()) { + fields.add(field); + } + clazz = clazz.getSuperclass(); + } + return fields; + } } diff --git a/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/query/builder/QueryFieldChecker.java b/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/query/builder/QueryFieldChecker.java index f31e1012a89..7ab1661349b 100644 --- a/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/query/builder/QueryFieldChecker.java +++ b/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/query/builder/QueryFieldChecker.java @@ -1,7 +1,7 @@ package org.egov.common.data.query.builder; -import org.egov.common.data.query.annotations.Exclude; import org.egov.common.data.query.annotations.UpdateBy; +import org.egov.common.models.core.Exclude; import java.lang.reflect.Field; import java.util.Optional; @@ -12,5 +12,6 @@ public interface QueryFieldChecker { QueryFieldChecker isNotNull = (field, object) -> Optional.ofNullable(field.get(object)).isPresent(); QueryFieldChecker isAnnotatedWithUpdateBy = (field, object) -> field.getDeclaredAnnotation(UpdateBy.class) != null; + // Exclude annotation is now referred from health-services-models QueryFieldChecker isNotAnnotatedWithExclude = ((field, object) -> field.getDeclaredAnnotation(Exclude.class) == null); } diff --git a/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/repository/GenericRepository.java b/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/repository/GenericRepository.java index 1c3f1f898dc..3ab5536b9d1 100644 --- a/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/repository/GenericRepository.java +++ b/health-services/libraries/health-services-common/src/main/java/org/egov/common/data/repository/GenericRepository.java @@ -253,7 +253,7 @@ public List find(Object searchObject, Boolean includeDeleted) throws QueryBuilderException { String query = selectQueryBuilder.build(searchObject, tableName); query += " AND tenantId=:tenantId "; - if (query.contains(tableName + " AND")) { + if (query.contains(tableName + " AND")) { query = query.replace(tableName + " AND", tableName + " WHERE"); } if (Boolean.FALSE.equals(includeDeleted)) { diff --git a/health-services/libraries/health-services-common/src/test/java/org/egov/common/data/query/GenericQueryBuilderTest.java b/health-services/libraries/health-services-common/src/test/java/org/egov/common/data/query/GenericQueryBuilderTest.java index 88fa60c9dfd..30ebaa7e17d 100644 --- a/health-services/libraries/health-services-common/src/test/java/org/egov/common/data/query/GenericQueryBuilderTest.java +++ b/health-services/libraries/health-services-common/src/test/java/org/egov/common/data/query/GenericQueryBuilderTest.java @@ -88,7 +88,7 @@ void shouldBuildSelectQueryForAnEmptyArrayListOfString() throws QueryBuilderExce DummyData data = DummyData.builder() .dummyStringList(strings) .build(); - String expectedQuery = "SELECT * FROM dummyData "; + String expectedQuery = "SELECT * FROM dummyData"; SelectQueryBuilder queryBuilder = new SelectQueryBuilder(); String actualQuery = queryBuilder.build(data); @@ -102,7 +102,7 @@ void shouldHandleNullArrayListOfStringWhileBuildingSelectQuery() throws QueryBui DummyData data = DummyData.builder() .dummyStringList(null) .build(); - String expectedQuery = "SELECT * FROM dummyData "; + String expectedQuery = "SELECT * FROM dummyData"; SelectQueryBuilder queryBuilder = new SelectQueryBuilder(); String actualQuery = queryBuilder.build(data); @@ -135,7 +135,7 @@ void shouldNotUsePrimitiveDataTypesWhileBuildingSelectingQuery() throws QueryBui void shouldNotUseWhereClauseWhenPropertiesAreSetToNullSelectQuery() throws QueryBuilderException { DummyData data = DummyData.builder() .build(); - String expectedQuery = "SELECT * FROM dummyData "; + String expectedQuery = "SELECT * FROM dummyData"; SelectQueryBuilder queryBuilder = new SelectQueryBuilder(); String actualQuery = queryBuilder.build(data); diff --git a/health-services/libraries/health-services-models/CHANGELOG.md b/health-services/libraries/health-services-models/CHANGELOG.md index 767df086abf..531680fc20e 100644 --- a/health-services/libraries/health-services-models/CHANGELOG.md +++ b/health-services/libraries/health-services-models/CHANGELOG.md @@ -4,6 +4,7 @@ All notable changes to this module will be documented in this file. - Added EgovModel, EgovSearchModel, EgovOfflineModel, EgovOfflineSearchModel - Updated Lombok to 1.18.22 for SuperBuilder annotation support. - Upgraded to 2.9 LTS +- Changed Dockerfile, base image required for Java 17. ## 1.0.19 - 2024-02-26 - Updated project staff search to accept a list of staffIds diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/core/URLParams.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/core/URLParams.java index 272705efd8e..522d5b95eff 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/core/URLParams.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/core/URLParams.java @@ -6,10 +6,10 @@ import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; -//TODO should we move all this to body model or should we keep this in url? same with search common models /** * Model class representing common search criteria for API search operations. * @author kanishq-egov @@ -57,8 +57,9 @@ public class URLParams { * Flag indicating whether soft deleted records should be included in search results. * This flag is used in search APIs to specify if deleted records should be included. */ + @Builder.Default @JsonProperty("includeDeleted") - private Boolean includeDeleted; + private Boolean includeDeleted = Boolean.FALSE; /** * Sets the URL parameters from the given URLParams object. diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/individual/IndividualSearch.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/individual/IndividualSearch.java index 5c907f249fe..d4dc75dfdea 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/individual/IndividualSearch.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/individual/IndividualSearch.java @@ -50,38 +50,50 @@ public class IndividualSearch extends EgovOfflineSearchModel { private List mobileNumber = null; @JsonProperty("socialCategory") + @Exclude private String socialCategory = null; @JsonProperty("wardCode") + @Exclude private String wardCode = null; + //Exclude annotation to exclude the field during dynamic sql query generation @JsonProperty("individualName") + @Exclude private String individualName = null; @JsonProperty("createdFrom") + @Exclude private BigDecimal createdFrom = null; @JsonProperty("createdTo") + @Exclude private BigDecimal createdTo = null; @JsonProperty("identifier") @Valid + @Exclude private Identifier identifier = null; @JsonProperty("boundaryCode") + @Exclude private String boundaryCode = null; @JsonProperty("roleCodes") + @Exclude private List roleCodes = null; @JsonProperty("username") + @Exclude private List username; @JsonProperty("userId") + @Exclude private List userId; @JsonProperty("userUuid") @Size(min = 1) + @Exclude private List userUuid; @Exclude diff --git a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/TaskResource.java b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/TaskResource.java index 382bd5e34ac..3ea472c9683 100644 --- a/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/TaskResource.java +++ b/health-services/libraries/health-services-models/src/main/java/org/egov/common/models/project/TaskResource.java @@ -3,16 +3,16 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import digit.models.coremodels.AuditDetails; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.egov.common.models.core.AdditionalFields; import org.springframework.validation.annotation.Validated; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - /** * TaskResource */ @@ -65,5 +65,11 @@ public class TaskResource { @Valid private AuditDetails auditDetails = null; + /** + * Additional fields that may be used for extending the information stored with each task. + */ + @JsonProperty("additionalFields") + @Valid + private AdditionalFields additionalFields = null; } diff --git a/health-services/product/CHANGELOG.md b/health-services/product/CHANGELOG.md index 657f753304d..6a3ffe49450 100644 --- a/health-services/product/CHANGELOG.md +++ b/health-services/product/CHANGELOG.md @@ -1,9 +1,6 @@ +# CHANGELOG All notable changes to this module will be documented in this file. -## To be released -- In ProductSearch, name , manufacturer updated to accept list of search entities instead of single entity -- In ProductVariantSearch, productId updated to accept list of search entities instead of single entity - ## 1.0.0 - Base version diff --git a/health-services/product/README.md b/health-services/product/README.md index e1bf5846eaf..a978b285f28 100644 --- a/health-services/product/README.md +++ b/health-services/product/README.md @@ -46,13 +46,3 @@ Product service APIs - contains create, update, delete and search end point ## Pre commit script [commit-msg](https://gist.github.com/jayantp-egov/14f55deb344f1648503c6be7e580fa12) - -## Updates -- Product Search - - `name` , and `manufacturer` now accepts a list of entities instead of single entity to search product -- Product Variant Search - - `productId` now accepts a list of entities instead of single entity to search product variants -## Usage -- Start the service -- Access the API endpoints for searching `product`, and `product variant` -- Pass list parameters for the search fields mentioned in updates \ No newline at end of file diff --git a/health-services/product/pom.xml b/health-services/product/pom.xml index fada716dc88..bb11e8702d6 100644 --- a/health-services/product/pom.xml +++ b/health-services/product/pom.xml @@ -44,11 +44,12 @@ org.flywaydb flyway-core + 9.22.3 org.postgresql postgresql - 42.2.2.jre7 + 42.7.1 org.springframework.boot @@ -75,12 +76,12 @@ org.egov.common health-services-common - 1.0.8-SNAPSHOT + 1.0.7-SNAPSHOT org.egov.common health-services-models - 1.0.15-SNAPSHOT + 1.0.7-SNAPSHOT compile diff --git a/health-services/product/src/main/java/org/egov/product/repository/rowmapper/ProductRowMapper.java b/health-services/product/src/main/java/org/egov/product/repository/rowmapper/ProductRowMapper.java index 98a34d40cc3..24c06d1721a 100644 --- a/health-services/product/src/main/java/org/egov/product/repository/rowmapper/ProductRowMapper.java +++ b/health-services/product/src/main/java/org/egov/product/repository/rowmapper/ProductRowMapper.java @@ -1,16 +1,16 @@ package org.egov.product.repository.rowmapper; -import java.sql.ResultSet; -import java.sql.SQLException; - import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import digit.models.coremodels.AuditDetails; -import org.egov.common.models.core.AdditionalFields; +import org.egov.common.models.product.AdditionalFields; import org.egov.common.models.product.Product; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Component; +import java.sql.ResultSet; +import java.sql.SQLException; + @Component public class ProductRowMapper implements RowMapper { private final ObjectMapper objectMapper = new ObjectMapper(); diff --git a/health-services/product/src/main/java/org/egov/product/repository/rowmapper/ProductVariantRowMapper.java b/health-services/product/src/main/java/org/egov/product/repository/rowmapper/ProductVariantRowMapper.java index b8897f9a999..01b1d4d1174 100644 --- a/health-services/product/src/main/java/org/egov/product/repository/rowmapper/ProductVariantRowMapper.java +++ b/health-services/product/src/main/java/org/egov/product/repository/rowmapper/ProductVariantRowMapper.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import digit.models.coremodels.AuditDetails; -import org.egov.common.models.core.AdditionalFields; +import org.egov.common.models.product.AdditionalFields; import org.egov.common.models.product.ProductVariant; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Component; diff --git a/health-services/product/src/main/java/org/egov/product/web/controllers/ProductApiController.java b/health-services/product/src/main/java/org/egov/product/web/controllers/ProductApiController.java index 305507edb07..2f7b8ccfae2 100644 --- a/health-services/product/src/main/java/org/egov/product/web/controllers/ProductApiController.java +++ b/health-services/product/src/main/java/org/egov/product/web/controllers/ProductApiController.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import io.swagger.annotations.ApiParam; -import org.egov.common.models.core.URLParams; import org.egov.common.models.product.Product; import org.egov.common.models.product.ProductRequest; import org.egov.common.models.product.ProductResponse; @@ -22,13 +21,17 @@ import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; +import javax.validation.constraints.Max; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import java.util.List; @javax.annotation.Generated(value = "org.egov.codegen.SpringBootCodegen", date = "2022-12-02T16:45:24.641+05:30") @@ -71,10 +74,15 @@ public ResponseEntity productV1CreatePost(@ApiParam(value = "Ca } @RequestMapping(value = "/v1/_search", method = RequestMethod.POST) - public ResponseEntity productV1SearchPost(@ApiParam(value = "Capture details of Product.", required = true) @Valid @RequestBody ProductSearchRequest productSearchRequest) throws Exception { - - List products = productService.search(productSearchRequest, searchCriteria.getLimit(), searchCriteria.getOffset(), - searchCriteria.getTenantId(), searchCriteria.getLastChangedSince(), searchCriteria.getIncludeDeleted()); + public ResponseEntity productV1SearchPost(@ApiParam(value = "Capture details of Product.", required = true) @Valid @RequestBody ProductSearchRequest productSearchRequest, + @NotNull @Min(0) @Max(1000) @ApiParam(value = "Pagination - limit records in response", required = true) @Valid @RequestParam(value = "limit", required = true) Integer limit, + @NotNull @Min(0) @ApiParam(value = "Pagination - offset from which records should be returned in response", required = true) @Valid @RequestParam(value = "offset", required = true) Integer offset, + @NotNull @ApiParam(value = "Unique id for a tenant.", required = true) @Valid @Size(min = 2, max = 1000) @RequestParam(value = "tenantId", required = true) String tenantId, + @ApiParam(value = "epoch of the time since when the changes on the object should be picked up. Search results from this parameter should include both newly created objects since this time as well as any modified objects since this time. This criterion is included to help polling clients to get the changes in system since a last time they synchronized with the platform. ") @Valid @RequestParam(value = "lastChangedSince", required = false) Long lastChangedSince, + @ApiParam(value = "Used in search APIs to specify if (soft) deleted records should be included in search results.", defaultValue = "false") @Valid @RequestParam(value = "includeDeleted", required = false, defaultValue = "false") Boolean includeDeleted) throws Exception { + + List products = productService.search(productSearchRequest, limit, offset, tenantId, + lastChangedSince, includeDeleted); ProductResponse productResponse = ProductResponse.builder() .product(products) .responseInfo(ResponseInfoFactory.createResponseInfo(productSearchRequest.getRequestInfo(), true)) @@ -119,10 +127,13 @@ public ResponseEntity productVariantV1CreatePost(@ApiPar @RequestMapping(value = "/variant/v1/_search", method = RequestMethod.POST) public ResponseEntity productVariantV1SearchPost(@ApiParam(value = "Capture details of Product variant.", required = true) @Valid @RequestBody ProductVariantSearchRequest productVariantSearchRequest, - ) throws Exception { - List productVariants = productVariantService.search(productVariantSearchRequest, - searchCriteria.getLimit(), searchCriteria.getOffset(), searchCriteria.getTenantId(), - searchCriteria.getLastChangedSince(), searchCriteria.getIncludeDeleted()); + @NotNull @Min(0) @Max(1000) @ApiParam(value = "Pagination - limit records in response", required = true) @Valid @RequestParam(value = "limit", required = true) Integer limit, + @NotNull @Min(0) @ApiParam(value = "Pagination - offset from which records should be returned in response", required = true) @Valid @RequestParam(value = "offset", required = true) Integer offset, + @NotNull @ApiParam(value = "Unique id for a tenant.", required = true) @Valid @Size(min = 2, max = 1000) @RequestParam(value = "tenantId", required = true) String tenantId, + @ApiParam(value = "epoch of the time since when the changes on the object should be picked up. Search results from this parameter should include both newly created objects since this time as well as any modified objects since this time. This criterion is included to help polling clients to get the changes in system since a last time they synchronized with the platform. ") @Valid @RequestParam(value = "lastChangedSince", required = false) Long lastChangedSince, + @ApiParam(value = "Used in search APIs to specify if (soft) deleted records should be included in search results.", defaultValue = "false") @Valid @RequestParam(value = "includeDeleted", required = false, defaultValue = "false") Boolean includeDeleted) throws Exception { + List productVariants = productVariantService.search(productVariantSearchRequest, limit, offset, + tenantId, lastChangedSince, includeDeleted); ProductVariantResponse productVariantResponse = ProductVariantResponse.builder() .productVariant(productVariants) .responseInfo(ResponseInfoFactory diff --git a/health-services/product/src/main/java/org/egov/product/web/models/ProductSearch.java b/health-services/product/src/main/java/org/egov/product/web/models/ProductSearch.java index 781af13c2b5..cf2f0121666 100644 --- a/health-services/product/src/main/java/org/egov/product/web/models/ProductSearch.java +++ b/health-services/product/src/main/java/org/egov/product/web/models/ProductSearch.java @@ -32,9 +32,9 @@ public class ProductSearch { private String type = null; @JsonProperty("name") - private List name = null; + private String name = null; @JsonProperty("manufacturer") - private List manufacturer = null; + private String manufacturer = null; } diff --git a/health-services/product/src/main/java/org/egov/product/web/models/ProductVariantSearch.java b/health-services/product/src/main/java/org/egov/product/web/models/ProductVariantSearch.java index dd08015e773..7eeccb423ac 100644 --- a/health-services/product/src/main/java/org/egov/product/web/models/ProductVariantSearch.java +++ b/health-services/product/src/main/java/org/egov/product/web/models/ProductVariantSearch.java @@ -30,7 +30,8 @@ public class ProductVariantSearch { private List id = null; @JsonProperty("productId") - private List productId = null; + @Size(min = 2, max = 64) + private String productId = null; @JsonProperty("sku") @Size(min = 0, max = 1000) diff --git a/health-services/product/src/main/resources/db/Dockerfile b/health-services/product/src/main/resources/db/Dockerfile index 60fc07ce69f..e7da01d7f0b 100644 --- a/health-services/product/src/main/resources/db/Dockerfile +++ b/health-services/product/src/main/resources/db/Dockerfile @@ -1,4 +1,4 @@ -FROM egovio/flyway:4.1.2 +FROM egovio/flyway:10.7.1 COPY ./migration/main /flyway/sql @@ -6,4 +6,4 @@ COPY migrate.sh /usr/bin/migrate.sh RUN chmod +x /usr/bin/migrate.sh -CMD ["/usr/bin/migrate.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/migrate.sh"] \ No newline at end of file diff --git a/health-services/product/src/main/resources/db/migrate.sh b/health-services/product/src/main/resources/db/migrate.sh index 43960b25cdb..f9d6617822c 100644 --- a/health-services/product/src/main/resources/db/migrate.sh +++ b/health-services/product/src/main/resources/db/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate \ No newline at end of file +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate diff --git a/health-services/product/src/test/java/org/egov/product/service/ProductServiceSearchTest.java b/health-services/product/src/test/java/org/egov/product/service/ProductServiceSearchTest.java index aa71a99891f..8cfe52953af 100644 --- a/health-services/product/src/test/java/org/egov/product/service/ProductServiceSearchTest.java +++ b/health-services/product/src/test/java/org/egov/product/service/ProductServiceSearchTest.java @@ -51,7 +51,7 @@ void setUp() throws QueryBuilderException { @DisplayName("should not raise exception if no search results are found") void shouldNotRaiseExceptionIfNoProductsFound() throws Exception { ProductSearch productSearch = ProductSearch.builder() - .id(Collections.singletonList("ID101")).name(Collections.singletonList("Product")).build(); + .id(Collections.singletonList("ID101")).name("Product").build(); ProductSearchRequest productSearchRequest = ProductSearchRequest.builder().product(productSearch) .requestInfo(RequestInfoTestBuilder.builder().withCompleteRequestInfo().build()).build(); @@ -63,7 +63,7 @@ void shouldNotRaiseExceptionIfNoProductsFound() throws Exception { void shouldReturnProductsIfSearchCriteriaIsMatched() throws Exception { products.add(ProductTestBuilder.builder().goodProduct().withId("ID101").build()); ProductSearch productSearch = ProductSearch.builder() - .id(Collections.singletonList("ID101")).name(Collections.singletonList("Product")).build(); + .id(Collections.singletonList("ID101")).name("Product").build(); ProductSearchRequest productSearchRequest = ProductSearchRequest.builder().product(productSearch) .requestInfo(RequestInfoTestBuilder.builder().withCompleteRequestInfo().build()).build(); diff --git a/health-services/product/src/test/java/org/egov/product/web/controllers/ProductVariantApiControllerTest.java b/health-services/product/src/test/java/org/egov/product/web/controllers/ProductVariantApiControllerTest.java index 73e84bfdcba..a87dd58849e 100644 --- a/health-services/product/src/test/java/org/egov/product/web/controllers/ProductVariantApiControllerTest.java +++ b/health-services/product/src/test/java/org/egov/product/web/controllers/ProductVariantApiControllerTest.java @@ -186,7 +186,7 @@ void shouldSend400BadRequestInCaseOfIncorrectApiOperationForUpdate() throws Exce void shouldAcceptSearchRequestAndReturnProductsVariants() throws Exception { ProductVariantSearchRequest productVariantSearchRequest = ProductVariantSearchRequest.builder().productVariant( - ProductVariantSearch.builder().productId(Arrays.asList("101","102")).build() + ProductVariantSearch.builder().productId("101").build() ).requestInfo(RequestInfoTestBuilder.builder().withCompleteRequestInfo().build()).build(); when(productVariantService.search(any(ProductVariantSearchRequest.class), any(Integer.class), @@ -213,7 +213,7 @@ void shouldAcceptSearchRequestAndReturnProductsVariants() throws Exception { void shouldThrowExceptionIfNoResultFound() throws Exception { ProductVariantSearchRequest productVariantSearchRequest = ProductVariantSearchRequest.builder().productVariant( - ProductVariantSearch.builder().productId(Arrays.asList("101","102")).build() + ProductVariantSearch.builder().productId("101").build() ).requestInfo(RequestInfoTestBuilder.builder().withCompleteRequestInfo().build()).build(); when(productVariantService.search(any(ProductVariantSearchRequest.class), any(Integer.class), diff --git a/health-services/project/CHANGELOG.md b/health-services/project/CHANGELOG.md index 1bcc937b721..427aa3e5917 100644 --- a/health-services/project/CHANGELOG.md +++ b/health-services/project/CHANGELOG.md @@ -8,6 +8,9 @@ All notable changes to this module will be documented in this file. - Boundary v2 Integration - MDMS v2 integration - Beneficiary Tag null check in update +- Upgraded PostgresSQL Driver version to 42.7.1 +- Upgraded Flyway base image version to 10.7.1 for DB Migration +- Upgraded Flyway-Core to 9.22.3 ## 1.1.2 - 2024-02-26 - Implemented validation for updating project start date and end date. diff --git a/health-services/project/pom.xml b/health-services/project/pom.xml index 86272917f42..54bd4fd9c91 100644 --- a/health-services/project/pom.xml +++ b/health-services/project/pom.xml @@ -45,7 +45,7 @@ org.egov.common health-services-common - 1.0.16-SNAPSHOT + 1.0.17-SNAPSHOT org.egov.common diff --git a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/TaskResourceRowMapper.java b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/TaskResourceRowMapper.java index 51a45703e65..bfb130d350b 100644 --- a/health-services/project/src/main/java/org/egov/project/repository/rowmapper/TaskResourceRowMapper.java +++ b/health-services/project/src/main/java/org/egov/project/repository/rowmapper/TaskResourceRowMapper.java @@ -1,6 +1,9 @@ package org.egov.project.repository.rowmapper; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import digit.models.coremodels.AuditDetails; +import org.egov.common.models.core.AdditionalFields; import org.egov.common.models.project.TaskResource; import org.springframework.jdbc.core.RowMapper; import org.springframework.stereotype.Component; @@ -11,24 +14,33 @@ @Component public class TaskResourceRowMapper implements RowMapper { + private final ObjectMapper objectMapper = new ObjectMapper(); + @Override public TaskResource mapRow(ResultSet resultSet, int i) throws SQLException { - return TaskResource.builder() - .id(resultSet.getString("id")) - .isDeleted(resultSet.getBoolean("isDeleted")) - .tenantId(resultSet.getString("tenantId")) - .taskId(resultSet.getString("taskId")) - .productVariantId(resultSet.getString("productVariantId")) - .quantity(resultSet.getLong("quantity")) - .isDelivered(resultSet.getBoolean("isDelivered")) - .deliveryComment(resultSet.getString("isDelivered")) - .clientReferenceId(resultSet.getString("clientReferenceId")) - .auditDetails(AuditDetails.builder() - .createdBy(resultSet.getString("createdBy")) - .createdTime(resultSet.getLong("createdTime")) - .lastModifiedBy(resultSet.getString("lastModifiedBy")) - .lastModifiedTime(resultSet.getLong("lastModifiedTime")) - .build()) - .build(); + try { + return TaskResource.builder() + .id(resultSet.getString("id")) + .isDeleted(resultSet.getBoolean("isDeleted")) + .tenantId(resultSet.getString("tenantId")) + .taskId(resultSet.getString("taskId")) + .productVariantId(resultSet.getString("productVariantId")) + .quantity(resultSet.getLong("quantity")) + .isDelivered(resultSet.getBoolean("isDelivered")) + .deliveryComment(resultSet.getString("reasonIfNotDelivered")) + .clientReferenceId(resultSet.getString("clientReferenceId")) + .auditDetails(AuditDetails.builder() + .createdBy(resultSet.getString("createdBy")) + .createdTime(resultSet.getLong("createdTime")) + .lastModifiedBy(resultSet.getString("lastModifiedBy")) + .lastModifiedTime(resultSet.getLong("lastModifiedTime")) + .build()) + .additionalFields(resultSet.getString("additionalDetails") == null ? null : objectMapper + .readValue(resultSet.getString("additionalDetails"), AdditionalFields.class)) + .build(); + } catch ( + JsonProcessingException e) { + throw new SQLException(e); + } } } diff --git a/health-services/project/src/main/java/org/egov/project/util/BoundaryV2Util.java b/health-services/project/src/main/java/org/egov/project/util/BoundaryV2Util.java index bc235615157..0face50eb9e 100644 --- a/health-services/project/src/main/java/org/egov/project/util/BoundaryV2Util.java +++ b/health-services/project/src/main/java/org/egov/project/util/BoundaryV2Util.java @@ -78,7 +78,7 @@ public void validateBoundaryDetails(Map> boundaryTypeBounda } catch (Exception e) { log.error("Exception while searching boundaries for tenantId: {}", tenantId, e); // Throw a custom exception if an error occurs during boundary search - throw new CustomException("BOUNDARY_SEARCH_ERROR", e.getMessage()); + throw new CustomException("BOUNDARY_SERVICE_SEARCH_ERROR","Error in while fetching boundaries from Boundary Service : " + e.getMessage()); } } } diff --git a/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbExistentEntityValidator.java b/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbExistentEntityValidator.java index 73a622a6d1e..167969d09e3 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbExistentEntityValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbExistentEntityValidator.java @@ -5,12 +5,15 @@ import java.util.Map; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.project.BeneficiaryBulkRequest; import org.egov.common.models.project.ProjectBeneficiary; import org.egov.common.models.project.ProjectBeneficiarySearch; import org.egov.common.validator.Validator; import org.egov.project.repository.ProjectBeneficiaryRepository; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import static org.egov.common.utils.CommonUtils.getIdFieldName; @@ -24,6 +27,9 @@ * * @author kanishq-egov */ +@Component +@Order(value = 1) +@Slf4j public class PbExistentEntityValidator implements Validator { private final ProjectBeneficiaryRepository projectBeneficiaryRepository; diff --git a/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbNonExistentEntityValidator.java b/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbNonExistentEntityValidator.java index 4f4c4e72cb1..01944744fba 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbNonExistentEntityValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/beneficiary/PbNonExistentEntityValidator.java @@ -1,24 +1,25 @@ package org.egov.project.validator.beneficiary; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.project.BeneficiaryBulkRequest; import org.egov.common.models.project.ProjectBeneficiary; +import org.egov.common.models.project.ProjectBeneficiarySearch; import org.egov.common.validator.Validator; import org.egov.project.repository.ProjectBeneficiaryRepository; +import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import static org.egov.common.utils.CommonUtils.checkNonExistentEntities; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.getIdToObjMap; import static org.egov.common.utils.CommonUtils.getMethod; import static org.egov.common.utils.CommonUtils.getObjClass; @@ -49,10 +50,31 @@ public Map> validate(BeneficiaryBulkRequest requ Method idMethod = getMethod(GET_ID, objClass); Map iMap = getIdToObjMap(projectBeneficiaries .stream().filter(notHavingErrors()).collect(Collectors.toList()), idMethod); + // Lists to store IDs and client reference IDs + List idList = new ArrayList<>(); + List clientReferenceIdList = new ArrayList<>(); + // Extract IDs and client reference IDs from Project Beneficiary entities + projectBeneficiaries.forEach(entity -> { + idList.add(entity.getId()); + clientReferenceIdList.add(entity.getClientReferenceId()); + }); if (!iMap.isEmpty()) { - List beneficiaryIds = new ArrayList<>(iMap.keySet()); - List existingProjectBeneficiaries = projectBeneficiaryRepository - .findById(beneficiaryIds, false, getIdFieldName(idMethod)); + ProjectBeneficiarySearch projectBeneficiarySearch = ProjectBeneficiarySearch.builder() + .clientReferenceId(clientReferenceIdList) + .id(idList) + .build(); + + List existingProjectBeneficiaries; + try { + // Query the repository to find existing entities + existingProjectBeneficiaries = projectBeneficiaryRepository.find(projectBeneficiarySearch, projectBeneficiaries.size(), 0, + projectBeneficiaries.get(0).getTenantId(), null, false).getResponse(); + } catch (Exception e) { + // Handle query builder exception + log.error("Search failed for ProjectBeneficiary with error: {}", e.getMessage(), e); + throw new CustomException("PROJECT_BENEFICIARY_SEARCH_FAILED", "Search Failed for ProjectBeneficiary, " + e.getMessage()); + } + List nonExistentIndividuals = checkNonExistentEntities(iMap, existingProjectBeneficiaries, idMethod); nonExistentIndividuals.forEach(projectBeneficiary -> { diff --git a/health-services/project/src/main/java/org/egov/project/validator/task/PtExistentEntityValidator.java b/health-services/project/src/main/java/org/egov/project/validator/task/PtExistentEntityValidator.java index 3a65cc6acc9..c3cb60b2b8c 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/task/PtExistentEntityValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/task/PtExistentEntityValidator.java @@ -5,12 +5,15 @@ import java.util.Map; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.project.Task; import org.egov.common.models.project.TaskBulkRequest; import org.egov.common.models.project.TaskSearch; import org.egov.common.validator.Validator; import org.egov.project.repository.ProjectTaskRepository; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import static org.egov.common.utils.CommonUtils.getIdFieldName; @@ -24,6 +27,9 @@ * * @author: kanishq-egov */ +@Component +@Order(value = 1) +@Slf4j public class PtExistentEntityValidator implements Validator { private final ProjectTaskRepository projectTaskRepository; diff --git a/health-services/project/src/main/java/org/egov/project/validator/task/PtNonExistentEntityValidator.java b/health-services/project/src/main/java/org/egov/project/validator/task/PtNonExistentEntityValidator.java index 5342d6ff90a..52b577acdbe 100644 --- a/health-services/project/src/main/java/org/egov/project/validator/task/PtNonExistentEntityValidator.java +++ b/health-services/project/src/main/java/org/egov/project/validator/task/PtNonExistentEntityValidator.java @@ -1,26 +1,27 @@ package org.egov.project.validator.task; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.project.Task; import org.egov.common.models.project.TaskBulkRequest; +import org.egov.common.models.project.TaskSearch; import org.egov.common.validator.Validator; import org.egov.project.repository.ProjectTaskRepository; +import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import org.springframework.util.ReflectionUtils; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import static org.egov.common.utils.CommonUtils.checkNonExistentEntities; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.getIdMethod; import static org.egov.common.utils.CommonUtils.getIdToObjMap; import static org.egov.common.utils.CommonUtils.getMethod; @@ -55,10 +56,30 @@ public Map> validate(TaskBulkRequest request) { Method idMethod = getMethod(GET_ID, objClass); Map eMap = getIdToObjMap(entities .stream().filter(notHavingErrors()).collect(Collectors.toList()), idMethod); + // Lists to store IDs and client reference IDs + List idList = new ArrayList<>(); + List clientReferenceIdList = new ArrayList<>(); + // Extract IDs and client reference IDs from Project Task entities + entities.forEach(entity -> { + idList.add(entity.getId()); + clientReferenceIdList.add(entity.getClientReferenceId()); + }); if (!eMap.isEmpty()) { - List entityIds = new ArrayList<>(eMap.keySet()); - List existingEntities = projectTaskRepository.findById(entityIds, - getIdFieldName(idMethod), false).getResponse(); + TaskSearch taskSearch = TaskSearch.builder() + .clientReferenceId(clientReferenceIdList) + .id(idList) + .build(); + + List existingEntities; + try { + // Query the repository to find existing entities + existingEntities = projectTaskRepository.find(taskSearch, entities.size(), 0, + entities.get(0).getTenantId(), null, false).getResponse(); + } catch (Exception e) { + // Handle query builder exception + log.error("Search failed for ProjectTask with error: {}", e.getMessage(), e); + throw new CustomException("SEARCH_FAILED", "Search Failed for given ProjectTask, " + e.getMessage()); + } List nonExistentEntities = checkNonExistentEntities(eMap, existingEntities, idMethod); nonExistentEntities.forEach(task -> { diff --git a/health-services/project/src/main/resources/db/Dockerfile b/health-services/project/src/main/resources/db/Dockerfile index 60fc07ce69f..e7da01d7f0b 100644 --- a/health-services/project/src/main/resources/db/Dockerfile +++ b/health-services/project/src/main/resources/db/Dockerfile @@ -1,4 +1,4 @@ -FROM egovio/flyway:4.1.2 +FROM egovio/flyway:10.7.1 COPY ./migration/main /flyway/sql @@ -6,4 +6,4 @@ COPY migrate.sh /usr/bin/migrate.sh RUN chmod +x /usr/bin/migrate.sh -CMD ["/usr/bin/migrate.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/migrate.sh"] \ No newline at end of file diff --git a/health-services/project/src/main/resources/db/migrate.sh b/health-services/project/src/main/resources/db/migrate.sh index 43960b25cdb..f9d6617822c 100644 --- a/health-services/project/src/main/resources/db/migrate.sh +++ b/health-services/project/src/main/resources/db/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate \ No newline at end of file +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate diff --git a/health-services/project/src/main/resources/db/migration/main/V20231121145400__task_resource_quantity_type_ddl.sql b/health-services/project/src/main/resources/db/migration/main/V20231121145400__task_resource_quantity_type_ddl.sql new file mode 100644 index 00000000000..d44a32d5b9e --- /dev/null +++ b/health-services/project/src/main/resources/db/migration/main/V20231121145400__task_resource_quantity_type_ddl.sql @@ -0,0 +1 @@ +ALTER TABLE task_resource ALTER COLUMN quantity TYPE double precision \ No newline at end of file diff --git a/health-services/project/src/main/resources/db/migration/main/V20231127145800__task_resource_additional_fields_ddl.sql b/health-services/project/src/main/resources/db/migration/main/V20231127145800__task_resource_additional_fields_ddl.sql new file mode 100644 index 00000000000..f6e63183775 --- /dev/null +++ b/health-services/project/src/main/resources/db/migration/main/V20231127145800__task_resource_additional_fields_ddl.sql @@ -0,0 +1 @@ +ALTER TABLE TASK_RESOURCE ADD COLUMN IF NOT EXISTS additionalDetails jsonb; \ No newline at end of file diff --git a/health-services/referralmanagement/CHANGELOG.md b/health-services/referralmanagement/CHANGELOG.md index d0b1da750c3..c605b868638 100644 --- a/health-services/referralmanagement/CHANGELOG.md +++ b/health-services/referralmanagement/CHANGELOG.md @@ -7,6 +7,9 @@ All notable changes to this module will be documented in this file. - Upgraded to health models 1.0.20 and health common 1.0.16 - Boundary v2 Integration - MDMS v2 integration +- Upgraded PostgresSQL Driver version to 42.7.1 +- Upgraded Flyway base image version to 10.7.1 for DB Migration +- Upgraded Flyway-Core to 9.22.3 ## 1.0.1 - 2024-02-28 - Added functionality for referrals handled by health facilities, referred to as "hfreferral". diff --git a/health-services/referralmanagement/pom.xml b/health-services/referralmanagement/pom.xml index d4aa379affc..915072c78a1 100644 --- a/health-services/referralmanagement/pom.xml +++ b/health-services/referralmanagement/pom.xml @@ -46,7 +46,7 @@ org.egov.common health-services-common - 1.0.16-SNAPSHOT + 1.0.17-SNAPSHOT org.egov.common diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HFReferralRepository.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HFReferralRepository.java index 18e2967741a..1e9c0f8cce0 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HFReferralRepository.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/HFReferralRepository.java @@ -20,6 +20,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.stereotype.Repository; +import org.springframework.util.CollectionUtils; import org.springframework.util.ReflectionUtils; import static org.egov.common.utils.CommonUtils.getIdMethod; @@ -81,7 +82,11 @@ public List find(HFReferralSearch searchObject, Integer limit, Integ query = query.replace("clientReferenceId IN (:clientReferenceId)", "hf.clientReferenceId IN (:clientReferenceId)"); // Add additional conditions based on tenant ID, includeDeleted, and lastChangedSince. - query = query + " and hf.tenantId=:tenantId "; + if(CollectionUtils.isEmpty(whereFields)) { + query = query + " where hf.tenantId=:tenantId "; + } else { + query = query + " and hf.tenantId=:tenantId "; + } if (Boolean.FALSE.equals(includeDeleted)) { query = query + "and hf.isDeleted=:isDeleted "; } diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/ReferralRepository.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/ReferralRepository.java index ade10b1392e..b4ae1ada5eb 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/ReferralRepository.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/ReferralRepository.java @@ -21,6 +21,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.stereotype.Repository; +import org.springframework.util.CollectionUtils; import org.springframework.util.ReflectionUtils; import static org.egov.common.utils.CommonUtils.constructTotalCountCTEAndReturnResult; @@ -51,8 +52,12 @@ public SearchResponse find(ReferralSearch searchObject, Integer limit, query = query.replace("clientReferenceId IN (:clientReferenceId)", "r.clientReferenceId IN (:clientReferenceId)"); query = query.replace("projectBeneficiaryClientReferenceId IN (:projectBeneficiaryClientReferenceId)", "r.projectBeneficiaryClientReferenceId IN (:projectBeneficiaryClientReferenceId)"); query = query.replace("projectBeneficiaryId IN (:projectBeneficiaryId)", "r.projectBeneficiaryId IN (:projectBeneficiaryId)"); - - query = query + " and r.tenantId=:tenantId "; + + if(CollectionUtils.isEmpty(whereFields)) { + query = query + " where r.tenantId=:tenantId "; + } else { + query = query + " and r.tenantId=:tenantId "; + } if (Boolean.FALSE.equals(includeDeleted)) { query = query + "and r.isDeleted=:isDeleted "; } diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/SideEffectRepository.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/SideEffectRepository.java index 91ea1628d32..8c4c6564116 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/SideEffectRepository.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/repository/SideEffectRepository.java @@ -27,6 +27,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; import org.springframework.stereotype.Repository; +import org.springframework.util.CollectionUtils; import org.springframework.util.ReflectionUtils; import lombok.extern.slf4j.Slf4j; @@ -80,7 +81,11 @@ public SearchResponse find(SideEffectSearch searchObject, Integer li query = query.replace("id IN (:id)", "ae.id IN (:id)"); query = query.replace("clientReferenceId IN (:clientReferenceId)", "ae.clientReferenceId IN (:clientReferenceId)"); - query = query + " and ae.tenantId=:tenantId "; + if(CollectionUtils.isEmpty(whereFields)) { + query = query + " where ae.tenantId=:tenantId "; + } else { + query = query + " and ae.tenantId=:tenantId "; + } if (Boolean.FALSE.equals(includeDeleted)) { query = query + "and ae.isDeleted=:isDeleted "; } diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmExistentEntityValidator.java index 6b760985b92..8725344af7d 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmExistentEntityValidator.java @@ -5,12 +5,15 @@ import java.util.Map; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.referralmanagement.Referral; import org.egov.common.models.referralmanagement.ReferralBulkRequest; import org.egov.common.models.referralmanagement.ReferralSearch; import org.egov.common.validator.Validator; import org.egov.referralmanagement.repository.ReferralRepository; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import static org.egov.common.utils.CommonUtils.getIdFieldName; @@ -23,6 +26,9 @@ * This validator checks if the provided referral entities already exist in the database based on their client reference IDs. * @author kanishq-egov */ +@Component +@Order(value = 1) +@Slf4j public class RmExistentEntityValidator implements Validator { private final ReferralRepository referralRepository; diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmNonExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmNonExistentEntityValidator.java index 8189c560ef1..cbed1346a10 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmNonExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/RmNonExistentEntityValidator.java @@ -1,32 +1,33 @@ package org.egov.referralmanagement.validator; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.referralmanagement.Referral; import org.egov.common.models.referralmanagement.ReferralBulkRequest; +import org.egov.common.models.referralmanagement.ReferralSearch; import org.egov.common.validator.Validator; import org.egov.referralmanagement.repository.ReferralRepository; +import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.egov.referralmanagement.Constants.GET_ID; import static org.egov.common.utils.CommonUtils.checkNonExistentEntities; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.getIdToObjMap; import static org.egov.common.utils.CommonUtils.getMethod; import static org.egov.common.utils.CommonUtils.getObjClass; import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForNonExistentEntity; +import static org.egov.referralmanagement.Constants.GET_ID; @Component @Order(value = 4) @@ -53,10 +54,32 @@ public Map> validate(ReferralBulkRequest request) { Method idMethod = getMethod(GET_ID, objClass); Map iMap = getIdToObjMap(referrals .stream().filter(notHavingErrors()).collect(Collectors.toList()), idMethod); + // Lists to store IDs and client reference IDs + List idList = new ArrayList<>(); + List clientReferenceIdList = new ArrayList<>(); + // Extract IDs and client reference IDs from referral entities + referrals.forEach(referral -> { + idList.add(referral.getId()); + clientReferenceIdList.add(referral.getClientReferenceId()); + }); if (!iMap.isEmpty()) { - List referralIds = new ArrayList<>(iMap.keySet()); - List existingReferrals = referralRepository - .findById(referralIds, getIdFieldName(idMethod),false).getResponse(); + + // Create a search object for querying existing entities + ReferralSearch referralSearch = ReferralSearch.builder() + .clientReferenceId(clientReferenceIdList) + .id(idList) + .build(); + + List existingReferrals; + try { + // Query the repository to find existing entities + existingReferrals = referralRepository.find(referralSearch, referrals.size(), 0, + referrals.get(0).getTenantId(), null, false).getResponse(); + } catch (Exception e) { + // Handle query builder exception + log.error("Search failed for Referral with error: {}", e.getMessage(), e); + throw new CustomException("REFERRAL_SEARCH_FAILED", "Search Failed for Referral, " + e.getMessage()); + } List nonExistentReferrals = checkNonExistentEntities(iMap, existingReferrals, idMethod); nonExistentReferrals.forEach(sideEffect -> { diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrExistentEntityValidator.java index 2eaebb8d5c2..33e3e750911 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrExistentEntityValidator.java @@ -5,12 +5,15 @@ import java.util.Map; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.referralmanagement.hfreferral.HFReferral; import org.egov.common.models.referralmanagement.hfreferral.HFReferralBulkRequest; import org.egov.common.models.referralmanagement.hfreferral.HFReferralSearch; import org.egov.common.validator.Validator; import org.egov.referralmanagement.repository.HFReferralRepository; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import static org.egov.common.utils.CommonUtils.getIdFieldName; @@ -24,6 +27,9 @@ * * @author kanishq-egov */ +@Component +@Order(value = 1) +@Slf4j public class HfrExistentEntityValidator implements Validator { private final HFReferralRepository hfReferralRepository; diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrNonExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrNonExistentEntityValidator.java index 515d37624a4..3011cef48ce 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrNonExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/hfreferral/HfrNonExistentEntityValidator.java @@ -12,14 +12,15 @@ import org.egov.common.models.Error; import org.egov.common.models.referralmanagement.hfreferral.HFReferral; import org.egov.common.models.referralmanagement.hfreferral.HFReferralBulkRequest; +import org.egov.common.models.referralmanagement.hfreferral.HFReferralSearch; import org.egov.common.validator.Validator; import org.egov.referralmanagement.repository.HFReferralRepository; +import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import static org.egov.common.utils.CommonUtils.checkNonExistentEntities; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.getIdToObjMap; import static org.egov.common.utils.CommonUtils.getMethod; import static org.egov.common.utils.CommonUtils.getObjClass; @@ -63,10 +64,30 @@ public Map> validate(HFReferralBulkRequest request) { Method idMethod = getMethod(GET_ID, objClass); Map iMap = getIdToObjMap(hfReferrals .stream().filter(notHavingErrors()).collect(Collectors.toList()), idMethod); + // Lists to store IDs and client reference IDs + List idList = new ArrayList<>(); + List clientReferenceIdList = new ArrayList<>(); + // Extract IDs and client reference IDs from HfReferral entities + hfReferrals.forEach(entity -> { + idList.add(entity.getId()); + clientReferenceIdList.add(entity.getClientReferenceId()); + }); if (!iMap.isEmpty()) { - List referralIds = new ArrayList<>(iMap.keySet()); - List existingReferrals = hfReferralRepository - .findById(referralIds, false, getIdFieldName(idMethod)); + HFReferralSearch hfReferralSearch = HFReferralSearch.builder() + .clientReferenceId(clientReferenceIdList) + .id(idList) + .build(); + + List existingReferrals; + try { + // Query the repository to find existing entities + existingReferrals = hfReferralRepository.find(hfReferralSearch, hfReferrals.size(), 0, + hfReferrals.get(0).getTenantId(), null, false); + } catch (Exception e) { + // Handle query builder exception + log.error("Search failed for HFReferral with error: {}", e.getMessage(), e); + throw new CustomException("HFREFERRAL_SEARCH_FAILED", "Search Failed for HFReferral, " + e.getMessage()); + } List nonExistentReferrals = checkNonExistentEntities(iMap, existingReferrals, idMethod); nonExistentReferrals.forEach(sideEffect -> { diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeExistentEntityValidator.java index 87b93e06920..9ed78e8db17 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeExistentEntityValidator.java @@ -5,12 +5,15 @@ import java.util.Map; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.referralmanagement.sideeffect.SideEffect; import org.egov.common.models.referralmanagement.sideeffect.SideEffectBulkRequest; import org.egov.common.models.referralmanagement.sideeffect.SideEffectSearch; import org.egov.common.validator.Validator; import org.egov.referralmanagement.repository.SideEffectRepository; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import static org.egov.common.utils.CommonUtils.getIdFieldName; @@ -24,6 +27,9 @@ * * @author kanishq-egov */ +@Component +@Order(value = 1) +@Slf4j public class SeExistentEntityValidator implements Validator { private final SideEffectRepository sideEffectRepository; diff --git a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeNonExistentEntityValidator.java b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeNonExistentEntityValidator.java index 5f70cd0fef5..adbc83e68c4 100644 --- a/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeNonExistentEntityValidator.java +++ b/health-services/referralmanagement/src/main/java/org/egov/referralmanagement/validator/sideeffect/SeNonExistentEntityValidator.java @@ -1,32 +1,33 @@ package org.egov.referralmanagement.validator.sideeffect; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import com.fasterxml.jackson.databind.ObjectMapper; import lombok.extern.slf4j.Slf4j; -import org.egov.referralmanagement.repository.SideEffectRepository; import org.egov.common.models.Error; import org.egov.common.models.referralmanagement.sideeffect.SideEffect; import org.egov.common.models.referralmanagement.sideeffect.SideEffectBulkRequest; +import org.egov.common.models.referralmanagement.sideeffect.SideEffectSearch; import org.egov.common.validator.Validator; +import org.egov.referralmanagement.repository.SideEffectRepository; +import org.egov.tracer.model.CustomException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static org.egov.referralmanagement.Constants.GET_ID; import static org.egov.common.utils.CommonUtils.checkNonExistentEntities; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.getIdToObjMap; import static org.egov.common.utils.CommonUtils.getMethod; import static org.egov.common.utils.CommonUtils.getObjClass; import static org.egov.common.utils.CommonUtils.notHavingErrors; import static org.egov.common.utils.CommonUtils.populateErrorDetails; import static org.egov.common.utils.ValidatorUtils.getErrorForNonExistentEntity; +import static org.egov.referralmanagement.Constants.GET_ID; @Component @Order(value = 4) @@ -53,10 +54,31 @@ public Map> validate(SideEffectBulkRequest request) { Method idMethod = getMethod(GET_ID, objClass); Map iMap = getIdToObjMap(sideEffects .stream().filter(notHavingErrors()).collect(Collectors.toList()), idMethod); + // Lists to store IDs and client reference IDs + List idList = new ArrayList<>(); + List clientReferenceIdList = new ArrayList<>(); + // Extract IDs and client reference IDs from Side Effect entities + sideEffects.forEach(sideEffect -> { + idList.add(sideEffect.getId()); + clientReferenceIdList.add(sideEffect.getClientReferenceId()); + }); if (!iMap.isEmpty()) { - List sideEffectIds = new ArrayList<>(iMap.keySet()); - List existingSideEffects = sideEffectRepository - .findById(sideEffectIds, false, getIdFieldName(idMethod)); + SideEffectSearch sideEffectSearch = SideEffectSearch.builder() + .clientReferenceId(clientReferenceIdList) + .id(idList) + .build(); + + List existingSideEffects; + try { + // Query the repository to find existing entities + existingSideEffects = sideEffectRepository.find(sideEffectSearch, sideEffects.size(), 0, + sideEffects.get(0).getTenantId(), null, false).getResponse(); + } catch (Exception e) { + // Handle query builder exception + log.error("Search failed for SideEffect with error: {}", e.getMessage(), e); + throw new CustomException("SIDE_EFFECT_SEARCH_FAILED", "Search Failed for SideEffect, " + e.getMessage()); + } + List nonExistentIndividuals = checkNonExistentEntities(iMap, existingSideEffects, idMethod); nonExistentIndividuals.forEach(sideEffect -> { diff --git a/health-services/referralmanagement/src/main/resources/db/Dockerfile b/health-services/referralmanagement/src/main/resources/db/Dockerfile index 60fc07ce69f..e7da01d7f0b 100644 --- a/health-services/referralmanagement/src/main/resources/db/Dockerfile +++ b/health-services/referralmanagement/src/main/resources/db/Dockerfile @@ -1,4 +1,4 @@ -FROM egovio/flyway:4.1.2 +FROM egovio/flyway:10.7.1 COPY ./migration/main /flyway/sql @@ -6,4 +6,4 @@ COPY migrate.sh /usr/bin/migrate.sh RUN chmod +x /usr/bin/migrate.sh -CMD ["/usr/bin/migrate.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/migrate.sh"] \ No newline at end of file diff --git a/health-services/referralmanagement/src/main/resources/db/migrate.sh b/health-services/referralmanagement/src/main/resources/db/migrate.sh index 43960b25cdb..f9d6617822c 100644 --- a/health-services/referralmanagement/src/main/resources/db/migrate.sh +++ b/health-services/referralmanagement/src/main/resources/db/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate \ No newline at end of file +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate diff --git a/health-services/stock/CHANGELOG.md b/health-services/stock/CHANGELOG.md index 43b00d03e48..564823f17b1 100644 --- a/health-services/stock/CHANGELOG.md +++ b/health-services/stock/CHANGELOG.md @@ -5,6 +5,9 @@ All notable changes to this module will be documented in this file. - Upgraded to health models 1.0.20 and health common 1.0.16 - Boundary v2 Integration - MDMS v2 integration +- Upgraded PostgresSQL Driver version to 42.7.1 +- Upgraded Flyway base image version to 10.7.1 for DB Migration +- Upgraded Flyway-Core to 9.22.3 ## 1.1.2 - 2024-02-26 - Enhance inventory flow with sender id and receiver id added. diff --git a/health-services/stock/pom.xml b/health-services/stock/pom.xml index 6387b32a497..fcceea2e322 100644 --- a/health-services/stock/pom.xml +++ b/health-services/stock/pom.xml @@ -45,7 +45,7 @@ org.egov.common health-services-common - 1.0.16-SNAPSHOT + 1.0.17-SNAPSHOT org.egov.common diff --git a/health-services/stock/src/main/java/org/egov/stock/validator/stock/SExistentEntityValidator.java b/health-services/stock/src/main/java/org/egov/stock/validator/stock/SExistentEntityValidator.java index 2db82a921ac..7ad90579428 100644 --- a/health-services/stock/src/main/java/org/egov/stock/validator/stock/SExistentEntityValidator.java +++ b/health-services/stock/src/main/java/org/egov/stock/validator/stock/SExistentEntityValidator.java @@ -5,12 +5,15 @@ import java.util.Map; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.stock.Stock; import org.egov.common.models.stock.StockBulkRequest; import org.egov.common.models.stock.StockSearch; import org.egov.common.validator.Validator; import org.egov.stock.repository.StockRepository; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import static org.egov.common.utils.CommonUtils.getIdFieldName; @@ -24,6 +27,9 @@ * * @author kanishq-egov */ +@Component +@Order(value = 1) +@Slf4j public class SExistentEntityValidator implements Validator { private final StockRepository stockRepository; diff --git a/health-services/stock/src/main/java/org/egov/stock/validator/stock/SNonExistentValidator.java b/health-services/stock/src/main/java/org/egov/stock/validator/stock/SNonExistentValidator.java index 47288df7848..297613136d3 100644 --- a/health-services/stock/src/main/java/org/egov/stock/validator/stock/SNonExistentValidator.java +++ b/health-services/stock/src/main/java/org/egov/stock/validator/stock/SNonExistentValidator.java @@ -1,23 +1,24 @@ package org.egov.stock.validator.stock; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.stock.Stock; import org.egov.common.models.stock.StockBulkRequest; +import org.egov.common.models.stock.StockSearch; import org.egov.common.validator.Validator; import org.egov.stock.repository.StockRepository; +import org.egov.tracer.model.CustomException; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import static org.egov.common.utils.CommonUtils.checkNonExistentEntities; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.getIdToObjMap; import static org.egov.common.utils.CommonUtils.getMethod; import static org.egov.common.utils.CommonUtils.getObjClass; @@ -46,10 +47,30 @@ public Map> validate(StockBulkRequest request) { Method idMethod = getMethod(GET_ID, objClass); Map eMap = getIdToObjMap(entities .stream().filter(notHavingErrors()).collect(Collectors.toList()), idMethod); + // Lists to store IDs and client reference IDs + List idList = new ArrayList<>(); + List clientReferenceIdList = new ArrayList<>(); + // Extract IDs and client reference IDs from stock entities + entities.forEach(entity -> { + idList.add(entity.getId()); + clientReferenceIdList.add(entity.getClientReferenceId()); + }); if (!eMap.isEmpty()) { - List entityIds = new ArrayList<>(eMap.keySet()); - List existingEntities = stockRepository.findById(entityIds,false, - getIdFieldName(idMethod)); + StockSearch stockSearch = StockSearch.builder() + .clientReferenceId(clientReferenceIdList) + .id(idList) + .build(); + + List existingEntities; + try { + // Query the repository to find existing entities + existingEntities = stockRepository.find(stockSearch, entities.size(), 0, + entities.get(0).getTenantId(), null, false); + } catch (Exception e) { + // Handle query builder exception + log.error("Search failed for Stock with error: {}", e.getMessage(), e); + throw new CustomException("STOCK_SEARCH_FAILED", "Search Failed for Stock, " + e.getMessage()); + } List nonExistentEntities = checkNonExistentEntities(eMap, existingEntities, idMethod); nonExistentEntities.forEach(task -> { diff --git a/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrExistentEntityValidator.java b/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrExistentEntityValidator.java index e804a150db2..e7c0ec35d16 100644 --- a/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrExistentEntityValidator.java +++ b/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrExistentEntityValidator.java @@ -5,12 +5,15 @@ import java.util.Map; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.stock.StockReconciliation; import org.egov.common.models.stock.StockReconciliationBulkRequest; import org.egov.common.models.stock.StockReconciliationSearch; import org.egov.common.validator.Validator; import org.egov.stock.repository.StockReconciliationRepository; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import static org.egov.common.utils.CommonUtils.getIdFieldName; @@ -24,6 +27,9 @@ * * @author kanishq-egov */ +@Component +@Order(value = 1) +@Slf4j public class SrExistentEntityValidator implements Validator { private final StockReconciliationRepository stockReconciliationRepository; diff --git a/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrNonExistentValidator.java b/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrNonExistentValidator.java index d1975a10872..389cc2a2460 100644 --- a/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrNonExistentValidator.java +++ b/health-services/stock/src/main/java/org/egov/stock/validator/stockreconciliation/SrNonExistentValidator.java @@ -1,23 +1,24 @@ package org.egov.stock.validator.stockreconciliation; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + import lombok.extern.slf4j.Slf4j; import org.egov.common.models.Error; import org.egov.common.models.stock.StockReconciliation; import org.egov.common.models.stock.StockReconciliationBulkRequest; +import org.egov.common.models.stock.StockReconciliationSearch; import org.egov.common.validator.Validator; import org.egov.stock.repository.StockReconciliationRepository; +import org.egov.tracer.model.CustomException; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - import static org.egov.common.utils.CommonUtils.checkNonExistentEntities; -import static org.egov.common.utils.CommonUtils.getIdFieldName; import static org.egov.common.utils.CommonUtils.getIdToObjMap; import static org.egov.common.utils.CommonUtils.getMethod; import static org.egov.common.utils.CommonUtils.getObjClass; @@ -46,10 +47,30 @@ public Map> validate(StockReconciliationBulkReq Method idMethod = getMethod(GET_ID, objClass); Map eMap = getIdToObjMap(entities .stream().filter(notHavingErrors()).collect(Collectors.toList()), idMethod); + // Lists to store IDs and client reference IDs + List idList = new ArrayList<>(); + List clientReferenceIdList = new ArrayList<>(); + // Extract IDs and client reference IDs from StockReconciliation entities + entities.forEach(entity -> { + idList.add(entity.getId()); + clientReferenceIdList.add(entity.getClientReferenceId()); + }); if (!eMap.isEmpty()) { - List entityIds = new ArrayList<>(eMap.keySet()); - List existingEntities = stockReconciliationRepository.findById(entityIds,false, - getIdFieldName(idMethod)); + StockReconciliationSearch stockReconciliationSearch = StockReconciliationSearch.builder() + .clientReferenceId(clientReferenceIdList) + .id(idList) + .build(); + + List existingEntities; + try { + // Query the repository to find existing entities + existingEntities = stockReconciliationRepository.find(stockReconciliationSearch, entities.size(), 0, + entities.get(0).getTenantId(), null, false); + } catch (Exception e) { + // Handle query builder exception + log.error("Search failed for StockReconciliation with error: {}", e.getMessage(), e); + throw new CustomException("STOCK_RECONCILIANTION_SEARCH_FAILED", "Search Failed for StockReconciliation, " + e.getMessage()); + } List nonExistentEntities = checkNonExistentEntities(eMap, existingEntities, idMethod); nonExistentEntities.forEach(task -> { diff --git a/health-services/stock/src/main/resources/db/Dockerfile b/health-services/stock/src/main/resources/db/Dockerfile index 60fc07ce69f..e7da01d7f0b 100644 --- a/health-services/stock/src/main/resources/db/Dockerfile +++ b/health-services/stock/src/main/resources/db/Dockerfile @@ -1,4 +1,4 @@ -FROM egovio/flyway:4.1.2 +FROM egovio/flyway:10.7.1 COPY ./migration/main /flyway/sql @@ -6,4 +6,4 @@ COPY migrate.sh /usr/bin/migrate.sh RUN chmod +x /usr/bin/migrate.sh -CMD ["/usr/bin/migrate.sh"] \ No newline at end of file +ENTRYPOINT ["/usr/bin/migrate.sh"] \ No newline at end of file diff --git a/health-services/stock/src/main/resources/db/migrate.sh b/health-services/stock/src/main/resources/db/migrate.sh index 43960b25cdb..f9d6617822c 100644 --- a/health-services/stock/src/main/resources/db/migrate.sh +++ b/health-services/stock/src/main/resources/db/migrate.sh @@ -1,3 +1,3 @@ #!/bin/sh -flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true -ignoreMissingMigrations=true migrate \ No newline at end of file +flyway -url=$DB_URL -table=$SCHEMA_TABLE -user=$FLYWAY_USER -password=$FLYWAY_PASSWORD -locations=$FLYWAY_LOCATIONS -baselineOnMigrate=true -outOfOrder=true migrate diff --git a/health-services/stock/src/test/java/org/egov/stock/validator/NonExistentEntityValidatorTest.java b/health-services/stock/src/test/java/org/egov/stock/validator/NonExistentEntityValidatorTest.java index 347f8e80ab2..cd21056b9c3 100644 --- a/health-services/stock/src/test/java/org/egov/stock/validator/NonExistentEntityValidatorTest.java +++ b/health-services/stock/src/test/java/org/egov/stock/validator/NonExistentEntityValidatorTest.java @@ -1,5 +1,11 @@ package org.egov.stock.validator; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import lombok.extern.slf4j.Slf4j; +import org.egov.common.data.query.exception.QueryBuilderException; import org.egov.common.models.Error; import org.egov.common.models.stock.Stock; import org.egov.common.models.stock.StockBulkRequest; @@ -13,6 +19,7 @@ import org.egov.stock.repository.StockRepository; import org.egov.stock.validator.stock.SNonExistentValidator; import org.egov.stock.validator.stockreconciliation.SrNonExistentValidator; +import org.egov.tracer.model.CustomException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -20,17 +27,12 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import java.util.Collections; -import java.util.List; -import java.util.Map; - import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.ArgumentMatchers.anyBoolean; -import static org.mockito.ArgumentMatchers.anyList; -import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) +@Slf4j class NonExistentEntityValidatorTest { @InjectMocks @@ -49,8 +51,13 @@ class NonExistentEntityValidatorTest { @DisplayName("should add to error details map if entity not found") void shouldAddToErrorDetailsMapIfEntityNotFound() { StockBulkRequest request = StockBulkRequestTestBuilder.builder().withStockId("some-id").withRequestInfo().build(); - when(stockRepository.findById(anyList(), anyBoolean(), anyString())) - .thenReturn(Collections.emptyList()); + try { + when(stockRepository.find(any(), any(), any(), any(), any(), any(Boolean.class))) + .thenReturn(Collections.emptyList()); + } catch (QueryBuilderException e) { + log.error("Search failed for Stock with error: {}", e.getMessage(), e); + throw new CustomException("STOCK_SEARCH_FAILED", "Search Failed for Stock, " + e.getMessage()); + } Map> errorDetailsMap = stockNonExistentValidator.validate(request); @@ -61,8 +68,13 @@ void shouldAddToErrorDetailsMapIfEntityNotFound() { @DisplayName("should not add to error details map if entity found") void shouldNotAddToErrorDetailsMapIfEntityFound() { StockBulkRequest request = StockBulkRequestTestBuilder.builder().withStockId("some-id").withRequestInfo().build(); - when(stockRepository.findById(anyList(), anyBoolean(), anyString())) - .thenReturn(Collections.singletonList(StockTestBuilder.builder().withStock().withId("some-id").build())); + try { + when(stockRepository.find(any(), any(), any(), any(), any(), any(Boolean.class))) + .thenReturn(Collections.singletonList(StockTestBuilder.builder().withStock().withId("some-id").build())); + } catch (QueryBuilderException e) { + log.error("Search failed for Stock with error: {}", e.getMessage(), e); + throw new CustomException("STOCK_SEARCH_FAILED", "Search Failed for Stock, " + e.getMessage()); + } Map> errorDetailsMap = stockNonExistentValidator.validate(request); @@ -75,8 +87,13 @@ void shouldNotAddToErrorDetailsMapIfEntityFound() { void shouldAddToErrorDetailsMapIfReconciliationEntityNotFound() { StockReconciliationBulkRequest request = StockReconciliationBulkRequestTestBuilder.builder() .withStockId("some-id").withRequestInfo().build(); - when(stockReconciliationRepository.findById(anyList(), anyBoolean(), anyString())) + try { + when(stockReconciliationRepository.find(any(), any(), any(), any(), any(), any(Boolean.class))) .thenReturn(Collections.emptyList()); + } catch (QueryBuilderException e) { + log.error("Search failed for StockReconciliation with error: {}", e.getMessage(), e); + throw new CustomException("STOCK_RECONCILIANTION_SEARCH_FAILED", "Search Failed for StockReconciliation, " + e.getMessage()); + } Map> errorDetailsMap = stockReconciliationNonExistentValidator.validate(request); @@ -88,9 +105,14 @@ void shouldAddToErrorDetailsMapIfReconciliationEntityNotFound() { void shouldNotAddToErrorDetailsMapIfReconciliationEntityFound() { StockReconciliationBulkRequest request = StockReconciliationBulkRequestTestBuilder.builder() .withStockId("some-id").withRequestInfo().build(); - when(stockReconciliationRepository.findById(anyList(), anyBoolean(), anyString())) - .thenReturn(Collections.singletonList(StockReconciliationTestBuilder.builder().withStock() - .withId("some-id").build())); + try { + when(stockReconciliationRepository.find(any(), any(), any(), any(), any(), any(Boolean.class))) + .thenReturn(Collections.singletonList(StockReconciliationTestBuilder.builder().withStock() + .withId("some-id").build())); + } catch (QueryBuilderException e) { + log.error("Search failed for StockReconciliation with error: {}", e.getMessage(), e); + throw new CustomException("STOCK_RECONCILIANTION_SEARCH_FAILED", "Search Failed for StockReconciliation, " + e.getMessage()); + } Map> errorDetailsMap = stockReconciliationNonExistentValidator.validate(request); diff --git a/health-services/transformer/CHANGELOG.md b/health-services/transformer/CHANGELOG.md index 1d11977c2a5..50427336512 100644 --- a/health-services/transformer/CHANGELOG.md +++ b/health-services/transformer/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this module will be documented in this file. - Upgraded to health models 1.0.20 and health common 1.0.16 - Boundary v2 Integration - MDMS v2 integration +- Upgraded PostgresSQL Driver version to 42.7.1 ## 1.1.1 - 2024-05-10 - Integrated Boundary v2 functionality diff --git a/health-services/transformer/pom.xml b/health-services/transformer/pom.xml index a38c13d9583..7a94fd3e47c 100644 --- a/health-services/transformer/pom.xml +++ b/health-services/transformer/pom.xml @@ -65,7 +65,7 @@ org.egov.common health-services-common - 1.0.16-SNAPSHOT + 1.0.17-SNAPSHOT compile diff --git a/health-services/transformer/src/main/java/org/egov/transformer/service/ProjectService.java b/health-services/transformer/src/main/java/org/egov/transformer/service/ProjectService.java index 788a2aa556e..e6c997a2dd6 100644 --- a/health-services/transformer/src/main/java/org/egov/transformer/service/ProjectService.java +++ b/health-services/transformer/src/main/java/org/egov/transformer/service/ProjectService.java @@ -123,7 +123,7 @@ public Map getBoundaryCodeToNameMap(String locationCode, String } catch (Exception e) { log.error("Exception while searching boundaries for tenantId: {}", tenantId, e); // Throw a custom exception if an error occurs during boundary search - throw new CustomException("BOUNDARY_SEARCH_ERROR", e.getMessage()); + throw new CustomException("BOUNDARY_SERVICE_SEARCH_ERROR","Error in while fetching boundaries from Boundary Service : " + e.getMessage()); } return boundaries.stream()