Skip to content

Instantly share code, notes, and snippets.

@httpmurilo
Created February 10, 2022 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save httpmurilo/32b134fef6e8a29565dd8aee76720c5d to your computer and use it in GitHub Desktop.
Save httpmurilo/32b134fef6e8a29565dd8aee76720c5d to your computer and use it in GitHub Desktop.
package io.httpmurilo.sales.mock;
import io.httpmurilo.sales.dto.UserDTO;
import io.httpmurilo.sales.entity.User;
import io.httpmurilo.sales.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
public class FakeService {
@Autowired
private FakeRepository repository; //INJETA UM REPOSITORY FAKE
public User save(UserDTO dto) { // PASSAMOS COMO PARÂMETRO NOSSO DTO
return repository.save(UserMapper.INSTANCE.toUser(dto)); //CONVERTEMOS PARA UM OBJETO USER QUE PODERÁ SER RE-APROVEITADO APÓS O SALVAMENTO
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment