Search in sources :

Example 1 with FriendsListManager

use of com.management.managers.FriendsListManager in project Internet-Software-Architectures by zivko11.

the class FriendsListControllerTests method AddingNewFriendsList_ReturnsOK.

@Test
public void AddingNewFriendsList_ReturnsOK() {
    // Arrange
    friendsListRepository = new FriendsListRepositoryFake();
    FriendslistDTO dto = new FriendslistDTO();
    dto.setFriendsStatus('P');
    FriendsListManager manager = new FriendsListManager(friendsListRepository);
    FriendsListController controller = new FriendsListController(manager);
    // Act and assert
    Assert.assertNotNull(controller);
    Assert.assertEquals(controller.addFriendslist(dto), new ResponseEntity<FriendslistDTO>(dto, HttpStatus.OK));
}
Also used : FriendslistDTO(com.management.dto.FriendslistDTO) FriendsListRepositoryFake(com.management.fake.FriendsListRepositoryFake) FriendsListManager(com.management.managers.FriendsListManager) Test(org.junit.Test)

Example 2 with FriendsListManager

use of com.management.managers.FriendsListManager in project Internet-Software-Architectures by zivko11.

the class FriendsListControllerTests method ReadAllFriendsLists_ReturnsOK.

@Test
public void ReadAllFriendsLists_ReturnsOK() {
    // Arrange
    Mockery mock = new Mockery();
    friendsListRepository = mock.mock(FriendsListRepository.class);
    final ArrayList<Friendslist> list = new ArrayList<Friendslist>();
    Friendslist list1 = new Friendslist();
    list1.setFriendsStatus('P');
    Friendslist list2 = new Friendslist();
    list2.setFriendsStatus('A');
    list.add(list1);
    list.add(list2);
    mock.checking(new Expectations() {

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

Example 3 with FriendsListManager

use of com.management.managers.FriendsListManager in project Internet-Software-Architectures by zivko11.

the class FriendsListControllerTests method DeletingFriendsList_ReturnsOK.

@Test
public void DeletingFriendsList_ReturnsOK() {
    // Arrange
    Mockery mock = new Mockery();
    friendsListRepository = mock.mock(FriendsListRepository.class);
    // expectations
    mock.checking(new Expectations() {

        {
            oneOf(friendsListRepository).delete(1);
        }
    });
    // Act and assert
    FriendsListManager manager = new FriendsListManager(friendsListRepository);
    FriendsListController controller = new FriendsListController(manager);
    Assert.assertNotNull(controller);
    Assert.assertEquals(controller.deleteFriendsList(1), new ResponseEntity<FriendslistDTO>(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) Test(org.junit.Test)

Example 4 with FriendsListManager

use of com.management.managers.FriendsListManager 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

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