• How to create test class with complete code coverage

    Date Posted: 09-29-2016
    Author: CEBUFREELANCER

    
    Create the following classes to test:
    
    package com.test.sample;
    
    public interface ProcessOperation {
    
    	String processOperation(Operation ops);
    }
    
    --------------------------------
    
    package com.test.sample;
    
    public class Operation {
    
    	private String operationType;
    	private int value;
    
    	public Operation() {
    	}
    
    	public String getOperationType() {
    		return operationType;
    	}
    
    	public void setOperationType(String operationType) {
    		this.operationType = operationType;
    	}
    
    	public int getValue() {
    		return value;
    	}
    
    	public void setValue(int value) {
    		this.value = value;
    	}
    
    }
    
    -----------------
    
    package com.test.sample;
    
    public class ProcessOperationImpl implements ProcessOperation {
    
    	public ProcessOperationImpl() {
    	}
    
    	public String processOperation(Operation ops) {
    
    		if (ops.getOperationType().equals("Math")) {
    			return "math";
    		} else if (ops.getOperationType().equals("English")) {
    			return "english";
    		} else if (ops.getOperationType().equals("Science")) {
    			return "science";
    		} else if (ops.getOperationType().equals("Filipino")) {
    			return "filipino";
    		}
    		return "";
    	}
    }
     
     

Advertisement