Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
2.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 AdminServicesTest {

	
	
	@Test
	public void testcheckUnderwriterCredentials(int id, String pass) throws ClassNotFoundException, SQLException {
			AdminServices service = new AdminServices();
			boolean output = service.checkUnderwriterCredentials(18,"default@123");
			assertEquals(true, output);
			Helper.getConnect().close();

	}
	
	
	@Test
	public void testcreateUnderwriter() throws ClassNotFoundException, SQLException {
		UnderWriter u = new UnderWriter();
		u.setDateOfBirth("18-12-2000"); // still to add date
		u.setDateOfJoining("12-10-2021"); //still to add
		u.setName("harsh");
		u.setPassword("default@123");
		AdminServices service = new AdminServices();
		boolean output = service.createUnderwriter(u);
		assertEquals(true, output);
		Helper.getConnect().close();

	}
	
	@Test
	public void testupdatePassword() throws ClassNotFoundException, SQLException{
		AdminServices service = new AdminServices();
		boolean output = service.updatePassword(1, "aBCD@123");
		assertEquals(true, output);
		Helper.getConnect().close();

	}
	
	@Test
	public void testdeleteUnderwriter() throws ClassNotFoundException, SQLException{
		AdminServices service = new AdminServices();
		boolean output = service.deleteUnderwriter(4);  //random id given currently
		assertEquals(true, output);
		Helper.getConnect().close();

	}
	
	@Test
	public void testgetAllUnderwriter() throws ClassNotFoundException, SQLException {
		AdminServices service = new AdminServices();
		ArrayList<UnderWriter> uw = service.getAllUnderwriter();
		if(uw==null) {
			assertEquals(null,uw);
		}
		else {
		assertTrue(uw.size()>0);
		}
		Helper.getConnect().close();

	}
	
	@Test
	public void testgetAllInsuranceByUnderwriterId() throws ClassNotFoundException, SQLException{
		AdminServices services = new AdminServices();
		ArrayList<Insurance> ins = services.getAllInsuranceByUnderwriterId(12);
		if(ins==null) {
			assertEquals(null,ins);
		}
		else {
		assertTrue(ins.size()>0);
		}
		Helper.getConnect().close();
		
	}
}
Leave a Comment