Search in sources :

Example 16 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class FilterRepositoryTest method testFind_ByOwnerAndName_ifNotFound.

@Test
public void testFind_ByOwnerAndName_ifNotFound() {
    Filter unexpected = new Filter("favorite_filter", "filter_owmer", true);
    entityManager.persist(unexpected);
    Filter actual = filterRepository.find("me", "favorite_filter");
    assertNull(actual);
}
Also used : Filter(com.artezio.arttime.filter.Filter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 17 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class FilterRepositoryTest method createFilter.

private Filter createFilter(String owner) {
    Filter filter = new Filter();
    filter.setOwner(owner);
    return filter;
}
Also used : Filter(com.artezio.arttime.filter.Filter)

Example 18 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class FilterRepositoryTest method testUpdate.

@Test
public void testUpdate() {
    Filter filter = new Filter();
    entityManager.persist(filter);
    filter.setName("new filter name");
    filterRepository.update(filter);
    Filter actual = entityManager.find(Filter.class, filter.getId());
    assertEquals(filter.getName(), actual.getName());
}
Also used : Filter(com.artezio.arttime.filter.Filter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 19 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class FilterRepositoryTest method testFetchDetails_ifFilterNoPersisted.

@Test
public void testFetchDetails_ifFilterNoPersisted() throws NoSuchMethodException, SecurityException, NoSuchFieldException {
    Filter filter = new Filter();
    Project project = new Project();
    List<Project> projects = Arrays.asList(project);
    filter.setProjects(projects);
    Project projectLoaded = new Project();
    List<Project> projectsLoaded = Arrays.asList(projectLoaded);
    entityManager.persist(project);
    entityManager.persist(projectLoaded);
    Method fetchCompleteMethod = ProjectRepository.class.getMethod("fetchComplete", List.class);
    projectRepository = EasyMock.createMockBuilder(ProjectRepository.class).addMockedMethod(fetchCompleteMethod).createMock();
    setField(filterRepository, "projectRepository", projectRepository);
    EasyMock.expect(projectRepository.fetchComplete(projects)).andReturn(projectsLoaded);
    EasyMock.replay(projectRepository);
    filterRepository.fetchDetails(filter);
    EasyMock.verify(projectRepository);
    assertSame(projectLoaded, filter.getProjects().get(0));
}
Also used : Project(com.artezio.arttime.datamodel.Project) ProjectRepository(com.artezio.arttime.services.repositories.ProjectRepository) Filter(com.artezio.arttime.filter.Filter) Method(java.lang.reflect.Method) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 20 with Filter

use of com.artezio.arttime.filter.Filter in project ART-TIME by Artezio.

the class FilterRepositoryTest method testFind_ByOwnerAndName_ifFound.

@Test
public void testFind_ByOwnerAndName_ifFound() {
    Filter unexpected = new Filter("favorite_filter1", "filter_owmer", true);
    Filter expected = new Filter("favorite_filter2", "filter_owmer", true);
    entityManager.persist(unexpected);
    entityManager.persist(expected);
    Filter actual = filterRepository.find("filter_owmer", "favorite_filter2");
    assertEquals(expected, actual);
}
Also used : Filter(com.artezio.arttime.filter.Filter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Filter (com.artezio.arttime.filter.Filter)126 Test (org.junit.Test)110 Project (com.artezio.arttime.datamodel.Project)32 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)25 Employee (com.artezio.arttime.datamodel.Employee)24 RangePeriodSelector (com.artezio.arttime.web.criteria.RangePeriodSelector)16 Date (java.util.Date)9 BigDecimal (java.math.BigDecimal)8 Hours (com.artezio.arttime.datamodel.Hours)7 Arrays.asList (java.util.Arrays.asList)7 List (java.util.List)7 HourType (com.artezio.arttime.datamodel.HourType)5 Efforts (com.artezio.arttime.services.WorkTimeService.Efforts)5 CalendarUtils.getOffsetDate (com.artezio.arttime.test.utils.CalendarUtils.getOffsetDate)5 ArrayList (java.util.ArrayList)4 Collections.emptyList (java.util.Collections.emptyList)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 Period (com.artezio.arttime.datamodel.Period)3 EmployeeRepository (com.artezio.arttime.repositories.EmployeeRepository)3