use of com.management.entities.Friendslist in project Internet-Software-Architectures by zivko11.
the class FriendsListManager method Update.
public boolean Update(FriendslistDTO dto) {
ModelMapper mapper = new ModelMapper();
Friendslist tmp;
try {
tmp = mapper.map(dto, Friendslist.class);
} catch (Exception exc) {
exc.printStackTrace();
return false;
}
friendsListRepository.save(tmp);
return true;
}
use of com.management.entities.Friendslist in project Internet-Software-Architectures by zivko11.
the class FriendsListManager method Create.
public boolean Create(FriendslistDTO dto) {
ModelMapper mapper = new ModelMapper();
Friendslist list;
try {
list = mapper.map(dto, Friendslist.class);
} catch (Exception exc) {
exc.printStackTrace();
return false;
}
friendsListRepository.save(list);
return true;
}
use of com.management.entities.Friendslist 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.entities.Friendslist 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