use of com.management.repositories.FriendsListRepository 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();
}
use of com.management.repositories.FriendsListRepository in project Internet-Software-Architectures by zivko11.
the class FriendsListManagerTest method ReadFriendsList_ReturnsUser.
@Test
public void ReadFriendsList_ReturnsUser() {
// 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);
// Act
FriendslistDTO dto = manager.Read(1);
// Assert
Assert.assertNotNull(dto);
Assert.assertEquals(dto.getFriendsStatus(), list.getFriendsStatus());
mock.assertIsSatisfied();
}
use of com.management.repositories.FriendsListRepository in project Internet-Software-Architectures by zivko11.
the class FriendsListManagerTest method ReadAllFriendsLists_ReturnsAllFriendsLists.
@Test
public void ReadAllFriendsLists_ReturnsAllFriendsLists() {
// 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);
// Act
ArrayList<FriendslistDTO> listDTO = manager.ReadAll();
// Assert
Assert.assertNotNull(listDTO);
Assert.assertEquals(listDTO.get(0).getFriendsStatus(), list.get(0).getFriendsStatus());
Assert.assertEquals(listDTO.get(1).getFriendsStatus(), list.get(1).getFriendsStatus());
mock.assertIsSatisfied();
}
use of com.management.repositories.FriendsListRepository in project Internet-Software-Architectures by zivko11.
the class FriendsListManagerTest method DeletingFriendsList_ReturnsBoolean.
@Test
public void DeletingFriendsList_ReturnsBoolean() {
// 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);
Assert.assertNotNull(manager);
Assert.assertTrue(manager.Delete(1));
mock.assertIsSatisfied();
}
use of com.management.repositories.FriendsListRepository 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();
}
Aggregations