Skip to content

Commit

Permalink
refactor(test): remove public modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Chamber6821 committed Apr 18, 2024
1 parent a314987 commit 4882691
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import org.junit.jupiter.api.Test;

public class DepartmentTest {
class DepartmentTest {
@Test
void getAll() {
var obj = new Department();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import org.junit.jupiter.api.Test;

public class EmployeeTest {
class EmployeeTest {
@Test
void getAll() {
var obj = new Employee();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import org.junit.jupiter.api.Test;

public class WorkPostTest {
class WorkPostTest {
@Test
void getAll() {
var obj = new WorkPost();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import com.example.jonebook.services.dto.ExtendedEmployee;
import org.junit.jupiter.api.Test;

public class EmployeeBuilderServiceTest {
class EmployeeBuilderServiceTest {
@Test
void x() {
var obj = new EmployeeBuilderService(mock(DepartmentRepository.class),
mock(WorkPostRepository.class));
mock(WorkPostRepository.class));
assertNotEquals(obj.createFromData(new ExtendedEmployee()), null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.Set;
import org.junit.jupiter.api.Test;

public class ExtendedEmployeeTest {
class ExtendedEmployeeTest {
@Test
void createWithoutArgs() {
new ExtendedEmployee();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,35 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;

public class CriteriaSearchEmployeeTest {
class CriteriaSearchEmployeeTest {
abstract class PartialEmployeeRepository implements EmployeeRepository {
@Override
public Page<Employee> findAll(Specification<Employee> spec,
Pageable pageable) {
Pageable pageable) {
var root = mock(Root.class);
when(root.get(any(String.class))).thenReturn(mock(Path.class));
when(root.join(any(String.class))).thenReturn(mock(Join.class));
spec.toPredicate(root, mock(CriteriaQuery.class),
mock(CriteriaBuilder.class));
mock(CriteriaBuilder.class));
return Page.<Employee>empty();
}
}

@Test
void searchAll() {
var employees = mock(PartialEmployeeRepository.class, Answers.CALLS_REAL_METHODS);
var employees =
mock(PartialEmployeeRepository.class, Answers.CALLS_REAL_METHODS);
new CriteriaSearchEmployee(employees).search(
EmployeeCriteria.builder()
.nameFragment("Petr")
.emailFragment("@")
.phonePrefix("123")
.internalPhonePrefix("321")
.departmentVariants(new HashSet<>() {
{
add("School");
}
{ add("School"); }
})
.postsFragment(new HashSet<>() {
{
add("Teacher");
}
{ add("Teacher"); }
})
.build(),
null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,22 @@
import java.util.HashSet;
import org.junit.jupiter.api.Test;

public class CustomQuerySearchEmployeeTest {
class CustomQuerySearchEmployeeTest {
@Test
void selectAll() {
new CustomQuerySearchEmployee(mock(EmployeeRepository.class))
.search(EmployeeCriteria.builder()
.nameFragment("Petr")
.emailFragment("@")
.phonePrefix("123")
.internalPhonePrefix("321")
.departmentVariants(new HashSet<>() {
{
add("School");
}
})
.postsFragment(new HashSet<>() {
{
add("Teacher");
}
})
.build(),
null);
.nameFragment("Petr")
.emailFragment("@")
.phonePrefix("123")
.internalPhonePrefix("321")
.departmentVariants(new HashSet<>() {
{ add("School"); }
})
.postsFragment(new HashSet<>() {
{ add("Teacher"); }
})
.build(),
null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;

public class MemCachedSearchEmployeeTest {
class MemCachedSearchEmployeeTest {
@Test
void shouldReturnTheSameValueFromOrigin() {
var pageable = PageRequest.of(0, 20);
assertEquals(new MemCachedSearchEmployee((x, p) -> Page.<Employee>empty(p))
.search(EmployeeCriteria.builder().build(), pageable),
Page.<Employee>empty(pageable));
.search(EmployeeCriteria.builder().build(), pageable),
Page.<Employee>empty(pageable));
}

@Test
void overflowCache() {
var service = new MemCachedSearchEmployee((x, p) -> Page.<Employee>empty(p));
var service =
new MemCachedSearchEmployee((x, p) -> Page.<Employee>empty(p));
for (int i = 0; i < 100000; i++) {
var pageable = PageRequest.of(i, 20);
assertEquals(service.search(EmployeeCriteria.builder().build(), pageable),
Page.<Employee>empty(pageable));
Page.<Employee>empty(pageable));
}
}
}

0 comments on commit 4882691

Please sign in to comment.