Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
3.3 kB
1
Indexable
Never
package com.service;

import static org.junit.jupiter.api.Assertions.*;
import java.sql.SQLException;
import java.util.ArrayList;

import com.bean.*;
import com.util.Helper;

import org.junit.jupiter.api.Test;
class UnderWritterServicesTest {
	private UnderWritterServices uw = new UnderWritterServices();

	@Test
	void test() {
		fail("Not yet implemented");
	}
	
	
	@Test
	public void testcreateNewInsurance() throws ClassNotFoundException, SQLException {
//		UnderWritterServices uw = new UnderWritterServices();
		Insurance ins = new Insurance(12,"23543","2-Wheeler","Harsh",234,4234,9682701,"Three-year","12-04-2023","12-4-2024",1200,23,123);
		boolean output = uw.createNewInsurance(ins);
		assertEquals(true,output);
		Helper.getConnect().close();
	}
	
	@Test
	public void testupdateInsuranceType() throws ClassNotFoundException, SQLException{
//		UnderWritterServices uw = new UnderWritterServices();
		boolean output = uw.updateInsuranceType(23,"Two-year");
		assertEquals(true,output);
		Helper.getConnect().close();

	}
	
	@Test
	public void testgetInsuranceDetailsByInsuranceId() throws ClassNotFoundException, SQLException{
//		UnderWritterServices uw = new UnderWritterServices();
		ArrayList<Insurance> output = uw.getInsuranceDetailsByInsuranceId(12);
		if(output==null) {
			assertEquals(null,output);
		}
		else {
		assertTrue(output.size()>0);
		}
		Helper.getConnect().close();
	}
	
	@Test
	public void testgetInsuranceDetailsByVehicleNo() throws ClassNotFoundException, SQLException {
//		UnderWritterServices uw = new UnderWritterServices();
		ArrayList<Insurance> ins = uw.getInsuranceDetailsByVehicleNo(123);
		if(ins==null) {
			assertEquals(null,ins);
		}
		else {
		assertTrue(ins.size()>0);
		}
		Helper.getConnect().close();
	}
	
	@Test
	public void testgetToDate() throws ClassNotFoundException, SQLException{
		
		String date = uw.getToDate(1);
		if(date==null) {
			assertEquals(null,date);
		}
		else {
		assertEquals("2023-12-01",date);
		}
		Helper.getConnect().close();


	}
	
	@Test
	public void testgetLastInsuranceId() throws ClassNotFoundException, SQLException{
//		UnderWritterServices uw = new UnderWritterServices();
		int id = uw.getLastInsuranceId();
		assertEquals(12,id);
		Helper.getConnect().close();

	}
	
	@Test
	public void testgetAllInsuranceOfUnderwriter() throws ClassNotFoundException, SQLException{
//		UnderWritterServices uw = new UnderWritterServices();
		ArrayList<Insurance> ins = uw.getAllInsuranceOfUnderwriter(12);
		if(ins==null) {
			assertEquals(null,ins);
		}
		else {
		assertTrue(ins.size()>0);
		}
		Helper.getConnect().close();

	}
	
	@Test
	public void testcalculateToDate() throws ClassNotFoundException, SQLException{
//		UnderWritterServices uw = new UnderWritterServices();
		String date = uw.calculateToDate("2023-12-10");
 		if(date==null) {
			assertEquals(null,date);
		}
		else {
		assertEquals("12-02-2024",date);
		}
		Helper.getConnect().close();

	}
	
	@Test
	public void testcheckPolicyExistsVehNo() throws ClassNotFoundException, SQLException{
//		UnderWritterServices uw = new UnderWritterServices();
		boolean output = uw.checkPolicyExistsVehNo(123);
		assertEquals(true,output);
		Helper.getConnect().close();

	}

}
Leave a Comment