LAB_ATKJE045 - Spring Core - Skill Based Assessment [201-INTERMEDIATE]
14-Feb-2020 20:25
14-Feb-2020 21:09
44 Mins
6 / 6
0 / 6
| Section Name | Total Questions | Answered | Not Answered | Correct Marks | Partial Marks | Penalty Marks | Score |
|---|---|---|---|---|---|---|---|
| Spring Core MCQ | 5 | 5 | 0 | 2.00 | 0.00 | 0.00 | 2.00 |
| Spring Core Skill | 1 | 1 | 0 | 89.25 | 0.00 | 0.00 | 89.25 |
| Priority | No of Violations | Percentage of Violations | Score |
|---|---|---|---|
| P1 | 0 | 0 | 4.00 |
| P2 | 0 | 0 | 3.00 |
| P3 | 17 | 20 | 2.25 |
| Total Score | 9.25 | ||
11 minutes 1 seconds InCorrect
William wants to test the method 'addEmployee' using Spring Test framework. He deletes all the data from T_EMPLOYEE, saves 1 record and attempts to retrieve it, by invoking findAll() method.
The test case ends in failure and the data is not retrieved back.
Choose and apply an appropriate solution for the given problem:
// imports omitted
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ServiceTestConfig.class})
public abstract class EmployeeServiceTest extends
AbstractTransactionalJUnit4SpringContextTests {
@PersistenceContext
protected EntityManager em;
@Test
public void testAddCustomer() throws Exception {
// Clear all existing data in T_EMPLOYEE table
deleteFromTables("T_EMPLOYEE");
Employee employee = new Employee();
employee.setFirstName("Mitchell");
employee.setLastName("Johnson");
employee = employeeService.save(contact); //line 13
List<Contact> contacts = employeeService.findAll(); //line 14
assertEquals(1, contacts.size());
}
}
According to Spring Test framework, the data will never be persisted in the original persistent store. Hence findAll() metthod will be always a failure.
William need to explicitly flush the data into persistent database by calling commit or flush before invoking the findAll() method
William need to create a transaction and wrap it around the save and findAll() operations
None of the listed options
According to Spring Test framework, the data will never be persisted in the original persistent store. Hence findAll() metthod will be always a failure.
20 seconds InCorrect
What are the declaration parts of PointCuts?
Select all that apply
4 seconds InCorrect
Jack wants to test the values of the property file using Spring Junit. Consider that the property file contains the below value
language=JAVA
Test Class name : SpringTest
The property file is loaded inside the configuration class 'Config.java'. Choose the code snippet that test the above scenario
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { Config.class })
public class SpringTest {
@Autowired
protected Environment env;
@Test
public void verifyProperty() {
assertEquals("JAVA", env.getProperty("language"));
}
}
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { Config.class })
public class SpringTest {
@Autowired
protected Environment env;
@Test
public void verifyProperty() {
assertEquals("JAVA", env.get("language"));
}
}
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { Config.class })
public class SpringTest {
@Autowired
protected Environment env;
@Test
public void verifyProperty()
{
assertEquals("JAVA",getProperty("language"));
}
}
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { Config.class })
public class SpringTest {
@Autowired
protected Environment env;
@Test
public void verifyProperty() {
assertEquals("JAVA", env.getProperty=="language");
}
}
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { Config.class })
public class SpringTest {
@Autowired
protected Environment env;
@Test
public void verifyProperty() {
assertEquals("JAVA", env.get("language"));
}
}
5 seconds InCorrect
What will happen if the below test case is executed? Assume that the save() method will throw 'MandatoryFieldConstraintVoilation' Exception if UserId is empty.
@Test(expected=MandatoryFieldConstraintViolationException.class)
public void testAddUserInvalidInput() throws Exception {
User user = new User();
user.setUserName("XXX");
user = userService.save(user);
}
Test will not get executed
Test case will get passed, the data will not get saved
Test case will fail, the data will get saved
The data will not get saved and the test case will also fail
Test will not get executed
9 seconds Correct
Which of the below statements are true ?
1. Spring AOP is proxy based
2. Spring AOP performs weaving at Run time
3. In Spring AOP, Join Point represents the method execution
32 minutes 36 seconds Correct
Important Instructions
1. Business Requirement
Emerge Hospital is one of the leading multi-specialty hospital, which provides the best medical treatment for its patients. As the hospital has now grown, the hospital management faces many issues in maintaining the patients’ medical records and health benefits for an insurance policy. Hence the management has decided to computerize some of their manual processes. As the first phase of the work, they have intended to automate the process of maintaining the patients’ health record information, and automatic reply of providing the list of benefits for any insurance policies.
1.1 Target Audience
The target audience for EHMS is the front office staffs. The front office staff uses this system to record the patient’s health information and also to provide the list of benefits that can be availed under an insurance policy.
2. Technical Specifications
Database Connectivity Details
Use MYSQL database for all the database activities. The script needed for the case study and the connection details is given below:
|
Driver Class |
com.mysql.jdbc.Driver |
|
URI Name |
jdbc:mysql://localhost/springHealthCare |
|
UserName |
root |
|
Password |
<PASSWORD IS BLANK> |
Create the tables before proceeding with the source code.
2.1 Add Patient Health Record Information
Background
The patients get admitted in the hospital after completing the registration process. The patient registration details like patient id, patient name, age, gender, registration fees, date of admission and policy number are already persisted in a table named “T_PATIENT_INFO” (this table would have been created by running the DB script). Once the patient is registered in the hospital, they undergo diagnostic test prescribed by the doctor.
|
Requirement Number |
Requirement Description |
|
2.1.1 |
To retrieve the cost associated for every diagnostic test, from a Map |
|
2.1.2 |
To use the cost retrieved in requirement number 2.1.1 and to store the patient health record into the database |
2.1.1 Retrieve Diagnostic Test Cost
This requirement is to retrieve the associated cost of the prescribed diagnostic test. The diagnostic test details are predefined by the hospital. The diagnostic test detail contains the diagnostic test name and its cost as shown below. The functionality gets the test name, and validates it against Diagnostic Test Map.
If the given diagnostic test name is valid it should return the cost of the test.
If the given diagnostic test name is invalid, then a user defined exception named “InvalidDiagnosticTestException” is thrown and the message “Incorrect Diagnostic Name” should be displayed
You have to provide solution to this requirement in the BO layer of the project. The Class ‘PatientHealthRecordBO’ has the method ‘getDiagnosticTestCost’ which must return the cost of the diagnostic test.
This method will be used in the requirement 2.1.2 in order to persist the patient health record in the database.
The BO class ‘PatientHealthRecordBO’ must be injected with the map that stores the Test and the associated cost in the Application Context.
PatientHealthRecordBO should be injected in PatientHealthRecordService and PatientHealthRecordDAO must be injected in PatientHealthRecordBO.
Do not change the package definitions or class names or method signatures in the code.
Diagnostic Test Map should be configured with the following data. Please DO NOT change the test_name or the test_cost VALUES while injecting the MAP in application context.
You can use either Annotation or XML based configuration to inject the necessary beans, unless specified. If you are using XML based configuration, define your beans in applicationcontext.xml file ONLY. If you are using annotation based configuration, define your beans in ‘EmergeHMSConfig’ class only.
|
Test_Name |
Test_Cost |
|
ECG |
200 |
|
Angiogram |
10000 |
|
BloodTest |
70 |
Method Specification:
|
Component Name |
Method |
Input |
Output |
Exceptional Case |
|
PatientHealthRecordBO |
getDiagnosticTestCost |
String testName
|
float cost |
If the test name is not found in the map, throw: InvalidDiagnosticTestException |
2.1.2 Store Patient Health Record
This requirement is to store the patient health record into the database. The Test Name and Patient ID will be obtained as input. The following fields must be persisted in the database, for the given patient ID:
|
PATIENT_ID |
Passed as input, this must be validated against the T_PATIENT table, before persisting the data into T_PATIENT_HEALTH_RECORD table |
|
TEST_NAME |
Passed as input |
|
TEST_COST |
The cost retrieved by the method written in 3.1.1 |
|
TEST_DATE |
The current system date |
The input, ‘patientId’ is validated to check if it is already present in the T_PATIENT table. If it is present, the input ‘patientId’ can be considered valid.
If the given ‘patientId’ is invalid, then a user defined exception named “NoDataFoundException” must be thrown with an error message “Invalid Patient ID”
The diagnostic test cost is obtained from Map using the requirement 2.1.1 functionality
On validating patient id, the patient id, test name, test cost, and test date is stored in the database table named “T_PATIENT_HEALTH_RECORD”.
Method Specification
|
Component Name |
Method |
Input |
Output |
Exceptional Case |
|
PatientHealthRecordService |
addpatientHealthRecord |
int patientId, String testName |
void |
Invalid patient id : NoDataFoundException Invalid Diagnostic Test Name: InvalidDiagnosticTestException |
|
PatientHealthRecordBO |
addpatientHealthRecord
|
PatientHealthRecordVO patienthealthrecordvo |
void
|
Invalid patient id : NoDataFoundException Invalid Diagnostic Test Name: InvalidDiagnosticTestException |
|
getDiagnosticTestCost |
String testName
|
float cost |
Invalid test Name: InvalidDiagnosticTestException |
|
|
PatientHealthRecordDAO |
addpatientHealthRecord |
PatientHealthRecordVO patienthealthrecordvo |
void |
None |
|
validatePatientId |
Int patientId |
Boolean isValid |
Invalid patient id : NoDataFoundException
|
Design Rules:
Do not change the layers of the application. The control must flow as specified in the sequence diagram
Do not change the property files provided in the application
The BO class ‘PatientHealthRecordBO’ must be injected with the map that stores the Test and the associated cost in the Application Context.
PatientHealthRecordBO should be injected in PatientHealthRecordService and PatientHealthRecordDAO must be injected in PatientHealthRecordBO.
Use ONLY DriverManagerDataSource for creating the datasource. You MUST NOT change the database properties file (mysql.properties) provided as part of the Skeleton. Use PropertyPlaceHolder configuration to read the properties and create the datasource bean.
Use ONLY Declarative Transaction management for inserting the patient health record into database. We expect you to have this transaction in the ‘PatientHealthRecordBO’ class, for the method ‘addPatientHealthRecord’.
Do not change the package definitions or class names or method signatures in the code.
You can use either Annotation or XML based configuration to inject the necessary beans. If you are using XML based configuration, define your beans in applicationcontext.xml file ONLY. If you are using annotation based configuration, define your beans in ‘EmergeHMSConfig’ class only.
Sequence Diagram (for 2.1.1 and 2.1.2)

