All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ch.manager.TestCaseManager Maven / Gradle / Ivy

The newest version!
package com.ch.manager;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

import com.ch.config.ConfigProperties;
import com.ch.exception.DAOException;
import com.ch.exception.ValidationException;
import com.ch.model.BaseEntity;
import com.ch.model.Report;
import com.ch.model.TestReport;
import com.ch.mongo.TemplateDao;
import com.ch.validator.TestReportValidator;

public class TestCaseManager {
	private static final Logger LOGGER = Logger.getLogger(TestCaseManager.class.getName());
	private TemplateDao testCaseDao;

	private TestCaseManager(TemplateDao testCaseDao) {
		super();
		this.testCaseDao = testCaseDao;
	}

	public static TestCaseManager getTestReportManager(String name, ConfigProperties configProperties)
			throws NoSuchMethodException, SecurityException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		Constructor cons = Class.forName(name).getConstructor(ConfigProperties.class);
		TemplateDao dao = (TemplateDao) cons.newInstance(configProperties);
		LOGGER.finest("TestCaseDAO class loaded.");
		return new TestCaseManager(dao);
	}

	public void createTestCase(BaseEntity testCase) throws ValidationException, DAOException {
		TestReport testReport = (TestReport) testCase;
		List reportList = new ArrayList();
		reportList.add(testReport);
		TestReportValidator.validate(reportList);
		testCaseDao.saveEntity(testCase);
		LOGGER.finest("Data saved successfully.");

	}

	public void createTestCase(Report report) throws ValidationException, DAOException {
		List testReport = report.getTestReports();
		try {
			TestReportValidator.validate(testReport);
			testCaseDao.saveBatchEntity(testReport);
			LOGGER.finest("Data saved successfully.");
		} catch (Exception e) {
			throw new ValidationException(e.getMessage());
		}

	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy