BAEL-88 Testing in Spring Boot (#1722)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package org.baeldung.boot.boottest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
@@ -12,9 +11,9 @@ import org.springframework.stereotype.Repository;
|
||||
@Transactional
|
||||
public interface EmployeeRepository extends JpaRepository<Employee, Long> {
|
||||
|
||||
public Optional<Employee> findByName(String name);
|
||||
public Employee findByName(String name);
|
||||
|
||||
public Optional<Employee> findById(Long id);
|
||||
public Employee findById(Long id);
|
||||
|
||||
public List<Employee> findAll();
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package org.baeldung.boot.boottest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface EmployeeService {
|
||||
|
||||
public Optional<Employee> getEmployeeById(Long id);
|
||||
public Employee getEmployeeById(Long id);
|
||||
|
||||
public Optional<Employee> getEmployeeByName(String name);
|
||||
public Employee getEmployeeByName(String name);
|
||||
|
||||
public List<Employee> getAllEmployees();
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.baeldung.boot.boottest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
@@ -16,12 +15,12 @@ public class EmployeeServiceImpl implements EmployeeService {
|
||||
private EmployeeRepository employeeRepository;
|
||||
|
||||
@Override
|
||||
public Optional<Employee> getEmployeeById(Long id) {
|
||||
public Employee getEmployeeById(Long id) {
|
||||
return employeeRepository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<Employee> getEmployeeByName(String name) {
|
||||
public Employee getEmployeeByName(String name) {
|
||||
return employeeRepository.findByName(name);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user