2.2 Retrieve the Policy Details for the Patient
Business Rules
The hospital allows patients to avail certain authorized insurance policies, while getting the medical services from the hospital.
|
Component Name |
Method |
Input |
Output |
Exceptional Case |
|
PatientHealthRecordService |
getPatientHealthBenefits |
String policyName |
HashMap<String,List<String>> |
None |
|
PatientHealthRecordBO |
getPatientHealthBenefits |
String policyName |
HashMap<String,List<String>> |
None |
Sequence Diagram

Design Considerations
Classes mentioned in the method specification table should be a Spring Bean
Use ‘ResourceBundleMessageSource’ in order to retrieve value from the property file (emergeBenefits.properties) which is provided to you part of the Skeleton
The bean defined of type ‘ResourceBundleMessageSource’ must be autowired to the ‘PatientHealthRecordBO’ class ONLY using annotations
The benefits will be comma separated for a given policy name
These comma separated values must be added as separate entry to a list, which again must be wrapped in a Hash map and returned.
For Example, for the policy ‘MOTHERHOOD’, the benefits are listed like below:

b. The output map structure should be like:
|
Key: String |
Value: List<String> |
|
|
{0=MATERNITY, 1=PEDIATRIC} |
vi.You can use either Annotation or XML based configuration to inject the necessary beans, unless specified. If you are using XML based configuration, define your beans in applicationcontext.xml file ONLY. If you are using annotation based configuration, define your beans in ‘EmergeHMSConfig’ class only.
| Criteria Name | Comments for Associates | Status |
|---|---|---|
| Destructive | Test Add patient Health Record Invalid Patient Id Service | Success |
| Test Add patient Health Record Invalid TestName Service | Success | |
| Test Invalid Validate PatientId DAO | Success | |
| Feature Test | Test Property PlaceHolder Configurer | Success |
| Test Resource Bundle Message Source | Success | |
| Test Autowiring | Success | |
| Test Collections | Success | |
| Test Transactions | Success | |
| Test JDBC | Success | |
| Test Dependency Injection Service Layer | Success | |
| Test Dependency Injection BO Layer | Success | |
| Functional | Test Add Patient Health Record Service | Success |
| Test Add Patient Health Record BO | Success | |
| Test Add Patient Health Record DAO | Success | |
| Test Validate Patient Id DAO | Success | |
| Test Get Diagnostic Test Ang Cost BO | Success | |
| Test Get Diagnostic Test BT Cost BO | Success | |
| Test Get Diagnostic Test ECG Cost BO | Success | |
| Test Get Patient Health Benefit Service | Success | |
| Test Get Patient Health Benefit BO | Success |
Report generated time : 18-02-2020 11:51 AM
Powered by