Search in sources :

Example 6 with Friendslist

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;
}
Also used : Friendslist(com.management.entities.Friendslist) ModelMapper(org.modelmapper.ModelMapper)

Example 7 with Friendslist

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;
}
Also used : Friendslist(com.management.entities.Friendslist) ModelMapper(org.modelmapper.ModelMapper)

Example 8 with Friendslist

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;
}
Also used : FriendslistDTO(com.management.dto.FriendslistDTO) ArrayList(java.util.ArrayList) Friendslist(com.management.entities.Friendslist) ModelMapper(org.modelmapper.ModelMapper)

Example 9 with Friendslist

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();
}
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

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