Search in sources :

Example 6 with FriendsListRepository

use of com.management.repositories.FriendsListRepository in project Internet-Software-Architectures by zivko11.

the class FriendsListControllerTests method ReadFriendsList_ReturnsOK.

@Test
public void ReadFriendsList_ReturnsOK() {
    // Arrange
    Mockery mock = new Mockery();
    friendsListRepository = mock.mock(FriendsListRepository.class);
    final Friendslist list = new Friendslist();
    list.setFriendsStatus('P');
    mock.checking(new Expectations() {

        {
            oneOf(friendsListRepository).findOne(1);
            will(returnValue(list));
        }
    });
    FriendsListManager manager = new FriendsListManager(friendsListRepository);
    FriendsListController controller = new FriendsListController(manager);
    // Act
    ResponseEntity<FriendslistDTO> response = controller.getFriendslist(1);
    FriendslistDTO dto = response.getBody();
    // Assert
    Assert.assertNotNull(controller);
    Assert.assertEquals(response, new ResponseEntity<FriendslistDTO>(dto, HttpStatus.OK));
    mock.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) FriendslistDTO(com.management.dto.FriendslistDTO) FriendsListRepository(com.management.repositories.FriendsListRepository) FriendsListManager(com.management.managers.FriendsListManager) Mockery(org.jmock.Mockery) Friendslist(com.management.entities.Friendslist) Test(org.junit.Test)

Aggregations

FriendsListRepository (com.management.repositories.FriendsListRepository)6 Expectations (org.jmock.Expectations)6 Mockery (org.jmock.Mockery)6 Test (org.junit.Test)6 FriendslistDTO (com.management.dto.FriendslistDTO)5 Friendslist (com.management.entities.Friendslist)4 FriendsListManager (com.management.managers.FriendsListManager)3 ArrayList (java.util.ArrayList)2 List (java.util.List)1