package com.yammer.stresstime.managers;

import com.yammer.stresstime.entities.Employee;
import com.yammer.stresstime.test.DatabaseTest;
import com.yammer.stresstime.test.TestUtils;
import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.assertNotNull;

public class EmployeeManagerTest extends DatabaseTest {

    private EmployeeManager employeeManager;

    @Before
    @Override
    public void setUp() throws Exception {
        super.setUp();
        employeeManager = new EmployeeManager(getSessionFactory());
    }

    @Test
    public void testFindByYammerIdRetrievesTheCorrectRecord() {
        String yammerId = TestUtils.nextYammerId();
        Employee employee = new Employee("John Doe", yammerId);
        employeeManager.save(employee);
        refresh(employee);
        Employee found = employeeManager.getByYammerId(yammerId);

        assertNotNull(found);
        assertThat(found, equalTo(employee));

        employeeManager.delete(employee);
    }
}

@@ -224,16 +224,40 @@
 .Test;%0A%0A
+import java.util.List;%0A%0A
 import s
@@ -1115,11 +1115,844 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testGetGlobalAdminsRetrievesTheCorrectRecord() %7B%0A        String gloalAdminYammerId = TestUtils.nextYammerId();%0A        Employee globalAdmin = new Employee(%22John Doe%22, gloalAdminYammerId);%0A        globalAdmin.setGlobalAdmin(true);%0A        employeeManager.save(globalAdmin);%0A        refresh(globalAdmin);%0A        String yammerId = TestUtils.nextYammerId();%0A        Employee employee = new Employee(%22Mary%22, yammerId);%0A        employeeManager.save(employee);%0A        List%3CEmployee%3E globalAdmins = employeeManager.getGlobalAdmins();%0A        assertNotNull(globalAdmins);%0A        assertThat(globalAdmins.size(), equalTo(1));%0A        Employee found = globalAdmins.get(0);%0A        assertThat(found, equalTo(globalAdmin));%0A        employeeManager.delete(globalAdmin);%0A        employeeManager.delete(employee);%0A    %7D
 %0A%7D%0A

Create global admin test