> Java 8 Qualis Hands-On Solutions - TECH UPDATE

Java 8 Qualis Hands-On Solutions

 Java 8 Qualis Hands-On Solutions 

The main agenda of this solution is those who are unable to do this course due to facing some issues, a little bit of lack of knowledge on these hands-on questions. Try to understand these codes and solve your hands-On Problems. (Not encourage copy and paste these solutions).

The course Id of Java 8 Qualis is 56911

1. JUnit Hands-On

  package com.tcs.fresco;

import static junit. framework.Assert.*;

import java.util.HashMap;
import java.util.Map;

import org.junit.After;
import org.junit.Before;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

public class SolutionTest extends TestCase{
    Map<Integer, String> customerTag = null;
int custId = 0;
Solution solution = new Solution();
public void setUp() throws Exception {
custId = 10511;
customerTag = new HashMap<Integer, String>();
    //Write your test cases here
    public void test() {
    assertTrue( true );

    public void testValidUser(){
      solution.saveCustomer(this.custId, "Tej");
    public void testinValidUser(){
      solution.saveCustomer(this.custId, "Tej");
public void tearDown() throws Exception {


2. Mockito 

package com.tcs.fresco;

/* Write static mocks for Assert and Mockito classes. -Q1 */

import static org.junit.Assert.*;
import static org.mockito.Mockito.doThrow;
//Write import statements for Mockito classes.
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class UserAuthenticatorTest {

UserAuthenticator authenticator = new UserAuthenticator();
public static UserAuthenticatorInterface authenticatorMock;

public static void setUp() {
      /* Create mock object using static mock configuration  -Q2 */
      //Write your code here
       authenticatorMock = mock(UserAuthenticatorInterface.class);

public void setUpAuthenticator() {

  /*Complete the test case with the expected exception -Q3 */

      // Write your code here
  @Test(expected = FailedToAuthenticateException.class)
public void testAuthenticate_InvalidCredentials() throws FailedToAuthenticateException {

String username = "User1";
String password = "wrong password";
String errorMessage = "Invalid credentials .Authentication Failed";
        /*Throw exception using doThrow...when configuration - Q4*/
        // Write your code here
    doThrow(new FailedToAuthenticateException(errorMessage)).when(authenticatorMock).authenticateUser("User1", "wrong password");
authenticator.authenticateUser(username, password);


public void testAuthenticate_ValidCredentials() throws FailedToAuthenticateException {

String username = "User1";
String password = "Password";
    /*Configure Returning True with when...thenReturn configuration on mock Object - Q5*/
        //Write your code here
    when(authenticatorMock.authenticateUser(username, password)).thenReturn(true);
assertTrue(authenticator.authenticateUser(username, password));


public void testAuthenticate_EmptyCredentials() throws FailedToAuthenticateException {

String username = "";
String password = "";
        String errorMessage= "Credentials cannot be empty";
        /*Configure Throwing exception using when...thenThrow configuration on mock Object - Q6*/
        //Write your code here
       when(authenticatorMock.authenticateUser(username, password)).thenThrow(new FailedToAuthenticateException(errorMessage));
     authenticator.authenticateUser(username, password);
        authenticator.authenticateUser(username, password);

    public void dummytest(){

3. MockMVC

No Need to write the Test Cases

4. Checkstyle

No need to write the Test Cases

5. FindBugs

No need to write anything just submit

6. JoCoCo 

No Need to write anything just submit 

Thank You 
Java 8 Qualis Hands-On Solutions Java 8 Qualis Hands-On Solutions Reviewed by TECH UPDATE on August 29, 2021 Rating: 5


  1. HI bro,

    Thank you so much for this, can you please recheck for Mockito once 1/4 test cases are not passing.

    1. in the last test case assertEquals(1,1); instead of 0,1

  2. Hi bro,
    thank you for this, can you please recheck once for mockito, all the test cases are not getting passed.

  3. my junit program is executed and i get build success, but in fresco play it is showing not passes, from three days i have facing the issue, please help me


Powered by Blogger.