LAB_ATKJE027 - Spring Core - Skill Based Assessment [301-ADVANCED]
14-Feb-2020 21:33
14-Feb-2020 21:50
17 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 | 88.50 | 0.00 | 0.00 | 88.50 |
| Priority | No of Violations | Percentage of Violations | Score |
|---|---|---|---|
| P1 | 0 | 0 | 4.00 |
| P2 | 1 | 10 | 2.25 |
| P3 | 12 | 14 | 2.25 |
| Total Score | 8.50 | ||
1 minutes 46 seconds Correct
Which of the below statements regarding "Advice" is true?
1. "After advice" will be executed after the actual method call.
2. "Before advice" will be executed before a method call.
3. " Around advice" will be executed only after a method call.
4. "Throw advice" will be executed if actual method throw exception.
3 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.getProperty=="language");
}
}
4 seconds InCorrect
What are the declaration parts of PointCuts?
Select all that apply
3 seconds InCorrect
Consider a Service class that retrieves the list of Tourist places available in TamilNadu. This class reads the values from Property file to retrieve the tourist places. City name is the key and the Tourist places will be the values.
Positive Scenario : If the provided city name is available in the property file, then the service class will return the list of tourist places against the given city
Negative Scenario : If the provided city name is not available in the property file, then service class will return the NoDataFound exception with no values in the output list.Write a test case, that test the negative scenario.
// Import Statements
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/applicationcontext.xml" })
public class ServiceTest {
@Autowired
private ResourceReaderService resourcereader;
@Test(expected = NoDataFoundException.class)
public void testPropertyValuesInCorrectData() throws NoDataFoundException {
HashMap> propValues = resourcereader .getPropertyValues("TRICHY");
assertTrue(propValues.isEmpty());
}
}
// Import Statements
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/applicationcontext.xml" })
public class ServiceTest {
@Autowired
private ResourceReaderService resourcereader;
@Test(expected = NoDataFoundException.class)
public void testPropertyValuesInCorrectData() throws NoDataFoundException {
HashMap> propValues = resourcereader.getPropertyValues("TRICHY");
assertTrue(propValues.isNull());
}
}
// Import Statements
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/applicationcontext.xml" })
public class ServiceTest {
@Autowired
private ResourceReaderService resourcereader;
public void testPropertyValuesInCorrectData() throws NoDataFoundException {
HashMap> propValues = resourcereader .getPropertyValues("TRICHY");
assertTrue(propValues.isEmpty());
}
}
// Import Statements
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/applicationcontext.xml" })
public class ServiceTest {
@Autowired
private ResourceReaderService resourcereader;
@Test(expected = NoDataFoundException.class)
public void testPropertyValuesInCorrectData() {
HashMap> propValues = resourcereader .getPropertyValues("TRICHY");
assertTrue(propValues.isEmpty());
}
}
// Import Statements
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/applicationcontext.xml" })
public class ServiceTest {
@Autowired
private ResourceReaderService resourcereader;
public void testPropertyValuesInCorrectData() throws NoDataFoundException {
HashMap> propValues = resourcereader .getPropertyValues("TRICHY");
assertTrue(propValues.isEmpty());
}
}
2 seconds InCorrect
Michael has built an application to retrieve the data of the existing employee details from the database. The application exception 'NoRecordFoundException' must be thrown if the employee is no more part of the organisation.
Choose the code snippet that perform the test to check whether the exception is thrown for the invalid Employee. Consider the id "44870211" is invalid.
@Test(expected = NoRecordFoundException.class) public void testInCorrectData() {
Employee employee = new Employee();
List employeeDetails = new ArrayList();
employeeDetails = employee.getDetails("44870211");
}
public void testInCorrectData() throws NoRecordFoundException {
Employee employee = new Employee();
List employeeDetails = new ArrayList();
employeeDetails = employee.getDetails("44870211");
}
public void testInCorrectData() try {
Employee employee = new Employee();
List employeeDetails = new ArrayList();
employeeDetails = employee.getDetails("44870211");
} catch (NoRecordFoundException e) {
e.printStackTrace();
}
}
public void testInCorrectData()
Employee employee = new Employee();
List employeeDetails = new ArrayList();
employeeDetails = employee.getDetails("44870211");
throw new(NoRecordFoundException e)
}
public void testInCorrectData() try {
Employee employee = new Employee();
List employeeDetails = new ArrayList();
employeeDetails = employee.getDetails("44870211");
} catch (NoRecordFoundException e) {
e.printStackTrace();
}
}
15 minutes 8 seconds Correct
Important Instructions
1.Business Requirement
Member Policy Management System is a system, which holds various Health Insurance Policies for Corporates. As the first phase of the work, they have intended to automate the process of maintaining the Member and Plan details.
1.1 Target Audience
Admin team will be the target audience of the Member Policy Management System.
2.Technical SpecificationsDatabase 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/member_policy |
|
UserName |
root |
|
Password |
<PASSWORD IS BLANK> |
Create the tables before proceeding with the source code. The detailed steps on how to execute the SQL file are available in the user manuals.
Code Skeleton for the Case Study
The code skeleton to be used for developing the case study will be given as a zip file. This will start as the base code for you to work on the solution.
3.1 Get Plan Details of the Member
Background
The member details are already recorded in the database in the table named “MEMBER_DETAILS”. Also the plan details are recorded in the table named “PLAN_DETAILS” (these tables would have been created by running the DB script). Based on the input, the relevant details need to be retrieved from the database.
Requirement Description:
This requirement is to retrieve the plan and the member details of the respective Member.
The functionality gets the member id, plan id and corporate name and retrieve the values from the database.
If the member holds the given plan id, then retrieve member_id, plan_id, plan_value, tenure, corporate_name, monthly_due_date from the database.
The retrieved values need to be set in MemberVO, which is already provided as part of the skeleton.
If the member does not hold the given plan, then a user defined exception named “MemberPolicyException” should be thrown with the message “Invalid Plan Id for the given Member”
Design Rules:
i. MemberPolicyBO should be injected in MemberPolicyService and MemberPolicyDAO must be injected in MemberPolicyBO
ii. Do not change the package definitions or class names or method signatures in the code.
iii. 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 ‘MemberPolicyConfig’ class only.
Method Specification:
|
Component Name |
Method |
Input |
Output |
Exceptional Case |
|
MemberPolicyDAO |
getPlanDetailsOfMember |
String memberId, String planId, String corporateName |
MemberVO |
MemberPolicyException |
3.2 Get Discount Details
Background
Each member can avail the discount percentage for the plan they hold. These discount percentages will be offered based on the Corporate Function Scheme.
Requirement Description:
This requirement is to retrieve the discount percentage for the respective Corporate Scheme.
If the given corporate name is present in the Map, it returns the discount percentage
If the given corporate name is not present in the Map, then a user defined exception named “MemberPolicyException” should be thrown with the message “There is no discount for this Corporate Function”
Design Rules:
MemberPolicyBO should have the method ‘getDiscountToBePaid’ which must return the discount percentage
Map should be configured with the below data. Please DO NOT change the corporate name or the discount percentage values while injecting the map in the Application Context
|
Corporate Name |
Discount Percentage |
|
IT |
50 |
|
Automobiles |
30 |
|
Manufacturing |
20 |
3.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 ‘MemberPolicyConfig’ class only.
Method Specification:
|
Component Name |
Method |
Input |
Output |
Exceptional Case |
|
MemberPolicyBO |
getDiscountDetails |
String corporateName |
Double discountPercentage |
MemberPolicyException |
3.3 Update Premium Amount of the Member
Background
The premium details of the member should be persisted in the database in the table named
“MEMBER_DETAILS”. (this table would have been created by running the DB script). Based on the discount amount retrieved from requirement 3.2, the premium amount should be calculated and should be persisted into the database.
Requirement Description:
This requirement is to update the premium amount of the member based on the discount percentage of the respective Member. The functionality gets the plan value from the database and calculate the premium amount based on the discount percentage.
From Requirement 3.1, the memberVO would have been returned to MemberPolicyBO layer with the values retrieved from the database.
Extract the plan value from the memberVO. The discount percentage would have been returned from the Map using requirement 3.2.
Calculate the Premium amount as per the below formula in the method ‘calculatePremiumAmount’
PREMIUM = (PLAN_VALUE * DISCOUNT_PERCENTAGE) /100;
The calculated premium amount needs to be updated in the database for the given member_id.
Design Rules:
i. MemberPolicyBO should be injected in MemberPolicyService and MemberPolicyDAO must be injected in MemberPolicyBO
ii. Do not change the package definitions or class names or method signatures in the code.
iii. Do not change the property files provided in the application
iv. 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. All the values from mysql.properties file should be read by using the PropertyPlaceHolder, except for driverclassname. The Driver Class name should be hard coded as it and should not be read using PropertyPlaceHolder.
v. Use ONLY Declarative Transaction management for updating the premium_amount into the database. We expect you to have this transaction in the ‘MemberPolicyBO’ class, for the method ‘updatePremiumAmount’.
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 ‘MemberPolicyConfig’ class only.
Method Specification:
|
Component Name |
Method |
Input |
Output |
Exceptional Case |
|
MemberPolicyService |
UpdatePremiumAmount |
String memberId, String planId, String corporateName |
void |
MemberPolicyException |
|
MemberPolicyBO |
UpdatePremiumAmount |
String memberId, String planId, String corporateName |
void |
MemberPolicyException |
|
MemberPolicyBO |
calculatePremiumAmount |
Double discountPercentage, MemberVO memberVO |
Integer |
MemberPolicyException |
|
MemberPolicyDAO |
updatePremiumAmount |
String memberId, String planId, String corporateName |
MemberVO |
MemberPolicyException |
| Criteria Name | Comments for Associates | Status |
|---|---|---|
| Destructive | Test the Invalid Corporate Name In BO | Success |
| Test the Invalid Corporate Name In Service | Success | |
| Test the Invalid Plan Details Of Member In Service | Success | |
| Test the Invalid plan Details Of Member In DAO | Success | |
| Test the Invalid plan Details Of Member In BO | Success | |
| Feature Test | Test the Premium Update In Database From Service | Success |
| Test the Premium Calculation | Success | |
| Test the Valid plan Details Of Member In DAO | Success | |
| Test the Premium Update In Database From BO | Success | |
| Test the Valid Corporate Name In BO | Success | |
| Functional | Test the Dependency Injection Service Layer | Success |
| Test the Dependency Injection BO Layer | Success | |
| Test the Property Place Holder Configurer | Success | |
| Test the Collections | Success | |
| Test the JDBC | Success | |
| Test the Transactions | Success |
Report generated time : 18-02-2020 11:49 AM
Powered by