banyan-logo

LAB_ATKJE045 - Spring Core - Skill Based Assessment [201-INTERMEDIATE]


  • Deepa (228120)
  • deepa.mariappan@cognizant.com
  • : PASS

14-Feb-2020 20:25

14-Feb-2020 21:09

44 Mins

Overall competency
91%

Candidate Answer Summary

6 / 6

0 / 6


Competency Breakdown
Unit Testing and Coding Standards
0%
Spring AOP
50%
Destructive
100%
Functional
100%
Feature Test
100%

Detailed Score
Section Name Total Questions Answered Not Answered Correct Marks Partial Marks Penalty Marks Score
Spring Core MCQ5502.000.00 0.002.00
Spring Core Skill11089.250.00 0.0089.25

PMD Code Quality Score
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
1. Spring Test framework

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.

2. Declaration parts of PointCuts

20 seconds InCorrect

What are the declaration parts of PointCuts?

Select all that apply

Signature comprising a name and any parameters
a pointcut expression that determines exactly about the method to be executed
Before advice declaration
JoinPoints declaration
a pointcut expression that determines exactly about the method to be executed
Signature comprising a name and any parameters
JoinPoints declaration
3. Property file

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")); 
   } 
 }

 

4. MandatoryFieldConstraintVoilation Exception

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

5. Spring AOP

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

1, 2
1 only
2, 3
1, 3
All of the listed options
All of the listed options
6. Emerge Hospital Management System

32 minutes 36 seconds Correct

Important Instructions

  1. Please read and understand the given case study carefully.
  2. Please navigate to the path to open Eclipse IDE.Javaca -> SDE_7_SSH -> eclipse - shortcut ->eclipse
  3. Refer to http://caportal/javaca/index.html for all user manuals and API documentations (Navigate to the appropriate skill, in which you are attempting the assessment).
  4. Adhere to the design specifications mentioned in the case study.
  5. Do not change or delete the class/method names or return types which are provided to you as a part of the base code skeleton.
  6. Please make sure that your code does not have any compilation errors while submitting your case study solution.
  7. You cannot open command prompt in this environment. Please use the equivalent batch files as recommended in the user manuals (for running database scripts), available in the portal,http://caportal/javaca/index.html.
  8. You will be using MySQL database as the back-end, all the necessary database objects will be provided part of the script file. You just need to run that file and start doing the solution.
  9. Once you have successfully completed the project, zip entire code and upload using upload option available.
  10. You must click the "Finish Assessment" button to complete the assessment, auto evaluate and generate profile Report.
  11. Please reach out to proctors if you have any queries.

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

Requirement Description:

            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

Design Rules:

  1. 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.

  2. This method will be used in the requirement 2.1.2 in order to persist the patient health record in the database.

  3. The BO class ‘PatientHealthRecordBO’ must be injected with the map that stores the Test and the associated cost in the Application Context.

  4. PatientHealthRecordBO should be injected in PatientHealthRecordService and PatientHealthRecordDAO must be injected in PatientHealthRecordBO.

  5.  Do not change the package definitions or class names or method signatures in the code.

  6. 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.

  7. 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:

  1. Do not change the layers of the application. The control must flow as specified in the sequence diagram

  2. Do not change the property files provided in the application

  3. The BO class ‘PatientHealthRecordBO’ must be injected with the map that stores the Test and the associated cost in the Application Context.

  4. PatientHealthRecordBO should be injected in PatientHealthRecordService and PatientHealthRecordDAO must be injected in PatientHealthRecordBO.

  5. 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.

  6. 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’.  

  7. Do not change the package definitions or class names or method signatures in the code.

  8. 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.

  • As a general inquiry, the hospital wants to build a reusable functionality that will provide the list of benefits of the authorized insurance policies of the hospital.
  • The authorized insurance policies and their associated benefits will be supplied to you as a property file. This is available in the Code skeleton provided to you.
  • We must need to read this file in the ‘PatientHealthRecordBO’ class and must return the list of benefits as a Hash Map.

Method Specification

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

  1. Classes mentioned in the method specification table should be a Spring Bean

  2. Use ‘ResourceBundleMessageSource’ in order to retrieve value from the property file (emergeBenefits.properties) which is provided to you part of the Skeleton

  3. The bean defined of type ‘ResourceBundleMessageSource’ must be autowired to the ‘PatientHealthRecordBO’ class  ONLY using annotations

  4. The benefits will be comma separated for a given policy name

  5. These comma separated values must be added as separate entry to a list, which again must be wrapped in a Hash map and returned.

    1. 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>

  1.  

{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
  • NOTE:
  • Success -Testcase is implemented successfully
  • Failure -Testcase is not implemented
  • Build Error -if your solution throws compilation error.
No Issues Found.

Report generated time : 18-02-2020 11:51 AM

Powered by banyan-logo