@Test(expected = InvalidServiceTypeCodeException.class) public void test_should_throw_exception_when_service_definition_is_not_defined() { final List<AttributeEntry> attributeEntries = Arrays.asList( new AttributeEntry("gender", "male"), new AttributeEntry("age", "30") ); final ServiceRequest serviceRequest = createServiceRequest(attributeEntries); final SevaRequest contractSevaRequest = mock(SevaRequest.class); final org.egov.pgrrest.common.contract.web.ServiceRequest mockServiceRequest = mock(org.egov.pgrrest.common.contract.web.ServiceRequest.class); final List<org.egov.pgr.common.contract.AttributeEntry> contractAttributeEntries = new ArrayList<>(); contractAttributeEntries.add(new org.egov.pgr.common.contract.AttributeEntry("gender", "male")); contractAttributeEntries.add(new org.egov.pgr.common.contract.AttributeEntry("age", "30")); when(contractSevaRequest.getAttributeValues()).thenReturn(contractAttributeEntries); final ServiceDefinitionSearchCriteria searchCriteria = new ServiceDefinitionSearchCriteria("serviceCode", "tenantId"); when(serviceDefinitionService.find(searchCriteria)).thenReturn(null); customFieldService.enrich(serviceRequest, contractSevaRequest, ServiceStatus.COMPLAINT_REGISTERED); }
public void enrich(ServiceRequest serviceRequest, SevaRequest contractSevaRequest, ServiceStatus action) { final List<org.egov.pgr.common.contract.AttributeEntry> attribValues = contractSevaRequest.getAttributeValues(); final ServiceDefinition serviceDefinition = getServiceDefinition(serviceRequest); validateKnownServiceDefinition(serviceRequest, serviceDefinition); if (serviceDefinition.isAttributesAbsent()) { return; } validateAttributeValues(serviceRequest, serviceDefinition, action); if (serviceDefinition.isComputedFieldsAbsent(action)) { return; } computeFields(serviceRequest, attribValues, serviceDefinition, action); }
ServiceRequestCustomFieldService { public void enrich(ServiceRequest serviceRequest, SevaRequest contractSevaRequest, ServiceStatus action) { final List<org.egov.pgr.common.contract.AttributeEntry> attribValues = contractSevaRequest.getAttributeValues(); final ServiceDefinition serviceDefinition = getServiceDefinition(serviceRequest); validateKnownServiceDefinition(serviceRequest, serviceDefinition); if (serviceDefinition.isAttributesAbsent()) { return; } validateAttributeValues(serviceRequest, serviceDefinition, action); if (serviceDefinition.isComputedFieldsAbsent(action)) { return; } computeFields(serviceRequest, attribValues, serviceDefinition, action); } }
ServiceRequestCustomFieldService { public void enrich(ServiceRequest serviceRequest, SevaRequest contractSevaRequest, ServiceStatus action) { final List<org.egov.pgr.common.contract.AttributeEntry> attribValues = contractSevaRequest.getAttributeValues(); final ServiceDefinition serviceDefinition = getServiceDefinition(serviceRequest); validateKnownServiceDefinition(serviceRequest, serviceDefinition); if (serviceDefinition.isAttributesAbsent()) { return; } validateAttributeValues(serviceRequest, serviceDefinition, action); if (serviceDefinition.isComputedFieldsAbsent(action)) { return; } computeFields(serviceRequest, attribValues, serviceDefinition, action); } ServiceRequestCustomFieldService(ServiceDefinitionService serviceDefinitionService,
                                            List<AttributeValueValidator> attributeValueValidators,
                                            JSScriptEngineFactory scriptEngineFactory); }
ServiceRequestCustomFieldService { public void enrich(ServiceRequest serviceRequest, SevaRequest contractSevaRequest, ServiceStatus action) { final List<org.egov.pgr.common.contract.AttributeEntry> attribValues = contractSevaRequest.getAttributeValues(); final ServiceDefinition serviceDefinition = getServiceDefinition(serviceRequest); validateKnownServiceDefinition(serviceRequest, serviceDefinition); if (serviceDefinition.isAttributesAbsent()) { return; } validateAttributeValues(serviceRequest, serviceDefinition, action); if (serviceDefinition.isComputedFieldsAbsent(action)) { return; } computeFields(serviceRequest, attribValues, serviceDefinition, action); } ServiceRequestCustomFieldService(ServiceDefinitionService serviceDefinitionService,
                                            List<AttributeValueValidator> attributeValueValidators,
                                            JSScriptEngineFactory scriptEngineFactory); void enrich(ServiceRequest serviceRequest, SevaRequest contractSevaRequest, ServiceStatus action); }
ServiceRequestCustomFieldService { public void enrich(ServiceRequest serviceRequest, SevaRequest contractSevaRequest, ServiceStatus action) { final List<org.egov.pgr.common.contract.AttributeEntry> attribValues = contractSevaRequest.getAttributeValues(); final ServiceDefinition serviceDefinition = getServiceDefinition(serviceRequest); validateKnownServiceDefinition(serviceRequest, serviceDefinition); if (serviceDefinition.isAttributesAbsent()) { return; } validateAttributeValues(serviceRequest, serviceDefinition, action); if (serviceDefinition.isComputedFieldsAbsent(action)) { return; } computeFields(serviceRequest, attribValues, serviceDefinition, action); } ServiceRequestCustomFieldService(ServiceDefinitionService serviceDefinitionService,
                                            List<AttributeValueValidator> attributeValueValidators,
                                            JSScriptEngineFactory scriptEngineFactory); void enrich(ServiceRequest serviceRequest, SevaRequest contractSevaRequest, ServiceStatus action);  }