Search in sources :

Example 1 with WorkTimeProblems

use of com.artezio.arttime.services.NotificationManager.WorkTimeProblems in project ART-TIME by Artezio.

the class NotificationManagerTest method testGetSubordinateProblems.

@Test
public void testGetSubordinateProblems() throws Exception {
    Employee employee1 = createEmployee("iivanov", "Ivan", "Ivanov");
    Employee employee2 = createEmployee("ppetrov", "Petr", "Petrov");
    Employee employee3 = createEmployee("asidorov", "Andrey", "Sidorov");
    Project project1 = createProject(1L, employee2);
    Project project2 = createProject(2L, employee3, employee1);
    project1.addManager(employee1);
    project2.addManager(employee2);
    List<Project> projects = Arrays.asList(project1, project2);
    Map<Employee, Map<Date, BigDecimal>> timeProblems = new HashMap<>();
    timeProblems.put(employee1, new HashMap<>());
    timeProblems.put(employee2, new HashMap<>());
    timeProblems.put(employee3, new HashMap<>());
    Set<WorkTimeProblems> actual = notificationManager.getEmployeeWorktimeProblems(employee1, projects, timeProblems);
    assertEquals(1, actual.size());
    assertEquals(employee2, actual.iterator().next().getEmployee());
}
Also used : Project(com.artezio.arttime.datamodel.Project) Employee(com.artezio.arttime.datamodel.Employee) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap) TreeMap(java.util.TreeMap) WorkTimeProblems(com.artezio.arttime.services.NotificationManager.WorkTimeProblems) Test(org.junit.Test)

Example 2 with WorkTimeProblems

use of com.artezio.arttime.services.NotificationManager.WorkTimeProblems in project ART-TIME by Artezio.

the class NotificationManagerTest method testSubordinateGetDeviationDetails.

@Test
public void testSubordinateGetDeviationDetails() throws Exception {
    Employee employee = createEmployee("iivanov", "Ivan", "Ivanov");
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
    Map<Date, BigDecimal> approvedWorkTimeProblems = new TreeMap<>();
    approvedWorkTimeProblems.put(sdf.parse("1-01-2015"), BigDecimal.ONE);
    approvedWorkTimeProblems.put(sdf.parse("2-01-2015"), BigDecimal.TEN);
    approvedWorkTimeProblems.put(sdf.parse("3-01-2015"), BigDecimal.ZERO);
    WorkTimeProblems subordinateProblem = notificationManager.new WorkTimeProblems(employee, approvedWorkTimeProblems);
    Object[] expected = new Object[] { new AbstractMap.SimpleEntry<>(sdf.parse("1-01-2015"), BigDecimal.ONE), new AbstractMap.SimpleEntry<>(sdf.parse("2-01-2015"), BigDecimal.TEN), new AbstractMap.SimpleEntry<>(sdf.parse("3-01-2015"), BigDecimal.ZERO) };
    Object[] actual = subordinateProblem.getDeviationDetails();
    // TODO use assertArrayEquals
    assertEquals(expected, actual);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) TreeMap(java.util.TreeMap) SimpleDateFormat(java.text.SimpleDateFormat) WorkTimeProblems(com.artezio.arttime.services.NotificationManager.WorkTimeProblems) Date(java.util.Date) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 3 with WorkTimeProblems

use of com.artezio.arttime.services.NotificationManager.WorkTimeProblems in project ART-TIME by Artezio.

the class NotificationManagerTest method testGetSubordinatesAsString.

@Test
public void testGetSubordinatesAsString() {
    Employee employee1 = createEmployee("iivanov", "Ivan", "Ivanov");
    Employee employee2 = createEmployee("ppetrov", "Petr", "Petrov");
    Employee employee3 = createEmployee("asidorov", "Andrey", "Sidorov");
    WorkTimeProblems subordinate1 = notificationManager.new WorkTimeProblems(employee1, new HashMap<>());
    WorkTimeProblems subordinate2 = notificationManager.new WorkTimeProblems(employee2, new HashMap<>());
    WorkTimeProblems subordinate3 = notificationManager.new WorkTimeProblems(employee3, new HashMap<>());
    List<WorkTimeProblems> subordinates = Arrays.asList(subordinate1, subordinate2, subordinate3);
    String expected = "iivanov,ppetrov,asidorov";
    String actual = notificationManager.getEmployeesAsString(subordinates);
    assertEquals(expected, actual);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) WorkTimeProblems(com.artezio.arttime.services.NotificationManager.WorkTimeProblems) Test(org.junit.Test)

Example 4 with WorkTimeProblems

use of com.artezio.arttime.services.NotificationManager.WorkTimeProblems in project ART-TIME by Artezio.

the class NotificationManagerTest method testSubordinateGetDeviation.

@Test
public void testSubordinateGetDeviation() throws Exception {
    Employee employee = createEmployee("iivanov", "Ivan", "Ivanov");
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
    Map<Date, BigDecimal> approvedWorkTimeProblems = new HashMap<>();
    approvedWorkTimeProblems.put(sdf.parse("1-01-2015"), BigDecimal.ONE);
    approvedWorkTimeProblems.put(sdf.parse("2-01-2015"), BigDecimal.TEN);
    approvedWorkTimeProblems.put(sdf.parse("3-01-2015"), BigDecimal.ZERO);
    WorkTimeProblems subordinateProblem = notificationManager.new WorkTimeProblems(employee, approvedWorkTimeProblems);
    BigDecimal actual = subordinateProblem.getDeviation();
    assertEquals(new BigDecimal(11), actual);
}
Also used : Employee(com.artezio.arttime.datamodel.Employee) HashMap(java.util.HashMap) SimpleDateFormat(java.text.SimpleDateFormat) WorkTimeProblems(com.artezio.arttime.services.NotificationManager.WorkTimeProblems) Date(java.util.Date) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Aggregations

Employee (com.artezio.arttime.datamodel.Employee)4 WorkTimeProblems (com.artezio.arttime.services.NotificationManager.WorkTimeProblems)4 Test (org.junit.Test)4 BigDecimal (java.math.BigDecimal)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 Project (com.artezio.arttime.datamodel.Project)1 AbstractMap (java.util.AbstractMap)1 Map (java.util.Map)1