use of com.management.dto.FriendslistDTO in project Internet-Software-Architectures by zivko11.
the class FriendsListManager method Read.
public FriendslistDTO Read(int id) {
ModelMapper mapper = new ModelMapper();
FriendslistDTO dto;
try {
Friendslist list = friendsListRepository.findOne(id);
dto = mapper.map(list, FriendslistDTO.class);
} catch (Exception exc) {
exc.printStackTrace();
return null;
}
return dto;
}
use of com.management.dto.FriendslistDTO in project Internet-Software-Architectures by zivko11.
the class FriendsListManager method ReadAll.
public ArrayList<FriendslistDTO> ReadAll() {
ModelMapper mapper = new ModelMapper();
ArrayList<Friendslist> listEntities = (ArrayList<Friendslist>) friendsListRepository.findAll();
ArrayList<FriendslistDTO> listDTO = new ArrayList<FriendslistDTO>();
for (Friendslist tmp : listEntities) {
try {
FriendslistDTO dto = mapper.map(tmp, FriendslistDTO.class);
listDTO.add(dto);
} catch (Exception exc) {
exc.printStackTrace();
return null;
}
}
return listDTO;
}
use of com.management.dto.FriendslistDTO 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();
}
use of com.management.dto.FriendslistDTO 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();
}
Aggregations