Java 无法通过向构造函数硬编码日期来执行testcase

Java 无法通过向构造函数硬编码日期来执行testcase,java,junit,junit4,Java,Junit,Junit4,我通过模拟连接对象为我的JavaDaoImpl类编写了一个测试用例,然而,这里有一个转折点。我一直在对值进行硬编码,以便将这些记录与从数据库中获取的记录进行比较,并最终断言它们 Error: java.lang.Error: Unresolved compilation problems: The constructor Employee(String, String, String, String, String, String, int, int, String, int, boo

我通过模拟连接对象为我的JavaDaoImpl类编写了一个测试用例,然而,这里有一个转折点。我一直在对值进行硬编码,以便将这些记录与从数据库中获取的记录进行比较,并最终断言它们

Error: java.lang.Error: Unresolved compilation problems: 
    The constructor Employee(String, String, String, String, String, String, int, int, String, int, boolean, int) is undefined
    The constructor Employee(String, String, String, String, String, String, int, int, String, int, boolean, int) is undefined

at com.cerner.devcenter.dao.junit.OrganizationDaoImplTest.testGetAllEmployeeDetails(OrganizationDaoImplTest.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
测试类:

public class OrganizationDaoImplTest {

    private SessionFactory sessionFactory;
    private Session session;
    private Query query;
    private OrganizationDaoImpl organizationDaoObj;

    String organizationId = "DevCenter01";
    boolean isActive = true;

    @Before
    public void setUp() {
        sessionFactory = mock(SessionFactory.class);
        session = mock(Session.class);
        query = mock(Query.class);
    }

    @Test
    public void testGetAllEmployeeDetails() throws ParseException {
        String hql = "from Employee where Organization_Id = organizationId and IsActive = isActive";
        List<Employee> expectedEmployeeList = new ArrayList<Employee>();
        expectedEmployeeList
                .add(new Employee("AD042997", "Anitha", "D", "AD042999", new SimpleDateFormat("2015-02-12"),
                        "DevCenter01", "anitha@cerner.com", 805678993, 987652134, "C-1234", 7, true, 1));
        expectedEmployeeList.add(new Employee("AS042987", "Asha", "S", "AD042999",
                "DevCenter01", "asha@cerner.com", 434343434, 676990909, "C-4567", 7, true, 3));
        expectedEmployeeList
                .add(new Employee("HN099239", "Heena", "N", "AD042999",
                        "DevCenter01", "heena@cerner.com", 873847399, 486584658, "C-7432", 7, true, 7));

        organizationDaoObj = new OrganizationDaoImpl();
        Mockito.when(sessionFactory.getCurrentSession()).thenReturn(session);
        Mockito.when(session.createQuery(hql)).thenReturn(query);
        Mockito.when(query.list()).thenReturn(expectedEmployeeList);
        List<Employee> actualEmployeeList = organizationDaoObj.getAllEmployeeDetails();
        assertNotNull(actualEmployeeList);
    }
}
有人能帮忙吗?

在这两行中

    expectedEmployeeList.add(new Employee("AS042987", "Asha", "S", "AD042999",
            "DevCenter01", "asha@cerner.com", 434343434, 676990909, "C-4567", 7, true, 3));
    expectedEmployeeList
            .add(new Employee("HN099239", "Heena", "N", "AD042999",
                    "DevCenter01", "heena@cerner.com", 873847399, 486584658, "C-7432", 7, true, 7));

您错过了构造函数的
SimpleDataFormat
参数。

这只是添加SimpleDataFormat的一个尝试,即使在将Dateformat添加到第2、第3条记录之后,它也失败了,并出现了相同的错误
    expectedEmployeeList.add(new Employee("AS042987", "Asha", "S", "AD042999",
            "DevCenter01", "asha@cerner.com", 434343434, 676990909, "C-4567", 7, true, 3));
    expectedEmployeeList
            .add(new Employee("HN099239", "Heena", "N", "AD042999",
                    "DevCenter01", "heena@cerner.com", 873847399, 486584658, "C-7432", 7, true, 7));