banyan-logo

LAB_ATKJE027 - Spring Core - Skill Based Assessment [301-ADVANCED]


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

14-Feb-2020 21:33

14-Feb-2020 21:50

17 Mins

Overall competency
91%

Candidate Answer Summary

6 / 6

0 / 6


Competency Breakdown
Unit Testing and Coding Standards
0%
Spring AOP
50%
Destructive
100%
Feature Test
100%
Functional
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 Skill11088.500.00 0.0088.50

PMD Code Quality Score
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. Execution of Advice

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.

1,2,3
1,2,4
1,3,4
2,3,4
1,2,4
2. Property file

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

 

3. Declaration parts of PointCuts

4 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
JoinPoints declaration
a pointcut expression that determines exactly about the method to be executed
Before advice declaration
4. Testcase Validation

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

 

5. NoRecordFoundException

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

 

6. Member Policy Management System

15 minutes 8 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

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:

  1. MemberPolicyBO should have the method ‘getDiscountToBePaid’ which must return the discount percentage

  2. 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
  • 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:49 AM

Powered by banyan-logo