Search in sources :

Example 1 with HourTypeRepository

use of com.artezio.arttime.repositories.HourTypeRepository in project ART-TIME by Artezio.

the class HourTypeServiceTest method testFind_HourTypeNotExists.

@Test
public void testFind_HourTypeNotExists() {
    HourTypeRepository.HourTypeQuery query = Mockito.mock(HourTypeRepository.HourTypeQuery.class, Mockito.RETURNS_DEEP_STUBS);
    EasyMock.expect(hourTypeRepository.query()).andReturn(query);
    Mockito.when(query.id(1L).getSingleResultOrNull()).thenReturn(null);
    EasyMock.replay(hourTypeRepository);
    HourType actual = hourTypeService.find(1L);
    EasyMock.verify(hourTypeRepository);
    Mockito.verify(query.id(1L)).getSingleResultOrNull();
    assertNull(actual);
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) HourTypeRepository(com.artezio.arttime.repositories.HourTypeRepository) Test(org.junit.Test)

Example 2 with HourTypeRepository

use of com.artezio.arttime.repositories.HourTypeRepository in project ART-TIME by Artezio.

the class HourTypeServiceTest method testFind_HourTypeExists.

@Test
public void testFind_HourTypeExists() {
    HourType hourType = createHourType(1L);
    HourTypeRepository.HourTypeQuery query = Mockito.mock(HourTypeRepository.HourTypeQuery.class, Mockito.RETURNS_DEEP_STUBS);
    EasyMock.expect(hourTypeRepository.query()).andReturn(query);
    Mockito.when(query.id(1L).getSingleResultOrNull()).thenReturn(hourType);
    EasyMock.replay(hourTypeRepository);
    HourType actual = hourTypeService.find(1L);
    EasyMock.verify(hourTypeRepository);
    Mockito.verify(query.id(1L)).getSingleResultOrNull();
    assertEquals(hourType, actual);
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) HourTypeRepository(com.artezio.arttime.repositories.HourTypeRepository) Test(org.junit.Test)

Example 3 with HourTypeRepository

use of com.artezio.arttime.repositories.HourTypeRepository in project ART-TIME by Artezio.

the class HourTypeServiceTest method testFindActualTime_HourTypeNotExists.

@Test
public void testFindActualTime_HourTypeNotExists() {
    HourTypeRepository.HourTypeQuery query = Mockito.mock(HourTypeRepository.HourTypeQuery.class, Mockito.RETURNS_DEEP_STUBS);
    EasyMock.expect(hourTypeRepository.query()).andReturn(query);
    Mockito.when(query.actualTime().getSingleResultOrNull()).thenReturn(null);
    EasyMock.replay(hourTypeRepository);
    HourType actual = hourTypeService.findActualTime();
    EasyMock.verify(hourTypeRepository);
    Mockito.verify(query.actualTime()).getSingleResultOrNull();
    assertNull(actual);
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) HourTypeRepository(com.artezio.arttime.repositories.HourTypeRepository) Test(org.junit.Test)

Example 4 with HourTypeRepository

use of com.artezio.arttime.repositories.HourTypeRepository in project ART-TIME by Artezio.

the class HourTypeServiceTest method testCreate_ActualTimeExists.

@Test
public void testCreate_ActualTimeExists() {
    HourType hourType = createHourType(1L);
    HourTypeRepository.HourTypeQuery query = Mockito.mock(HourTypeRepository.HourTypeQuery.class, Mockito.RETURNS_DEEP_STUBS);
    EasyMock.expect(hourTypeRepository.query()).andReturn(query);
    EasyMock.expect(hourTypeRepository.create(hourType)).andReturn(hourType);
    Mockito.when(query.actualTime().getSingleResultOrNull()).thenReturn(createHourType(2L));
    EasyMock.replay(hourTypeRepository);
    HourType actual = hourTypeService.create(hourType);
    EasyMock.verify(hourTypeRepository);
    Mockito.verify(query.actualTime()).getSingleResultOrNull();
    assertEquals(hourType, actual);
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) HourTypeRepository(com.artezio.arttime.repositories.HourTypeRepository) Test(org.junit.Test)

Example 5 with HourTypeRepository

use of com.artezio.arttime.repositories.HourTypeRepository in project ART-TIME by Artezio.

the class HourTypeServiceTest method testFindActualTime_HourTypeExists.

@Test
public void testFindActualTime_HourTypeExists() {
    HourType hourType = createHourType(1L);
    HourTypeRepository.HourTypeQuery query = Mockito.mock(HourTypeRepository.HourTypeQuery.class, Mockito.RETURNS_DEEP_STUBS);
    EasyMock.expect(hourTypeRepository.query()).andReturn(query);
    Mockito.when(query.actualTime().getSingleResultOrNull()).thenReturn(hourType);
    EasyMock.replay(hourTypeRepository);
    HourType actual = hourTypeService.findActualTime();
    EasyMock.verify(hourTypeRepository);
    Mockito.verify(query.actualTime()).getSingleResultOrNull();
    assertEquals(hourType, actual);
}
Also used : HourType(com.artezio.arttime.datamodel.HourType) HourTypeRepository(com.artezio.arttime.repositories.HourTypeRepository) Test(org.junit.Test)

Aggregations

HourType (com.artezio.arttime.datamodel.HourType)6 HourTypeRepository (com.artezio.arttime.repositories.HourTypeRepository)6 Test (org.junit.Test)6